| 223 | | var map, model, tree, node; |
|---|
| 224 | | |
|---|
| 225 | | t.plan(5 + 20 + 20 + 13 + 7); |
|---|
| 226 | | |
|---|
| 227 | | ////////////////////////////////////////////////////////////// |
|---|
| 228 | | // Test environment 1 |
|---|
| 229 | | // Map with one baseLayer |
|---|
| 230 | | // Automatic model generation |
|---|
| 231 | | |
|---|
| 232 | | map = createMap(); |
|---|
| 233 | | |
|---|
| 234 | | var wms = new OpenLayers.Layer.WMS("vmap0", |
|---|
| 235 | | "http://labs.metacarta.com/wms/vmap0", |
|---|
| 236 | | {layers: 'basic'}, |
|---|
| 237 | | {isBaseLayer: true} |
|---|
| 238 | | ); |
|---|
| 239 | | map.addLayer(wms); |
|---|
| 240 | | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| 241 | | |
|---|
| 242 | | tree = createTree(map); |
|---|
| 243 | | |
|---|
| 244 | | expectedStatus = [ |
|---|
| 245 | | {text: "Root"}, |
|---|
| 246 | | {text: "vmap0", attr_checked: true, radio: true} |
|---|
| 247 | | ]; |
|---|
| 248 | | checkStatus(t, tree, expectedStatus); // 5 tests |
|---|
| 249 | | |
|---|
| 250 | | reset(); |
|---|
| 251 | | |
|---|
| 252 | | ////////////////////////////////////////////////////////////// |
|---|
| 253 | | // Test environment 2 |
|---|
| 254 | | // Map with base layers and WMS service |
|---|
| 255 | | // The WMS sublayers should be drawn as children of the WMS layer |
|---|
| 256 | | |
|---|
| 257 | | map = createMap(); |
|---|
| 258 | | |
|---|
| 259 | | var wms = new OpenLayers.Layer.WMS("vmap0", |
|---|
| 260 | | "http://labs.metacarta.com/wms/vmap0", |
|---|
| 261 | | {layers: 'basic'}, |
|---|
| 262 | | {isBaseLayer: true} |
|---|
| 263 | | ); |
|---|
| 264 | | map.addLayer(wms); |
|---|
| 265 | | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| 266 | | |
|---|
| 267 | | var c2cwmsLayers = ['parkings', 'summits', 'refuges', 'sites']; |
|---|
| 268 | | c2cwms = new OpenLayers.Layer.WMS("C2C Objects", |
|---|
| 269 | | "http://demo.mapfish.org/mapfishsample/trunk/wms?", |
|---|
| 270 | | { |
|---|
| 271 | | singleTile: true, |
|---|
| 272 | | layers: c2cwmsLayers, |
|---|
| 273 | | format: 'image/png', |
|---|
| 274 | | transparent: true |
|---|
| 275 | | } |
|---|
| 276 | | ); |
|---|
| 277 | | c2cwms.setVisibility(false); |
|---|
| 278 | | map.addLayer(c2cwms); |
|---|
| 279 | | |
|---|
| 280 | | tree = createTree(map); |
|---|
| 281 | | |
|---|
| 282 | | expectedStatus = [ |
|---|
| 283 | | {text: "Root"}, |
|---|
| 284 | | {text: "vmap0", attr_checked: true, radio: true}, |
|---|
| 285 | | {text: "C2C Objects", attr_checked: false}, |
|---|
| 286 | | {text: "parkings", attr_checked: false}, |
|---|
| 287 | | {text: "summits", attr_checked: false}, |
|---|
| 288 | | {text: "refuges", attr_checked: false}, |
|---|
| 289 | | {text: "sites", attr_checked: false} |
|---|
| 290 | | ]; |
|---|
| 291 | | |
|---|
| 292 | | checkStatus(t, tree, expectedStatus); // 20 tests |
|---|
| 293 | | |
|---|
| 294 | | resetTree(); |
|---|
| 295 | | |
|---|
| 296 | | // Testing ascending property |
|---|
| 297 | | // |
|---|
| 298 | | tree = createTree(map, null, {ascending: false}); |
|---|
| 299 | | |
|---|
| 300 | | expectedStatus = [ |
|---|
| 301 | | {text: "Root"}, |
|---|
| 302 | | {text: "C2C Objects", attr_checked: false}, |
|---|
| 303 | | {text: "parkings", attr_checked: false}, |
|---|
| 304 | | {text: "summits", attr_checked: false}, |
|---|
| 305 | | {text: "refuges", attr_checked: false}, |
|---|
| 306 | | {text: "sites", attr_checked: false}, |
|---|
| 307 | | {text: "vmap0", attr_checked: true, radio: true} |
|---|
| 308 | | ]; |
|---|
| 309 | | |
|---|
| 310 | | checkStatus(t, tree, expectedStatus); // 20 tests |
|---|
| 311 | | |
|---|
| 312 | | reset(); |
|---|
| 313 | | |
|---|
| 314 | | ////////////////////////////////////////////////////////////// |
|---|
| 315 | | // Test environment 3 |
|---|
| 316 | | // Map with one baseLayer, and two overlays |
|---|
| 317 | | // Some layers have displayInLayerSwitcher set to false |
|---|
| 318 | | // Automatic model generation |
|---|
| 319 | | // |
|---|
| 320 | | // This tests that layers with displayInLayerSwitcher=false are |
|---|
| 321 | | // not visible |
|---|
| 322 | | |
|---|
| 323 | | map = createMap(); |
|---|
| 324 | | |
|---|
| 325 | | var wms = new OpenLayers.Layer.WMS("vmap0", |
|---|
| 326 | | "http://labs.metacarta.com/wms/vmap0", |
|---|
| 327 | | { |
|---|
| 328 | | layers: 'basic' |
|---|
| 329 | | },{ |
|---|
| 330 | | isBaseLayer: true, |
|---|
| 331 | | displayInLayerSwitcher: false |
|---|
| 332 | | } |
|---|
| 333 | | ); |
|---|
| 334 | | map.addLayer(wms); |
|---|
| 335 | | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| 336 | | |
|---|
| 337 | | var twms = new OpenLayers.Layer.WMS("World Map", |
|---|
| 338 | | "http://world.freemap.in/cgi-bin/mapserv?", |
|---|
| 339 | | { |
|---|
| 340 | | map: '/www/freemap.in/world/map/factbooktrans.map', |
|---|
| 341 | | layers: 'factbook', |
|---|
| 342 | | format: 'image/png', |
|---|
| 343 | | transparent: true |
|---|
| 344 | | },{ |
|---|
| 345 | | displayInLayerSwitcher: false |
|---|
| 346 | | } |
|---|
| 347 | | ); |
|---|
| 348 | | twms.setVisibility(false); |
|---|
| 349 | | map.addLayer(twms); |
|---|
| 350 | | |
|---|
| 351 | | var jpl_wms = new OpenLayers.Layer.WMS("Satellite", |
|---|
| 352 | | "http://labs.metacarta.com/wms-c/Basic.py?", |
|---|
| 353 | | { |
|---|
| 354 | | layers: 'satellite', |
|---|
| 355 | | format: 'image/png', |
|---|
| 356 | | transparent: true |
|---|
| 357 | | } |
|---|
| 358 | | ); |
|---|
| 359 | | jpl_wms.setVisibility(true); |
|---|
| 360 | | map.addLayer(jpl_wms); |
|---|
| 361 | | |
|---|
| 362 | | tree = createTree(map); |
|---|
| 363 | | |
|---|
| 364 | | expectedStatus = [ |
|---|
| 365 | | {text: "Root"}, |
|---|
| 366 | | {text: "vmap0", attr_checked: true, attr_cls: 'x-hidden', radio: true}, |
|---|
| 367 | | {text: "World Map", attr_checked: false, attr_cls: 'x-hidden'}, |
|---|
| 368 | | {text: "Satellite", attr_checked: true} |
|---|
| 369 | | ]; |
|---|
| 370 | | checkStatus(t, tree, expectedStatus); // 13 tests |
|---|
| 371 | | |
|---|
| 372 | | expectedOlStatus = [ |
|---|
| 373 | | {name: "vmap0", visibility: true}, |
|---|
| 374 | | {name: "World Map", visibility: false}, |
|---|
| 375 | | {name: "Satellite", visibility: true} |
|---|
| 376 | | ]; |
|---|
| 377 | | checkOlStatus(t, map, expectedOlStatus); // 7 tests |
|---|
| 378 | | |
|---|
| 379 | | reset(); |
|---|
| 380 | | |
|---|
| 381 | | // TODO: test how displayInLayerSwitcher interacts with |
|---|
| 382 | | // reordering (drag/drop) |
|---|
| | 223 | function __test_AutomaticModel(layerClass) { |
|---|
| | 224 | var map, layer, model, tree, node; |
|---|
| | 225 | |
|---|
| | 226 | ////////////////////////////////////////////////////////////// |
|---|
| | 227 | // Test environment 1 |
|---|
| | 228 | // Map with one baseLayer |
|---|
| | 229 | // Automatic model generation |
|---|
| | 230 | |
|---|
| | 231 | map = createMap(); |
|---|
| | 232 | |
|---|
| | 233 | layer = new layerClass("vmap0", |
|---|
| | 234 | "http://labs.metacarta.com/wms/vmap0", |
|---|
| | 235 | {layers: 'basic'}, |
|---|
| | 236 | {isBaseLayer: true} |
|---|
| | 237 | ); |
|---|
| | 238 | map.addLayer(layer); |
|---|
| | 239 | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| | 240 | |
|---|
| | 241 | tree = createTree(map); |
|---|
| | 242 | |
|---|
| | 243 | expectedStatus = [ |
|---|
| | 244 | {text: "Root"}, |
|---|
| | 245 | {text: "vmap0", attr_checked: true, radio: true} |
|---|
| | 246 | ]; |
|---|
| | 247 | checkStatus(t, tree, expectedStatus); // 5 tests |
|---|
| | 248 | |
|---|
| | 249 | reset(); |
|---|
| | 250 | |
|---|
| | 251 | ////////////////////////////////////////////////////////////// |
|---|
| | 252 | // Test environment 2 |
|---|
| | 253 | // Map with one base layer and one overlay with sublayers |
|---|
| | 254 | // The sublayers should be drawn as children of the overlay |
|---|
| | 255 | |
|---|
| | 256 | map = createMap(); |
|---|
| | 257 | |
|---|
| | 258 | layer = new layerClass("vmap0", |
|---|
| | 259 | "http://labs.metacarta.com/wms/vmap0", |
|---|
| | 260 | {layers: 'basic'}, |
|---|
| | 261 | {isBaseLayer: true} |
|---|
| | 262 | ); |
|---|
| | 263 | map.addLayer(layer); |
|---|
| | 264 | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| | 265 | |
|---|
| | 266 | var c2cLayers = ['parkings', 'summits', 'refuges', 'sites']; |
|---|
| | 267 | layer = new layerClass("C2C Objects", |
|---|
| | 268 | "http://demo.mapfish.org/mapfishsample/trunk/wms?", |
|---|
| | 269 | { |
|---|
| | 270 | singleTile: true, |
|---|
| | 271 | layers: c2cLayers, |
|---|
| | 272 | format: 'image/png', |
|---|
| | 273 | transparent: true |
|---|
| | 274 | } |
|---|
| | 275 | ); |
|---|
| | 276 | layer.setVisibility(false); |
|---|
| | 277 | map.addLayer(layer); |
|---|
| | 278 | |
|---|
| | 279 | tree = createTree(map); |
|---|
| | 280 | |
|---|
| | 281 | expectedStatus = [ |
|---|
| | 282 | {text: "Root"}, |
|---|
| | 283 | {text: "vmap0", attr_checked: true, radio: true}, |
|---|
| | 284 | {text: "C2C Objects", attr_checked: false}, |
|---|
| | 285 | {text: "parkings", attr_checked: false}, |
|---|
| | 286 | {text: "summits", attr_checked: false}, |
|---|
| | 287 | {text: "refuges", attr_checked: false}, |
|---|
| | 288 | {text: "sites", attr_checked: false} |
|---|
| | 289 | ]; |
|---|
| | 290 | |
|---|
| | 291 | checkStatus(t, tree, expectedStatus); // 20 tests |
|---|
| | 292 | |
|---|
| | 293 | resetTree(); |
|---|
| | 294 | |
|---|
| | 295 | // Testing ascending property |
|---|
| | 296 | // |
|---|
| | 297 | tree = createTree(map, null, {ascending: false}); |
|---|
| | 298 | |
|---|
| | 299 | expectedStatus = [ |
|---|
| | 300 | {text: "Root"}, |
|---|
| | 301 | {text: "C2C Objects", attr_checked: false}, |
|---|
| | 302 | {text: "parkings", attr_checked: false}, |
|---|
| | 303 | {text: "summits", attr_checked: false}, |
|---|
| | 304 | {text: "refuges", attr_checked: false}, |
|---|
| | 305 | {text: "sites", attr_checked: false}, |
|---|
| | 306 | {text: "vmap0", attr_checked: true, radio: true} |
|---|
| | 307 | ]; |
|---|
| | 308 | |
|---|
| | 309 | checkStatus(t, tree, expectedStatus); // 20 tests |
|---|
| | 310 | |
|---|
| | 311 | reset(); |
|---|
| | 312 | |
|---|
| | 313 | ////////////////////////////////////////////////////////////// |
|---|
| | 314 | // Test environment 3 |
|---|
| | 315 | // Map with one baseLayer, and two overlays |
|---|
| | 316 | // Some layers have displayInLayerSwitcher set to false |
|---|
| | 317 | // Automatic model generation |
|---|
| | 318 | // |
|---|
| | 319 | // This tests that layers with displayInLayerSwitcher=false are |
|---|
| | 320 | // not visible |
|---|
| | 321 | |
|---|
| | 322 | map = createMap(); |
|---|
| | 323 | |
|---|
| | 324 | layer = new layerClass("vmap0", |
|---|
| | 325 | "http://labs.metacarta.com/wms/vmap0", |
|---|
| | 326 | { |
|---|
| | 327 | layers: 'basic' |
|---|
| | 328 | },{ |
|---|
| | 329 | isBaseLayer: true, |
|---|
| | 330 | displayInLayerSwitcher: false |
|---|
| | 331 | } |
|---|
| | 332 | ); |
|---|
| | 333 | map.addLayer(layer); |
|---|
| | 334 | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| | 335 | |
|---|
| | 336 | layer = new layerClass("World Map", |
|---|
| | 337 | "http://world.freemap.in/cgi-bin/mapserv?", |
|---|
| | 338 | { |
|---|
| | 339 | map: '/www/freemap.in/world/map/factbooktrans.map', |
|---|
| | 340 | layers: 'factbook', |
|---|
| | 341 | format: 'image/png', |
|---|
| | 342 | transparent: true |
|---|
| | 343 | },{ |
|---|
| | 344 | displayInLayerSwitcher: false |
|---|
| | 345 | } |
|---|
| | 346 | ); |
|---|
| | 347 | layer.setVisibility(false); |
|---|
| | 348 | map.addLayer(layer); |
|---|
| | 349 | |
|---|
| | 350 | layer = new layerClass("Satellite", |
|---|
| | 351 | "http://labs.metacarta.com/wms-c/Basic.py?", |
|---|
| | 352 | { |
|---|
| | 353 | layers: 'satellite', |
|---|
| | 354 | format: 'image/png', |
|---|
| | 355 | transparent: true |
|---|
| | 356 | } |
|---|
| | 357 | ); |
|---|
| | 358 | layer.setVisibility(true); |
|---|
| | 359 | map.addLayer(layer); |
|---|
| | 360 | |
|---|
| | 361 | tree = createTree(map); |
|---|
| | 362 | |
|---|
| | 363 | expectedStatus = [ |
|---|
| | 364 | {text: "Root"}, |
|---|
| | 365 | {text: "vmap0", attr_checked: true, attr_cls: 'x-hidden', radio: true}, |
|---|
| | 366 | {text: "World Map", attr_checked: false, attr_cls: 'x-hidden'}, |
|---|
| | 367 | {text: "Satellite", attr_checked: true} |
|---|
| | 368 | ]; |
|---|
| | 369 | checkStatus(t, tree, expectedStatus); // 13 tests |
|---|
| | 370 | |
|---|
| | 371 | expectedOlStatus = [ |
|---|
| | 372 | {name: "vmap0", visibility: true}, |
|---|
| | 373 | {name: "World Map", visibility: false}, |
|---|
| | 374 | {name: "Satellite", visibility: true} |
|---|
| | 375 | ]; |
|---|
| | 376 | checkOlStatus(t, map, expectedOlStatus); // 7 tests |
|---|
| | 377 | |
|---|
| | 378 | reset(); |
|---|
| | 379 | |
|---|
| | 380 | // TODO: test how displayInLayerSwitcher interacts with |
|---|
| | 381 | // reordering (drag/drop) |
|---|
| | 382 | } |
|---|
| | 383 | |
|---|
| | 384 | t.plan(2*(5 + 20 + 20 + 13 + 7)); |
|---|
| | 385 | |
|---|
| | 386 | __test_AutomaticModel(OpenLayers.Layer.WMS); |
|---|
| | 387 | __test_AutomaticModel(OpenLayers.Layer.MapServer); |
|---|
| 387 | | var map, model, tree; |
|---|
| 388 | | |
|---|
| 389 | | t.plan(3 + 3 + |
|---|
| 390 | | 23 + 5 + 23 + 5 + 23 + 5 + |
|---|
| 391 | | 30 + 7 + 30 + 7 + 30 + 7); |
|---|
| 392 | | |
|---|
| 393 | | ////////////////////////////////////////////////////////////// |
|---|
| 394 | | // Test environment 1 |
|---|
| 395 | | // Map with one baseLayer |
|---|
| 396 | | // User model with one layer mapped 1:1 |
|---|
| 397 | | |
|---|
| 398 | | map = createMap(); |
|---|
| 399 | | |
|---|
| 400 | | var wms = new OpenLayers.Layer.WMS("vmap0", |
|---|
| 401 | | "http://labs.metacarta.com/wms/vmap0", |
|---|
| 402 | | {layers: 'basic'}, |
|---|
| 403 | | {isBaseLayer: true} |
|---|
| 404 | | ); |
|---|
| 405 | | map.addLayer(wms); |
|---|
| 406 | | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| 407 | | |
|---|
| 408 | | model = [ |
|---|
| 409 | | {text: "vmap0", expanded: true, checked: true, layerName: "vmap0"} |
|---|
| 410 | | ]; |
|---|
| 411 | | |
|---|
| 412 | | tree = createTree(map, model); |
|---|
| 413 | | |
|---|
| 414 | | // Only one baseLayer should be active at any time. Clicking on |
|---|
| 415 | | // the active one will do nothing |
|---|
| 416 | | |
|---|
| 417 | | var expectedOlStatus, node; |
|---|
| 418 | | |
|---|
| 419 | | expectedOlStatus = [ |
|---|
| 420 | | {name: "vmap0", visibility: true} |
|---|
| 421 | | ]; |
|---|
| 422 | | checkOlStatus(t, map, expectedOlStatus); // 3 tests |
|---|
| 423 | | |
|---|
| 424 | | node = getNodeByText(tree.getRootNode(), "vmap0"); |
|---|
| 425 | | tree.setNodeChecked(node, false); |
|---|
| 426 | | |
|---|
| 427 | | expectedOlStatus = [ |
|---|
| 428 | | {name: "vmap0", visibility: true} |
|---|
| 429 | | ]; |
|---|
| 430 | | checkOlStatus(t, map, expectedOlStatus); // 3 tests |
|---|
| 431 | | |
|---|
| 432 | | reset(); |
|---|
| 433 | | |
|---|
| 434 | | ////////////////////////////////////////////////////////////// |
|---|
| 435 | | // Test environment 2 |
|---|
| 436 | | // Map with one baselayer, and one overlay |
|---|
| 437 | | |
|---|
| 438 | | map = createMap(); |
|---|
| 439 | | |
|---|
| 440 | | var wms = new OpenLayers.Layer.WMS("vmap0", |
|---|
| 441 | | "http://labs.metacarta.com/wms/vmap0", |
|---|
| 442 | | {layers: 'basic'}, |
|---|
| 443 | | {isBaseLayer: true} |
|---|
| 444 | | ); |
|---|
| 445 | | map.addLayer(wms); |
|---|
| 446 | | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| 447 | | |
|---|
| 448 | | var jpl_wms = new OpenLayers.Layer.WMS("Satellite", |
|---|
| 449 | | "http://labs.metacarta.com/wms-c/Basic.py?", |
|---|
| 450 | | { |
|---|
| 451 | | layers: 'satellite', |
|---|
| 452 | | format: 'image/png', |
|---|
| 453 | | transparent: true |
|---|
| 454 | | } |
|---|
| 455 | | ); |
|---|
| 456 | | jpl_wms.setVisibility(false); |
|---|
| 457 | | map.addLayer(jpl_wms); |
|---|
| 458 | | |
|---|
| 459 | | model = [ |
|---|
| 460 | | {text: "root_vmap0", expanded: true, checked: true, children: [ |
|---|
| | 392 | function __test_ModelSync(layerClass) { |
|---|
| | 393 | var map, layer, model, tree; |
|---|
| | 394 | |
|---|
| | 395 | ////////////////////////////////////////////////////////////// |
|---|
| | 396 | // Test environment 1 |
|---|
| | 397 | // Map with one baseLayer |
|---|
| | 398 | // User model with one layer mapped 1:1 |
|---|
| | 399 | |
|---|
| | 400 | map = createMap(); |
|---|
| | 401 | |
|---|
| | 402 | layer = new layerClass("vmap0", |
|---|
| | 403 | "http://labs.metacarta.com/wms/vmap0", |
|---|
| | 404 | {layers: 'basic'}, |
|---|
| | 405 | {isBaseLayer: true} |
|---|
| | 406 | ); |
|---|
| | 407 | map.addLayer(layer); |
|---|
| | 408 | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| | 409 | |
|---|
| | 410 | model = [ |
|---|
| | 411 | {text: "vmap0", expanded: true, checked: true, layerName: "vmap0"} |
|---|
| | 412 | ]; |
|---|
| | 413 | |
|---|
| | 414 | tree = createTree(map, model); |
|---|
| | 415 | |
|---|
| | 416 | // Only one baseLayer should be active at any time. Clicking on |
|---|
| | 417 | // the active one will do nothing |
|---|
| | 418 | |
|---|
| | 419 | var expectedOlStatus, node; |
|---|
| | 420 | |
|---|
| | 421 | expectedOlStatus = [ |
|---|
| | 422 | {name: "vmap0", visibility: true} |
|---|
| | 423 | ]; |
|---|
| | 424 | checkOlStatus(t, map, expectedOlStatus); // 3 tests |
|---|
| | 425 | |
|---|
| | 426 | node = getNodeByText(tree.getRootNode(), "vmap0"); |
|---|
| | 427 | tree.setNodeChecked(node, false); |
|---|
| | 428 | |
|---|
| | 429 | expectedOlStatus = [ |
|---|
| | 430 | {name: "vmap0", visibility: true} |
|---|
| | 431 | ]; |
|---|
| | 432 | checkOlStatus(t, map, expectedOlStatus); // 3 tests |
|---|
| | 433 | |
|---|
| | 434 | reset(); |
|---|
| | 435 | |
|---|
| | 436 | ////////////////////////////////////////////////////////////// |
|---|
| | 437 | // Test environment 2 |
|---|
| | 438 | // Map with one baselayer, and one overlay |
|---|
| | 439 | |
|---|
| | 440 | map = createMap(); |
|---|
| | 441 | |
|---|
| | 442 | layer = new layerClass("vmap0", |
|---|
| | 443 | "http://labs.metacarta.com/wms/vmap0", |
|---|
| | 444 | {layers: 'basic'}, |
|---|
| | 445 | {isBaseLayer: true} |
|---|
| | 446 | ); |
|---|
| | 447 | map.addLayer(layer); |
|---|
| | 448 | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| | 449 | |
|---|
| | 450 | layer = new layerClass("Satellite", |
|---|
| | 451 | "http://labs.metacarta.com/wms-c/Basic.py?", |
|---|
| | 452 | { |
|---|
| | 453 | layers: 'satellite', |
|---|
| | 454 | format: 'image/png', |
|---|
| | 455 | transparent: true |
|---|
| | 456 | } |
|---|
| | 457 | ); |
|---|
| | 458 | layer.setVisibility(false); |
|---|
| | 459 | map.addLayer(layer); |
|---|
| | 460 | |
|---|
| | 461 | model = [ |
|---|
| | 462 | {text: "root_vmap0", expanded: true, checked: true, children: [ |
|---|
| | 463 | {text: "vmap0", expanded: true, checked: true, layerName: "vmap0", children: [ |
|---|
| | 464 | {text: "vmap0_child", expanded: true, checked: true} |
|---|
| | 465 | ]} |
|---|
| | 466 | ]}, |
|---|
| | 467 | {text: "sat_bis", expanded: true, checked: true, layerName: "Satellite"}, |
|---|
| | 468 | {text: "root_sat", expanded: true, checked: true, children: [ |
|---|
| | 469 | {text: "sat", expanded: true, checked: true, layerName: "Satellite", children: [ |
|---|
| | 470 | {text: "sat_child", expanded: true, checked: true} |
|---|
| | 471 | ]} |
|---|
| | 472 | ]} |
|---|
| | 473 | ]; |
|---|
| | 474 | |
|---|
| | 475 | tree = createTree(map, model); |
|---|
| | 476 | |
|---|
| | 477 | expectedStatus = [ |
|---|
| | 478 | {text: "Root"}, |
|---|
| | 479 | {text: "root_vmap0", attr_checked: true}, |
|---|
| | 480 | {text: "vmap0", attr_checked: true, radio: true}, |
|---|
| | 481 | {text: "vmap0_child", attr_checked: true}, |
|---|
| | 482 | {text: "sat_bis", attr_checked: true}, |
|---|
| | 483 | {text: "root_sat", attr_checked: true}, |
|---|
| | 484 | {text: "sat", attr_checked: true}, |
|---|
| | 485 | {text: "sat_child", attr_checked: true} |
|---|
| | 486 | ]; |
|---|
| | 487 | |
|---|
| | 488 | checkStatus(t, tree, expectedStatus); // 23 tests |
|---|
| | 489 | |
|---|
| | 490 | expectedOlStatus = [ |
|---|
| | 491 | {name: "vmap0", visibility: true}, |
|---|
| | 492 | {name: "Satellite", visibility: true} |
|---|
| | 493 | ]; |
|---|
| | 494 | checkOlStatus(t, map, expectedOlStatus); // 5 tests |
|---|
| | 495 | |
|---|
| | 496 | // If selecting a child unselects an ancestor which controls an OL layer, |
|---|
| | 497 | // The OL layer should be updated. |
|---|
| | 498 | |
|---|
| | 499 | |
|---|
| | 500 | node = getNodeByText(tree.getRootNode(), "sat_child"); |
|---|
| | 501 | tree.setNodeChecked(node, false); |
|---|
| | 502 | |
|---|
| | 503 | expectedStatus = [ |
|---|
| | 504 | {text: "Root"}, |
|---|
| | 505 | {text: "root_vmap0", attr_checked: true}, |
|---|
| | 506 | {text: "vmap0", attr_checked: true, radio: true}, |
|---|
| | 507 | {text: "vmap0_child", attr_checked: true}, |
|---|
| | 508 | {text: "sat_bis", attr_checked: false}, |
|---|
| | 509 | {text: "root_sat", attr_checked: false}, |
|---|
| | 510 | {text: "sat", attr_checked: false}, |
|---|
| | 511 | {text: "sat_child", attr_checked: false} |
|---|
| | 512 | ]; |
|---|
| | 513 | checkStatus(t, tree, expectedStatus); // 23 tests |
|---|
| | 514 | |
|---|
| | 515 | expectedOlStatus = [ |
|---|
| | 516 | {name: "vmap0", visibility: true}, |
|---|
| | 517 | {name: "Satellite", visibility: false} |
|---|
| | 518 | ]; |
|---|
| | 519 | checkOlStatus(t, map, expectedOlStatus); // 5 tests |
|---|
| | 520 | |
|---|
| | 521 | |
|---|
| | 522 | // Thing checks node which is will check another node as a side |
|---|
| | 523 | // effect (they map to the same layer name). The node which is |
|---|
| | 524 | // checked as a side effect should update its ancestors or |
|---|
| | 525 | // descendants. |
|---|
| | 526 | |
|---|
| | 527 | // TODO: not implemented yet |
|---|
| | 528 | |
|---|
| | 529 | node = getNodeByText(tree.getRootNode(), "sat_bis"); |
|---|
| | 530 | tree.setNodeChecked(node, true); |
|---|
| | 531 | |
|---|
| | 532 | expectedStatus = [ |
|---|
| | 533 | {text: "Root"}, |
|---|
| | 534 | {text: "root_vmap0", attr_checked: true}, |
|---|
| | 535 | {text: "vmap0", attr_checked: true, radio: true}, |
|---|
| | 536 | {text: "vmap0_child", attr_checked: true}, |
|---|
| | 537 | {text: "sat_bis", attr_checked: true}, |
|---|
| | 538 | {text: "root_sat", attr_checked: false}, // TODO: should be true |
|---|
| | 539 | {text: "sat", attr_checked: true}, |
|---|
| | 540 | {text: "sat_child", attr_checked: false} // TODO: should be true |
|---|
| | 541 | ]; |
|---|
| | 542 | checkStatus(t, tree, expectedStatus); // 23 tests |
|---|
| | 543 | |
|---|
| | 544 | expectedOlStatus = [ |
|---|
| | 545 | {name: "vmap0", visibility: true}, |
|---|
| | 546 | {name: "Satellite", visibility: true} |
|---|
| | 547 | ]; |
|---|
| | 548 | checkOlStatus(t, map, expectedOlStatus); // 5 tests |
|---|
| | 549 | |
|---|
| | 550 | reset(); |
|---|
| | 551 | |
|---|
| | 552 | ////////////////////////////////////////////////////////////// |
|---|
| | 553 | // Test environment 3 |
|---|
| | 554 | // Map with two base layers and one overlay |
|---|
| | 555 | |
|---|
| | 556 | // Tests that the invariant "only one base layer selected" is respected |
|---|
| | 557 | |
|---|
| | 558 | map = createMap(); |
|---|
| | 559 | |
|---|
| | 560 | layer = new layerClass("vmap0", |
|---|
| | 561 | "http://labs.metacarta.com/wms/vmap0", |
|---|
| | 562 | {layers: 'basic'}, |
|---|
| | 563 | {isBaseLayer: true} |
|---|
| | 564 | ); |
|---|
| | 565 | map.addLayer(layer); |
|---|
| | 566 | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| | 567 | |
|---|
| | 568 | layer = new layerClass("Satellite", |
|---|
| | 569 | "http://labs.metacarta.com/wms-c/Basic.py?", |
|---|
| | 570 | { |
|---|
| | 571 | layers: 'satellite', |
|---|
| | 572 | format: 'image/png' |
|---|
| | 573 | } |
|---|
| | 574 | ); |
|---|
| | 575 | layer.setVisibility(false); |
|---|
| | 576 | map.addLayer(layer); |
|---|
| | 577 | |
|---|
| | 578 | layer = new layerClass("World Map", |
|---|
| | 579 | "http://world.freemap.in/cgi-bin/mapserv?", |
|---|
| | 580 | { |
|---|
| | 581 | map: '/www/freemap.in/world/map/factbooktrans.map', |
|---|
| | 582 | layers: 'factbook', |
|---|
| | 583 | format: 'image/png', |
|---|
| | 584 | transparent: true |
|---|
| | 585 | } |
|---|
| | 586 | ); |
|---|
| | 587 | layer.setVisibility(false); |
|---|
| | 588 | map.addLayer(layer); |
|---|
| | 589 | |
|---|
| | 590 | model = [ |
|---|
| 469 | | ]} |
|---|
| 470 | | ]} |
|---|
| 471 | | ]; |
|---|
| 472 | | |
|---|
| 473 | | tree = createTree(map, model); |
|---|
| 474 | | |
|---|
| 475 | | expectedStatus = [ |
|---|
| 476 | | {text: "Root"}, |
|---|
| 477 | | {text: "root_vmap0", attr_checked: true}, |
|---|
| 478 | | {text: "vmap0", attr_checked: true, radio: true}, |
|---|
| 479 | | {text: "vmap0_child", attr_checked: true}, |
|---|
| 480 | | {text: "sat_bis", attr_checked: true}, |
|---|
| 481 | | {text: "root_sat", attr_checked: true}, |
|---|
| 482 | | {text: "sat", attr_checked: true}, |
|---|
| 483 | | {text: "sat_child", attr_checked: true} |
|---|
| 484 | | ]; |
|---|
| 485 | | |
|---|
| 486 | | checkStatus(t, tree, expectedStatus); // 23 tests |
|---|
| 487 | | |
|---|
| 488 | | expectedOlStatus = [ |
|---|
| 489 | | {name: "vmap0", visibility: true}, |
|---|
| 490 | | {name: "Satellite", visibility: true} |
|---|
| 491 | | ]; |
|---|
| 492 | | checkOlStatus(t, map, expectedOlStatus); // 5 tests |
|---|
| 493 | | |
|---|
| 494 | | // If selecting a child unselects an ancestor which controls an OL layer, |
|---|
| 495 | | // The OL layer should be updated. |
|---|
| 496 | | |
|---|
| 497 | | |
|---|
| 498 | | node = getNodeByText(tree.getRootNode(), "sat_child"); |
|---|
| 499 | | tree.setNodeChecked(node, false); |
|---|
| 500 | | |
|---|
| 501 | | expectedStatus = [ |
|---|
| 502 | | {text: "Root"}, |
|---|
| 503 | | {text: "root_vmap0", attr_checked: true}, |
|---|
| 504 | | {text: "vmap0", attr_checked: true, radio: true}, |
|---|
| 505 | | {text: "vmap0_child", attr_checked: true}, |
|---|
| 506 | | {text: "sat_bis", attr_checked: false}, |
|---|
| 507 | | {text: "root_sat", attr_checked: false}, |
|---|
| 508 | | {text: "sat", attr_checked: false}, |
|---|
| 509 | | {text: "sat_child", attr_checked: false} |
|---|
| 510 | | ]; |
|---|
| 511 | | checkStatus(t, tree, expectedStatus); // 23 tests |
|---|
| 512 | | |
|---|
| 513 | | expectedOlStatus = [ |
|---|
| 514 | | {name: "vmap0", visibility: true}, |
|---|
| 515 | | {name: "Satellite", visibility: false} |
|---|
| 516 | | ]; |
|---|
| 517 | | checkOlStatus(t, map, expectedOlStatus); // 5 tests |
|---|
| 518 | | |
|---|
| 519 | | |
|---|
| 520 | | // Thing checks node which is will check another node as a side |
|---|
| 521 | | // effect (they map to the same layer name). The node which is |
|---|
| 522 | | // checked as a side effect should update its ancestors or |
|---|
| 523 | | // descendants. |
|---|
| 524 | | |
|---|
| 525 | | // TODO: not implemented yet |
|---|
| 526 | | |
|---|
| 527 | | node = getNodeByText(tree.getRootNode(), "sat_bis"); |
|---|
| 528 | | tree.setNodeChecked(node, true); |
|---|
| 529 | | |
|---|
| 530 | | expectedStatus = [ |
|---|
| 531 | | {text: "Root"}, |
|---|
| 532 | | {text: "root_vmap0", attr_checked: true}, |
|---|
| 533 | | {text: "vmap0", attr_checked: true, radio: true}, |
|---|
| 534 | | {text: "vmap0_child", attr_checked: true}, |
|---|
| 535 | | {text: "sat_bis", attr_checked: true}, |
|---|
| 536 | | {text: "root_sat", attr_checked: false}, // TODO: should be true |
|---|
| 537 | | {text: "sat", attr_checked: true}, |
|---|
| 538 | | {text: "sat_child", attr_checked: false} // TODO: should be true |
|---|
| 539 | | ]; |
|---|
| 540 | | checkStatus(t, tree, expectedStatus); // 23 tests |
|---|
| 541 | | |
|---|
| 542 | | expectedOlStatus = [ |
|---|
| 543 | | {name: "vmap0", visibility: true}, |
|---|
| 544 | | {name: "Satellite", visibility: true} |
|---|
| 545 | | ]; |
|---|
| 546 | | checkOlStatus(t, map, expectedOlStatus); // 5 tests |
|---|
| 547 | | |
|---|
| 548 | | reset(); |
|---|
| 549 | | |
|---|
| 550 | | ////////////////////////////////////////////////////////////// |
|---|
| 551 | | // Test environment 3 |
|---|
| 552 | | // Map with two base layers and one overlay |
|---|
| 553 | | |
|---|
| 554 | | // Tests that the invariant "only one base layer selected" is respected |
|---|
| 555 | | |
|---|
| 556 | | map = createMap(); |
|---|
| 557 | | |
|---|
| 558 | | var wms = new OpenLayers.Layer.WMS("vmap0", |
|---|
| 559 | | "http://labs.metacarta.com/wms/vmap0", |
|---|
| 560 | | {layers: 'basic'}, |
|---|
| 561 | | {isBaseLayer: true} |
|---|
| 562 | | ); |
|---|
| 563 | | map.addLayer(wms); |
|---|
| 564 | | map.setCenter(new OpenLayers.LonLat(5,45), 6); |
|---|
| 565 | | |
|---|
| 566 | | var jpl_wms = new OpenLayers.Layer.WMS("Satellite", |
|---|
| 567 | | "http://labs.metacarta.com/wms-c/Basic.py?", |
|---|
| 568 | | { |
|---|
| 569 | | layers: 'satellite', |
|---|
| 570 | | format: 'image/png' |
|---|
| 571 | | } |
|---|
| 572 | | ); |
|---|
| 573 | | jpl_wms.setVisibility(false); |
|---|
| 574 | | map.addLayer(jpl_wms); |
|---|
| 575 | | |
|---|
| 576 | | var twms = new OpenLayers.Layer.WMS("World Map", |
|---|
| 577 | | "http://world.freemap.in/cgi-bin/mapserv?", |
|---|
| 578 | | { |
|---|
| 579 | | map: '/www/freemap.in/world/map/factbooktrans.map', |
|---|
| 580 | | layers: 'factbook', |
|---|
| 581 | | format: 'image/png', |
|---|
| 582 | | transparent: true |
|---|
| 583 | | } |
|---|
| 584 | | ); |
|---|
| 585 | | twms.setVisibility(false); |
|---|
| 586 | | map.addLayer(twms); |
|---|
| 587 | | |
|---|
| 588 | | model = [ |
|---|
| 589 | | {text: "vmap0", expanded: true, checked: true, layerName: "vmap0", children: [ |
|---|
| 590 | | {text: "vmap0_child", expanded: true, checked: true} |
|---|
| 591 | | ]}, |
|---|
| 592 | | {text: "sat", expanded: true, checked: true, layerName: "Satellite", children: [ |
|---|
| 593 | | {text: "sat_child", expanded: true, checked: true} |
|---|
| 594 | | ]}, |
|---|
| 595 | | {text: "vmap_and_sat", expanded: true, checked: true, layerNames: ["vmap0", "Satellite"], children: [ |
|---|
| 596 | | {text: "vmap0_2", expanded: true, checked: true, layerName: "vmap0"}, |
|---|
| 597 | | {text: "sat_2", expanded: true, checked: true, layerNames: ["Satellite"], layerName: "this_is_ignored"} |
|---|
| 598 | | ]}, |
|---|
| 599 | | {text: "dummy", expanded: true, children: [ |
|---|
| 600 | | {text: "world_map", checked: true, layerNames: ["World Map"]}, |
|---|
| 601 | | {text: "world_map_2", checked: true, layerNames: ["World Map"]} |
|---|
| 602 | | ]}, |
|---|
| 603 | | ]; |
|---|
| 604 | | |
|---|
| 605 | | tree = createTree(map, model); |
|---|
| 606 | | |
|---|
| 607 | | expectedStatus = [ |
|---|
| 608 | | {text: "Root"}, |
|---|
| 609 | | {text: "vmap0", attr_checked: true, radio: true}, |
|---|
| 610 | | {text: "vmap0_child", attr_checked: true}, |
|---|
| 611 | | {text: "sat", attr_checked: false, radio: true}, |
|---|
| 612 | | {text: "sat_child", attr_checked: true}, |
|---|
| 613 | | {text: "vmap_and_sat", attr_checked: false, radio: true}, |
|---|
| 614 | | {text: "vmap0_2", attr_checked: true, radio: true}, |
|---|
| 615 | | {text: "sat_2", attr_checked: false, radio: true}, |
|---|
| 616 | | {text: "dummy"}, |
|---|
| 617 | | {text: "world_map", attr_checked: true}, |
|---|
| 618 | | {text: "world_map_2", attr_checked: true} |
|---|
| 619 | | ]; |
|---|
| 620 | | checkStatus(t, tree, expectedStatus); // 30 tests |
|---|
| 621 | | |
|---|
| 622 | | expectedOlStatus = [ |
|---|
| 623 | | {name: "vmap0", visibility: true}, |
|---|
| 624 | | {name: "Satellite", visibility: false}, |
|---|
| 625 | | {name: "World Map", visibility: true} |
|---|
| 626 | | ]; |
|---|
| 627 | | checkOlStatus(t, map, expectedOlStatus); // 7 tests |
|---|
| 628 | | |
|---|
| 629 | | |
|---|
| 630 | | // Selecting another base layer. This should unselect the other |
|---|
| 631 | | // base layers. |
|---|
| 632 | | |
|---|
| 633 | | node = getNodeByText(tree.getRootNode(), "sat"); |
|---|
| 634 | | tree.setNodeChecked(node, true); |
|---|
| 635 | | |
|---|
| 636 | | expectedStatus = [ |
|---|
| 637 | | {text: "Root"}, |
|---|
| 638 | | {text: "vmap0", attr_checked: false, radio: true}, |
|---|
| 639 | | {text: "vmap0_child", attr_checked: true}, |
|---|
| 640 | | {text: "sat", attr_checked: true, radio: true}, |
|---|
| 641 | | {text: "sat_child", attr_checked: true}, |
|---|
| 642 | | {text: "vmap_and_sat", attr_checked: false, radio: true}, |
|---|
| 643 | | {text: "vmap0_2", attr_checked: false, radio: true}, |
|---|
| 644 | | {text: "sat_2", attr_checked: true, radio: true}, |
|---|
| 645 | | {text: "dummy"}, |
|---|
| 646 | | {text: "world_map", attr_checked: true}, |
|---|
| 647 | | {text: "world_map_2", attr_checked: true} |
|---|
| 648 | | ]; |
|---|
| 649 | | checkStatus(t, tree, expectedStatus); // 30 tests |
|---|
| 650 | | |
|---|
| 651 | | expectedOlStatus = [ |
|---|
| 652 | | {name: "vmap0", visibility: false}, |
|---|
| 653 | | {name: "Satellite", visibility: true}, |
|---|
| 654 | | {name: "World Map", visibility: true} |
|---|
| 655 | | ]; |
|---|
| 656 | | checkOlStatus(t, map, expectedOlStatus); // 7 tests |
|---|
| 657 | | |
|---|
| 658 | | // Unselecting an overlay should unselect all node referring to |
|---|
| 659 | | // that layer. |
|---|
| 660 | | |
|---|
| 661 | | node = getNodeByText(tree.getRootNode(), "world_map"); |
|---|
| 662 | | tree.setNodeChecked(node, false); |
|---|
| 663 | | |
|---|
| 664 | | expectedStatus = [ |
|---|
| 665 | | {text: "Root"}, |
|---|
| 666 | | {text: "vmap0", attr_checked: false, radio: true}, |
|---|
| 667 | | {text: "vmap0_child", attr_checked: true}, |
|---|
| 668 | | {text: "sat", attr_checked: true, radio: true}, |
|---|
| 669 | | {text: "sat_child", attr_checked: true}, |
|---|
| 670 | | {text: "vmap_and_sat", attr_checked: false, radio: true}, |
|---|
| 671 | | {text: "vmap0_2", attr_checked: false, radio: true}, |
|---|
| 672 | | {text: "sat_2", attr_checked: true, radio: true}, |
|---|
| 673 | | {text: "dummy"}, |
|---|
| 674 | | {text: "world_map", attr_checked: false}, |
|---|
| 675 | | {text: "world_map_2", attr_checked: false} |
|---|
| 676 | | ]; |
|---|
| 677 | | checkStatus(t, tree, expectedStatus); // 30 tests |
|---|
| 678 | | |
|---|
| 679 | | expectedOlStatus = [ |
|---|
| 680 | | {name: "vmap0", visibility: false}, |
|---|
| 681 | | {name: "Satellite", visibility: true}, |
|---|
| 682 | | {name: "World Map", visibility: false} |
|---|
| 683 | | ]; |
|---|
| 684 | | checkOlStatus(t, map, expectedOlStatus); // 7 tests |
|---|
| 685 | | |
|---|
| 686 | | reset(); |
|---|
| 687 | | }; |
|---|
| | 596 | ]}, |
|---|
| | 597 | {text: "vmap_and_sat", expanded: true, checked: true, layerNames: ["vmap0", "Satellite"], children: [ |
|---|
| | 598 | {text: "vmap0_2", expanded: true, checked: true, layerName: "vmap0"}, |
|---|
| | 599 | {text: "sat_2", expanded: true, checked: true, layerNames: ["Satellite"], layerName: "this_is_ignored"} |
|---|
| | 600 | ]}, |
|---|
| | 601 | {text: "dummy", expanded: true, children: [ |
|---|
| | 602 | {text: "world_map", checked: true, layerNames: ["World Map"]}, |
|---|
| | 603 | {text: "world_map_2", checked: true, layerNames: ["World Map"]} |
|---|
| | 604 | ]}, |
|---|
| | 605 | ]; |
|---|
| | 606 | |
|---|
| | 607 | tree = createTree(map, model); |
|---|
| | 608 | |
|---|
| | 609 | expectedStatus = [ |
|---|
| | 610 | {text: "Root"}, |
|---|
| | 611 | {text: "vmap0", attr_checked: true, radio: true}, |
|---|
| | 612 | {text: "vmap0_child", attr_checked: true}, |
|---|
| | 613 | {text: "sat", attr_checked: false, radio: true}, |
|---|
| | 614 | {text: "sat_child", attr_checked: true}, |
|---|
| | 615 | {text: "vmap_and_sat", attr_checked: false, radio: true}, |
|---|
| | 616 | {text: "vmap0_2", attr_checked: true, radio: true}, |
|---|
| | 617 | {text: "sat_2", attr_checked: false, radio: true}, |
|---|
| | 618 | {text: "dummy"}, |
|---|
| | 619 | {text: "world_map", attr_checked: true}, |
|---|
| | 620 | {text: "world_map_2", attr_checked: true} |
|---|
| | 621 | ]; |
|---|
| | 622 | checkStatus(t, tree, expectedStatus); // 30 tests |
|---|
| | 623 | |
|---|
| | 624 | expectedOlStatus = [ |
|---|
| | 625 | {name: "vmap0", visibility: true}, |
|---|
| | 626 | {name: "Satellite", visibility: false}, |
|---|
| | 627 | {name: "World Map", visibility: true} |
|---|
| | 628 | ]; |
|---|
| | 629 | checkOlStatus(t, map, expectedOlStatus); // 7 tests |
|---|
| | 630 | |
|---|
| | 631 | |
|---|
| | 632 | // Selecting another base layer. This should unselect the other |
|---|
| | 633 | // base layers. |
|---|
| | 634 | |
|---|
| | 635 | node = getNodeByText(tree.getRootNode(), "sat"); |
|---|
| | 636 | tree.setNodeChecked(node, true); |
|---|
| | 637 | |
|---|
| | 638 | expectedStatus = [ |
|---|
| | 639 | {text: "Root"}, |
|---|
| | 640 | {text: "vmap0", attr_checked: false, radio: true}, |
|---|
| | 641 | {text: "vmap0_child", attr_checked: true}, |
|---|
| | 642 | {text: "sat", attr_checked: true, radio: true}, |
|---|
| | 643 | {text: "sat_child", attr_checked: true}, |
|---|
| | 644 |   |
|---|