1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
<html>
<head>
<script src="../OLLoader.js"></script>
<script type="text/javascript">
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
var isMSIE = (navigator.userAgent.indexOf("MSIE") > -1);
var layer;
var georss_txt = "./georss.txt";
var atom_xml = "./atom-1.0.xml";
// if this test is running online, different rules apply
if (isMSIE) {
georss_txt = "." + georss_txt;
atom_xml = "." + atom_xml;
}
function test_Layer_GeoRSS_constructor (t) {
t.plan( 7 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt );
t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" );
t.eq( layer.location, georss_txt, "layer.location is correct" );
var markers;
layer.loadRSS();
t.delay_call( 1, function() {
t.eq( layer.markers.length, 40, "marker length is correct" );
var ll = new OpenLayers.LonLat(-71.142197, 42.405696);
var theTitle = "Knitting Room";
var theDescription = 'This little shop is jammed full. Yarn, yarn everywhere. They make the most of every possible nook and cranny. I like this place also because they have a lot of different kinds of knitting needles in all different sizes. Also, the people who work here are younger and hipper than in the other stores I go to. I reccomend buying supplies here and then knitting your way through a good documentary at the Capitol Theater across the street.<br/>Address: 2 lake St, Arlington, MA <br/>Tags: knitting, yarn, pins and needles, handspun, hand dyed, novelty yarn, fancy, simple, young, hip, friendly, needles, addy, cute hats<br /><br /><a href="http://platial.com/place/90306">Map this on Platial</a><br /> <a href="http://platial.com/place_grab/90306">Grab this on Platial</a> ';
t.ok( layer.markers[0].lonlat.equals(ll), "lonlat on first marker is correct" );
t.eq( layer.name, "Crschmidt's Places At Platial", "Layer name is correct." );
t.eq( layer.features[0].data.title, theTitle);
t.eq( layer.features[0].data.description, theDescription);
} );
}
function test_Layer_GeoRSS_dontUseFeedTitle (t) {
t.plan( 1 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt, {'useFeedTitle': false} );
t.delay_call( 1, function() {
t.eq( layer.name, "Test Layer", "Layer name is correct when not used from feed." );
} );
}
function test_Layer_GeoRSS_AtomParsing (t) {
t.plan( 6 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', atom_xml );
t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" );
t.eq( layer.location, atom_xml, "layer.location is correct" );
var markers;
layer.loadRSS();
t.delay_call( 1, function() {
t.eq( layer.markers.length, 2, "marker length is correct" );
var ll = new OpenLayers.LonLat(29.9805, 36.7702);
t.ok( layer.markers[0].lonlat.equals(ll), "lonlat on first marker is correct" );
t.like( layer.features[0].data['popupContentHTML'], '<a class="link" href="http://pleiades.stoa.org/places/638896" target="_blank">Unnamed Tumulus</a>', "Link is correct.");
t.eq( layer.name, "tumulus", "Layer name is correct." );
} );
}
function test_Layer_GeoRSS_draw (t) {
// t.plan(5);
t.plan( 2 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" );
var map = new OpenLayers.Map('map');
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(baseLayer);
map.addLayer(layer);
t.delay_call( 1, function() {
map.setCenter(new OpenLayers.LonLat(0,0),0);
t.eq( map.layers[1].name, layer.name, "Layer name is correct" );
});;
}
function test_Layer_GeoRSS_load_events (t) {
t.plan( 1 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
var map = new OpenLayers.Map('map');
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(baseLayer);
map.addLayer(layer);
layer.events.register("loadstart", t, function() { this.ok(true, "loadstart event triggered once (#1580)") });
map.setCenter(new OpenLayers.LonLat(0,0),0);
}
function test_Layer_GeoRSS_events (t) {
t.plan( 4 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
var map = new OpenLayers.Map('map');
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(baseLayer);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0),0);
var event = {};
t.delay_call( 2, function() {
t.ok(layer.markers[0].events, "First marker has an events object");
t.eq(layer.markers[0].events.listeners['click'].length, 1, "Marker events has one object");
layer.markers[0].events.triggerEvent('click', event);
t.eq(map.popups.length, 1, "Popup opened correctly");
layer.markers[1].events.triggerEvent('click', event);
t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly");
});
}
function test_Layer_GeoRSS_popups (t) {
t.plan( 4 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
var map = new OpenLayers.Map('map');
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(baseLayer);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0),0);
var event = {};
t.delay_call( 1, function() {
t.ok(layer.markers[0].events, "First marker has an events object");
t.eq(layer.markers[0].events.listeners['click'].length, 1, "Marker events has one object");
layer.markers[0].events.triggerEvent('click', event);
t.eq(map.popups.length, 1, "Popup opened correctly");
layer.markers[1].events.triggerEvent('click', event);
t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly");
});
}
function test_Layer_GeoRSS_resizedPopups(t) {
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt, {'popupSize': new OpenLayers.Size(200,100)});
t.plan( 4 );
var map = new OpenLayers.Map('map');
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(baseLayer);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0),0);
var event = {};
t.delay_call( 1, function() {
t.ok(layer.markers[0].events, "First marker has an events object");
t.eq(layer.markers[0].events.listeners['click'].length, 1, "Marker events has one object");
layer.markers[0].events.triggerEvent('click', event);
t.eq(map.popups.length, 1, "Popup opened correctly");
map.popups[0].size.w=300;
layer.markers[1].events.triggerEvent('click', event);
t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly");
});
}
function test_Layer_GeoRSS_icon(t) {
t.plan( 3 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
var the_icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png');
var otherLayer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt,{icon:the_icon});
var map = new OpenLayers.Map('map');
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
"http://octo.metacarta.com/cgi-bin/mapserv?",
{map: "/mapdata/vmap_wms.map", layers: "basic"});
map.addLayer(baseLayer);
map.addLayers([layer,otherLayer]);
map.setCenter(new OpenLayers.LonLat(0,0),0);
var defaultIcon = OpenLayers.Marker.defaultIcon();
layer.loadRSS();
otherLayer.loadRSS();
t.delay_call( 2, function() {
t.ok(layer.markers[0].icon, "The layer has a icon");
t.eq(layer.markers[0].icon.url, defaultIcon.url, "The layer without icon has the default icon.");
t.eq(otherLayer.markers[0].icon.url, the_icon.url,"The layer with an icon has that icon.");
});
}
function test_Layer_GeoRSS_loadend_Event(t) {
var browserCode = OpenLayers.BROWSER_NAME;
if (browserCode == "msie") {
t.plan(1);
t.ok(true, "IE fails the GeoRSS test. This could probably be fixed by someone with enough energy to fix it.");
} else {
t.plan(2);
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
t.delay_call(2, function() {
layer.events.register('loadend', layer, function() {
t.ok(true, "Loadend event fired");
});
layer.parseData({
'responseText': '<xml xmlns="http://example.com"><title> </title></xml>'
});
t.ok(true, "Parsing data didn't fail");
});
}
}
function test_Layer_GeoRSS_destroy (t) {
t.plan( 1 );
layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt);
var map = new OpenLayers.Map('map');
map.addLayer(layer);
t.delay_call( 1, function() {
layer.destroy();
t.eq( layer.map, null, "layer.map is null after destroy" );
});
}
</script>
</head>
<body>
<div id="map" style="width:500px; height:500px"></div>
</body>
</html>
|