OpenLayers OpenLayers

root/trunk/openlayers/tests/Layer/MultiMap.html

Revision 6724, 3.9 kB (checked in by euzuro, 9 months ago)

fix up tests, remove _01_. (Closes #1387)

  • Property svn:eol-style set to native
Line 
1 <html>
2 <head>
3       <script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>
4   <script src="../../lib/OpenLayers.js"></script>
5   <script type="text/javascript">
6     var layer;
7
8     function test_Layer_MultiMap_constructor (t) {
9         t.plan( 4 );
10        
11         var map = new OpenLayers.Map('map');
12         var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
13         map.addLayer(layer);
14        
15        
16         t.ok( layer instanceof OpenLayers.Layer.MultiMap, "new OpenLayers.Layer.MultiMap returns object" );
17         t.eq( layer.CLASS_NAME, "OpenLayers.Layer.MultiMap", "CLASS_NAME variable set correctly");
18
19         t.eq( layer.name, "Goog Layer", "layer.name is correct" );
20
21         t.ok ( layer.mapObject != null, "MultiMap Object correctly loaded");
22     }
23
24     function test_Layer_MultiMap_isBaseLayer (t) {
25         t.plan(1);
26        
27         var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
28
29         t.ok(layer.isBaseLayer, "a default load of google layer responds as a base layer");
30     }   
31
32     function test_Layer_MultiMap_Translation_lonlat (t) {
33        
34         t.plan( 4 );
35        
36         var map = new OpenLayers.Map('map');
37         var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
38         map.addLayer(layer);
39
40      // these two lines specify an appropriate translation.
41      //  the code afterwards works by itself to test that translation
42      //  works correctly both ways.
43         var gLatLng = new MMLatLon(50,100);
44         var correspondingOLLonLat = new OpenLayers.LonLat(100,50);
45
46
47         olLonLat = layer.getOLLonLatFromMapObjectLonLat(gLatLng);
48         t.ok(olLonLat.equals(correspondingOLLonLat), "Translation from GLatLng to OpenLayers.LonLat works");
49
50         var transGLatLng = layer.getMapObjectLonLatFromOLLonLat(olLonLat);
51         t.ok( (transGLatLng.lat == gLatLng.lat) && (transGLatLng.lon == transGLatLng.lon), "Translation from OpenLayers.LonLat to GLatLng works");
52
53         t.ok( layer.getMapObjectLonLatFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
54         t.ok( layer.getOLLonLatFromMapObjectLonLat(null) == null, "getOLLonLatFromGLatLng(null) returns null");
55     }
56
57     function test_Layer_MultiMap_Translation_pixel (t) {
58        
59         t.plan( 4 );
60        
61         var map = new OpenLayers.Map('map');
62         var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
63         map.addLayer(layer);
64
65      // these two lines specify an appropriate translation.
66      //  the code afterwards works by itself to test that translation
67      //  works correctly both ways.
68         var gPoint = new MMPoint(50,100);
69         var correspondingOLPixel = new OpenLayers.Pixel(50, 100);
70
71
72         olPixel = layer.getOLPixelFromMapObjectPixel(gPoint);
73         t.ok( olPixel.equals(correspondingOLPixel), "Translation from GPoint to OpenLayers.Pixel works");
74
75         var transGPoint = layer.getMapObjectPixelFromOLPixel(olPixel);
76         t.ok( ((transGPoint.x == transGPoint.x) && (transGPoint.y == transGPoint.y)), "Translation from OpenLayers.Pixel to GPoint works");
77
78         t.ok( layer.getMapObjectPixelFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
79         t.ok( layer.getOLPixelFromMapObjectPixel(null) == null, "getOLPixelFromGPoint(null) returns null");
80     }
81
82
83     function test_Layer_destroy (t) {
84         t.plan( 5 );   
85
86         var map = new OpenLayers.Map('map');
87        
88         layer = new OpenLayers.Layer.MultiMap('Test Layer');
89         map.addLayer(layer);
90
91         layer.destroy();
92
93         t.eq( layer.name, null, "layer.name is null after destroy" );
94         t.eq( layer.div, null, "layer.div is null after destroy" );
95         t.eq( layer.map, null, "layer.map is null after destroy" );
96         t.eq( layer.options, null, "layer.options is null after destroy" );
97         t.eq( layer.multimap, null, "layer.gmap is null after destroy" );
98     }
99
100   </script>
101 </head>
102 <body>
103   <div id="map"></div>
104 </body>
105 </html>
Note: See TracBrowser for help on using the browser.