| | 292 | } |
|---|
| | 293 | |
|---|
| | 294 | |
|---|
| | 295 | function test_16_Bounds_extend(t) { |
|---|
| | 296 | t.plan( 8 ); |
|---|
| | 297 | |
|---|
| | 298 | var originalBounds = new OpenLayers.Bounds(10,20,50,80); |
|---|
| | 299 | |
|---|
| | 300 | var bounds = originalBounds.clone(); |
|---|
| | 301 | |
|---|
| | 302 | //null obj |
|---|
| | 303 | bounds.extend(null); |
|---|
| | 304 | t.ok(bounds.equals(originalBounds), "null to extend does not crash or change original bounds"); |
|---|
| | 305 | |
|---|
| | 306 | //obj with no classname |
|---|
| | 307 | var object = new Object(); |
|---|
| | 308 | bounds.extend(object); |
|---|
| | 309 | t.ok(bounds.equals(originalBounds), "extend() passing object with no classname does not crash or change original bounds") |
|---|
| | 310 | |
|---|
| | 311 | //obj is bounds |
|---|
| | 312 | |
|---|
| | 313 | //pushing all limits with bounds obj |
|---|
| | 314 | var testBounds = new OpenLayers.Bounds(5, 10, 60, 90); |
|---|
| | 315 | object = testBounds.clone(); |
|---|
| | 316 | |
|---|
| | 317 | bounds.extend(object); |
|---|
| | 318 | t.ok(bounds.equals(testBounds), "extend by valid bounds, pushing all limits, correctly extends bounds"); |
|---|
| | 319 | |
|---|
| | 320 | //pushing no limits with bounds obj |
|---|
| | 321 | bounds = originalBounds.clone(); |
|---|
| | 322 | |
|---|
| | 323 | testBounds = new OpenLayers.Bounds(15, 30, 40, 70); |
|---|
| | 324 | object = testBounds.clone(); |
|---|
| | 325 | |
|---|
| | 326 | bounds.extend(object); |
|---|
| | 327 | t.ok(bounds.equals(originalBounds), "extend by valid bounds, pushing no limits, correctly does not extend bounds"); |
|---|
| | 328 | |
|---|
| | 329 | // obj is lonlat |
|---|
| | 330 | |
|---|
| | 331 | //left, bottom |
|---|
| | 332 | bounds = originalBounds.clone(); |
|---|
| | 333 | |
|---|
| | 334 | object = new OpenLayers.LonLat(5, 10); |
|---|
| | 335 | |
|---|
| | 336 | bounds.extend(object); |
|---|
| | 337 | |
|---|
| | 338 | t.ok( ((bounds.left == object.lon) && |
|---|
| | 339 | (bounds.bottom == object.lat) && |
|---|
| | 340 | (bounds.right == originalBounds.right) && |
|---|
| | 341 | (bounds.top == originalBounds.top)), "obj lonlat to extends correclty modifies left and bottom"); |
|---|
| | 342 | |
|---|
| | 343 | //right, top |
|---|
| | 344 | bounds = originalBounds.clone(); |
|---|
| | 345 | |
|---|
| | 346 | object = new OpenLayers.LonLat(60,90); |
|---|
| | 347 | |
|---|
| | 348 | bounds.extend(object); |
|---|
| | 349 | |
|---|
| | 350 | t.ok( ((bounds.left == originalBounds.left) && |
|---|
| | 351 | (bounds.bottom == originalBounds.bottom) && |
|---|
| | 352 | (bounds.right == object.lon) && |
|---|
| | 353 | (bounds.top == object.lat)), "obj lonlat to extends correclty modifies right and top"); |
|---|
| | 354 | |
|---|
| | 355 | // obj is point |
|---|
| | 356 | |
|---|
| | 357 | //left, bottom |
|---|
| | 358 | bounds = originalBounds.clone(); |
|---|
| | 359 | |
|---|
| | 360 | object = new OpenLayers.Geometry.Point(5, 10); |
|---|
| | 361 | |
|---|
| | 362 | bounds.extend(object); |
|---|
| | 363 | |
|---|
| | 364 | t.ok( ((bounds.left == object.lon) && |
|---|
| | 365 | (bounds.bottom == object.lat) && |
|---|
| | 366 | (bounds.right == originalBounds.right) && |
|---|
| | 367 | (bounds.top == originalBounds.top)), "obj Point to extends correclty modifies left and bottom"); |
|---|
| | 368 | |
|---|
| | 369 | //right, top |
|---|
| | 370 | bounds = originalBounds.clone(); |
|---|
| | 371 | |
|---|
| | 372 | object = new OpenLayers.Geometry.Point(60,90); |
|---|
| | 373 | |
|---|
| | 374 | bounds.extend(object); |
|---|
| | 375 | |
|---|
| | 376 | t.ok( ((bounds.left == originalBounds.left) && |
|---|
| | 377 | (bounds.bottom == originalBounds.bottom) && |
|---|
| | 378 | (bounds.right == object.lon) && |
|---|
| | 379 | (bounds.top == object.lat)), "obj Point to extends correclty modifies right and top"); |
|---|
| | 380 | |
|---|