OpenLayers OpenLayers

Changeset 2846

Show
Ignore:
Timestamp:
03/22/07 10:11:40 (2 years ago)
Author:
emanuel
Message:

unit tests for animated zooming and panning

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js

    r2827 r2846  
    353353            this.createMap(); 
    354354        } 
     355 
    355356        if(!this.isSuitableOverview()) { 
    356357            this.updateOverview(); 
    357358        } 
     359 
     360        // update extent rectangle 
    358361        this.updateRectToMap(); 
    359 this.updateOverview(); 
     362 
     363        this.updateOverview(); 
    360364    }, 
    361365    /** 
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/PanZoomBar.js

    r2635 r2846  
    150150     */ 
    151151    divClick: function (evt) { 
    152         if (!OpenLayers.Event.isLeftClick(evt)) return; 
     152        //if (!OpenLayers.Event.isLeftClick(evt)) return; 
    153153        var y = evt.xy.y; 
    154154        var top = OpenLayers.Util.pagePosition(evt.object)[1]; 
    155155        var levels = Math.floor((y - top)/this.zoomStopHeight); 
    156          
     156       
    157157        if (!this.map.zoomanimationActive) 
    158158            this.map.zoomTo((this.map.getNumZoomLevels() -1) -  levels); 
     
    217217            this.map.events.unregister("mouseup", this, this.passEventToSlider); 
    218218            this.map.events.unregister("mousemove", this, this.passEventToSlider); 
    219             var deltaY = this.map.zoomStart.y - evt.xy.y 
    220   
     219            var deltaY = this.map.zoomStart.y - evt.xy.y; 
     220 
    221221            // zoom map to new zoomlevel 
    222222            var finalZoomlevel = this.map.zoom + Math.round(deltaY/this.zoomStopHeight); 
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js

    r2827 r2846  
    850850    /**  
    851851     * The actual clone function: 
    852      * Freeze current map while tiles of viewport are loading
     852     * Hold scaled map while tiles are loading successive
    853853     *   
    854854     * special function; shares with some baselayers; calls from subclasses 
     
    876876            this.map.baseLayerDivClone.style.zIndex--;  
    877877                 
    878             // 4. set original div invisible during the tiles are loading             
    879             //this.map.layerContainerDiv.style.display= "none"; 
    880             
    881             // 5. set zoomOut tile (of original div) invisible  
     878            // 4. set zoomOut tile (of original div) invisible  
    882879            if (this.map.baseLayer.zoomOutTile) 
    883880                this.map.baseLayer.zoomOutTile.imgDiv.style.display = "none"; 
     
    911908            } 
    912909        } 
    913  
    914910        // set flag that zoom animation finished 
    915911        this.map.zoomanimationActive = false; 
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/Image.js

    r2635 r2846  
    135135                this.tile.position = ulPx.clone(); 
    136136            } 
    137  
    138             // fire loadstart event 
    139             this.events.triggerEvent("loadstart"); 
    140             this.doneLoading = false; 
    141  
    142137            this.tile.draw(); 
    143  
    144             var onload = function() {  
    145                 this.doneLoading = true;  
    146                 this.events.triggerEvent("loadend");  
    147             } 
    148  
    149             OpenLayers.Event.observe(this.tile.imgDiv, 'load', 
    150                                      onload.bindAsEventListener(this)); 
    151138        } 
    152139    },  
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Map.js

    r2827 r2846  
    939939        }; 
    940940        var move = function() { 
    941             var dx = OpenLayers.Util.easeInOut(this.slideX,  
     941            var dx = OpenLayers.Util.easeInOutPan(this.slideX,  
    942942                                                this.totalSteps,  
    943943                                                this.step,  
    944944                                                this.power); 
    945             var dy = OpenLayers.Util.easeInOut(this.slideY, 
     945            var dy = OpenLayers.Util.easeInOutPan(this.slideY, 
    946946                                                this.totalSteps,  
    947947                                                this.step,  
     
    14021402 
    14031403        // set zoomanimation flag to false _manually_  
    1404         // (only for image baselayer, because there is no onimageload event); 
     1404        // (only for baselayers without onimageload events, f.e. imagelayer); 
    14051405        // for all other layers it calls automatically from 
    14061406        // loadendevent in layers.js 
    1407         if (!this.baseLayer.CLASS_NAME.match("OpenLayers.Layer.WMS")){ 
     1407        if (this.baseLayer.CLASS_NAME.match("OpenLayers.Layer.Image")){ 
    14081408            this.zoomanimationActive = false; 
    14091409        } 
     
    14281428            this.zoomlevel_scale = 0;  
    14291429        }  
    1430         if (this.zoomlevel_scale > (this.getNumZoomLevels()-1)) {  
     1430        if (this.zoomlevel_scale > (this.getNumZoomLevels()- 1)) {  
    14311431            this.zoomlevel_scale = this.getNumZoomLevels() - 1;  
    14321432        } 
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Util.js

    r2827 r2846  
    973973 * @param {float} power 
    974974 *  
    975  * @returns The delta to the next position in the animation movement 
     975 * @returns The delta to the next position in the pan animation movement 
    976976 * @type int 
    977977 */ 
    978 OpenLayers.Util.easeInOut = function(delta, totalSteps, step, power) { 
     978OpenLayers.Util.easeInOutPan = function(delta, totalSteps, step, power) { 
    979979    var prevStepVal = Math.pow(((1/totalSteps)*(step-1)),power) * delta; 
    980980    var stepVal = Math.pow(((1/totalSteps)*step),power) * delta; 
     
    991991 * @param {float} power 
    992992 *  
    993  * @returns The delta to the next position in the animation movement 
     993 * @returns The next zoomlevel in the zoom animation movement 
    994994 * @type float 
    995995 */ 
    996996OpenLayers.Util.easeInOutZoom = function(delta, totalSteps, step, power) { 
    997     var prevStepVal = Math.pow(((1/totalSteps)*(step-1)),power) * delta; 
    998997    var stepVal = Math.pow(((1/totalSteps)*step),power) * delta; 
    999998    return stepVal;  
  • sandbox/emanuel/animatedZooming/tests/Control/test_OverviewMap.html

    r2827 r2846  
    44  <script type="text/javascript"><!-- 
    55    var map;  
    6     function test_01_Control_PanZoom_constructor (t) { 
     6    function test_01_Control_OverviewMap_constructor (t) { 
    77        t.plan( 1 ); 
    88     
     
    1010        t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" ); 
    1111    } 
    12     function test_02_Control_PanZoom_addControl (t) { 
     12    function test_02_Control_OverviewMap_addControl (t) { 
    1313        t.plan( 6 ); 
    1414        map = new OpenLayers.Map('map'); 
     
    2323 
    2424    } 
    25     function test_03_Control_PanZoom_control_events (t) { 
     25    function test_03_Control_OverviewMap_control_events (t) { 
    2626        t.plan( 10 ); 
    2727        var evt = {which: 1}; // control expects left-click 
     
    4545         
    4646        control.mapDivDblClick({'xy':new OpenLayers.Pixel(5,5)}); 
    47         t.delay_call( 1, function() { 
    48             var cent = map.getCenter(); 
    49             t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon"); 
    50             t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat"); 
     47        t.delay_call(  
     48            1, function() { 
     49                var cent = map.getCenter(); 
     50                t.eq(cent.lon, -71.3515625, "Clicking on the Overview Map has the correct effect on map lon"); 
     51                t.eq(cent.lat, 42.17578125, "Clicking on the Overview Map has the correct effect on map lat"); 
    5152 
    52             control.rectMouseDown({'xy':new OpenLayers.Pixel(5,5), 'which':1}); 
    53             control.rectMouseMove({'xy':new OpenLayers.Pixel(15,15), 'which':1}); 
    54             control.rectMouseUp({'xy':new OpenLayers.Pixel(15,15), 'which':1}); 
    55              
    56             t.delay_call( 1, function() { 
     53                control.rectMouseDown({'xy':new OpenLayers.Pixel(5,5), 'which':1}); 
     54                control.rectMouseMove({'xy':new OpenLayers.Pixel(15,15), 'which':1}); 
     55                control.rectMouseUp({'xy':new OpenLayers.Pixel(15,15), 'which':1}); 
     56            }, 
     57 
     58            1, function() { 
    5759                var cent = map.getCenter(); 
    5860                t.eq(cent.lon, -71.27328491210938, "Dragging on the Overview Map has the correct effect on map lon"); 
     
    6567                t.eq(overviewCenter.lat, 0, "Overviewmap center lat correct -- second zoom"); 
    6668                t.eq(overviewZoom, 0, "Overviewmap zoomcorrect -- second zoom"); 
    67            }); 
    68         }); 
     69           } 
     70        ); 
     71    } 
    6972 
     73    function test_04_Control_OverviewMap_updateRectToMap (t) { 
     74        t.plan( 4 ); 
     75 
     76        map = new OpenLayers.Map('map'); 
     77        var layer = new OpenLayers.Layer.WMS("Test Layer",  
     78            "http://octo.metacarta.com/cgi-bin/mapserv?", 
     79            {map: "/mapdata/vmap_wms.map", layers: "basic"}); 
     80        map.addLayer(layer); 
     81 
     82        control = new OpenLayers.Control.OverviewMap(); 
     83        map.addControl(control, new OpenLayers.Pixel(20,20)); 
     84        map.setCenter(new OpenLayers.LonLat(0,0), 5); 
     85        control.updateRectToMap(); 
     86        t.eq(control.extentRectangle.style.left, "45px", "rectangle left position has been set correctly"); 
     87        t.eq(control.extentRectangle.style.top, "23px", "rectangle top position has been set correctly"); 
     88        t.eq(control.extentRectangle.style.width, "90px", "rectangle width position has been set correctly"); 
     89        t.eq(control.extentRectangle.style.height, "45px", "rectangle height position has been set correctly"); 
     90    } 
     91 
     92    function test_05_Control_OverviewMap_updateMapToRect (t) { 
     93        t.plan( 4 ); 
     94 
     95        map = new OpenLayers.Map('map'); 
     96        var layer = new OpenLayers.Layer.WMS("Test Layer",  
     97            "http://octo.metacarta.com/cgi-bin/mapserv?", 
     98            {map: "/mapdata/vmap_wms.map", layers: "basic"}); 
     99        map.addLayer(layer); 
     100 
     101        control = new OpenLayers.Control.OverviewMap(); 
     102        map.addControl(control, new OpenLayers.Pixel(20,20)); 
     103        map.setCenter(new OpenLayers.LonLat(0,0), 5); 
     104        control.updateRectToMap(); 
     105        t.eq(control.extentRectangle.style.left, "45px", "rectangle left position has been set correctly"); 
     106        t.eq(control.extentRectangle.style.top, "23px", "rectangle top position has been set correctly"); 
     107        t.eq(control.extentRectangle.style.width, "90px", "rectangle width position has been set correctly"); 
     108        t.eq(control.extentRectangle.style.height, "45px", "rectangle height position has been set correctly"); 
    70109    } 
    71110  // --> 
  • sandbox/emanuel/animatedZooming/tests/Control/test_PanZoom.html

    r2827 r2846  
    4343 
    4444        control.buttons[0].onmousedown(evt); 
    45         t.delay_call( 1, function() { 
    46           t.ok( map.getCenter().lat > centerLL.lat, "Pan up works correctly" ); 
    47  
    48           control.buttons[1].onmousedown(evt); 
    49           t.delay_call( 1, function() { 
    50             t.ok( map.getCenter().lon < centerLL.lon, "Pan left works correctly" ); 
    51  
    52             control.buttons[2].onmousedown(evt); 
    53             t.delay_call( 1, function() { 
    54               t.ok( map.getCenter().lon == centerLL.lon, "Pan right works correctly" ); 
    55  
    56               control.buttons[3].onmousedown(evt); 
    57               t.delay_call( 1, function() { 
     45        t.delay_call(  
     46            1, function() { 
     47                t.ok( map.getCenter().lat > centerLL.lat, "Pan up works correctly" ); 
     48                control.buttons[1].onmousedown(evt); 
     49            }, 
     50             
     51            1, function() { 
     52                t.ok( map.getCenter().lon < centerLL.lon, "Pan left works correctly" ); 
     53                control.buttons[2].onmousedown(evt); 
     54            }, 
     55             
     56            1, function() { 
     57                t.ok( map.getCenter().lon == centerLL.lon, "Pan right works correctly" ); 
     58                control.buttons[3].onmousedown(evt); 
     59            }, 
     60             
     61            1, function() { 
    5862                t.ok( map.getCenter().lat == centerLL.lat, "Pan down works correctly" ); 
    59  
    6063                control.buttons[4].onmousedown(evt); 
    61                 t.delay_call( 1, function() { 
    62                   t.eq( map.getZoom(), 6, "zoomin works correctly" ); 
    63  
    64                   // set zoomanimation flag manually,  
    65                   // reason: loadend event in layers.js will not achieved in unittests 
    66                   map.zoomanimationActive = false; 
    67                   control.buttons[6].onmousedown(evt); 
    68                   t.delay_call( 1, function() { 
    69                     t.eq( map.getZoom(), 5, "zoomout works correctly" ); 
    70  
    71                     control.buttons[5].onmousedown(evt); 
    72                     t.delay_call( 1, function() { 
    73                       t.eq( map.getZoom(), 2, "zoomworld works correctly" ); 
    74                     }); 
    75                   }); 
    76                 }); 
    77               }); 
    78             }); 
    79           }); 
    80         }); 
     64            }, 
     65             
     66            1, function() { 
     67                t.eq( map.getZoom(), 6, "zoomin works correctly" ); 
     68                // set zoomanimation flag manually,  
     69                // reason: loadend event in layers.js will not achieved in unittests 
     70                map.zoomanimationActive = false; 
     71                control.buttons[6].onmousedown(evt); 
     72            }, 
     73             
     74            1, function() { 
     75                t.eq( map.getZoom(), 5, "zoomout works correctly" ); 
     76                control.buttons[5].onmousedown(evt); 
     77            }, 
     78             
     79            1, function() { 
     80                t.eq( map.getZoom(), 2, "zoomworld works correctly" ); 
     81            } 
     82        ); 
    8183 
    8284    } 
  • sandbox/emanuel/animatedZooming/tests/Control/test_PanZoomBar.html

    r2827 r2846  
    44  <script type="text/javascript"><!-- 
    55    var map;  
     6    var layer;  
     7    var name = 'Test Layer'; 
     8    var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 
     9    var params = { map: '/mapdata/vmap_wms.map',  
     10                   layers: 'basic',  
     11                   format: 'image/png'}; 
     12 
    613    function test_01_Control_PanZoomBar_constructor (t) { 
    714        t.plan( 1 ); 
     
    1219    function test_02_Control_PanZoomBar_addControl (t) { 
    1320        t.plan( 8 ); 
     21 
    1422        map = new OpenLayers.Map('map', {controls:[]}); 
    15         var layer = new OpenLayers.Layer.WMS("Test Layer",  
    16             "http://octo.metacarta.com/cgi-bin/mapserv?", 
    17             {map: "/mapdata/vmap_wms.map", layers: "basic"}); 
     23        layer = new OpenLayers.Layer.WMS(name, url, params); 
    1824        map.addLayer(layer); 
    1925        control = new OpenLayers.Control.PanZoomBar(); 
     
    3137        t.eq( control2.div.style.top, "100px", "2nd control div is located correctly"); 
    3238    } 
     39 
     40    function test_03_Control_PanZoomBar_control_events (t) { 
     41        t.plan( 3 ); 
     42 
     43        var evt = {which: 1}; // control expects left-click 
     44        map = new OpenLayers.Map('map'); 
     45        layer = new OpenLayers.Layer.WMS(name, url, params); 
     46        map.addLayer(layer); 
     47        control = new OpenLayers.Control.PanZoomBar(); 
     48        map.addControl(control); 
     49        var centerLL = new OpenLayers.LonLat(0,0);  
     50        map.setCenter(centerLL, 0); 
     51 
     52        evt.xy = new OpenLayers.Pixel(10,115);  
     53        evt.object = control; 
     54        control.divClick(evt); 
     55        t.delay_call( 
     56            1, function() { 
     57                t.eq(map.zoom, 5,  
     58                    "Clicking on the zoombar has the correct effect on zoomlevel"); 
     59 
     60                control.zoomBarDown(evt); 
     61                evt.xy.y -= 30;   
     62                control.zoomBarDrag(evt); 
     63 
     64                control.zoomBarUp(evt); 
     65            }, 
     66            1, function() { 
     67                t.eq(map.zoom, 8,  
     68                    "Dragging the zoomslider works correctly"); 
     69                t.eq(control.slider.style.top, "159px",  
     70                    "Zoomslider top position has been set correctly"); 
     71            } 
     72 
     73        ); 
     74         
     75 
     76 
     77    } 
     78 
    3379  // --> 
    3480  </script> 
  • sandbox/emanuel/animatedZooming/tests/Control/test_Scale.html

    r2827 r2846  
    1919        map.addLayer(layer); 
    2020        map.zoomTo(0); 
    21         t.delay_call( 1, function() { 
    22             map.addControl(control); 
    23             t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 443M", "Scale set by default."  ); 
    24             // set zoomanimation flag manually,  
    25             // reason: loadend event in layers.js will not achieved in unittests 
    26             map.zoomanimationActive = false; 
    27             map.zoomIn(); 
    28             t.delay_call( 1, function() { 
     21        t.delay_call(  
     22            1, function() { 
     23                map.addControl(control); 
     24                t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 443M", "Scale set by default."  ); 
     25                // set zoomanimation flag manually,  
     26                // reason: loadend event in layers.js will not achieved in unittests 
     27                map.zoomanimationActive = false; 
     28                map.zoomIn(); 
     29            }, 
     30            1, function() { 
    2931                t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 221M", "Zooming in changes scale"  ); 
    3032                 
     
    3436                map.baseLayer.resolutions = [OpenLayers.Util.getResolutionFromScale(110)]; 
    3537                map.zoomTo(0,false); 
    36                 t.delay_call( 1, function() { 
    37                     t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 110", "Scale of 100 isn't rounded"  ); 
    38                 }); 
    39             }); 
    40         }); 
     38            }, 
     39            1, function() { 
     40                t.eq(OpenLayers.Util.getElement('scale').innerHTML, "Scale = 1 : 110", "Scale of 100 isn't rounded"  ); 
     41            } 
     42        ); 
    4143    } 
    4244    function test_03_Control_Scale_internalScale (t) { 
  • sandbox/emanuel/animatedZooming/tests/Layer/test_Grid.html

    r2827 r2846  
    44  <script type="text/javascript"><!-- 
    55    var isMozilla = (navigator.userAgent.indexOf("compatible") == -1); 
     6    var map; 
    67    var layer;  
    7  
     8     
    89    var name = 'Test Layer'; 
    910    var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 
    1011    var params = { map: '/mapdata/vmap_wms.map',  
    1112                   layers: 'basic',  
    12                   format: 'image/png'}; 
     13                  format: 'image/png'}; 
    1314 
    1415    /** 
    1516     *  NOTE TO READER: 
    16      *  
     17     * 
    1718     *    Some of the tests on the Grid class actually use the WMS class.  
    1819     *    This is because WMS is a subclass of Grid and it implements the  
     
    3334    function test_02_Layer_Grid_inittiles (t) { 
    3435        t.plan( 2 ); 
    35         var map = new OpenLayers.Map('map'); 
     36        map = new OpenLayers.Map('map'); 
    3637        layer = new OpenLayers.Layer.WMS(name, url, params); 
    3738        map.addLayer(layer); 
     
    4445    function test_03_Layer_Grid_clearTiles (t) { 
    4546        t.plan(1); 
    46         var map = new OpenLayers.Map('map'); 
     47        map = new OpenLayers.Map('map'); 
    4748        layer = new OpenLayers.Layer.WMS(name, url, params); 
    4849        map.addLayer(layer); 
     
    8283        t.plan( 1 ); 
    8384 
    84         var map = new OpenLayers.Map('map'); 
     85        map = new OpenLayers.Map('map'); 
    8586        layer = new OpenLayers.Layer.WMS(name, url, params); 
    8687        map.addLayer(layer); 
     
    9596        var bounds, zoom; 
    9697 
    97         var map = new OpenLayers.Map('map'); 
     98        map = new OpenLayers.Map('map'); 
    9899        layer = new OpenLayers.Layer.WMS(name, url, params); 
    99100        map.addLayer(layer); 
     
    133134         
    134135        var options = {tileSize: new OpenLayers.Size(500,50)}; 
    135         var map = new OpenLayers.Map('map', options); 
     136        map = new OpenLayers.Map('map', options); 
    136137        layer = new OpenLayers.Layer.Grid(name, url, params); 
    137138        map.addLayer(layer); 
     
    157158 
    158159    function test_11_Layer_Grid_setMap(t) { 
    159  
    160160        t.plan(2); 
    161161         
    162162        var options = {tileSize: new OpenLayers.Size(500,50)}; 
    163         var map = new OpenLayers.Map('map', options); 
     163        map = new OpenLayers.Map('map', options); 
    164164        layer = new OpenLayers.Layer.Grid(name, url, params); 
    165165 
     
    172172 
    173173 
     174 
     175    /*** animated zooming test functions ***/ 
     176 
     177    function test_12_Layer_Grid_setZoomOutTile (t) { 
     178        t.plan(5); 
     179         
     180        map = new OpenLayers.Map('map'); 
     181        layer = new OpenLayers.Layer.WMS(name, url, params); 
     182        map.addLayer(layer); 
     183        map.tileSize = new OpenLayers.Size(256,256);  
     184        map.zoomOutTileFactor = 4; 
     185        var tile = map.baseLayer.zoomOutTile; 
     186 
     187        t.ok( tile instanceof OpenLayers.Tile.Image,  
     188                "zoomOutTile is a Tile.Image object"); 
     189         
     190        var firstChild = map.baseLayer.div.firstChild; 
     191        t.eq( tile.imgDiv.id, firstChild.id,  
     192                "zoomOutTile is first child of baseLayerDiv"); 
     193 
     194        size = map.baseLayer.zoomOutTile.size; 
     195        t.eq( size.w, 1024, "zoomOutTile width is 1024px"); 
     196        t.eq( size.h, 1024, "zoomOutTile height is 1024px"); 
     197 
     198        t.ok( tile.imgDiv.style.display == "none",  
     199                "zoomOutTile is invisible"); 
     200    } 
     201 
     202 
     203    function test_13_Layer_Grid_getTileSize (t) { 
     204        t.plan(2); 
     205 
     206        map = new OpenLayers.Map('map'); 
     207        layer = new OpenLayers.Layer.WMS(name, url, params); 
     208        map.addLayer(layer); 
     209        map.tileSize = new OpenLayers.Size(256,256);   
     210 
     211        size = map.baseLayer.getTileSize(); 
     212        t.eq(size.w, 256, "tile width is correct");  
     213        t.eq(size.h, 256, "tile height is correct"); 
     214    } 
     215 
     216    function test_14_Layer_Grid_getCenterTile (t) { 
     217        t.plan(1); 
     218 
     219        map = new OpenLayers.Map('map'); 
     220        layer = new OpenLayers.Layer.WMS(name, url, params); 
     221        map.addLayer(layer); 
     222        map.setCenter(new OpenLayers.LonLat(0,0)); 
     223         
     224        tile = map.baseLayer.getCenterTile();  
     225        t.ok(tile.bounds.contains(0,0,true),  
     226                "center tile has been set correctly" ); 
     227    } 
     228 
     229    function test_15_Layer_Grid_setTilesOutsideInvisible (t) { 
     230        t.plan(1); 
     231 
     232        map = new OpenLayers.Map('map'); 
     233        layer = new OpenLayers.Layer.WMS(name, url, params); 
     234        map.addLayer(layer); 
     235        map.setCenter(new OpenLayers.LonLat(0,0)); 
     236        map.zoomTo(5,false); 
     237        map.baseLayer.setTilesOutsideInvisible(); 
     238 
     239        var tileOutside = map.baseLayer.grid[0][0]; 
     240        t.ok( tileOutside.imgDiv.style.display == "none",  
     241                "tiles outside the viewport have been set invisible"); 
     242 
     243    } 
     244 
     245    function test_16_Layer_Grid_scaleTilesOfGrid (t) { 
     246        t.plan(4); 
     247 
     248        map = new OpenLayers.Map('map'); 
     249        layer = new OpenLayers.Layer.WMS(name, url, params); 
     250        map.addLayer(layer); 
     251        map.setCenter(new OpenLayers.LonLat(0,0)); 
     252        map.zoomTo(5,false); 
     253         
     254        var tile = map.baseLayer.grid[3][2]; 
     255        var centerTile = map.baseLayer.getCenterTile(); 
     256        var newTileSize = new OpenLayers.Size(128,128); 
     257        map.baseLayer.scaleTileTo(centerTile,newTileSize); 
     258        map.baseLayer.scaleTilesOfGrid(centerTile,newTileSize); 
     259 
     260        t.eq( tile.imgDiv.style.width, "128px",  
     261                "width of tiles has been set correctly"); 
     262        t.eq( tile.imgDiv.style.height, "128px",  
     263                "height of tiles has been set correctly"); 
     264        t.eq( tile.imgDiv.style.top, "147px",  
     265                "top position of tiles has been set correctly"); 
     266        t.eq( tile.imgDiv.style.left, "122px",  
     267                "left position of tiles has been set correctly"); 
     268    } 
     269 
     270    function test_17_Layer_Grid_scaleZoomOutTile (t) { 
     271        t.plan(5); 
     272 
     273        map = new OpenLayers.Map('map'); 
     274        layer = new OpenLayers.Layer.WMS(name, url, params); 
     275        map.addLayer(layer); 
     276        map.setCenter(new OpenLayers.LonLat(0,0)); 
     277        map.tileSize = new OpenLayers.Size(256,256); 
     278        map.zoomToMaxExtent(); 
     279        var tile = map.baseLayer.zoomOutTile; 
     280        map.baseLayer.scaleZoomOutTile(1,map.maxResolution/2); 
     281 
     282        t.eq( tile.imgDiv.style.width, "512px",  
     283                "width of zoomOutTile has been set correctly"); 
     284        t.eq( tile.imgDiv.style.height, "512px",  
     285                "height of zoomOutTile has been set correctly"); 
     286        t.eq( tile.imgDiv.style.top, "-109px",  
     287                "top position of zoomOutTile has been set correctly"); 
     288        t.eq( tile.imgDiv.style.left, "-6px",  
     289                "left position of zoomOutTile has been set correctly"); 
     290        t.ok( tile.imgDiv.style.display != "none",  
     291                "zoomOutTile has been set visible"); 
     292    } 
     293 
     294    function test_18_Layer_Grid_cloneBaseLayerDiv (t) { 
     295        t.plan(4); 
     296 
     297        map = new OpenLayers.Map('map'); 
     298        layer = new OpenLayers.Layer.WMS(name, url, params); 
     299        map.addLayer(layer); 
     300         
     301        map.baseLayer.cloneBaseLayerDiv(); 
     302        var cloneDiv = map.baseLayerDivClone; 
     303        var originDiv = map.baseLayer.div;  
     304        t.ok( cloneDiv instanceof HTMLDivElement,  
     305                "cloned baseLayerDiv is a valid HTMLDivElement"); 
     306        t.eq( cloneDiv.childNodes.length, originDiv.childNodes.length, 
     307                "cloned baseLayerDiv has the same number of childs"); 
     308        t.eq( parseInt(cloneDiv.style.zIndex)+1, parseInt(originDiv.style.zIndex), 
     309                "zIndex has been set correctly"); 
     310        t.ok( map.baseLayer.zoomOutTile.imgDiv.style.display == "none", 
     311                "zoomOutTile of original div has been set invisible"); 
     312    } 
     313 
     314 
     315 
    174316    function test_99_Layer_Grid_destroy (t) { 
    175317 
    176318        t.plan( 3 ); 
    177319 
    178         var map = new OpenLayers.Map('map'); 
     320        map = new OpenLayers.Map('map'); 
    179321        layer = new OpenLayers.Layer.Grid(name, url, params); 
    180322        map.addLayer(layer); 
     
    184326 
    185327 
    186     //test with tile creation 
     328        //test with tile creation 
    187329        layer = new OpenLayers.Layer.WMS(name, url, params); 
    188330        map.addLayer(layer); 
  • sandbox/emanuel/animatedZooming/tests/Layer/test_Image.html

    r2827 r2846  
    3939    } 
    4040 
    41     function test_50_Layer_Image_tileTests (t) { 
     41    function test_02_Layer_Image_tileTests (t) { 
    4242        t.plan(4); 
    4343        var map = new OpenLayers.Map('map'); 
     
    6666 
    6767 
     68    /*** animated zooming test functions ***/ 
     69    function test_03_Layer_Image_getTileSize (t) { 
     70        t.plan(2); 
     71 
     72        map = new OpenLayers.Map('map'); 
     73        layer = new OpenLayers.Layer.Image('Test Layer',  
     74                'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif', 
     75                new OpenLayers.Bounds(-180, -88.759, 180, 88.759), 
     76                new OpenLayers.Size(580, 288)); 
     77        map.addLayer(layer); 
     78        map.setCenter(new OpenLayers.LonLat(0,0)); 
     79 
     80        var size = map.baseLayer.getTileSize(); 
     81        t.eq(size.w, 580, "tile width is correct");  
     82        t.eq(size.h, 288, "tile height is correct"); 
     83    } 
     84    function test_04_Layer_Image_getCenterTile (t) { 
     85        t.plan(1); 
     86 
     87        map = new OpenLayers.Map('map'); 
     88        layer = new OpenLayers.Layer.Image('Test Layer',  
     89                'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif', 
     90                new OpenLayers.Bounds(-180, -88.759, 180, 88.759), 
     91                new OpenLayers.Size(580, 288)); 
     92        map.addLayer(layer); 
     93        map.setCenter(new OpenLayers.LonLat(0,0)); 
     94 
     95        tile = map.baseLayer.getCenterTile();  
     96        t.ok(map.baseLayer.tile == tile,  
     97                "center tile has been set correctly" ); 
     98    } 
     99    function test_05_Layer_Image_cloneBaseLayerDiv (t) { 
     100        t.plan(3); 
     101 
     102        map = new OpenLayers.Map('map'); 
     103        layer = new OpenLayers.Layer.Image('Test Layer',  
     104                'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif', 
     105                new OpenLayers.Bounds(-180, -88.759, 180, 88.759), 
     106                new OpenLayers.Size(580, 288)); 
     107        map.addLayer(layer); 
     108         
     109        map.baseLayer.cloneBaseLayerDiv(); 
     110        var cloneDiv = map.baseLayerDivClone; 
     111        var originDiv = map.baseLayer.div;  
     112        t.ok( cloneDiv instanceof HTMLDivElement,  
     113                "cloned baseLayerDiv is a valid HTMLDivElement"); 
     114        t.eq( cloneDiv.childNodes.length, originDiv.childNodes.length, 
     115                "cloned baseLayerDiv has the same number of childs"); 
     116        t.eq( parseInt(cloneDiv.style.zIndex)+1, parseInt(originDiv.style.zIndex), 
     117                "zIndex has been set correctly"); 
     118    } 
     119 
    68120    function test_99_Layer_Image_destroy (t) { 
    69121        t.plan( 4 );     
     
    72124         
    73125        layer = new OpenLayers.Layer.Image('Test Layer',  
    74                                         'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif', 
    75                                                                         new OpenLayers.Bounds(-180, -88.759, 180, 88.759), 
    76                                                                                                         new OpenLayers.Size(580, 288)); 
     126                'http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif', 
     127                new OpenLayers.Bounds(-180, -88.759, 180, 88.759), 
     128                new OpenLayers.Size(580, 288)); 
    77129 
    78130        map.addLayer(layer); 
     
    92144<body> 
    93145  <div id="map" style="width:500px;height:500px"></div> 
    94   <div id="map2" style="width:100px;height:100px"></div> 
    95146</body> 
    96147</html> 
  • sandbox/emanuel/animatedZooming/tests/Layer/test_WMS.html

    r2827 r2846  
    2727    } 
    2828     
    29     function test_02_Layer_WMS_addtile (t) { 
     29    function test_03_Layer_WMS_getURL (t) { 
     30        t.plan( 3 ); 
     31     
     32        var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 
     33        layer = new OpenLayers.Layer.WMS(name, url, params); 
     34        var map = new OpenLayers.Map('map'); 
     35        map.addLayer(layer); 
     36 
     37        var bounds = new OpenLayers.Bounds(1,2,3,4);         
     38        var url = map.baseLayer.getURL(bounds); 
     39        t.eq( url, "http://octo.metacarta.com/cgi-bin/mapserv?MAP=%2Fmapdata%2Fvmap_wms.map&LAYERS=basic&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=1%2C2%2C3%2C4&WIDTH=256&HEIGHT=256",  
     40                "url has been set correctly"); 
     41         
     42        var tileSize = new OpenLayers.Size(512,512); 
     43        url = map.baseLayer.getURL(bounds,tileSize);         
     44        t.ok( url.match("WIDTH=512"),  
     45                "url with custom width has been set correctly"); 
     46        t.ok( url.match("HEIGHT=512"),  
     47                "url with custom height has been set correctly"); 
     48 
     49    } 
     50 
     51    function test_03_Layer_WMS_addtile (t) { 
    3052        t.plan( 6 ); 
    3153     
     
    6688    } 
    6789     
    68     function test_03_Layer_WMS_inittiles (t) { 
     90    function test_04_Layer_WMS_inittiles (t) { 
    6991        t.plan( 2 ); 
    7092        var map = new OpenLayers.Map('map'); 
     
    78100 
    79101 
    80     function test_04_Layer_WMS_clone (t) { 
     102    function test_05_Layer_WMS_clone (t) { 
    81103        t.plan(4); 
    82104         
     
    105127    } 
    106128 
    107     function test_05_Layer_WMS_isBaseLayer(t) { 
     129    function test_06_Layer_WMS_isBaseLayer(t) { 
    108130        t.plan(3); 
    109131         
     
    121143    } 
    122144 
    123     function test_06_Layer_WMS_mergeNewParams (t) { 
     145    function test_07_Layer_WMS_mergeNewParams (t) { 
    124146        t.plan( 5 ); 
    125147 
     
    146168    } 
    147169 
    148     function test_07_Layer_WMS_getFullRequestString (t) { 
     170    function test_08_Layer_WMS_getFullRequestString (t) { 
    149171 
    150172         
     
    176198    } 
    177199 
    178     function test_08_Layer_WMS_setOpacity (t) { 
     200    function test_09_Layer_WMS_setOpacity (t) { 
    179201        t.plan( 5 ); 
    180202 
  • sandbox/emanuel/animatedZooming/tests/list-tests.html

    r2827 r2846  
    11<ul id="testlist"> 
     2    <li>BaseTypes/test_Bounds.html</li> 
    23    <li>BaseTypes/test_Class.html</li> 
     4    <li>BaseTypes/test_LonLat.html</li> 
    35    <li>BaseTypes/test_Pixel.html</li> 
    46    <li>BaseTypes/test_Size.html</li> 
    5     <li>BaseTypes/test_LonLat.html</li> 
    6     <li>BaseTypes/test_Bounds.html</li> 
    77    <li>test_Geometry.html</li> 
    8     <li>Geometry/test_Point.html</li> 
    9     <li>Geometry/test_Curve.html</li> 
    10     <li>Geometry/test_LineString.html</li> 
     8    <li>Geometry/test_Collection.html</li> 
     9    <li>Geometry/test_LinearRing.html</li> 
     10    <li>Geometry/test_LineString.html</li>     
    1111    <li>Geometry/test_MultiLineString.html</li> 
    12     <li>Geometry/test_LinearRing.html</li> 
    13     <li>Geometry/test_Collection.html</li>