Merge pull request #702 from ahocevar/smart-queue
New tile image cache and tile queue improvements. r=@bartvde,@elemoine
This commit is contained in:
@@ -4,9 +4,6 @@
|
||||
<script type="text/javascript">window.alert = oldAlert;</script>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
// turn off animation frame handling, so we can check img urls in tests
|
||||
delete OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
||||
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
|
||||
|
||||
+3
-20
@@ -1,19 +1,5 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
/**
|
||||
* Because browsers that implement requestAnimationFrame may not execute
|
||||
* animation functions while a window is not displayed (e.g. in a hidden
|
||||
* iframe as in these tests), we mask the native implementations here. The
|
||||
* native requestAnimationFrame functionality is tested in Util.html and
|
||||
* in PanZoom.html (where a popup is opened before panning).
|
||||
*/
|
||||
window.requestAnimationFrame =
|
||||
window.webkitRequestAnimationFrame =
|
||||
window.mozRequestAnimationFrame =
|
||||
window.oRequestAnimationFrame =
|
||||
window.msRequestAnimationFrame = null;
|
||||
</script>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
var map, layer;
|
||||
@@ -108,10 +94,9 @@
|
||||
isBaseLayer: false
|
||||
}, options));
|
||||
map.addLayer(layer);
|
||||
var tile = layer.tileQueue[0];
|
||||
|
||||
t.delay_call(5, function() {
|
||||
t.ok(tile.url, "Tile not empty");
|
||||
t.ok(layer.grid[0][0].url, "Tile not empty");
|
||||
map.destroy();
|
||||
});
|
||||
}
|
||||
@@ -186,12 +171,11 @@
|
||||
layer = new OpenLayers.Layer.Bing(options);
|
||||
map.addLayer(layer);
|
||||
map.zoomToMaxExtent();
|
||||
var tile = layer.tileQueue[0];
|
||||
|
||||
t.delay_call(5, function() {
|
||||
t.ok(OpenLayers.Util.indexOf(layer.attribution, '<img src="//') != -1, "Attribution contains a logo with protocol //");
|
||||
t.ok(OpenLayers.Util.indexOf(layer.attribution, '<img src="http://') == -1, "Attribution logo does not have http:// protocol");
|
||||
t.ok(tile.url.indexOf('http:') == -1, "Tile url does not contain http:");
|
||||
t.ok(layer.grid[1][1].url.indexOf('http:') == -1, "Tile url does not contain http:");
|
||||
|
||||
map.destroy();
|
||||
});
|
||||
@@ -200,11 +184,10 @@
|
||||
layer_https = new OpenLayers.Layer.Bing(OpenLayers.Util.applyDefaults({protocol: 'https:'}, options));
|
||||
map2.addLayer(layer_https);
|
||||
map2.zoomToMaxExtent();
|
||||
var tile = layer_https.tileQueue[0];
|
||||
|
||||
t.delay_call(5, function() {
|
||||
t.ok(OpenLayers.Util.indexOf(layer_https.attribution, '<img src="https://') != -1, "Attribution logo has https:// protocol");
|
||||
t.ok(tile.url.indexOf('https:') == 0, "Tile url contains https:");
|
||||
t.ok(layer_https.grid[1][1].url.indexOf('https:') == 0, "Tile url contains https:");
|
||||
map2.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
+2
-51
@@ -2,9 +2,6 @@
|
||||
<head>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
// turn off animation frame handling, so we can check img urls in tests
|
||||
var origQueueTileDraw = OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
||||
delete OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
||||
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var layer;
|
||||
@@ -100,26 +97,6 @@
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_queueTileDraw(t) {
|
||||
t.plan(3);
|
||||
OpenLayers.Layer.Grid.prototype.queueTileDraw = origQueueTileDraw;
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
map.addLayer(layer);
|
||||
map.setCenter([0, 0], 3);
|
||||
var queued = layer.tileQueue.length;
|
||||
t.ok(layer.tileQueue.length, "Tiles queued for drawing");
|
||||
map.zoomIn();
|
||||
t.eq(layer.tileQueue.length, queued, "Tile queue has same length after immediate zoom change");
|
||||
t.delay_call(1, function() {
|
||||
t.eq(layer.tileQueue.length, 0, "Tiles from queue processed");
|
||||
});
|
||||
|
||||
map.destroy();
|
||||
delete OpenLayers.Layer.Grid.prototype.queueTileDraw;
|
||||
}
|
||||
|
||||
function test_Layer_Grid_clearTiles (t) {
|
||||
t.plan(4);
|
||||
|
||||
@@ -258,10 +235,7 @@
|
||||
|
||||
function test_Layer_Grid_moveTo(t) {
|
||||
|
||||
t.plan(17);
|
||||
|
||||
var origIsNative = OpenLayers.Animation.isNative;
|
||||
OpenLayers.Animation.isNative = false;
|
||||
t.plan(13);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
@@ -271,23 +245,6 @@
|
||||
map.setCenter([-10, 0], 5);
|
||||
|
||||
var log = [];
|
||||
var origDeferMoveGriddedTiles = layer.deferMoveGriddedTiles;
|
||||
layer.deferMoveGriddedTiles = function() {
|
||||
log.push("deferMoveGriddedTiles");
|
||||
origDeferMoveGriddedTiles.apply(this, arguments);
|
||||
};
|
||||
layer.moveGriddedTiles = function() {
|
||||
log.push("moveGriddedTiles");
|
||||
OpenLayers.Layer.WMS.prototype.moveGriddedTiles.apply(this, arguments);
|
||||
};
|
||||
map.moveTo([5, 0]);
|
||||
t.eq(log[0], "moveGriddedTiles", "deferred after moveTo");
|
||||
map.moveTo([0, 0]);
|
||||
t.eq(log[1], "moveGriddedTiles", "deferred again after another moveTo");
|
||||
t.eq(log.length, 2, "no tiles loaded yet");
|
||||
t.delay_call(1, function() {
|
||||
t.eq(log[2], "deferMoveGriddedTiles", "tiles moved after tileLoadingDelay");
|
||||
});
|
||||
|
||||
//make sure null bounds doesnt cause script error.
|
||||
// no test necessary, just action
|
||||
@@ -309,9 +266,6 @@
|
||||
g_WhichFunc = "MoveGridded";
|
||||
g_Bounds = layer.map.getExtent();
|
||||
};
|
||||
layer.deferMoveGriddedTiles = function() {
|
||||
g_WhichFunc = "DeferMoveGridded";
|
||||
}
|
||||
var clearTestBounds = function() {
|
||||
g_WhichFunc = null;
|
||||
g_Bounds = null;
|
||||
@@ -418,8 +372,6 @@
|
||||
layer.moveTo(null, zoomChanged);
|
||||
t.ok(g_WhichFunc == "InitGridded", "if tiles drastically out of bounds, we call initGriddedTile()");
|
||||
t.ok(g_Bounds.equals(b), "if tiles drastically out of bounds, we call initGriddedTile() with correct bounds");
|
||||
|
||||
OpenLayers.Animation.isNative = origIsNative;
|
||||
}
|
||||
|
||||
/** THIS WOULD BE WHERE THE TESTS WOULD GO FOR
|
||||
@@ -438,7 +390,7 @@
|
||||
*/
|
||||
|
||||
function test_Layer_Grid_clone(t) {
|
||||
t.plan(7);
|
||||
t.plan(6);
|
||||
|
||||
var options = {tileSize: new OpenLayers.Size(500,50)};
|
||||
var map = new OpenLayers.Map('map', options);
|
||||
@@ -453,7 +405,6 @@
|
||||
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.tileQueue !== layer.tileQueue, "new tileQueue for clone");
|
||||
t.eq(clone.backBuffer, null, "no backbuffer from original");
|
||||
|
||||
t.ok( clone.tileSize.equals(layer.tileSize), "tileSize correctly cloned");
|
||||
|
||||
@@ -555,9 +555,6 @@
|
||||
}
|
||||
|
||||
function test_tileBounds(t) {
|
||||
// do not defer moveGriddedTiles
|
||||
var isNative = OpenLayers.Animation.isNative;
|
||||
OpenLayers.Animation.isNative = true;
|
||||
t.plan(3);
|
||||
|
||||
var map = new OpenLayers.Map("map", {projection: "EPSG:3857"});
|
||||
@@ -575,7 +572,6 @@
|
||||
t.eq(bounds.right, 0, "0 is 0, and not some super small number");
|
||||
|
||||
map.destroy();
|
||||
OpenLayers.Animation.isNative = isNative;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user