[OpenLayers-Commits] r2309 - in sandbox/vector-2.4/tests: . BaseTypes Control Layer Tile
commits at openlayers.org
commits at openlayers.org
Mon Mar 5 11:08:22 EST 2007
Author: euzuro
Date: 2007-03-05 11:07:30 -0500 (Mon, 05 Mar 2007)
New Revision: 2309
Added:
sandbox/vector-2.4/tests/BaseTypes/
sandbox/vector-2.4/tests/BaseTypes/test_Bounds.html
sandbox/vector-2.4/tests/BaseTypes/test_Class.html
sandbox/vector-2.4/tests/BaseTypes/test_LonLat.html
sandbox/vector-2.4/tests/BaseTypes/test_Pixel.html
sandbox/vector-2.4/tests/BaseTypes/test_Size.html
sandbox/vector-2.4/tests/Control/
sandbox/vector-2.4/tests/Control/test_Control_LayerSwitcher.html
sandbox/vector-2.4/tests/Control/test_Control_MouseToolbar.html
sandbox/vector-2.4/tests/Control/test_Control_OverviewMap.html
sandbox/vector-2.4/tests/Control/test_Control_PanZoom.html
sandbox/vector-2.4/tests/Control/test_Control_PanZoomBar.html
sandbox/vector-2.4/tests/Control/test_Control_Permalink.html
sandbox/vector-2.4/tests/Control/test_Control_Scale.html
sandbox/vector-2.4/tests/Feature/
sandbox/vector-2.4/tests/Layer/
sandbox/vector-2.4/tests/Layer/test_Layer_EventPane.html
sandbox/vector-2.4/tests/Layer/test_Layer_FixedZoomLevels.html
sandbox/vector-2.4/tests/Layer/test_Layer_GeoRSS.html
sandbox/vector-2.4/tests/Layer/test_Layer_Google.html
sandbox/vector-2.4/tests/Layer/test_Layer_Grid.html
sandbox/vector-2.4/tests/Layer/test_Layer_HTTPRequest.html
sandbox/vector-2.4/tests/Layer/test_Layer_Image.html
sandbox/vector-2.4/tests/Layer/test_Layer_KaMap.html
sandbox/vector-2.4/tests/Layer/test_Layer_Markers.html
sandbox/vector-2.4/tests/Layer/test_Layer_MultiMap.html
sandbox/vector-2.4/tests/Layer/test_Layer_TMS.html
sandbox/vector-2.4/tests/Layer/test_Layer_Text.html
sandbox/vector-2.4/tests/Layer/test_Layer_WMS.html
sandbox/vector-2.4/tests/Marker/
sandbox/vector-2.4/tests/Popup/
sandbox/vector-2.4/tests/Tile/
sandbox/vector-2.4/tests/Tile/test_Tile_Image.html
Removed:
sandbox/vector-2.4/tests/test_Bounds.html
sandbox/vector-2.4/tests/test_Class.html
sandbox/vector-2.4/tests/test_Control_LayerSwitcher.html
sandbox/vector-2.4/tests/test_Control_MouseToolbar.html
sandbox/vector-2.4/tests/test_Control_OverviewMap.html
sandbox/vector-2.4/tests/test_Control_PanZoom.html
sandbox/vector-2.4/tests/test_Control_PanZoomBar.html
sandbox/vector-2.4/tests/test_Control_Permalink.html
sandbox/vector-2.4/tests/test_Control_Scale.html
sandbox/vector-2.4/tests/test_Layer_EventPane.html
sandbox/vector-2.4/tests/test_Layer_FixedZoomLevels.html
sandbox/vector-2.4/tests/test_Layer_GeoRSS.html
sandbox/vector-2.4/tests/test_Layer_Google.html
sandbox/vector-2.4/tests/test_Layer_Grid.html
sandbox/vector-2.4/tests/test_Layer_HTTPRequest.html
sandbox/vector-2.4/tests/test_Layer_Image.html
sandbox/vector-2.4/tests/test_Layer_KaMap.html
sandbox/vector-2.4/tests/test_Layer_Markers.html
sandbox/vector-2.4/tests/test_Layer_MultiMap.html
sandbox/vector-2.4/tests/test_Layer_TMS.html
sandbox/vector-2.4/tests/test_Layer_Text.html
sandbox/vector-2.4/tests/test_Layer_WMS.html
sandbox/vector-2.4/tests/test_LonLat.html
sandbox/vector-2.4/tests/test_Pixel.html
sandbox/vector-2.4/tests/test_Size.html
sandbox/vector-2.4/tests/test_Tile_Image.html
Modified:
sandbox/vector-2.4/tests/list-tests.html
Log:
give tests hierarchy
Copied: sandbox/vector-2.4/tests/BaseTypes/test_Bounds.html (from rev 2307, sandbox/vector-2.4/tests/test_Bounds.html)
===================================================================
--- sandbox/vector-2.4/tests/BaseTypes/test_Bounds.html (rev 0)
+++ sandbox/vector-2.4/tests/BaseTypes/test_Bounds.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,300 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var bounds;
+ function test_01_Bounds_constructor (t) {
+ t.plan( 11 );
+ bounds = new OpenLayers.Bounds(0,2,10,4);
+ t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
+ t.eq( bounds.CLASS_NAME, "OpenLayers.Bounds", "bounds.CLASS_NAME is set correctly" );
+ t.eq( bounds.left, 0, "bounds.left is set correctly" );
+ t.eq( bounds.bottom, 2, "bounds.bottom is set correctly" );
+ t.eq( bounds.right, 10, "bounds.right is set correctly" );
+ t.eq( bounds.top, 4, "bounds.top is set correctly" );
+ t.eq( bounds.getWidth(), 10, "bounds.getWidth() returns correct value" );
+ t.eq( bounds.getHeight(), 2, "bounds.getHeight() returns correct value" );
+
+ var sz = bounds.getSize();
+ var size = new OpenLayers.Size(10,2);
+ t.ok(sz.equals(size),"bounds.getSize() has correct value" );
+
+ var center = new OpenLayers.Pixel(5,3);
+ var boundsCenter = bounds.getCenterPixel();
+ t.ok( boundsCenter.equals(center), "bounds.getCenterLonLat() has correct value" );
+
+ var center = new OpenLayers.LonLat(5,3);
+ var boundsCenter = bounds.getCenterLonLat();
+ t.ok( boundsCenter.equals(center), "bounds.getCenterLonLat() has correct value" );
+ }
+
+ function test_01a_Bounds_constructorFromStrings(t) {
+ t.plan( 6 );
+ bounds = new OpenLayers.Bounds("0","2","10","4");
+ t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
+ t.eq( bounds.CLASS_NAME, "OpenLayers.Bounds", "bounds.CLASS_NAME is set correctly" );
+ t.eq( bounds.left, 0, "bounds.left is set correctly" );
+ t.eq( bounds.bottom, 2, "bounds.bottom is set correctly" );
+ t.eq( bounds.right, 10, "bounds.right is set correctly" );
+ t.eq( bounds.top, 4, "bounds.top is set correctly" );
+
+ }
+
+ function test_02_Bounds_toBBOX(t) {
+ t.plan( 5 );
+ bounds = new OpenLayers.Bounds(1,2,3,4);
+ t.eq( bounds.toBBOX(), "1,2,3,4", "toBBOX() returns correct value." );
+ bounds = new OpenLayers.Bounds(1.00000001,2,3,4);
+ t.eq( bounds.toBBOX(), "1,2,3,4", "toBBOX() rounds off small differences." );
+ bounds = new OpenLayers.Bounds(1.00000001,2.5,3,4);
+ t.eq( bounds.toBBOX(), "1,2.5,3,4", "toBBOX() returns correct value. for a half number" );
+ bounds = new OpenLayers.Bounds(1,2.5555555,3,4);
+ t.eq( bounds.toBBOX(), "1,2.555556,3,4", "toBBOX() rounds to correct value." );
+ bounds = new OpenLayers.Bounds(1,2.5555555,3,4);
+ t.eq( bounds.toBBOX(1), "1,2.6,3,4", "toBBOX() rounds to correct value with power provided." );
+ bounds = new OpenLayers.Bounds(1,2.5555555,3,4);
+ }
+
+ function test_03_Bounds_toString(t) {
+ t.plan( 1 );
+ bounds = new OpenLayers.Bounds(1,2,3,4);
+ t.eq( bounds.toString(), "left-bottom=(1,2) right-top=(3,4)", "toString() returns correct value." );
+ }
+
+ function test_04_Bounds_contains(t) {
+ t.plan( 6 );
+ bounds = new OpenLayers.Bounds(10,10,40,40);
+ t.eq( bounds.contains(20,20), true, "bounds(10,10,40,40) correctly contains LonLat(20,20)" );
+ t.eq( bounds.contains(0,0), false, "bounds(10,10,40,40) correctly does not contain LonLat(0,0)" );
+ t.eq( bounds.contains(40,40), true, "bounds(10,10,40,40) correctly contains LonLat(40,40) with inclusive set to true" );
+ t.eq( bounds.contains(40,40, false), false, "bounds(10,10,40,40) correctly does not contain LonLat(40,40) with inclusive set to false" );
+
+ var px = new OpenLayers.Pixel(15,30);
+ t.eq( bounds.containsPixel(px), bounds.contains(px.x, px.y), "containsPixel works");
+
+ var ll = new OpenLayers.LonLat(15,30);
+ t.eq( bounds.containsLonLat(ll), bounds.contains(ll.lon, ll.lat), "containsLonLat works");
+
+ }
+
+ function test_05_Bounds_fromString(t) {
+ t.plan( 10 );
+ bounds = OpenLayers.Bounds.fromString("1,2,3,4");
+ t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
+ t.eq( bounds.left, 1, "bounds.left is set correctly" );
+ t.eq( bounds.bottom, 2, "bounds.bottom is set correctly" );
+ t.eq( bounds.right, 3, "bounds.right is set correctly" );
+ t.eq( bounds.top, 4, "bounds.top is set correctly" );
+
+ bounds = OpenLayers.Bounds.fromString("1.1,2.2,3.3,4.4");
+ t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
+ t.eq( bounds.left, 1.1, "bounds.left is set correctly" );
+ t.eq( bounds.bottom, 2.2, "bounds.bottom is set correctly" );
+ t.eq( bounds.right, 3.3, "bounds.right is set correctly" );
+ t.eq( bounds.top, 4.4, "bounds.top is set correctly" );
+
+ }
+
+ function test_06_Bounds_getSize(t) {
+ t.plan( 1 );
+ var bounds = new OpenLayers.Bounds(0,10,100,120);
+
+ t.ok( bounds.getSize().equals(new OpenLayers.Size(100, 110)), "getCenterPixel() works correctly");
+ }
+
+ function test_07_Bounds_clone(t) {
+ t.plan( 6 );
+ var oldBounds = new OpenLayers.Bounds(1,2,3,4);
+ var bounds = oldBounds.clone();
+ t.ok( bounds instanceof OpenLayers.Bounds, "clone returns new OpenLayers.Bounds object" );
+ t.eq( bounds.left, 1, "bounds.left is set correctly" );
+ t.eq( bounds.bottom, 2, "bounds.bottom is set correctly" );
+ t.eq( bounds.right, 3, "bounds.right is set correctly" );
+ t.eq( bounds.top, 4, "bounds.top is set correctly" );
+
+ oldBounds.left = 100;
+ t.eq( bounds.left, 1, "changing olBounds.left does not change bounds.left" );
+ }
+
+ function test_08a_Bounds_intersectsBounds(t) {
+ t.plan( 17 );
+
+ var aBounds = new OpenLayers.Bounds(-180, -90, 180, 90);
+
+ //inside
+ var bBounds = new OpenLayers.Bounds(-20, -10, 20, 10);
+ var cBounds = new OpenLayers.Bounds(-181,-90,180,90);
+ t.eq( aBounds.intersectsBounds(bBounds), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + ")" );
+ t.eq( aBounds.intersectsBounds(bBounds, true), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is true" );
+ t.eq( aBounds.intersectsBounds(bBounds, false), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is false" );
+ t.eq( aBounds.intersectsBounds(cBounds, false), true, "aBounds with cBounds adjusted one degree left passes intersect bounds. (3 sides match, 1 side different)." );
+ t.eq( cBounds.intersectsBounds(aBounds, false), true, "cBounds with aBounds adjusted one degree left passes intersect bounds. (3 sides match, 1 side different)." );
+
+ //outside
+ bBounds = new OpenLayers.Bounds(-181, -91, 181, 91);
+ t.eq( aBounds.intersectsBounds(bBounds), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + ")" );
+ t.eq( aBounds.intersectsBounds(bBounds, true), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is true" );
+ t.eq( aBounds.intersectsBounds(bBounds, false), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is false" );
+
+ //total intersect
+ bBounds = new OpenLayers.Bounds(-185, -100, 20, 50);
+ t.eq( aBounds.intersectsBounds(bBounds), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + ")" );
+ t.eq( aBounds.intersectsBounds(bBounds, true), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is true" );
+ t.eq( aBounds.intersectsBounds(bBounds, false), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is false" );
+
+ //border intersect
+ bBounds = new OpenLayers.Bounds(-360, -180, -180, -90);
+ t.eq( aBounds.intersectsBounds(bBounds), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + ")" );
+ t.eq( aBounds.intersectsBounds(bBounds, true), true, "(" + aBounds.toBBOX() + ") correctly intersects (" + bBounds.toBBOX() + "), inclusive is true" );
+ t.eq( aBounds.intersectsBounds(bBounds, false), false, "(" + aBounds.toBBOX() + ") does not intersect (" + bBounds.toBBOX() + "), inclusive is false" );
+
+ //no intersect
+ bBounds = new OpenLayers.Bounds(-360, -180, -185, -95);
+ t.eq( aBounds.intersectsBounds(bBounds), false, "(" + aBounds.toBBOX() + ") does not intersect (" + bBounds.toBBOX() + ")" );
+ t.eq( aBounds.intersectsBounds(bBounds, true), false, "(" + aBounds.toBBOX() + ") does not intersect (" + bBounds.toBBOX() + "), inclusive is true" );
+ t.eq( aBounds.intersectsBounds(bBounds, false), false, "(" + aBounds.toBBOX() + ") does not intersect (" + bBounds.toBBOX() + "), inclusive is false" );
+
+ }
+
+ function test_08b_Bounds_containsBounds(t) {
+ t.plan( 35 );
+ containerBounds = new OpenLayers.Bounds(10,10,40,40);
+
+ //totally outside
+ bounds = new OpenLayers.Bounds(0,0,5,5);
+ t.eq( containerBounds.containsBounds(bounds) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ")");
+ t.eq( containerBounds.containsBounds(bounds, false) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false" );
+ t.eq( containerBounds.containsBounds(bounds, false, true) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is true" );
+ t.eq( containerBounds.containsBounds(bounds, false, false), false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is false" );
+ t.eq( containerBounds.containsBounds(bounds, true) , false , "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is true" );
+ t.eq( containerBounds.containsBounds(bounds, true, true) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is true, inclusive is true" );
+ t.eq( containerBounds.containsBounds(bounds, true, false) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is true, inclusive is false" );
+
+ //totally outside on border
+ bounds = new OpenLayers.Bounds(15,0,30,10);
+ t.eq( containerBounds.containsBounds(bounds) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ")");
+ t.eq( containerBounds.containsBounds(bounds, false) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false" );
+ t.eq( containerBounds.containsBounds(bounds, false, true) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is true" );
+ t.eq( containerBounds.containsBounds(bounds, false, false), false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is false" );
+ t.eq( containerBounds.containsBounds(bounds, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true" );
+ t.eq( containerBounds.containsBounds(bounds, true, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is true" );
+ t.eq( containerBounds.containsBounds(bounds, true, false) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is true, inclusive is false" );
+
+ //partially inside
+ bounds = new OpenLayers.Bounds(20,20,50,30);
+ t.eq( containerBounds.containsBounds(bounds) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ")");
+ t.eq( containerBounds.containsBounds(bounds, false) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false" );
+ t.eq( containerBounds.containsBounds(bounds, false, true) , false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is true" );
+ t.eq( containerBounds.containsBounds(bounds, false, false), false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is false" );
+ t.eq( containerBounds.containsBounds(bounds, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true" );
+ t.eq( containerBounds.containsBounds(bounds, true, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is true" );
+ t.eq( containerBounds.containsBounds(bounds, true, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is false" );
+
+ //totally inside on border
+ bounds = new OpenLayers.Bounds(10,20,30,30);
+ t.eq( containerBounds.containsBounds(bounds) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ")");
+ t.eq( containerBounds.containsBounds(bounds, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false" );
+ t.eq( containerBounds.containsBounds(bounds, false, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false, inclusive is true" );
+ t.eq( containerBounds.containsBounds(bounds, false, false), false, "(" + containerBounds.toBBOX() + ") correctly does not contain (" + bounds.toBBOX() + ") when partial is false, inclusive is false" );
+ t.eq( containerBounds.containsBounds(bounds, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true" );
+ t.eq( containerBounds.containsBounds(bounds, true, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is true" );
+ t.eq( containerBounds.containsBounds(bounds, true, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is false" );
+
+ //totally inside
+ bounds = new OpenLayers.Bounds(20,20,30,30);
+ t.eq( containerBounds.containsBounds(bounds) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ")");
+ t.eq( containerBounds.containsBounds(bounds, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false" );
+ t.eq( containerBounds.containsBounds(bounds, false, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false, inclusive is true" );
+ t.eq( containerBounds.containsBounds(bounds, false, false), true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is false, inclusive is false" );
+ t.eq( containerBounds.containsBounds(bounds, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true" );
+ t.eq( containerBounds.containsBounds(bounds, true, true) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is true" );
+ t.eq( containerBounds.containsBounds(bounds, true, false) , true, "(" + containerBounds.toBBOX() + ") correctly contains (" + bounds.toBBOX() + ") when partial is true, inclusive is false" );
+ }
+
+ function test_09_Bounds_determineQuadrant(t) {
+
+ t.plan( 4 );
+ var bounds = new OpenLayers.Bounds(0,0,100,100);
+
+ var tl = new OpenLayers.LonLat(25, 75);
+ var tr = new OpenLayers.LonLat(75, 75);
+ var bl = new OpenLayers.LonLat(25, 25);
+ var br = new OpenLayers.LonLat(75, 25);
+
+ t.eq( bounds.determineQuadrant(tl), "tl", "bounds.determineQuadrant correctly identifies a coordinate in the top left quadrant");
+ t.eq( bounds.determineQuadrant(tr), "tr", "bounds.determineQuadrant correctly identifies a coordinate in the top right quadrant");
+ t.eq( bounds.determineQuadrant(bl), "bl", "bounds.determineQuadrant correctly identifies a coordinate in the bottom left quadrant");
+ t.eq( bounds.determineQuadrant(br), "br", "bounds.determineQuadrant correctly identifies a coordinate in the bottom right quadrant");
+ }
+
+ function test_10_Bounds_oppositeQuadrant(t) {
+
+ t.plan( 4 );
+
+ t.eq( OpenLayers.Bounds.oppositeQuadrant("tl"), "br", "OpenLayers.Bounds.oppositeQuadrant returns 'br' for 'tl'");
+ t.eq( OpenLayers.Bounds.oppositeQuadrant("tr"), "bl", "OpenLayers.Bounds.oppositeQuadrant returns 'bl' for 'tr'");
+ t.eq( OpenLayers.Bounds.oppositeQuadrant("bl"), "tr", "OpenLayers.Bounds.oppositeQuadrant returns 'tr' for 'bl'");
+ t.eq( OpenLayers.Bounds.oppositeQuadrant("br"), "tl", "OpenLayers.Bounds.oppositeQuadrant returns 'tl' for 'br'");
+ }
+
+ function test_11_Bounds_equals(t) {
+ t.plan( 3 );
+ var boundsA = new OpenLayers.Bounds(1,2,3,4);
+ var boundsB = new OpenLayers.Bounds(1,2,3,4);
+ var boundsC = new OpenLayers.Bounds(1,5,3,4);
+
+ t.ok( boundsA.equals(boundsB), "equals() returns true on two equal bounds." );
+ t.ok( !boundsA.equals(boundsC), "equals() returns false on two different bounds." );
+ t.ok( !boundsA.equals(null), "equals() returns false on comparison to null");
+ }
+
+ function test_12_Bounds_getHeight_getWidth(t) {
+ t.plan( 2 );
+ var bounds = new OpenLayers.Bounds(10,20,100,120);
+
+ t.eq( bounds.getWidth(), 90, "getWidth() works" );
+ t.eq( bounds.getHeight(), 100, "getHeight() works" );
+
+ }
+
+ function test_13_Bounds_getCenters(t) {
+ t.plan( 2 );
+ var bounds = new OpenLayers.Bounds(0,20,100,120);
+
+ t.ok( bounds.getCenterPixel().equals(new OpenLayers.Pixel(50, 70)), "getCenterPixel() works correctly");
+ t.ok( bounds.getCenterLonLat().equals(new OpenLayers.LonLat(50, 70)), "getCenterLonLat() works correctly");
+ }
+
+ function test_14_Bounds_fromArray(t) {
+ t.plan( 5 );
+
+ var bbox = [1,2,3,4];
+ bounds = OpenLayers.Bounds.fromArray(bbox);
+ t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
+ t.eq( bounds.left, 1, "bounds.left is set correctly" );
+ t.eq( bounds.bottom, 2, "bounds.bottom is set correctly" );
+ t.eq( bounds.right, 3, "bounds.right is set correctly" );
+ t.eq( bounds.top, 4, "bounds.top is set correctly" );
+ }
+
+ function test_14_Bounds_fromSize(t) {
+ t.plan( 5 );
+
+ var height = 15;
+ var width = 16;
+ var size = new OpenLayers.Size(width, height);
+ bounds = OpenLayers.Bounds.fromSize(size);
+ t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
+ t.eq( bounds.left, 0, "bounds.left is set correctly" );
+ t.eq( bounds.bottom, height, "bounds.bottom is set correctly" );
+ t.eq( bounds.right, width, "bounds.right is set correctly" );
+ t.eq( bounds.top, 0, "bounds.top is set correctly" );
+ }
+
+ // -->
+ </script>
+</head>
+<body>
+</body>
+</html>
+
Copied: sandbox/vector-2.4/tests/BaseTypes/test_Class.html (from rev 2307, sandbox/vector-2.4/tests/test_Class.html)
===================================================================
--- sandbox/vector-2.4/tests/BaseTypes/test_Class.html (rev 0)
+++ sandbox/vector-2.4/tests/BaseTypes/test_Class.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,106 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
+
+ function test_01_Class_create (t) {
+ t.plan( 3 );
+ var cls = OpenLayers.Class.create();
+ cls.prototype = {
+ initialize: function () {
+ if (isMozilla)
+ t.ok(this instanceof cls,
+ "initialize is called on the right class");
+ else
+ t.ok(true, "initialize is called");
+ }
+ };
+ var obj = new cls();
+ t.eq(typeof obj, "object", "obj is an object");
+ if (isMozilla)
+ t.ok(obj instanceof cls,
+ "object is of the right class");
+ else
+ t.ok(true, "this test doesn't work in IE");
+ }
+
+ function test_02_Class_inherit (t) {
+ t.plan( 20 );
+ var A = OpenLayers.Class.create();
+ var initA = 0;
+ A.prototype = {
+ count: 0,
+ initialize: function () {
+ initA++;
+ this.count++;
+ }
+ };
+
+ var B = OpenLayers.Class.create();
+ var initB = 0;
+ B.prototype = OpenLayers.Class.inherit( A, {
+ initialize: function () {
+ A.prototype.initialize.apply(this, arguments);
+ initB++;
+ this.count++;
+ }
+ });
+
+ var mixin = OpenLayers.Class.create()
+ mixin.prototype = {
+ mixed: true
+ };
+
+ t.eq( initA, 0, "class A not inited" );
+ t.eq( initB, 0, "class B not inited" );
+
+ var objA = new A();
+ t.eq( objA.count, 1, "object A init" );
+ t.eq( initA, 1, "class A init" );
+ if (isMozilla)
+ t.ok( objA instanceof A, "obj A isa A" );
+ else
+ t.ok( true, "IE sucks" );
+
+ var objB = new B();
+ t.eq( initA, 2, "class A init" );
+ t.eq( initB, 1, "class B init" );
+ t.eq( objB.count, 2, "object B init twice" );
+ if (isMozilla) {
+ t.ok( objB instanceof A, "obj B isa A" );
+ t.ok( objB instanceof B, "obj B isa B" );
+ } else {
+ t.ok( true, "IE sucks" );
+ t.ok( true, "IE sucks" );
+ }
+
+ var C = OpenLayers.Class.create();
+ C.prototype = OpenLayers.Class.inherit( B, mixin, {count: 0} );
+ t.eq( initA, 2, "class A init unchanged" );
+ t.eq( initB, 1, "class B init unchanged" );
+
+ var objC = new C();
+ t.eq( initA, 3, "class A init changed" );
+ t.eq( initB, 2, "class B init changed" );
+ t.eq( objC.count, 2, "object C init changed" );
+ if (isMozilla) {
+ t.ok( objC instanceof A, "obj C isa A" );
+ t.ok( objC instanceof B, "obj C isa B" );
+ t.ok( objC instanceof C, "obj C isa C" );
+ t.ok( !(objC instanceof mixin), "obj C isn'ta mixin" );
+ } else {
+ t.ok( true, "IE sucks" );
+ t.ok( true, "IE sucks" );
+ t.ok( true, "IE sucks" );
+ t.ok( true, "IE sucks" );
+ }
+ t.eq( objC.mixed, true, "class C mixes has mixin properties" );
+ }
+
+ // -->
+ </script>
+</head>
+<body>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/BaseTypes/test_LonLat.html (from rev 2307, sandbox/vector-2.4/tests/test_LonLat.html)
===================================================================
--- sandbox/vector-2.4/tests/BaseTypes/test_LonLat.html (rev 0)
+++ sandbox/vector-2.4/tests/BaseTypes/test_LonLat.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,96 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+
+ var lonlat;
+
+ function test_01_LonLat_constructor (t) {
+ t.plan( 4 );
+ lonlat = new OpenLayers.LonLat(6, 5);
+ t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
+ t.eq( lonlat.CLASS_NAME, "OpenLayers.LonLat", "lonlat.CLASS_NAME is set correctly");
+ t.eq( lonlat.lon, 6, "lonlat.lon is set correctly");
+ t.eq( lonlat.lat, 5, "lonlat.lat is set correctly");
+ }
+
+ function test_01a_LonLat_constructorFromStrings (t) {
+ t.plan( 4 );
+ lonlat = new OpenLayers.LonLat("6", "5");
+ t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
+ t.eq( lonlat.CLASS_NAME, "OpenLayers.LonLat", "lonlat.CLASS_NAME is set correctly");
+ t.eq( lonlat.lon, 6, "lonlat.lon is set correctly");
+ t.eq( lonlat.lat, 5, "lonlat.lat is set correctly");
+ }
+
+ function test_02_LonLat_toString(t) {
+ t.plan( 1 );
+ lonlat = new OpenLayers.LonLat(5,6);
+ t.eq( lonlat.toString(), "lon=5,lat=6", "lonlat.toString() returns correctly");
+ }
+
+ function test_02A_LonLat_toShortString(t) {
+ t.plan( 1 );
+ lonlat = new OpenLayers.LonLat(5,6);
+ t.eq( lonlat.toShortString(), "5, 6", "lonlat.toShortString() returns correctly");
+ }
+
+ function test_03_LonLat_clone(t) {
+ t.plan( 3 );
+ oldLonLat = new OpenLayers.LonLat(5,6);
+ lonlat = oldLonLat.clone();
+ t.ok( lonlat instanceof OpenLayers.LonLat, "clone returns new OpenLayers.LonLat object" );
+ t.ok( lonlat.equals(oldLonLat), "lonlat is set correctly");
+
+ oldLonLat.lon = 100;
+ t.eq( lonlat.lon, 5, "changing oldLonLat.lon doesn't change lonlat.lon");
+ }
+
+ function test_04_LonLat_add(t) {
+ t.plan( 2 );
+
+ lonlatA = new OpenLayers.LonLat(10,100);
+
+ addpx = lonlatA.add(5, 50);
+ var ll = new OpenLayers.LonLat(10,100);
+ t.ok( lonlatA.equals(ll), "lonlatA is not modified by add operation");
+
+ var ll = new OpenLayers.LonLat(15,150);
+ t.ok( addpx.equals(ll), "addpx is set correctly");
+ }
+
+ function test_06_LonLat_equals(t) {
+ t.plan( 5 );
+ lonlat = new OpenLayers.LonLat(5,6);
+
+ ll = new OpenLayers.LonLat(5,6);
+ t.eq( lonlat.equals(ll), true, "(5,6) equals (5,6)");
+
+ ll = new OpenLayers.LonLat(1,6);
+ t.eq( lonlat.equals(ll), false, "(5,6) does not equal (1,6)");
+
+ ll = new OpenLayers.LonLat(5,2);
+ t.eq( lonlat.equals(ll), false, "(5,6) does not equal (5,2)");
+
+ ll = new OpenLayers.LonLat(1,2);
+ t.eq( lonlat.equals(ll), false, "(5,6) does not equal (1,2)");
+
+ t.ok( !lonlat.equals(null), "equals() returns false on comparison to null");
+
+ }
+
+ function test_07_LonLat_fromString(t) {
+ t.plan( 2 );
+ lonlat = OpenLayers.LonLat.fromString("6,5");
+ t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
+
+ var ll = new OpenLayers.LonLat(6, 5);
+ t.ok( lonlat.equals(ll), "lonlat is set correctly");
+ }
+
+ // -->
+ </script>
+</head>
+<body>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/BaseTypes/test_Pixel.html (from rev 2307, sandbox/vector-2.4/tests/test_Pixel.html)
===================================================================
--- sandbox/vector-2.4/tests/BaseTypes/test_Pixel.html (rev 0)
+++ sandbox/vector-2.4/tests/BaseTypes/test_Pixel.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,96 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var pixel;
+
+ function test_01_Pixel_constructor (t) {
+ t.plan( 4 );
+ pixel = new OpenLayers.Pixel(5,6);
+ t.ok( pixel instanceof OpenLayers.Pixel, "new OpenLayers.Pixel returns Pixel object" );
+ t.eq( pixel.CLASS_NAME, "OpenLayers.Pixel", "pixel.CLASS_NAME is set correctly");
+ t.eq( pixel.x, 5, "pixel.x is set correctly");
+ t.eq( pixel.y, 6, "pixel.y is set correctly");
+ }
+
+ function test_01a_Pixel_constructorFromString (t) {
+ t.plan( 4 );
+ pixel = new OpenLayers.Pixel("5","6");
+ t.ok( pixel instanceof OpenLayers.Pixel, "new OpenLayers.Pixel returns Pixel object" );
+ t.eq( pixel.CLASS_NAME, "OpenLayers.Pixel", "pixel.CLASS_NAME is set correctly");
+ t.eq( pixel.x, 5, "pixel.x is set correctly");
+ t.eq( pixel.y, 6, "pixel.y is set correctly");
+ }
+
+ function test_02_Pixel_toString(t) {
+ t.plan( 1 );
+ pixel = new OpenLayers.Pixel(5,6);
+ t.eq( pixel.toString(), "x=5,y=6", "pixel.toString() returns correctly");
+ }
+
+ function test_03_Pixel_clone(t) {
+ t.plan( 4 );
+ oldPixel = new OpenLayers.Pixel(5,6);
+ pixel = oldPixel.clone();
+ t.ok( pixel instanceof OpenLayers.Pixel, "clone returns new OpenLayers.Pixel object" );
+ t.eq( pixel.x, 5, "pixel.x is set correctly");
+ t.eq( pixel.y, 6, "pixel.y is set correctly");
+
+ oldPixel.x = 100;
+ t.eq( pixel.x, 5, "changing oldPixel.x doesn't change pixel.x");
+ }
+
+ function test_06_Pixel_equals(t) {
+ t.plan( 5 );
+ pixel = new OpenLayers.Pixel(5,6);
+
+ px = new OpenLayers.Pixel(5,6);
+ t.eq( pixel.equals(px), true, "(5,6) equals (5,6)");
+
+ px = new OpenLayers.Pixel(1,6);
+ t.eq( pixel.equals(px), false, "(5,6) does not equal (1,6)");
+
+ px = new OpenLayers.Pixel(5,2);
+ t.eq( pixel.equals(px), false, "(5,6) does not equal (5,2)");
+
+ px = new OpenLayers.Pixel(1,2);
+ t.eq( pixel.equals(px), false, "(5,6) does not equal (1,2)");
+
+ t.ok( !pixel.equals(null), "equals() returns false on comparison to null");
+
+ }
+
+ function test_07_Pixel_add(t) {
+ t.plan( 4 );
+ oldPixel = new OpenLayers.Pixel(5,6);
+
+ pixel = oldPixel.add(10,20);
+
+ t.eq( oldPixel.x, 5, "oldPixel.x not modified by add operation");
+ t.eq( oldPixel.y, 6, "oldPixel.y not modified by add operation");
+
+ t.eq( pixel.x, 15, "pixel.x is set correctly");
+ t.eq( pixel.y, 26, "pixel.y is set correctly");
+ }
+
+ function test_08_Pixel_offset(t) {
+ t.plan( 4 );
+
+ var oldPixel = new OpenLayers.Pixel(5,6);
+ var offset = new OpenLayers.Pixel(10,20);
+
+ pixel = oldPixel.offset(offset);
+
+ t.eq( oldPixel.x, 5, "oldPixel.x not modified by offset operation");
+ t.eq( oldPixel.y, 6, "oldPixel.y not modified by offset operation");
+
+ t.eq( pixel.x, 15, "pixel.x is set correctly");
+ t.eq( pixel.y, 26, "pixel.y is set correctly");
+ }
+
+ // -->
+ </script>
+</head>
+<body>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/BaseTypes/test_Size.html (from rev 2307, sandbox/vector-2.4/tests/test_Size.html)
===================================================================
--- sandbox/vector-2.4/tests/BaseTypes/test_Size.html (rev 0)
+++ sandbox/vector-2.4/tests/BaseTypes/test_Size.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,67 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var Size;
+
+ function test_01_Size_constructor (t) {
+ t.plan( 4 );
+ size = new OpenLayers.Size(5,6);
+ t.ok( size instanceof OpenLayers.Size, "new OpenLayers.Size returns size object" );
+ t.eq( size.CLASS_NAME, "OpenLayers.Size", "size.CLASS_NAME is set correctly");
+ t.eq( size.w, 5, "size.w is set correctly");
+ t.eq( size.h, 6, "size.h is set correctly");
+ }
+
+ function test_01a_Size_constructorFromString (t) {
+ t.plan( 4 );
+ size = new OpenLayers.Size("5","6");
+ t.ok( size instanceof OpenLayers.Size, "new OpenLayers.Size returns size object" );
+ t.eq( size.CLASS_NAME, "OpenLayers.Size", "size.CLASS_NAME is set correctly");
+ t.eq( size.w, 5, "size.w is set correctly");
+ t.eq( size.h, 6, "size.h is set correctly");
+ }
+
+ function test_02_Size_toString(t) {
+ t.plan( 1 );
+ size = new OpenLayers.Size(5,6);
+ t.eq( size.toString(), "w=5,h=6", "size.toString() returns correctly");
+ }
+
+ function test_03_Size_clone(t) {
+ t.plan( 3 );
+
+ oldSize = new OpenLayers.Size(5,6);
+ size = oldSize.clone();
+ t.ok( size instanceof OpenLayers.Size, "clone returns new OpenLayers.Size object" );
+ t.ok( size.equals(oldSize), "new size is equal to old size correctly");
+
+ oldSize.w = 100;
+ t.eq( size.w, 5, "changing oldSize.w doesn't change size.w");
+ }
+
+ function test_04_Size_equals(t) {
+ t.plan( 5 );
+ size = new OpenLayers.Size(5,6);
+
+ sz = new OpenLayers.Size(5,6);
+ t.eq( size.equals(sz), true, "(5,6) equals (5,6)");
+
+ sz = new OpenLayers.Size(1,6);
+ t.eq( size.equals(sz), false, "(5,6) does not equal (1,6)");
+
+ sz = new OpenLayers.Size(5,2);
+ t.eq( size.equals(sz), false, "(5,6) does not equal (5,2)");
+
+ sz = new OpenLayers.Size(1,2);
+ t.eq( size.equals(sz), false, "(5,6) does not equal (1,2)");
+
+ t.ok( !size.equals(null), "equals() returns false on comparison to null");
+ }
+
+ // -->
+ </script>
+</head>
+<body>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Control/test_Control_LayerSwitcher.html (from rev 2307, sandbox/vector-2.4/tests/test_Control_LayerSwitcher.html)
===================================================================
--- sandbox/vector-2.4/tests/Control/test_Control_LayerSwitcher.html (rev 0)
+++ sandbox/vector-2.4/tests/Control/test_Control_LayerSwitcher.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,114 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var map;
+
+ function test_01_Control_LayerSwitcher_constructor (t) {
+ t.plan( 1 );
+
+ control = new OpenLayers.Control.LayerSwitcher();
+ t.ok( control instanceof OpenLayers.Control.LayerSwitcher, "new OpenLayers.Control.LayerSwitcher returns object" );
+ }
+
+ function test_02_Control_LayerSwitcher_draw (t) {
+ t.plan( 2 );
+
+ map = new OpenLayers.Map('map');
+ control = new OpenLayers.Control.LayerSwitcher();
+ map.addControl(control);
+
+ var div = control.draw();
+ t.ok( control.div != null, "draw makes a div" );
+ t.ok( div != null, "draw returns its div" );
+ }
+
+ function test_03_Control_LayerSwitcher_loadContents(t) {
+
+ t.plan( 5 );
+
+ map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.WMS("WMS",
+ "http://octo.metacarta.com/cgi-bin/mapserv?",
+ {map: "/mapdata/vmap_wms.map", layers: "basic"});
+ map.addLayer(layer);
+
+ markers = new OpenLayers.Layer.Markers("markers");
+ map.addLayer(markers);
+
+ control = new OpenLayers.Control.LayerSwitcher();
+ map.addControl(control);
+
+ t.ok(control.layersDiv != null, "correctly makes layers div");
+ t.ok(control.baseLayersDiv != null, "correctly makes layers div");
+ t.ok(control.dataLayersDiv != null, "correctly makes layers div");
+
+ t.ok(control.maximizeDiv != null, "correctly makes resize div");
+ t.ok(control.minimizeDiv != null, "correctly makes resize div");
+
+
+
+ }
+
+
+ function test_04_Control_LayerSwitcher_redraw (t) {
+
+ t.plan( 8 );
+
+ map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.WMS("WMS",
+ "http://octo.metacarta.com/cgi-bin/mapserv?",
+ {map: "/mapdata/vmap_wms.map", layers: "basic"});
+ map.addLayer(layer);
+
+ markers = new OpenLayers.Layer.Markers("markers");
+ map.addLayer(markers);
+
+ control = new OpenLayers.Control.LayerSwitcher();
+ map.addControl(control);
+
+
+ var wmsInput = $("input_" + layer.name);
+ t.ok(wmsInput != null, "correctly makes an input for wms layer");
+ t.eq(wmsInput.type, "radio", "wms correctly made a radio button");
+ t.eq(wmsInput.name, "baseLayers", "wms correctly named");
+ t.eq(wmsInput.value, layer.name, "wms correctly valued");
+
+ var markersInput = $("input_" + markers.name);
+ t.ok(markersInput != null, "correctly makes an input for markers layer");
+ t.eq(markersInput.type, "checkbox", "wms correctly made a radio button");
+ t.eq(markersInput.name, markers.name, "wms correctly named");
+ t.eq(markersInput.value, markers.name, "wms correctly valued");
+
+ }
+ function test_05_Control_LayerSwitcher_ascendingw (t) {
+
+ t.plan( 4 );
+
+ map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.WMS("WMS",
+ "http://octo.metacarta.com/cgi-bin/mapserv?",
+ {map: "/mapdata/vmap_wms.map", layers: "basic"});
+ map.addLayer(layer);
+
+ markers = new OpenLayers.Layer.Markers("markers");
+ map.addLayer(markers);
+
+ control = new OpenLayers.Control.LayerSwitcher();
+ map.addControl(control);
+ control2 = new OpenLayers.Control.LayerSwitcher({'ascending':false});
+ map.addControl(control2);
+ t.ok(control.div.childNodes[1].childNodes[0].innerHTML.match("Base Layer"), "Base Layers first in LayerSwitcher with ascending true");
+ t.ok(control.div.childNodes[1].childNodes[2].innerHTML.match("Overlays"), "Overlays in LayerSwitcher with ascending true");
+ t.ok(control2.div.childNodes[1].childNodes[2].innerHTML.match("Base Layer"), "Base Layers last in LayerSwitcher with ascending false");
+ t.ok(control2.div.childNodes[1].childNodes[0].innerHTML.match("Overlays"), "Base Layers last in LayerSwitcher with ascending false");
+ }
+
+
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map" style="width: 1024px; height: 512px;"/>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Control/test_Control_MouseToolbar.html (from rev 2307, sandbox/vector-2.4/tests/test_Control_MouseToolbar.html)
===================================================================
--- sandbox/vector-2.4/tests/Control/test_Control_MouseToolbar.html (rev 0)
+++ sandbox/vector-2.4/tests/Control/test_Control_MouseToolbar.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,58 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var map;
+ function test_01_Control_MouseToolbar_constructor (t) {
+ t.plan( 1 );
+
+ control = new OpenLayers.Control.MouseToolbar();
+ t.ok( control instanceof OpenLayers.Control.MouseToolbar, "new OpenLayers.Control.MouseToolbar returns object" );
+ }
+ function test_02_Control_MouseToolbar_addControl (t) {
+ t.plan( 7 );
+ map = new OpenLayers.Map('map');
+ control = new OpenLayers.Control.MouseToolbar();
+ t.ok( control instanceof OpenLayers.Control.MouseToolbar, "new OpenLayers.Control.MouseToolbar returns object" );
+ t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
+ map.addControl(control);
+ t.ok( control.map === map, "Control.map is set to the map object" );
+ t.ok( map.controls[3] === control, "map.controls contains control" );
+ t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Control div zIndexed properly" );
+ t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Viewport div contains control div" );
+ t.eq( control.div.style.top, "6px", "Control div top located correctly by default");
+
+ }
+ function test_03_Control_MouseToolbar_control_events (t) {
+ t.plan( 1 );
+ if ((navigator.userAgent.indexOf("compatible") == -1)) {
+ var evt = {which: 1}; // control expects left-click
+ map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.WMS("Test Layer",
+ "http://octo.metacarta.com/cgi-bin/mapserv?",
+ {map: "/mapdata/vmap_wms.map", layers: "basic"});
+ map.addLayer(layer);
+
+ control = new OpenLayers.Control.MouseToolbar();
+ map.addControl(control);
+
+ var centerLL = new OpenLayers.LonLat(0,0);
+ map.setCenter(centerLL, 5);
+
+ evt.shiftKey = true;
+ evt.xy = new OpenLayers.Size(5,5);
+ control.defaultMouseDown(evt);
+ evt.xy = new OpenLayers.Size(15,15);
+ control.defaultMouseUp(evt);
+ t.eq(map.getZoom(), 6, "Map zoom set correctly after zoombox");
+ } else {
+ t.ok(true, "IE does not run this test.")
+ }
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map" style="width: 1024px; height: 512px;"/>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Control/test_Control_OverviewMap.html (from rev 2307, sandbox/vector-2.4/tests/test_Control_OverviewMap.html)
===================================================================
--- sandbox/vector-2.4/tests/Control/test_Control_OverviewMap.html (rev 0)
+++ sandbox/vector-2.4/tests/Control/test_Control_OverviewMap.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,75 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var map;
+ function test_01_Control_PanZoom_constructor (t) {
+ t.plan( 1 );
+
+ control = new OpenLayers.Control.OverviewMap();
+ t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" );
+ }
+ function test_02_Control_PanZoom_addControl (t) {
+ t.plan( 6 );
+ map = new OpenLayers.Map('map');
+ control = new OpenLayers.Control.OverviewMap();
+ t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" );
+ t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
+ map.addControl(control);
+ t.ok( control.map === map, "Control.map is set to the map object" );
+ t.ok( map.controls[3] === control, "map.controls contains control" );
+ t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Control div zIndexed properly" );
+ t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Viewport div contains control div" );
+
+ }
+ function test_03_Control_PanZoom_control_events (t) {
+ t.plan( 10 );
+ var evt = {which: 1}; // control expects left-click
+ map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.WMS("Test Layer",
+ "http://octo.metacarta.com/cgi-bin/mapserv?",
+ {map: "/mapdata/vmap_wms.map", layers: "basic"});
+ map.addLayer(layer);
+
+ control = new OpenLayers.Control.OverviewMap();
+ map.addControl(control, new OpenLayers.Pixel(20,20));
+
+ var centerLL = new OpenLayers.LonLat(-71,42);
+ map.setCenter(centerLL, 11);
+
+ var overviewCenter = control.ovmap.getCenter();
+ var overviewZoom = control.ovmap.getZoom();
+ t.eq(overviewCenter.lon, -71, "Overviewmap center lon correct");
+ t.eq(overviewCenter.lat, 42, "Overviewmap center lat correct");
+ t.eq(overviewZoom, 8, "Overviewmap zoomcorrect");
+
+ control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)});
+
+ var cent = map.getCenter();
+ t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon");
+ t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat");
+
+ control.rectMouseDown({'xy':new OpenLayers.Pixel(5,5), 'which':1});
+ control.rectMouseMove({'xy':new OpenLayers.Pixel(15,15), 'which':1});
+ control.rectMouseUp({'xy':new OpenLayers.Pixel(15,15), 'which':1});
+
+ var cent = map.getCenter();
+ t.eq(cent.lon, -71.2734375, "Dragging on the Overview Map has the correct effect on map lon");
+ t.eq(cent.lat, 42.09765625, "Dragging on the Overview Map has the correct effect on map lat");
+
+ map.setCenter(new OpenLayers.LonLat(0,0), 0);
+ var overviewCenter = control.ovmap.getCenter();
+ var overviewZoom = control.ovmap.getZoom();
+ t.eq(overviewCenter.lon, 0, "Overviewmap center lon correct -- second zoom");
+ t.eq(overviewCenter.lat, 0, "Overviewmap center lat correct -- second zoom");
+ t.eq(overviewZoom, 0, "Overviewmap zoomcorrect -- second zoom");
+
+
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map" style="width: 1024px; height: 512px;"/>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Control/test_Control_PanZoom.html (from rev 2307, sandbox/vector-2.4/tests/test_Control_PanZoom.html)
===================================================================
--- sandbox/vector-2.4/tests/Control/test_Control_PanZoom.html (rev 0)
+++ sandbox/vector-2.4/tests/Control/test_Control_PanZoom.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,72 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var map;
+ function test_01_Control_PanZoom_constructor (t) {
+ t.plan( 1 );
+
+ control = new OpenLayers.Control.PanZoom();
+ t.ok( control instanceof OpenLayers.Control.PanZoom, "new OpenLayers.Control.PanZoom returns object" );
+ }
+ function test_02_Control_PanZoom_addControl (t) {
+ t.plan( 8 );
+ map = new OpenLayers.Map('map');
+ control = new OpenLayers.Control.PanZoom();
+ t.ok( control instanceof OpenLayers.Control.PanZoom, "new OpenLayers.Control.PanZoom returns object" );
+ t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
+ map.addControl(control);
+ t.ok( control.map === map, "Control.map is set to the map object" );
+ t.ok( map.controls[3] === control, "map.controls contains control" );
+ t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Control div zIndexed properly" );
+ t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 4, "Viewport div contains control div" );
+ t.eq( control.div.style.top, "4px", "Control div top located correctly by default");
+
+ var control2 = new OpenLayers.Control.PanZoom();
+ map.addControl(control2, new OpenLayers.Pixel(100,100));
+ t.eq( control2.div.style.top, "100px", "2nd control div is located correctly");
+ }
+ function test_03_Control_PanZoom_control_events (t) {
+ t.plan( 7 );
+ var evt = {which: 1}; // control expects left-click
+ map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.WMS("Test Layer",
+ "http://octo.metacarta.com/cgi-bin/mapserv?",
+ {map: "/mapdata/vmap_wms.map", layers: "basic"});
+ map.addLayer(layer);
+
+ control = new OpenLayers.Control.PanZoom();
+ map.addControl(control, new OpenLayers.Pixel(20,20));
+
+ var centerLL = new OpenLayers.LonLat(0,0);
+ map.setCenter(centerLL, 5);
+
+ control.buttons[0].onmousedown(evt);
+ t.ok( map.getCenter().lat > centerLL.lat, "Pan up works correctly" );
+
+ control.buttons[1].onmousedown(evt);
+ t.ok( map.getCenter().lon < centerLL.lon, "Pan left works correctly" );
+
+ control.buttons[2].onmousedown(evt);
+ t.ok( map.getCenter().lon == centerLL.lon, "Pan right works correctly" );
+
+ control.buttons[3].onmousedown(evt);
+ t.ok( map.getCenter().lat == centerLL.lat, "Pan down works correctly" );
+
+ control.buttons[4].onmousedown(evt);
+ t.eq( map.getZoom(), 6, "zoomin works correctly" );
+
+ control.buttons[6].onmousedown(evt);
+ t.eq( map.getZoom(), 5, "zoomout works correctly" );
+
+ control.buttons[5].onmousedown(evt);
+ t.eq( map.getZoom(), 2, "zoomworld works correctly" );
+
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map" style="width: 1024px; height: 512px;"/>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Control/test_Control_PanZoomBar.html (from rev 2307, sandbox/vector-2.4/tests/test_Control_PanZoomBar.html)
===================================================================
--- sandbox/vector-2.4/tests/Control/test_Control_PanZoomBar.html (rev 0)
+++ sandbox/vector-2.4/tests/Control/test_Control_PanZoomBar.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,39 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var map;
+ function test_01_Control_PanZoomBar_constructor (t) {
+ t.plan( 1 );
+
+ control = new OpenLayers.Control.PanZoomBar();
+ t.ok( control instanceof OpenLayers.Control.PanZoomBar, "new OpenLayers.Control.PanZoomBar returns object" );
+ }
+ function test_02_Control_PanZoomBar_addControl (t) {
+ t.plan( 8 );
+ map = new OpenLayers.Map('map', {controls:[]});
+ var layer = new OpenLayers.Layer.WMS("Test Layer",
+ "http://octo.metacarta.com/cgi-bin/mapserv?",
+ {map: "/mapdata/vmap_wms.map", layers: "basic"});
+ map.addLayer(layer);
+ control = new OpenLayers.Control.PanZoomBar();
+ t.ok( control instanceof OpenLayers.Control.PanZoomBar, "new OpenLayers.Control.PanZoomBar returns object" );
+ t.ok( map instanceof OpenLayers.Map, "new OpenLayers.Map creates map" );
+ map.addControl(control);
+ t.ok( control.map === map, "Control.map is set to the map object" );
+ t.ok( map.controls[0] === control, "map.controls contains control" );
+ t.eq( parseInt(control.div.style.zIndex), 1001, "Control div zIndexed properly" );
+ t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), 1001, "Viewport div contains control div" );
+ t.eq( control.div.style.top, "4px", "Control div top located correctly by default");
+
+ var control2 = new OpenLayers.Control.PanZoomBar();
+ map.addControl(control2, new OpenLayers.Pixel(100,100));
+ t.eq( control2.div.style.top, "100px", "2nd control div is located correctly");
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map" style="width: 1024px; height: 512px;"/>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Control/test_Control_Permalink.html (from rev 2307, sandbox/vector-2.4/tests/test_Control_Permalink.html)
===================================================================
--- sandbox/vector-2.4/tests/Control/test_Control_Permalink.html (rev 0)
+++ sandbox/vector-2.4/tests/Control/test_Control_Permalink.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,59 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var map;
+ function test_01_Control_Permalink_constructor (t) {
+ t.plan( 1 );
+
+ control = new OpenLayers.Control.Permalink();
+ t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
+ }
+ function test_02_Control_Permalink_updateLinks (t) {
+ t.plan( 2 );
+
+ control = new OpenLayers.Control.Permalink($('permalink'));
+ t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
+ map = new OpenLayers.Map($('map'));
+ layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
+ map.addLayer(layer);
+ if (!map.getCenter()) map.zoomToMaxExtent();
+ map.addControl(control);
+ map.pan(5, 0);
+ if (/MSIE/.test(navigator.userAgent)) {
+ t.eq($('permalink').href, "?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");
+ } else {
+ t.eq($('permalink').href, location+"?lat=0&lon=1.75781&zoom=2&layers=B", "Panning sets permalink");
+ }
+ }
+ function test_03_Control_Permalink_updateLinksBase (t) {
+ t.plan( 2 );
+
+ control = new OpenLayers.Control.Permalink($('permalink'), "./edit.html" );
+ t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
+ map = new OpenLayers.Map($('map'));
+ layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
+ map.addLayer(layer);
+ if (!map.getCenter()) map.zoomToMaxExtent();
+ map.addControl(control);
+ map.pan(5, 0);
+ $('edit_permalink').href = './edit.html?lat=0&lon=1.75781&zoom=2&layers=B';
+ t.eq($('permalink').href, $('edit_permalink').href, "Panning sets permalink with base");
+ }
+ function test_04_Control_Permalink_noElement (t) {
+ t.plan( 2 );
+ control = new OpenLayers.Control.Permalink( );
+ t.ok( control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object" );
+ map = new OpenLayers.Map($('map'));
+ map.addControl(control);
+ t.eq(map.controls[3].div.firstChild.nodeName, "A", "Permalink control creates div with 'a' inside." );
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <a id="permalink" href="">Permalink</a> <br />
+ <a id="edit_permalink" href="">Edit</a> <br />
+ <div id="map" style="width: 1024px; height: 512px;"/>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Control/test_Control_Scale.html (from rev 2307, sandbox/vector-2.4/tests/test_Control_Scale.html)
===================================================================
--- sandbox/vector-2.4/tests/Control/test_Control_Scale.html (rev 0)
+++ sandbox/vector-2.4/tests/Control/test_Control_Scale.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,47 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var map;
+ function test_01_Control_Scale_constructor (t) {
+ t.plan( 1 );
+
+ control = new OpenLayers.Control.Scale();
+ t.ok( control instanceof OpenLayers.Control.Scale, "new OpenLayers.Control returns object" );
+ }
+ function test_02_Control_Scale_updateScale (t) {
+ t.plan( 4 );
+
+ control = new OpenLayers.Control.Scale($('scale'));
+ t.ok( control instanceof OpenLayers.Control.Scale, "new OpenLayers.Control returns object" );
+ map = new OpenLayers.Map($('map'));
+ layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
+ map.addLayer(layer);
+ map.zoomTo(0);
+ map.addControl(control);
+ t.eq($('scale').innerHTML, "Scale = 1 : 443M", "Scale set by default." );
+ map.zoomIn();
+ t.eq($('scale').innerHTML, "Scale = 1 : 221M", "Zooming in changes scale" );
+ map.baseLayer.resolutions = [OpenLayers.Util.getResolutionFromScale(110)];
+ map.zoomTo(0);
+ t.eq($('scale').innerHTML, "Scale = 1 : 110", "Scale of 100 isn't rounded" );
+ }
+ function test_03_Control_Scale_internalScale (t) {
+ t.plan(2);
+ control = new OpenLayers.Control.Scale();
+ t.ok( control instanceof OpenLayers.Control.Scale, "new OpenLayers.Control returns object" );
+ map = new OpenLayers.Map($('map'));
+ layer = new OpenLayers.Layer.WMS('Test Layer', "http://octo.metacarta.com/cgi-bin/mapserv", {map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'});
+ map.addLayer(layer);
+ map.zoomTo(0);
+ map.addControl(control);
+ t.eq(control.div.firstChild.innerHTML, "Scale = 1 : 443M", "Internal scale displayed properly.");
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <a id="scale" href="">Scale</a> <br />
+ <div id="map" style="width: 1024px; height: 512px;"/>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_EventPane.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_EventPane.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_EventPane.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_EventPane.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,114 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
+ var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
+ var layer;
+
+ function test_01_Layer_EventPane_constructor (t) {
+ t.plan( 5 );
+
+ var layer = new OpenLayers.Layer.EventPane('Test Layer');
+
+ t.ok( layer instanceof OpenLayers.Layer.EventPane, "new OpenLayers.Layer.EventPane returns object" );
+ t.eq( layer.CLASS_NAME, "OpenLayers.Layer.EventPane", "CLASS_NAME variable set correctly");
+ t.eq( layer.name, "Test Layer", "layer.name is correct" );
+ t.eq( layer.isBaseLayer, true, "EventPane layer is always base layer" );
+ if (!isMozilla) {
+ t.ok( true, "skipping element test outside of Mozilla");
+ } else {
+ t.ok( layer.pane instanceof HTMLDivElement, "layer.pane is an HTMLDivElement" );
+ }
+ }
+
+ function test_02_Layer_EventPane_clone (t) {
+ t.plan( 1 );
+ t.ok( true, "need to actually write some tests here" );
+ return;
+
+ /// FIX ME FIX ME: fix this later
+
+ var map = new OpenLayers.Map('map');
+ var options = { chicken: 151, foo: "bar" };
+ var layer = new OpenLayers.Layer('Test Layer', options);
+ map.addLayer(layer);
+
+ // randomly assigned property
+ layer.chocolate = 5;
+
+ var clone = layer.clone();
+
+ t.ok( clone instanceof OpenLayers.Layer, "new OpenLayers.Layer returns object" );
+ t.eq( clone.name, "Test Layer", "default clone.name is correct" );
+ t.ok( ((clone.options["chicken"] == 151) && (clone.options["foo"] == "bar")), "clone.options correctly set" );
+ t.eq(clone.chocolate, 5, "correctly copied randomly assigned property");
+
+ layer.addOptions({chicken:152});
+ t.eq(clone.options["chicken"], 151, "made a clean copy of options");
+
+
+ t.ok( clone.map == null, "cloned layer has map property set to null")
+
+ }
+
+ function test_10_Layer_EventPane_setMap (t) {
+
+// MOUSEMOVE test does not seem to work...
+// t.plan( 2 );
+
+ if (!isMozilla || isOpera) {
+ t.plan(4);
+ } else {
+ t.plan(3);
+ }
+ var map = new OpenLayers.Map('map');
+
+ layer = new OpenLayers.Layer.EventPane('Test Layer');
+
+ //give dummy function so test wont bomb on layer.setMap()
+ layer.loadMapObject = function() { };
+ layer.getWarningHTML = function() { this.warning = true; return ""; };
+ map.addLayer(layer);
+ t.eq( parseInt(layer.pane.style.zIndex) - parseInt(layer.div.style.zIndex),
+ 1, "layer pane is 1 z-level above its div" );
+
+ t.ok( layer.warning, "warning correctly registered on no mapObject load" );
+
+ layer2 = new OpenLayers.Layer.EventPane('Test Layer');
+
+ //give dummy function so test wont bomb on layer.setMap()
+ layer2.loadMapObject = function() { this.mapObject = new Object(); };
+ layer2.getWarningHTML = function() { this.warning = true; return ""; }
+
+ map.addLayer(layer2);
+ t.ok( !layer2.warning, "warning not registered on mapObject load" );
+
+ map.events.register("mousemove", map, function () {
+ t.ok(true, "got mouse move");
+ });
+
+ if( document.createEvent ) { // Mozilla
+ var evObj = document.createEvent('MouseEvents');
+ evObj.initEvent( 'mousemove', true, false );
+ layer.pane.dispatchEvent(evObj);
+ } else if( document.createEventObject ) { // IE
+ layer.pane.fireEvent('onmousemove');
+ }
+ }
+
+ function test_20_Layer_EventPane_setVisibility (t) {
+ t.plan( 2 );
+ layer = new OpenLayers.Layer.EventPane('Test Layer');
+ layer.setVisibility(false);
+ t.eq(layer.visibility, false, "layer pane is now invisible");
+ layer.setVisibility(true);
+ t.eq(layer.visibility, true, "layer pane is now visible");
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map" style="height:500px;width:500px"></div>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_FixedZoomLevels.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_FixedZoomLevels.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_FixedZoomLevels.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_FixedZoomLevels.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,97 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var layer;
+
+ function test_01_Layer_FixedZoomLevels (t) {
+ t.plan( 36 );
+
+ var layer = { 'MIN_ZOOM_LEVEL': 5,
+ 'MAX_ZOOM_LEVEL': 10 };
+
+
+ //defaults
+
+ layer = p_createLayer(layer);
+ p_minMaxNum(t, layer, layer.MIN_ZOOM_LEVEL, layer.MAX_ZOOM_LEVEL, "nothing specified");
+
+
+ //layer.options
+
+ // min,num
+ layer = p_createLayer(layer, {}, { minZoomLevel: 3, numZoomLevels: 12});
+ p_minMaxNum(t, layer, layer.MIN_ZOOM_LEVEL, layer.MAX_ZOOM_LEVEL, "min too low num too high(layer.options)");
+
+ layer = p_createLayer(layer, {}, { minZoomLevel: 6, numZoomLevels: 3 });
+ p_minMaxNum(t, layer, 6, 8, "valid min,num(layer.options)");
+
+
+ // max
+ layer = p_createLayer(layer, {}, { maxZoomLevel: 9 });
+ p_minMaxNum(t, layer, layer.MIN_ZOOM_LEVEL, 9, "valid max(layer.options)");
+
+ layer = p_createLayer(layer, {}, { maxZoomLevel: 12 });
+ p_minMaxNum(t, layer, layer.MIN_ZOOM_LEVEL, layer.MAX_ZOOM_LEVEL, "invalid max(layer.options)");
+
+
+
+ //map
+
+ // min,num
+ layer = p_createLayer(layer, { minZoomLevel: 3, numZoomLevels: 12});
+ p_minMaxNum(t, layer, layer.MIN_ZOOM_LEVEL, layer.MAX_ZOOM_LEVEL, "min too low num too high(map)");
+
+ layer = p_createLayer(layer, { minZoomLevel: 6, numZoomLevels: 3 });
+ p_minMaxNum(t, layer, 6, 8, "valid min,num(map)");
+
+
+ // max
+ layer = p_createLayer(layer, { maxZoomLevel: 9 });
+ p_minMaxNum(t, layer, layer.MIN_ZOOM_LEVEL, 9, "valid max(map)");
+
+ layer = p_createLayer(layer, { maxZoomLevel: 12 });
+ p_minMaxNum(t, layer, layer.MIN_ZOOM_LEVEL, layer.MAX_ZOOM_LEVEL, "invalid max(map)");
+
+ //map vs. options
+
+ layer = p_createLayer(layer, {minZoomLevel: 6, numZoomLevels: 2}, { minZoomLevel: 7, numZoomLevels: 3});
+ p_minMaxNum(t, layer, 7, 9, "min,num(layer.options) wins over (map)");
+
+ layer = p_createLayer(layer, {minZoomLevel: 6, maxZoomLevel: 8}, { minZoomLevel: 7, maxZoomLevel: 9});
+ p_minMaxNum(t, layer, 7, 9, "min,max(layer.options) wins over (map)");
+
+
+ // numZoomLevels vs. maxZoomLevel
+
+ layer = p_createLayer(layer, {maxZoomLevel: 8, numZoomLevels: 6});
+ p_minMaxNum(t, layer, layer.MIN_ZOOM_LEVEL, 10, "min,max(layer.options) wins over (map)");
+
+
+
+ }
+
+ function p_createLayer(layer, mapOptions, layerOptions) {
+
+ layer.map = mapOptions || {};
+ layer.options = layerOptions || {};
+ OpenLayers.Layer.FixedZoomLevels.prototype.initResolutions.apply(layer);
+
+ return layer;
+ }
+
+ function p_minMaxNum(t, layer, min, max, msg) {
+
+ t.eq( layer.minZoomLevel, min, "min zoom level inherited from layer constant: " + msg);
+ t.eq( layer.maxZoomLevel, max, "max zoom level inherited from layer constant: " + msg);
+ t.eq( layer.numZoomLevels, max - min + 1, "num zoom levels correctly calcuated: " + msg);
+
+ }
+
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map"></div>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_GeoRSS.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_GeoRSS.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_GeoRSS.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_GeoRSS.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,89 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
+ var layer;
+
+ function test_01_Layer_GeoRSS_constructor (t) {
+ t.plan( 5 );
+ 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;
+ t.delay_call( 1, function() {
+ t.eq( layer.markers.length, 40, "marker length is correct" );
+ var ll = new OpenLayers.LonLat(-71.142197, 42.405696);
+ 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." );
+ } );
+ }
+
+ function test_01_Layer_GeoRSS_AtomParsing (t) {
+ t.plan( 6 );
+ layer = new OpenLayers.Layer.GeoRSS('Test Layer', "./atom-1.0.xml" );
+ t.ok( layer instanceof OpenLayers.Layer.GeoRSS, "new OpenLayers.Layer.GeoRSS returns object" );
+ t.eq( layer.location, "./atom-1.0.xml", "layer.location is correct" );
+ var markers;
+ 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_02_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_03_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( 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_99_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);
+ 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>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_Google.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_Google.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_Google.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_Google.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,156 @@
+<html>
+<head>
+ <!-- this gmaps key generated for http://openlayers.org/dev/ -->
+ <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghSPUCi5aRYVveCcVYxzezM4iaj_gxQ9t-UajFL70jfcpquH5l1IJ-Zyyw'></script>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var layer;
+
+ function test_01_Layer_Google_constructor (t) {
+ t.plan( 4 );
+
+ var map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.Google('Goog Layer');
+ map.addLayer(layer);
+
+
+ t.ok( layer instanceof OpenLayers.Layer.Google, "new OpenLayers.Layer.Google returns object" );
+ t.eq( layer.CLASS_NAME, "OpenLayers.Layer.Google", "CLASS_NAME variable set correctly");
+
+ t.eq( layer.name, "Goog Layer", "layer.name is correct" );
+
+ t.ok ( layer.gmap != null, "GMap2 Object correctly loaded");
+ }
+
+ function test_02_Layer_Google_isBaseLayer (t) {
+ t.plan(1);
+
+ var layer = new OpenLayers.Layer.Google('Goog Layer');
+
+ t.ok(layer.isBaseLayer, "a default load of google layer responds as a base layer");
+ }
+
+ function test_03_Layer_Google_Translation_zoom (t) {
+
+ t.plan( 4 );
+
+ var map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.Google('Goog Layer');
+ map.addLayer(layer);
+
+ // these two lines specify an appropriate translation.
+ // the code afterwards works by itself to test that translation
+ // works correctly both ways.
+ var gZoom = 5;
+ var correspondingOLZoom = 5;
+
+
+ olZoom = layer.getOLZoomFromGZoom(gZoom);
+ t.eq(olZoom, correspondingOLZoom, "Translation from GZoom to OL Zoom works");
+ t.eq(layer.getGZoomFromOLZoom(olZoom), gZoom, "Translation from OL Zoom to GZoom works");
+
+ t.ok( layer.getGZoomFromOLZoom(null) == null, "getGZoomFromOLZoom(null) returns null");
+ t.ok( layer.getOLZoomFromGZoom(null) == null, "getOLZoomFromGZoom(null) returns null");
+ }
+
+ function test_04_Layer_Google_Translation_lonlat (t) {
+
+ t.plan( 4 );
+
+ var map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.Google('Goog Layer');
+ map.addLayer(layer);
+
+ // these two lines specify an appropriate translation.
+ // the code afterwards works by itself to test that translation
+ // works correctly both ways.
+ var gLatLng = new GLatLng(50,100);
+ var correspondingOLLonLat = new OpenLayers.LonLat(100,50);
+
+
+ olLonLat = layer.getOLLonLatFromGLatLng(gLatLng);
+ t.ok(olLonLat.equals(correspondingOLLonLat), "Translation from GLatLng to OpenLayers.LonLat works");
+
+ var transGLatLng = layer.getGLatLngFromOLLonLat(olLonLat);
+ t.ok( transGLatLng.equals(gLatLng), "Translation from OpenLayers.LonLat to GLatLng works");
+
+ t.ok( layer.getGLatLngFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
+ t.ok( layer.getOLLonLatFromGLatLng(null) == null, "getOLLonLatFromGLatLng(null) returns null");
+ }
+
+ function test_05_Layer_Google_Translation_pixel (t) {
+
+ t.plan( 4 );
+
+ var map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.Google('Goog Layer');
+ map.addLayer(layer);
+
+ // these two lines specify an appropriate translation.
+ // the code afterwards works by itself to test that translation
+ // works correctly both ways.
+ var gPoint = new GPoint(50,100);
+ var correspondingOLPixel = new OpenLayers.Pixel(50, 100);
+
+
+ olPixel = layer.getOLPixelFromGPoint(gPoint);
+ t.ok( olPixel.equals(correspondingOLPixel), "Translation from GPoint to OpenLayers.Pixel works");
+
+ var transGPoint = layer.getGPointFromOLPixel(olPixel);
+ t.ok( transGPoint.equals(gPoint), "Translation from OpenLayers.Pixel to GPoint works");
+
+ t.ok( layer.getGPointFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
+ t.ok( layer.getOLPixelFromGPoint(null) == null, "getOLPixelFromGPoint(null) returns null");
+ }
+
+ function test_06_Layer_Google_Translation_bounds (t) {
+
+ t.plan( 4 );
+
+ var map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.Google('Goog Layer');
+ map.addLayer(layer);
+
+ // these two lines specify an appropriate translation.
+ // the code afterwards works by itself to test that translation
+ // works correctly both ways.
+ var sw = new GLatLng(10,20);
+ var ne = new GLatLng(50,40)
+ var gBounds = new GLatLngBounds(sw, ne);
+ var correspondingOLBounds = new OpenLayers.Bounds(20, 10, 40, 50);
+
+
+ olBounds = layer.getOLBoundsFromGLatLngBounds(gBounds);
+
+ t.ok(olBounds.equals(correspondingOLBounds), "Translation from GLatLngBounds to OpenLayers.Bounds works");
+
+ var transGBounds = layer.getGLatLngBoundsFromOLBounds(olBounds);
+ t.ok( transGBounds.equals(gBounds), "Translation from OpenLayers.Bounds to GLatLngBounds works");
+
+ t.ok( layer.getGLatLngBoundsFromOLBounds(null) == null, "getGLatLngBoundsFromOLBounds(null) returns null");
+ t.ok( layer.getOLBoundsFromGLatLngBounds(null) == null, "getOLBoundsFromGLatLngBounds(null) returns null");
+ }
+
+ function test_99_Layer_destroy (t) {
+ t.plan( 5 );
+
+ var map = new OpenLayers.Map('map');
+
+ layer = new OpenLayers.Layer.Google('Test Layer');
+ map.addLayer(layer);
+
+ layer.destroy();
+
+ t.eq( layer.name, null, "layer.name is null after destroy" );
+ t.eq( layer.div, null, "layer.div is null after destroy" );
+ t.eq( layer.map, null, "layer.map is null after destroy" );
+ t.eq( layer.options, null, "layer.options is null after destroy" );
+ t.eq( layer.gmap, null, "layer.gmap is null after destroy" );
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map"></div>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_Grid.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_Grid.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_Grid.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_Grid.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,206 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
+ var layer;
+
+ var name = 'Test Layer';
+ var url = "http://octo.metacarta.com/cgi-bin/mapserv";
+ var params = { map: '/mapdata/vmap_wms.map',
+ layers: 'basic',
+ format: 'image/png'};
+
+ /**
+ * NOTE TO READER:
+ *
+ * Some of the tests on the Grid class actually use the WMS class.
+ * This is because WMS is a subclass of Grid and it implements the
+ * core functions which are necessary to test the tile-generation
+ * mechanism.
+ *
+ */
+
+
+ function test_01_Layer_Grid_constructor (t) {
+ t.plan( 1 );
+
+ layer = new OpenLayers.Layer.Grid(name, url, params, null);
+ t.ok( layer instanceof OpenLayers.Layer.Grid, "returns OpenLayers.Layer.Grid object" );
+ }
+
+
+ function test_02_Layer_Grid_inittiles (t) {
+ t.plan( 2 );
+ var map = new OpenLayers.Map($('map'));
+ layer = new OpenLayers.Layer.WMS(name, url, params);
+ map.addLayer(layer);
+ map.setCenter(new OpenLayers.LonLat(0,0),5);
+ t.eq( layer.grid.length, 7, "Grid rows is correct." );
+ t.eq( layer.grid[0].length, 6, "Grid cols is correct." );
+
+ }
+
+ function test_03_Layer_Grid_clearTiles (t) {
+ t.plan(1);
+ var map = new OpenLayers.Map('map');
+ layer = new OpenLayers.Layer.WMS(name, url, params);
+ map.addLayer(layer);
+
+ map.setCenter(new OpenLayers.LonLat(0,0));
+
+
+ //grab a reference to one of the tiles
+ var tile = layer.grid[0][0];
+
+ layer.clearGrid();
+
+ t.ok( layer.grid != null, "layer.grid does not get nullified" );
+ }
+
+
+ function test_04_Layer_Grid_getGridBounds(t) {
+ t.plan( 1 );
+
+ layer = new OpenLayers.Layer.WMS(name, url, params);
+
+ var bl = { bounds: new OpenLayers.Bounds(1,2,0,0)};
+ var tr = { bounds: new OpenLayers.Bounds(0,0,3,4)};
+ layer.grid = [ [6, tr],
+ [bl, 7]];
+
+ var bounds = layer.getGridBounds();
+
+ var testBounds = new OpenLayers.Bounds(1,2,3,4);
+
+ t.ok( bounds.equals(testBounds), "getGridBounds() returns correct bounds")
+
+ layer.grid = null;
+ }
+
+ function test_05_Layer_Grid_getResolution(t) {
+ t.plan( 1 );
+
+ var map = new OpenLayers.Map('map');
+ layer = new OpenLayers.Layer.WMS(name, url, params);
+ map.addLayer(layer);
+
+ map.zoom = 5;
+
+ t.eq( layer.getResolution(), 0.0439453125, "getResolution() returns correct value");
+ }
+
+ function test_06_Layer_Grid_getZoomForExtent(t) {
+ t.plan( 2 );
+ var bounds, zoom;
+
+ var map = new OpenLayers.Map('map');
+ layer = new OpenLayers.Layer.WMS(name, url, params);
+ map.addLayer(layer);
+
+ bounds = new OpenLayers.Bounds(10,10,12,12);
+ zoom = layer.getZoomForExtent(bounds);
+
+ t.eq( zoom, 8, "getZoomForExtent() returns correct value");
+
+ bounds = new OpenLayers.Bounds(10,10,100,100);
+ zoom = layer.getZoomForExtent(bounds);
+
+ t.eq( zoom, 2, "getZoomForExtent() returns correct value");
+ }
+
+
+ /** THIS WOULD BE WHERE THE TESTS WOULD GO FOR
+ *
+ * -moveTo
+ * -insertColumn
+ * -insertRow
+
+ function 07_Layer_Grid_moveTo(t) {
+ }
+
+ function 08_Layer_Grid_insertColumn(t) {
+ }
+
+ function 09_Layer_Grid_insertRow(t) {
+ }
+
+ *
+ */
+
+ function test_10_Layer_Grid_clone(t) {
+ t.plan(5);
+
+ var options = {tileSize: new OpenLayers.Size(500,50)};
+ var map = new OpenLayers.Map('map', options);
+ layer = new OpenLayers.Layer.Grid(name, url, params);
+ map.addLayer(layer);
+
+ layer.grid = [ [6, 7],
+ [8, 9]];
+
+ var clone = layer.clone();
+
+ t.ok( clone.grid != layer.grid, "clone does not copy grid");
+ t.ok( clone.grid.length == 0, "clone creates a new array instead");
+
+ t.ok( clone.tileSize.equals(layer.tileSize), "tileSize correctly cloned");
+
+ layer.tileSize.w += 40;
+
+ t.eq( clone.tileSize.w, 500, "changing layer.tileSize does not change clone.tileSize -- a fresh copy was made, not just copied reference");
+
+ t.eq( clone.alpha, layer.alpha, "alpha copied correctly");
+
+ layer.grid = null;
+ }
+
+ function test_11_Layer_Grid_setMap(t) {
+
+ t.plan(2);
+
+ var options = {tileSize: new OpenLayers.Size(500,50)};
+ var map = new OpenLayers.Map('map', options);
+ layer = new OpenLayers.Layer.Grid(name, url, params);
+
+
+ layer.setMap(map);
+
+ t.ok( layer.tileSize != null, "tileSize has been set");
+ t.ok( (layer.tileSize.h == 50) && (layer.tileSize.w == 500), "tileSize has been set correctly");
+ }
+
+
+ function test_99_Layer_Grid_destroy (t) {
+
+ t.plan( 3 );
+
+ var map = new OpenLayers.Map('map');
+ layer = new OpenLayers.Layer.Grid(name, url, params);
+ map.addLayer(layer);
+ layer.destroy();
+ t.eq( layer.grid, null, "layer.grid is null after destroy" );
+ t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );
+
+
+ //test with tile creation
+ layer = new OpenLayers.Layer.WMS(name, url, params);
+ map.addLayer(layer);
+
+ map.setCenter(new OpenLayers.LonLat(0,0), 5);
+
+ //grab a reference to one of the tiles
+ var tile = layer.grid[0][0];
+
+ layer.destroy();
+
+ t.ok( layer.grid == null, "tiles appropriately destroyed")
+ }
+
+ // -->
+ </script>
+</head>
+<body>
+<div id="map" style="width:500px;height:550px;display:none"></div>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_HTTPRequest.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_HTTPRequest.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_HTTPRequest.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_HTTPRequest.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,183 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var layer;
+
+ var name = "Test Layer";
+ var url = "http://octo.metacarta.com/cgi-bin/mapserv";
+ var params = { map: '/mapdata/vmap_wms.map',
+ layers: 'basic',
+ format: 'image/png'};
+ var options = { chicken: 151, foo: "bar" };
+
+ function test_01_Layer_HTTPRequest_constructor (t) {
+ t.plan( 5 );
+
+ layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
+
+ t.ok( layer instanceof OpenLayers.Layer.HTTPRequest, "new OpenLayers.Layer.HTTPRequest returns correctly typed object" );
+
+ // correct bubbling up to Layer.initialize()
+ t.eq( layer.name, name, "layer.name is correct" );
+ t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly set" );
+
+ // HTTPRequest-specific properties
+ t.eq( layer.url, url, "layer.name is correct" );
+ t.ok( ((layer.params["map"] == '/mapdata/vmap_wms.map') &&
+ (layer.params["layers"] == "basic") &&
+ (layer.params["format"] == "image/png")), "layer.params correctly set" );
+
+
+ }
+
+ function test_02_Layer_HTTPRequest_clone (t) {
+ t.plan( 6 );
+
+ var toClone = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
+ toClone.chocolate = 5;
+
+ var layer = toClone.clone();
+
+ t.eq(layer.chocolate, 5, "correctly copied randomly assigned property");
+
+ t.ok( layer instanceof OpenLayers.Layer.HTTPRequest, "new OpenLayers.Layer.HTTPRequest returns correctly typed object" );
+
+ // correct bubbling up to Layer.initialize()
+ t.eq( layer.name, name, "layer.name is correct" );
+ t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly set" );
+
+ // HTTPRequest-specific properties
+ t.eq( layer.url, url, "layer.name is correct" );
+ t.ok( ((layer.params["map"] == '/mapdata/vmap_wms.map') &&
+ (layer.params["layers"] == "basic") &&
+ (layer.params["format"] == "image/png")), "layer.params correctly set" );
+
+ }
+
+ function test_03_Layer_HTTPRequest_setUrl (t) {
+ t.plan( 1 );
+
+ layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
+
+ layer.setUrl("foo");
+ t.eq( layer.url, "foo", "setUrl() works");
+ }
+
+ function test_05_Layer_HTTPRequest_mergeNewParams (t) {
+ t.plan( 3 );
+
+ layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
+
+ var newParams = { layers: 'sooper',
+ chickpeas: 'image/png'};
+
+ layer.mergeNewParams(newParams);
+
+ t.eq( layer.params.layers, "sooper", "mergeNewParams() overwrites well");
+ t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() adds well");
+
+ newParams.chickpeas = 151;
+
+ t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() makes clean copy of hash");
+
+
+ }
+
+ function test_06_Layer_HTTPRequest_getFullRequestString (t) {
+
+ tParams = { layers: 'basic',
+ format: 'image/png'};
+
+ t.plan( 9 );
+
+ // without ?
+ tUrl = "http://octo.metacarta.com/cgi-bin/mapserv";
+ layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
+ str = layer.getFullRequestString();
+ t.eq(str, tUrl + '?' + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url sans ?");
+
+
+ // with ?
+ tUrl = "http://octo.metacarta.com/cgi-bin/mapserv?";
+ layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
+ str = layer.getFullRequestString();
+ t.eq(str, tUrl + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url with ?");
+
+ // with ?param1=5
+ tUrl = "http://octo.metacarta.com/cgi-bin/mapserv?param1=5";
+ layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
+ str = layer.getFullRequestString();
+ t.eq(str, tUrl + '&' + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url with ?param1=5");
+
+ // with ?param1=5&
+ tUrl = "http://octo.metacarta.com/cgi-bin/mapserv?param1=5&format=image/jpeg";
+ layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
+ str = layer.getFullRequestString();
+ t.eq(str, tUrl + '&' + OpenLayers.Util.getParameterString({'layers':'basic'}), "getFullRequestString() doesn't override already-existing params in URL");
+
+
+ // with ?param1=5&
+ tUrl = "http://octo.metacarta.com/cgi-bin/mapserv?param1=5&";
+ layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
+ str = layer.getFullRequestString();
+ t.eq(str, tUrl + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url with ?param1=5&");
+
+
+
+ // passing in new params
+ layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
+ str = layer.getFullRequestString( { chicken: 6,
+ layers:"road" } );
+ t.eq(str, tUrl + OpenLayers.Util.getParameterString({layers: 'road', format: "image/png", chicken: 6}), "getFullRequestString() works for passing in new params");
+
+ // layer with null params
+ layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, null, null);
+ str = layer.getFullRequestString();
+ t.eq(str, tUrl + OpenLayers.Util.getParameterString({}), "getFullRequestString() works for layer with null params");
+
+ // layer with null params passing in new params
+ layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, null, null);
+ str = layer.getFullRequestString( { chicken: 6,
+ layers:"road" } );
+ t.eq(str, tUrl + OpenLayers.Util.getParameterString({chicken: 6, layers: "road"}), "getFullRequestString() works for layer with null params passing in new params");
+
+ // with specified altUrl parameter
+ tUrl = "http://octo.metacarta.com/cgi-bin/mapserv";
+ layer = new OpenLayers.Layer.HTTPRequest(name, "chicken", tParams, null);
+ str = layer.getFullRequestString(null, tUrl);
+ t.eq(str, tUrl + '?' + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url sans ?");
+
+ }
+
+ function test_99_Layer_HTTPRequest_destroy (t) {
+ t.plan( 6 );
+
+ var map = new OpenLayers.Map('map');
+
+ layer = new OpenLayers.Layer.HTTPRequest("Test Layer",
+ "http://www.openlayers.org",
+ { foo: 2, bar: 3},
+ { opt1: 8, opt2: 9});
+
+ map.addLayer(layer);
+ layer.destroy();
+
+ // Ensure Layer.destroy() is called
+ t.eq( layer.name, null, "layer.name is null after destroy" );
+ t.eq( layer.div, null, "layer.div is null after destroy" );
+ t.eq( layer.map, null, "layer.map is null after destroy" );
+ t.eq( layer.options, null, "layer.options is null after destroy" );
+
+
+ // Specific to HTTPRequest
+ t.eq( layer.url, null, "layer.url is null after destroy" );
+ t.eq( layer.params, null, "layer.params is null after destroy" );
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map"></div>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_Image.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_Image.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_Image.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_Image.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,96 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var layer;
+
+ function test_01_Layer_Image_constructor (t) {
+ t.plan( 13 );
+
+ var options = { chicken: 151, foo: "bar", projection: "none" };
+ var layer = new OpenLayers.Layer.Image('Test Layer',
+ 'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
+ new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
+ new OpenLayers.Size(580, 288), options);
+
+ t.ok( layer instanceof OpenLayers.Layer.Image, "new OpenLayers.Layer.Image returns object" );
+ t.eq( layer.CLASS_NAME, "OpenLayers.Layer.Image", "CLASS_NAME variable set correctly");
+
+ t.eq( layer.name, "Test Layer", "layer.name is correct" );
+ t.ok( layer.id != null, "Layer is given an id");
+ t.ok( layer.projection, "none", "default layer projection correctly set");
+ t.ok( ((layer.chicken == 151) && (layer.foo == "bar")), "layer.options correctly set to Layer Object" );
+ t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly backed up" );
+
+ options.chicken = 552;
+
+ t.eq( layer.options["chicken"], 151 , "layer.options correctly made fresh copy" );
+
+ t.eq( layer.isBaseLayer, true, "Default img layer is base layer" );
+
+ layer = new OpenLayers.Layer.Image('Test Layer',
+ 'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
+ new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
+ new OpenLayers.Size(580, 288));
+ t.ok( layer instanceof OpenLayers.Layer.Image, "new OpenLayers.Layer.Image returns object" );
+ t.eq( layer.name, "Test Layer", "layer.name is correct" );
+ t.ok( layer.projection == null, "default layer projection correctly set");
+ t.ok( layer.options instanceof Object, "layer.options correctly initialized as a non-null Object" );
+ }
+
+ function test_50_Layer_Image_tileTests (t) {
+ t.plan(4);
+ var map = new OpenLayers.Map('map');
+
+ layer = new OpenLayers.Layer.Image('Test Layer',
+ 'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
+ new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
+ new OpenLayers.Size(580, 288));
+
+ map.addLayer(layer);
+ map.zoomToMaxExtent();
+ t.eq(layer.tile.position.x,-40, "Tile x positioned correctly at maxextent");
+ t.eq(layer.tile.position.y,107, "Tile y positioned correctly at maxextent");
+ t.eq(layer.tile.imgDiv.src, "http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif", "URL is correct");
+ map.zoomIn();
+ t.eq(layer.tile.imgDiv.src, "http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif", "URL is correct");
+ }
+/******
+ *
+ *
+ * HERE IS WHERE SOME TESTS SHOULD BE PUT TO CHECK ON THE LONLAT-PX TRANSLATION
+ * FUNCTIONS AND RESOLUTION AND GETEXTENT GETZOOMLEVEL, ETC
+ *
+ *
+ */
+
+
+ function test_99_Layer_Image_destroy (t) {
+ t.plan( 4 );
+
+ var map = new OpenLayers.Map('map');
+
+ layer = new OpenLayers.Layer.Image('Test Layer',
+ 'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif',
+ new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
+ new OpenLayers.Size(580, 288));
+
+ map.addLayer(layer);
+ map.zoomToMaxExtent();
+
+ layer.destroy();
+
+ t.eq( layer.name, null, "layer.name is null after destroy" );
+ t.eq( layer.div, null, "layer.div is null after destroy" );
+ t.eq( layer.map, null, "layer.map is null after destroy" );
+ t.eq( layer.options, null, "layer.options is null after destroy" );
+
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map" style="width:500px;height:500px"></div>
+ <div id="map2" style="width:100px;height:100px"></div>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_KaMap.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_KaMap.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_KaMap.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_KaMap.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,220 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
+ var layer;
+
+ var name = 'Test Layer';
+ var url = "http://boston.freemap.in/tile.php?";
+ var params = {
+ 'map':'boston-new',
+ 'g':'border,water,roads,openspace',
+ 'i':'JPEG'
+ };
+ var units = "meters";
+
+
+
+ function test_01_Layer_KaMap_constructor (t) {
+ t.plan( 1 );
+
+ layer = new OpenLayers.Layer.KaMap(name, url, params, units);
+ t.ok( layer instanceof OpenLayers.Layer.KaMap, "returns OpenLayers.Layer.KaMap object" );
+ }
+
+
+ function test_02_Layer_KaMap_inittiles (t) {
+ t.plan( 2 );
+ var map = new OpenLayers.Map($('map'));
+ layer = new OpenLayers.Layer.KaMap(name, url, params, units);
+ map.addLayer(layer);
+ map.setCenter(new OpenLayers.LonLat(0,0),5);
+ t.eq( layer.grid.length, 6, "KaMap rows is correct." );
+ t.eq( layer.grid[0].length, 4, "KaMap cols is correct." );
+
+ }
+
+ function test_03_Layer_KaMap_clearTiles (t) {
+ t.plan( 1 );
+ var map = new OpenLayers.Map('map');
+ layer = new OpenLayers.Layer.KaMap(name, url, params, units);
+ map.addLayer(layer);
+
+ map.setCenter(new OpenLayers.LonLat(0,0));
+
+ //grab a reference to one of the tiles
+ var tile = layer.grid[0][0];
+
+ layer.clearGrid();
+
+ t.ok( layer.grid != null, "layer.grid does not get nullified" );
+ }
+
+
+ function test_04_Layer_KaMap_getKaMapBounds(t) {
+ t.plan( 1 );
+
+ layer = new OpenLayers.Layer.KaMap(name, url, params, units);
+
+ var bl = { bounds: new OpenLayers.Bounds(1,2,0,0)};
+ var tr = { bounds: new OpenLayers.Bounds(0,0,3,4)};
+ layer.grid = [ [6, tr],
+ [bl, 7]];
+
+ var bounds = layer.getGridBounds();
+
+ var testBounds = new OpenLayers.Bounds(1,2,3,4);
+
+ t.ok( bounds.equals(testBounds), "getKaMapBounds() returns correct bounds")
+
+ layer.grid = null;
+ }
+
+ function test_05_Layer_KaMap_getResolution(t) {
+ t.plan( 1 );
+
+ var map = new OpenLayers.Map('map');
+ layer = new OpenLayers.Layer.KaMap(name, url, params, units);
+ map.addLayer(layer);
+
+ map.zoom = 5;
+
+ t.eq( layer.getResolution(), 0.0439453125, "getResolution() returns correct value");
+ }
+
+ function test_06_Layer_KaMap_getZoomForExtent(t) {
+ t.plan( 2 );
+ var bounds, zoom;
+
+ var map = new OpenLayers.Map('map');
+ layer = new OpenLayers.Layer.KaMap(name, url, params, units);
+ map.addLayer(layer);
+
+ bounds = new OpenLayers.Bounds(10,10,12,12);
+ zoom = layer.getZoomForExtent(bounds);
+
+ t.eq( zoom, 8, "getZoomForExtent() returns correct value");
+
+ bounds = new OpenLayers.Bounds(10,10,100,100);
+ zoom = layer.getZoomForExtent(bounds);
+
+ t.eq( zoom, 2, "getZoomForExtent() returns correct value");
+ }
+
+ function test_06_Layer_kaMap_mergeNewParams (t) {
+ t.plan( 5 );
+
+ var map = new OpenLayers.Map("map");
+ var url = "http://octo.metacarta.com/cgi-bin/mapserv";
+ layer = new OpenLayers.Layer.KaMap(name, url, params);
+
+ var newParams = { layers: 'sooper',
+ chickpeas: 'image/png'};
+
+ map.addLayer(layer);
+ map.zoomToMaxExtent();
+ t.ok( !layer.grid[0][0].url.match("chickpeas"), "chickpeas is not in URL of first tile in grid" );
+
+ layer.mergeNewParams(newParams);
+
+ t.eq( layer.params.layers, "sooper", "mergeNewParams() overwrites well");
+ t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() adds well");
+ t.ok( layer.grid[0][0].url.match("chickpeas"), "CHICKPEAS is in URL of first tile in grid" );
+
+ newParams.chickpeas = 151;
+
+ t.eq( layer.params.chickpeas, "image/png", "mergeNewParams() makes clean copy of hashtable");
+ }
+
+
+ /** THIS WOULD BE WHERE THE TESTS WOULD GO FOR
+ *
+ * -moveTo
+ * -insertColumn
+ * -insertRow
+
+ function 07_Layer_KaMap_moveTo(t) {
+ }
+
+ function 08_Layer_KaMap_insertColumn(t) {
+ }
+
+ function 09_Layer_KaMap_insertRow(t) {
+ }
+
+ *
+ */
+
+ function test_10_Layer_KaMap_clone(t) {
+ t.plan(4);
+
+ var options = {tileSize: new OpenLayers.Size(500,50)};
+ var map = new OpenLayers.Map('map', options);
+ layer = new OpenLayers.Layer.KaMap(name, url, params, units);
+ map.addLayer(layer);
+
+ layer.grid = [ [6, 7],
+ [8, 9]];
+
+ var clone = layer.clone();
+
+ t.ok( clone.grid != layer.grid, "clone does not copy grid");
+
+ t.ok( clone.tileSize.equals(layer.tileSize), "tileSize correctly cloned");
+
+ layer.tileSize.w += 40;
+
+ t.eq( clone.tileSize.w, 500, "changing layer.tileSize does not change clone.tileSize -- a fresh copy was made, not just copied reference");
+
+ t.eq( clone.alpha, layer.alpha, "alpha copied correctly");
+
+ layer.grid = null;
+ }
+
+ function test_11_Layer_KaMap_setMap(t) {
+
+ t.plan(2);
+
+ var options = {tileSize: new OpenLayers.Size(500,50)};
+ var map = new OpenLayers.Map('map', options);
+ layer = new OpenLayers.Layer.KaMap(name, url, params, units);
+
+
+ layer.setMap(map);
+
+ t.ok( layer.tileSize != null, "tileSize has been set");
+ t.ok( (layer.tileSize.h == 50) && (layer.tileSize.w == 500), "tileSize has been set correctly");
+ }
+
+ function test_99_Layer_KaMap_destroy (t) {
+
+ t.plan( 3 );
+
+ var map = new OpenLayers.Map('map');
+ layer = new OpenLayers.Layer.KaMap(name, url, params, units);
+ map.addLayer(layer);
+ layer.destroy();
+ t.eq( layer.grid, null, "layer.grid is null after destroy" );
+ t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );
+
+
+ //test with tile creation
+ layer = new OpenLayers.Layer.KaMap(name, url, params, units);
+ map.addLayer(layer);
+ map.setCenter(new OpenLayers.LonLat(0,0), 5);
+ //grab a reference to one of the tiles
+ var tile = layer.grid[0][0];
+
+ layer.destroy();
+
+ t.ok( layer.grid == null, "tiles appropriately destroyed");
+ }
+
+ // -->
+ </script>
+</head>
+<body>
+<div id="map" style="width:500px;height:550px;display:none"></div>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_Markers.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_Markers.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_Markers.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_Markers.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,40 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var layer;
+
+ function test_01_Layer_Markers_constructor (t) {
+ t.plan( 2 );
+
+ layer = new OpenLayers.Layer.Markers('Test Layer');
+ t.ok( layer instanceof OpenLayers.Layer.Markers, "new OpenLayers.Layer.Markers returns object" );
+ t.eq( layer.name, "Test Layer", "layer.name is correct" );
+ }
+ function test_02_Layer_Markers_addlayer (t) {
+ t.plan( 3 );
+
+ layer = new OpenLayers.Layer.Markers('Test Layer');
+ t.ok( layer instanceof OpenLayers.Layer.Markers, "new OpenLayers.Layer.Markers returns object" );
+ t.eq( layer.name, "Test Layer", "layer.name is correct" );
+ layer.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),
+ new OpenLayers.Icon())
+ );
+ t.eq( layer.markers.length, 1, "addLayer adds marker to layer." );
+ }
+
+ function test_99_Layer_Markers_destroy (t) {
+ t.plan( 1 );
+ layer = new OpenLayers.Layer.Markers('Test Layer');
+ var map = new OpenLayers.Map('map');
+ map.addLayer(layer);
+ layer.destroy();
+ t.eq( layer.map, null, "layer.map is null after destroy" );
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map"></div>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_MultiMap.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_MultiMap.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_MultiMap.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_MultiMap.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,128 @@
+<html>
+<head>
+ <script type="text/javascript" src="http://clients.multimap.com/API/maps/1.1/metacarta_04"></script>
+ <script src="../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var layer;
+
+ function test_01_Layer_MultiMap_constructor (t) {
+ t.plan( 4 );
+
+ var map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
+ map.addLayer(layer);
+
+
+ t.ok( layer instanceof OpenLayers.Layer.MultiMap, "new OpenLayers.Layer.MultiMap returns object" );
+ t.eq( layer.CLASS_NAME, "OpenLayers.Layer.MultiMap", "CLASS_NAME variable set correctly");
+
+ t.eq( layer.name, "Goog Layer", "layer.name is correct" );
+
+ t.ok ( layer.multimap != null, "MultiMap Object correctly loaded");
+ }
+
+ function test_02_Layer_MultiMap_isBaseLayer (t) {
+ t.plan(1);
+
+ var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
+
+ t.ok(layer.isBaseLayer, "a default load of google layer responds as a base layer");
+ }
+
+ function test_03_Layer_MultiMap_Translation_zoom (t) {
+
+ t.plan( 4 );
+
+ var map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
+ map.addLayer(layer);
+
+ // these two lines specify an appropriate translation.
+ // the code afterwards works by itself to test that translation
+ // works correctly both ways.
+ var gZoom = 5;
+ var correspondingOLZoom = 4;
+
+
+ olZoom = layer.getOLZoomFromMMZoom(gZoom);
+ t.eq(olZoom, correspondingOLZoom, "Translation from GZoom to OL Zoom works");
+ t.eq(layer.getMMZoomFromOLZoom(olZoom), gZoom, "Translation from OL Zoom to GZoom works");
+
+ t.ok( layer.getMMZoomFromOLZoom(null) == null, "getGZoomFromOLZoom(null) returns null");
+ t.ok( layer.getOLZoomFromMMZoom(null) == null, "getOLZoomFromGZoom(null) returns null");
+ }
+
+ function test_04_Layer_MultiMap_Translation_lonlat (t) {
+
+ t.plan( 4 );
+
+ var map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
+ map.addLayer(layer);
+
+ // these two lines specify an appropriate translation.
+ // the code afterwards works by itself to test that translation
+ // works correctly both ways.
+ var gLatLng = new MMLatLon(50,100);
+ var correspondingOLLonLat = new OpenLayers.LonLat(100,50);
+
+
+ olLonLat = layer.getOLLonLatFromMMLatLong(gLatLng);
+ t.ok(olLonLat.equals(correspondingOLLonLat), "Translation from GLatLng to OpenLayers.LonLat works");
+
+ var transGLatLng = layer.getMMLatLongFromOLLonLat(olLonLat);
+ t.ok( (transGLatLng.lat == gLatLng.lat) && (transGLatLng.lon == transGLatLng.lon), "Translation from OpenLayers.LonLat to GLatLng works");
+
+ t.ok( layer.getMMLatLongFromOLLonLat(null) == null, "getGLatLngFromOLLonLat(null) returns null");
+ t.ok( layer.getOLLonLatFromMMLatLong(null) == null, "getOLLonLatFromGLatLng(null) returns null");
+ }
+
+ function test_05_Layer_MultiMap_Translation_pixel (t) {
+
+ t.plan( 4 );
+
+ var map = new OpenLayers.Map('map');
+ var layer = new OpenLayers.Layer.MultiMap('Goog Layer');
+ map.addLayer(layer);
+
+ // these two lines specify an appropriate translation.
+ // the code afterwards works by itself to test that translation
+ // works correctly both ways.
+ var gPoint = new MMPoint(50,100);
+ var correspondingOLPixel = new OpenLayers.Pixel(50, 100);
+
+
+ olPixel = layer.getOLPixelFromPixel(gPoint);
+ t.ok( olPixel.equals(correspondingOLPixel), "Translation from GPoint to OpenLayers.Pixel works");
+
+ var transGPoint = layer.getPixelFromOLPixel(olPixel);
+ t.ok( ((transGPoint.x == transGPoint.x) && (transGPoint.y == transGPoint.y)), "Translation from OpenLayers.Pixel to GPoint works");
+
+ t.ok( layer.getPixelFromOLPixel(null) == null, "getGPointFromOLPixel(null) returns null");
+ t.ok( layer.getOLPixelFromPixel(null) == null, "getOLPixelFromGPoint(null) returns null");
+ }
+
+
+ function test_99_Layer_destroy (t) {
+ t.plan( 5 );
+
+ var map = new OpenLayers.Map('map');
+
+ layer = new OpenLayers.Layer.MultiMap('Test Layer');
+ map.addLayer(layer);
+
+ layer.destroy();
+
+ t.eq( layer.name, null, "layer.name is null after destroy" );
+ t.eq( layer.div, null, "layer.div is null after destroy" );
+ t.eq( layer.map, null, "layer.map is null after destroy" );
+ t.eq( layer.options, null, "layer.options is null after destroy" );
+ t.eq( layer.multimap, null, "layer.gmap is null after destroy" );
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <div id="map"></div>
+</body>
+</html>
Copied: sandbox/vector-2.4/tests/Layer/test_Layer_TMS.html (from rev 2307, sandbox/vector-2.4/tests/test_Layer_TMS.html)
===================================================================
--- sandbox/vector-2.4/tests/Layer/test_Layer_TMS.html (rev 0)
+++ sandbox/vector-2.4/tests/Layer/test_Layer_TMS.html 2007-03-05 16:07:30 UTC (rev 2309)
@@ -0,0 +1,164 @@
+<html>
+<head>
+ <script src="../../lib/OpenLayers.js"></script>
+ <script type="text/javascript"><!--
+ var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
+ var layer;
+
+ var name = 'Test Layer';
+ var url = "http://labs.metacarta.com/wms-c/Basic.py/";
+ var options = {'layername':'basic', 'type':'png'};
+
+
+ function test_01_Layer_TMS_constructor (t) {
+ t.plan( 1 );
+
+