Project

General

Profile

1 3032 perry
<html>
2
<head>
3
  <script src="../lib/OpenLayers.js"></script>
4
  <script type="text/javascript"><!--
5
    var pixel;
6
7
    function test_01_Pixel_constructor (t) {
8
        t.plan( 4 );
9
        pixel = new OpenLayers.Pixel(5,6);
10
        t.ok( pixel instanceof OpenLayers.Pixel, "new OpenLayers.Pixel returns Pixel object" );
11
        t.eq( pixel.CLASS_NAME, "OpenLayers.Pixel", "pixel.CLASS_NAME is set correctly");
12
        t.eq( pixel.x, 5, "pixel.x is set correctly");
13
        t.eq( pixel.y, 6, "pixel.y is set correctly");
14
    }
15
16
    function test_02_Pixel_toString(t) {
17
        t.plan( 1 );
18
        pixel = new OpenLayers.Pixel(5,6);
19
        t.eq( pixel.toString(), "x=5,y=6", "pixel.toString() returns correctly");
20
    }
21
22
    function test_03_Pixel_clone(t) {
23
        t.plan( 4 );
24
        oldPixel = new OpenLayers.Pixel(5,6);
25
        pixel = oldPixel.clone();
26
        t.ok( pixel instanceof OpenLayers.Pixel, "clone returns new OpenLayers.Pixel object" );
27
        t.eq( pixel.x, 5, "pixel.x is set correctly");
28
        t.eq( pixel.y, 6, "pixel.y is set correctly");
29
30
        oldPixel.x = 100;
31
        t.eq( pixel.x, 5, "changing oldPixel.x doesn't change pixel.x");
32
    }
33
34
    function test_06_Pixel_equals(t) {
35
        t.plan( 5 );
36
        pixel = new OpenLayers.Pixel(5,6);
37
38
        px = new OpenLayers.Pixel(5,6);
39
        t.eq( pixel.equals(px), true, "(5,6) equals (5,6)");
40
41
        px = new OpenLayers.Pixel(1,6);
42
        t.eq( pixel.equals(px), false, "(5,6) does not equal (1,6)");
43
44
        px = new OpenLayers.Pixel(5,2);
45
        t.eq( pixel.equals(px), false, "(5,6) does not equal (5,2)");
46
47
        px = new OpenLayers.Pixel(1,2);
48
        t.eq( pixel.equals(px), false, "(5,6) does not equal (1,2)");
49
50
        t.ok( !pixel.equals(null), "equals() returns false on comparison to null");
51
52
    }
53
54
    function test_07_Pixel_add(t) {
55
        t.plan( 4 );
56
        oldPixel = new OpenLayers.Pixel(5,6);
57
58
        pixel = oldPixel.add(10,20);
59
60
        t.eq( oldPixel.x, 5, "oldPixel.x not modified by add operation");
61
        t.eq( oldPixel.y, 6, "oldPixel.y not modified by add operation");
62
63
        t.eq( pixel.x, 15, "pixel.x is set correctly");
64
        t.eq( pixel.y, 26, "pixel.y is set correctly");
65
    }
66
67
    function test_08_Pixel_offset(t) {
68
        t.plan( 4 );
69
70
        var oldPixel = new OpenLayers.Pixel(5,6);
71
        var offset = new OpenLayers.Pixel(10,20);
72
73
        pixel = oldPixel.offset(offset);
74
75
        t.eq( oldPixel.x, 5, "oldPixel.x not modified by offset operation");
76
        t.eq( oldPixel.y, 6, "oldPixel.y not modified by offset operation");
77
78
        t.eq( pixel.x, 15, "pixel.x is set correctly");
79
        t.eq( pixel.y, 26, "pixel.y is set correctly");
80
    }
81
82
  // -->
83
  </script>
84
</head>
85
<body>
86
</body>
87
</html>