git-svn-id: http://svn.openlayers.org/trunk/openlayers@961 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
88 lines
2.7 KiB
HTML
88 lines
2.7 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../lib/OpenLayers.js"></script>
|
|
<script type="text/javascript"><!--
|
|
var pixel;
|
|
|
|
function test_01_Pixel_constructor (t) {
|
|
t.plan( 4 );
|
|
pixel = new OpenLayers.Pixel(5,6);
|
|
t.ok( pixel instanceof OpenLayers.Pixel, "new OpenLayers.Pixel returns Pixel object" );
|
|
t.eq( pixel.CLASS_NAME, "OpenLayers.Pixel", "pixel.CLASS_NAME is set correctly");
|
|
t.eq( pixel.x, 5, "pixel.x is set correctly");
|
|
t.eq( pixel.y, 6, "pixel.y is set correctly");
|
|
}
|
|
|
|
function test_02_Pixel_toString(t) {
|
|
t.plan( 1 );
|
|
pixel = new OpenLayers.Pixel(5,6);
|
|
t.eq( pixel.toString(), "x=5,y=6", "pixel.toString() returns correctly");
|
|
}
|
|
|
|
function test_03_Pixel_clone(t) {
|
|
t.plan( 4 );
|
|
oldPixel = new OpenLayers.Pixel(5,6);
|
|
pixel = oldPixel.clone();
|
|
t.ok( pixel instanceof OpenLayers.Pixel, "clone returns new OpenLayers.Pixel object" );
|
|
t.eq( pixel.x, 5, "pixel.x is set correctly");
|
|
t.eq( pixel.y, 6, "pixel.y is set correctly");
|
|
|
|
oldPixel.x = 100;
|
|
t.eq( pixel.x, 5, "changing oldPixel.x doesn't change pixel.x");
|
|
}
|
|
|
|
function test_06_Pixel_equals(t) {
|
|
t.plan( 5 );
|
|
pixel = new OpenLayers.Pixel(5,6);
|
|
|
|
px = new OpenLayers.Pixel(5,6);
|
|
t.eq( pixel.equals(px), true, "(5,6) equals (5,6)");
|
|
|
|
px = new OpenLayers.Pixel(1,6);
|
|
t.eq( pixel.equals(px), false, "(5,6) does not equal (1,6)");
|
|
|
|
px = new OpenLayers.Pixel(5,2);
|
|
t.eq( pixel.equals(px), false, "(5,6) does not equal (5,2)");
|
|
|
|
px = new OpenLayers.Pixel(1,2);
|
|
t.eq( pixel.equals(px), false, "(5,6) does not equal (1,2)");
|
|
|
|
t.ok( !pixel.equals(null), "equals() returns false on comparison to null");
|
|
|
|
}
|
|
|
|
function test_07_Pixel_add(t) {
|
|
t.plan( 4 );
|
|
oldPixel = new OpenLayers.Pixel(5,6);
|
|
|
|
pixel = oldPixel.add(10,20);
|
|
|
|
t.eq( oldPixel.x, 5, "oldPixel.x not modified by add operation");
|
|
t.eq( oldPixel.y, 6, "oldPixel.y not modified by add operation");
|
|
|
|
t.eq( pixel.x, 15, "pixel.x is set correctly");
|
|
t.eq( pixel.y, 26, "pixel.y is set correctly");
|
|
}
|
|
|
|
function test_08_Pixel_offset(t) {
|
|
t.plan( 4 );
|
|
|
|
var oldPixel = new OpenLayers.Pixel(5,6);
|
|
var offset = new OpenLayers.Pixel(10,20);
|
|
|
|
pixel = oldPixel.offset(offset);
|
|
|
|
t.eq( oldPixel.x, 5, "oldPixel.x not modified by offset operation");
|
|
t.eq( oldPixel.y, 6, "oldPixel.y not modified by offset operation");
|
|
|
|
t.eq( pixel.x, 15, "pixel.x is set correctly");
|
|
t.eq( pixel.y, 26, "pixel.y is set correctly");
|
|
}
|
|
|
|
// -->
|
|
</script>
|
|
</head>
|
|
<body>
|
|
</body>
|
|
</html>
|