Project

General

Profile

1
<html>
2
<head>
3
  <script src="../lib/OpenLayers.js"></script>
4
  <script type="text/javascript"><!--
5
    var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
6
    var map; 
7
    var feature, layer; 
8
    
9
    function test_01_Feature_constructor (t) {
10
        t.plan( 6 );
11

    
12
        var layer = new Object();
13
        var lonlat = new OpenLayers.LonLat(2,1);
14
        var iconURL = 'http://boston.openguides.org/features/ORANGE.png';
15
        var iconSize = new OpenLayers.Size(12, 17);
16
        var data =  { iconURL: iconURL,
17
                      iconSize: iconSize 
18
                    };
19
        
20
        feature = new OpenLayers.Feature(layer, lonlat, data);
21

    
22
        t.ok( feature instanceof OpenLayers.Feature, "new OpenLayers.Feature returns Feature object" );
23
        t.eq( feature.layer, layer, "feature.layer set correctly" );
24
        t.ok( feature.id.startsWith("Feature_"), "feature.id set correctly" );
25
        t.ok( feature.lonlat.equals(lonlat), "feature.lonlat set correctly" );
26
        t.eq( feature.data.iconURL, iconURL, "feature.data.iconURL set correctly" );
27
        t.ok( feature.data.iconSize.equals(iconSize), "feature.data.iconSize set correctly" );
28
    }
29
    
30
    function test_02_Feature_createMarker (t) {
31
        t.plan(1);
32
        t.ok(true);
33
/*
34

    
35
        t.plan( 11 );
36
        feature = new OpenLayers.Feature("myfeature", new OpenLayers.LonLat(2,1), 
37
               {
38
                iconURL:'http://boston.openguides.org/features/ORANGE.png',
39
                iconW: 12,
40
                iconH: 17
41
               });
42
        layer = new OpenLayers.Layer.Markers('Marker Layer');
43
        t.ok( feature instanceof OpenLayers.Feature, "new OpenLayers.Feature returns Feature object" );
44
        t.ok( layer instanceof OpenLayers.Layer.Markers, "Layer is a marker layer" );
45
        feature.createMarker(layer);
46
        
47
        t.ok( feature.marker instanceof OpenLayers.Marker, 
48
              "createMarker sets a marker property to a marker" );
49
        t.ok( layer.markers[0] === feature.marker, 
50
              "First marker in layer is the feature marker" );
51
        
52
        t.ok( feature.marker.lonlat instanceof OpenLayers.LonLat, 
53
              "createMarker sets a marker lontlat property to a lonlat" );
54
        t.ok( layer.markers[0].lonlat === feature.lonlat, 
55
              "First marker in the layer matches feature lonlat" );
56
        
57
        t.ok( feature.marker.icon instanceof OpenLayers.Icon, 
58
              "createMarker sets a marker icon property to an icon" );
59
        
60
        t.eq( feature.marker.icon.url, 
61
              "http://boston.openguides.org/features/ORANGE.png", 
62
              "createMarker sets marker url correctly" );
63
       
64
        var map = new OpenLayers.Map('map');
65
        map.addLayer(layer);
66
        map.setCenter(new OpenLayers.LonLat(0,0),0);
67
        t.ok( map.layers[0] == layer,
68
              "Marker layer added to map okay." );
69
        if (!isMozilla)
70
            t.ok( true, "skipping element test outside of Mozilla");
71
        else
72
            t.ok( map.layers[0].div.firstChild instanceof HTMLImageElement,
73
                  "layer div firstChild is an image" );
74
        t.eq( map.layers[0].div.firstChild.src,
75
              "http://boston.openguides.org/features/ORANGE.png", 
76
              "Layer div img contains correct url" );
77
*/
78
    }
79

    
80
  // -->
81
  </script>
82
</head>
83
<body>
84
  <div id="map" style="width: 500px; height: 300px;"></div>
85
</body>
86
</html>
(14-14/35)