diff options
author | Chris Schlaeger <chris@linux.com> | 2015-10-17 21:36:38 +0200 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2015-10-17 21:36:38 +0200 |
commit | e30f267181d990947e67909de4809fa941698c85 (patch) | |
tree | 46e9f94c2b3699ed378963b420b8a8d361286ea1 /misc/openlayers/tests/Strategy/Paging.html | |
parent | e763ceb183f389fcd314a4a6a712d87c9d4cdb32 (diff) | |
download | postrunner-e30f267181d990947e67909de4809fa941698c85.zip |
Upgrading openlayers to 3.x
Diffstat (limited to 'misc/openlayers/tests/Strategy/Paging.html')
-rw-r--r-- | misc/openlayers/tests/Strategy/Paging.html | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/misc/openlayers/tests/Strategy/Paging.html b/misc/openlayers/tests/Strategy/Paging.html deleted file mode 100644 index a85167e..0000000 --- a/misc/openlayers/tests/Strategy/Paging.html +++ /dev/null @@ -1,113 +0,0 @@ -<html> -<head> - <script src="../OLLoader.js"></script> - <script type="text/javascript"> - - function test_activate(t) { - t.plan(2); - - var strategy = new OpenLayers.Strategy.Paging(); - t.eq(strategy.active, false, "not active after construction"); - - var layer = new OpenLayers.Layer.Vector("Vector Layer", { - strategies: [strategy] - }); - var map = new OpenLayers.Map('map'); - map.addLayer(layer); - - t.eq(strategy.active, true, "active after adding to map"); - } - - function test_paging(t) { - t.plan(18); - - var strategy = new OpenLayers.Strategy.Paging(); - var layer = new OpenLayers.Layer.Vector("Vector Layer", { - strategies: [strategy], - drawFeature: function() {} - }); - var map = new OpenLayers.Map('map'); - map.addLayer(layer); - - var features = new Array(25); - for(var i=0; i<features.length; ++i) { - features[i] = {destroy: function() {}}; - } - - function featuresEq(got, exp) { - var eq = false; - if(got instanceof Array && exp instanceof Array) { - if(got.length === exp.length) { - for(var i=0; i<got.length; ++i) { - if(got[i] !== exp[i]) { - console.log(got[i], exp[i]); - break; - } - } - eq = (i == got.length); - } - } - return eq; - } - - var len = strategy.pageLength(); - t.eq(len, 10, "page length defaults to 10"); - - // add 25 features to the layer - layer.addFeatures(features); - t.eq(strategy.features.length, features.length, "strategy caches all features"); - t.eq(layer.features.length, len, "layer gets one page of features"); - t.ok(featuresEq(layer.features, features.slice(0, len)), "layer gets first page initially"); - t.eq(strategy.pageNum(), 0, "strategy reports 0 based page number"); - t.eq(strategy.pageCount(), Math.ceil(features.length / len), "strategy reports correct number of pages"); - - // load next page of features - var changed = strategy.pageNext(); - t.eq(changed, true, "(1) strategy reports change"); - t.eq(strategy.pageNum(), 1, "second page"); - t.ok(featuresEq(layer.features, features.slice(len, 2*len)), "layer has second page of features"); - - // load next page of features (half page) - changed = strategy.pageNext(); - t.eq(changed, true, "(2) strategy reports change"); - t.eq(strategy.pageNum(), 2, "third page"); - - // try to change forward again - changed = strategy.pageNext(); - t.eq(changed, false, "strategy reports no change"); - t.eq(layer.features.length, features.length % len, "layer has partial page"); - t.ok(featuresEq(layer.features, features.slice(2*len, 3*len)), "layer has third page of features"); - t.eq(strategy.pageNum(), 2, "still on third page"); - - // change back a page - changed = strategy.pagePrevious(); - t.eq(changed, true, "(3) strategy reports change"); - t.eq(strategy.pageNum(), 1, "back on second page"); - t.ok(featuresEq(layer.features, features.slice(len, 2*len)), "layer has second page of features again"); - - layer.destroy(); - - } - - function test_deactivate(t) { - t.plan(2); - - var strategy = new OpenLayers.Strategy.Paging(); - var layer = new OpenLayers.Layer.Vector("Vector Layer", { - strategies: [strategy] - }); - var map = new OpenLayers.Map('map'); - map.addLayer(layer); - - t.eq(strategy.active, true, "active after adding to map"); - - map.removeLayer(layer); - t.eq(strategy.active, false, "not active after removing from map"); - } - - </script> -</head> -<body> - <div id="map" style="width: 400px; height: 200px" /> -</body> -</html> |