git-svn-id: http://svn.openlayers.org/trunk/openlayers@129 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
70 lines
2.1 KiB
HTML
70 lines
2.1 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_copyOf(t) {
|
|
t.plan( 4 );
|
|
oldPixel = new OpenLayers.Pixel(5,6);
|
|
pixel = oldPixel.copyOf();
|
|
t.ok( pixel instanceof OpenLayers.Pixel, "copyOf 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( 4 );
|
|
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)");
|
|
}
|
|
|
|
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");
|
|
}
|
|
|
|
// -->
|
|
</script>
|
|
</head>
|
|
<body>
|
|
</body>
|
|
</html>
|