Merge branch 'master' of github.com:openlayers/openlayers into utfgrid
This commit is contained in:
@@ -17,12 +17,22 @@
|
||||
function test_all(t) {
|
||||
t.plan(8);
|
||||
t.ok(OpenLayers.Animation.isNative !== undefined, "isNative is set.");
|
||||
t.open_window("Animation.html", function(win) {
|
||||
|
||||
function doIt(win) {
|
||||
win.requestFrame(t);
|
||||
win.start(t);
|
||||
win.startDuration(t);
|
||||
win.stop(t);
|
||||
});
|
||||
}
|
||||
|
||||
// Test in an extra window in Firefox, and directly in other browsers.
|
||||
// This is needed because requestAnimationFrame does not work
|
||||
// correctly in Firefox in a hidden IFrame.
|
||||
if (window.mozRequestAnimationFrame) {
|
||||
t.open_window("Animation.html", doIt);
|
||||
} else {
|
||||
doIt(window);
|
||||
}
|
||||
}
|
||||
|
||||
function requestFrame(t) {
|
||||
|
||||
@@ -25,15 +25,17 @@
|
||||
t.ok( div != null, "draw returns its div" );
|
||||
}
|
||||
function test_Control_LayerSwitcher_outsideViewport (t) {
|
||||
t.plan( 2 );
|
||||
t.plan( 4 );
|
||||
|
||||
map = new OpenLayers.Map('map');
|
||||
control = new OpenLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('layerswitcher')});
|
||||
map.addControl(control);
|
||||
t.eq(control.div.style.width, "250px", "Div is not minimized when added.");
|
||||
t.eq(control.div.style.width, "250px", "Div is not minimized when added.");
|
||||
t.ok(control.events.element && control.events.listeners.buttonclick, "[outside] Events instance attached to div and has buttonclick event");
|
||||
control = new OpenLayers.Control.LayerSwitcher();
|
||||
map.addControl(control);
|
||||
t.eq(control.div.style.width, "0px", "Div is minimized when added.");
|
||||
t.ok(!control.events.element && map.events.listeners.buttonclick, "[inside] Events instance not attached to div and buttonclick event registered on map");
|
||||
}
|
||||
|
||||
function test_Control_LayerSwitcher_loadContents(t) {
|
||||
|
||||
@@ -289,16 +289,16 @@
|
||||
// move 10 pixels
|
||||
trigger("mousemove", 0, 10);
|
||||
|
||||
t.eq(log.length, 0, "a) no event fired yet");
|
||||
t.eq(log.length, 1, "a) has fired an event");
|
||||
|
||||
t.delay_call(
|
||||
delay, function() {
|
||||
// confirm measurepartial is fired
|
||||
t.eq(log.length, 1, "a) event logged");
|
||||
t.eq(log.length, 1, "a) one event logged");
|
||||
t.ok(log[0] && log[0].type == "measurepartial", "a) correct type");
|
||||
// mousemove within the partialDelay fires no event, so the
|
||||
// measure below is the one of the initial point
|
||||
t.ok(log[0] && log[0].measure == 0, "a) correct measure");
|
||||
t.eq(log[0]?log[0].measure:-1 , 10, "a) correct measure");
|
||||
|
||||
// b) move 10 pixels
|
||||
trigger("mousemove", 0, 20);
|
||||
|
||||
@@ -3,19 +3,23 @@
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
var map, control;
|
||||
|
||||
function test_initialize(t) {
|
||||
t.plan( 2 );
|
||||
|
||||
control = new OpenLayers.Control.OverviewMap();
|
||||
t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" );
|
||||
t.eq( control.displayClass, "olControlOverviewMap", "displayClass is correct" );
|
||||
t.ok( control instanceof OpenLayers.Control.OverviewMap,
|
||||
"new OpenLayers.Control.OverviewMap returns object" );
|
||||
t.eq( control.displayClass,
|
||||
"olControlOverviewMap", "displayClass is correct" );
|
||||
}
|
||||
|
||||
function test_setMap(t) {
|
||||
t.plan(4);
|
||||
|
||||
var setMapTest = function(map) {
|
||||
t.ok(true, "Handler.setMap called for " + this.CLASS_NAME);
|
||||
t.ok(true,
|
||||
"Handler.setMap called for " + this.CLASS_NAME);
|
||||
this.map = map;
|
||||
};
|
||||
var drag_setMap = OpenLayers.Handler.Drag.prototype.setMap;
|
||||
@@ -32,8 +36,10 @@
|
||||
map.addControl(control);
|
||||
|
||||
map.zoomToMaxExtent();
|
||||
t.eq(control.handlers.drag.map.id, control.ovmap.id, "drag.map is correct");
|
||||
t.eq(control.handlers.click.map.id, control.ovmap.id, "click.map is correct");
|
||||
t.eq(control.handlers.drag.map.id, control.ovmap.id,
|
||||
"drag.map is correct");
|
||||
t.eq(control.handlers.click.map.id, control.ovmap.id,
|
||||
"click.map is correct");
|
||||
|
||||
map.destroy();
|
||||
OpenLayers.Handler.Drag.prototype.setMap = drag_setMap;
|
||||
@@ -66,85 +72,112 @@
|
||||
|
||||
control.destroy();
|
||||
t.eq(log_drag.length, 2,
|
||||
"destroy() destroys drag handler twice, expected");
|
||||
"destroy() destroys drag handler twice, expected");
|
||||
if (log_drag.length == 2) {
|
||||
t.eq(log_drag[0].map, true,
|
||||
"destroy() destroys drag handler before ovmap is destroyed (0)");
|
||||
"destroy() destroys drag handler before ovmap is destroyed (0)");
|
||||
t.eq(log_drag[1].map, false,
|
||||
"destroy() destroys drag handler after ovmap is destroyed (1)");
|
||||
"destroy() destroys drag handler after ovmap is destroyed (1)");
|
||||
}
|
||||
t.eq(log_click.length, 2,
|
||||
"destroy() destroys click handler twice, expected");
|
||||
"destroy() destroys click handler twice, expected");
|
||||
if (log_click.length == 2) {
|
||||
t.eq(log_click[0].map, true,
|
||||
"destroy() destroys click handler before ovmap is destroyed (0)");
|
||||
"destroy() destroys click handler before ovmap is destroyed (0)");
|
||||
t.eq(log_click[1].map, false,
|
||||
"destroy() destroys click handler after ovmap is destroyed (1)");
|
||||
"destroy() destroys click handler after ovmap is destroyed (1)");
|
||||
}
|
||||
|
||||
// tear down
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_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" );
|
||||
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[4] === control, "map.controls contains control" );
|
||||
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Control div zIndexed properly" );
|
||||
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Viewport div contains control div" );
|
||||
t.ok( control.map === map,
|
||||
"Control.map is set to the map object" );
|
||||
t.ok( map.controls[4] === control,
|
||||
"map.controls contains control" );
|
||||
t.eq( parseInt(control.div.style.zIndex), map.Z_INDEX_BASE['Control'] + 5,
|
||||
"Control div zIndexed properly" );
|
||||
t.eq( parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 5,
|
||||
"Viewport div contains control div" );
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_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);
|
||||
|
||||
map = new OpenLayers.Map('map', {
|
||||
// when we recenter, don't waste time animating the panning
|
||||
// without this, the test fails in Firefox 10.0.1 on Linux
|
||||
panMethod: null,
|
||||
layers: [ new OpenLayers.Layer('Test Layer', {isBaseLayer: true}) ]
|
||||
});
|
||||
|
||||
control = new OpenLayers.Control.OverviewMap();
|
||||
map.addControl(control, new OpenLayers.Pixel(20,20));
|
||||
|
||||
var centerLL = new OpenLayers.LonLat(-71,42);
|
||||
map.setCenter(centerLL, 11);
|
||||
t.delay_call(1, function() {
|
||||
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)});
|
||||
}, 2, function() {
|
||||
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.handlers.drag = {
|
||||
last: new OpenLayers.Pixel(5,5),
|
||||
destroy: function() {}
|
||||
};
|
||||
control.rectDrag(new OpenLayers.Pixel(15, 15));
|
||||
control.updateMapToRect();
|
||||
}, 2, function() {
|
||||
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");
|
||||
t.delay_call(
|
||||
0.1,
|
||||
function() {
|
||||
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 zoom correct");
|
||||
|
||||
control.mapDivClick({'xy':new OpenLayers.Pixel(5,5)});
|
||||
},
|
||||
0.1,
|
||||
function() {
|
||||
var cent = map.getCenter();
|
||||
t.eq(cent.lon, -71.3515625,
|
||||
"Clicking on OverviewMap has correct effect on map lon");
|
||||
t.eq(cent.lat, 42.17578125,
|
||||
"Clicking on OverviewMap has 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");
|
||||
map.destroy();
|
||||
});
|
||||
control.handlers.drag = {
|
||||
last: new OpenLayers.Pixel(5,5),
|
||||
destroy: function() {}
|
||||
};
|
||||
control.rectDrag(new OpenLayers.Pixel(15, 15));
|
||||
control.updateMapToRect();
|
||||
},
|
||||
0.1,
|
||||
function() {
|
||||
var cent = map.getCenter();
|
||||
t.eq(cent.lon, -71.2734375,
|
||||
"Dragging on OverviewMap has correct effect on map lon");
|
||||
t.eq(cent.lat, 42.09765625,
|
||||
"Dragging on OverviewMap has 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");
|
||||
map.destroy();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function test_initialize_maximized(t) {
|
||||
@@ -156,8 +189,10 @@
|
||||
controls: [control]
|
||||
});
|
||||
|
||||
t.eq(control.maximized, false, "OverviewMap is not maximized by default");
|
||||
t.eq(control.element.style.display, 'none', "OverviewMap.element is not visible");
|
||||
t.eq(control.maximized, false,
|
||||
"OverviewMap is not maximized by default");
|
||||
t.eq(control.element.style.display, 'none',
|
||||
"OverviewMap.element is not visible");
|
||||
map.destroy();
|
||||
|
||||
control = new OpenLayers.Control.OverviewMap({
|
||||
@@ -167,8 +202,10 @@
|
||||
layers : [new OpenLayers.Layer("layer", {isBaseLayer: true})],
|
||||
controls: [control]
|
||||
});
|
||||
t.eq(control.maximized, true, "OverviewMap.maximized is set");
|
||||
t.eq(control.element.style.display, '', "OverviewMap.element is visible");
|
||||
t.eq(control.maximized, true,
|
||||
"OverviewMap.maximized is set");
|
||||
t.eq(control.element.style.display, '',
|
||||
"OverviewMap.element is visible");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
@@ -176,6 +213,6 @@
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 1024px; height: 512px;"/>
|
||||
<div id="map" style="width: 1024px; height: 512px;"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink('permalink', 'test.html');
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -18,6 +19,7 @@
|
||||
t.eq(control.base, 'test.html', "base is correct");
|
||||
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink('permalink');
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -25,6 +27,7 @@
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -32,6 +35,7 @@
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink({anchor: true});
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -39,18 +43,21 @@
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(control.element == null, "element is null");
|
||||
t.ok(control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink({anchor: false});
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink({});
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
t.eq(control.displayClass, "olControlPermalink", "displayClass is correct");
|
||||
t.eq(control.base, document.location.href, "base is correct");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html'});
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -58,6 +65,7 @@
|
||||
t.eq(control.base, 'test.html', "base is correct");
|
||||
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
|
||||
t.ok(!control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Permalink({element: 'permalink', base: 'test.html', anchor: true});
|
||||
t.ok(control instanceof OpenLayers.Control.Permalink, "new OpenLayers.Control returns object");
|
||||
@@ -65,6 +73,7 @@
|
||||
t.eq(control.base, 'test.html', "base is correct");
|
||||
t.ok(OpenLayers.Util.isElement(control.element), "element is a dom object");
|
||||
t.ok(control.anchor, "anchor is correct");
|
||||
control.destroy();
|
||||
}
|
||||
function test_Control_Permalink_uncentered (t) {
|
||||
t.plan( 1 );
|
||||
@@ -74,12 +83,14 @@
|
||||
map.addControl(control);
|
||||
map.events.triggerEvent("changelayer", {});
|
||||
t.ok(true, "permalink didn't bomb out.");
|
||||
map.destroy();
|
||||
}
|
||||
function test_Control_Permalink_initwithelem (t) {
|
||||
t.plan( 1 );
|
||||
|
||||
control = new OpenLayers.Control.Permalink(OpenLayers.Util.getElement('permalink'));
|
||||
t.ok(true, "If the above line doesn't throw an error, we're safe.");
|
||||
control.destroy();
|
||||
}
|
||||
function test_Control_Permalink_updateLinks (t) {
|
||||
t.plan( 3 );
|
||||
@@ -100,6 +111,7 @@
|
||||
map.layers[1].setVisibility(false);
|
||||
|
||||
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"?zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
|
||||
map.destroy();
|
||||
}
|
||||
function test_Control_Permalink_updateLinksBase (t) {
|
||||
t.plan( 2 );
|
||||
@@ -114,6 +126,7 @@
|
||||
map.pan(5, 0, {animate:false});
|
||||
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base");
|
||||
map.destroy();
|
||||
}
|
||||
function test_Control_Permalink_noElement (t) {
|
||||
t.plan( 2 );
|
||||
@@ -122,6 +135,7 @@
|
||||
map = new OpenLayers.Map('map');
|
||||
map.addControl(control);
|
||||
t.eq(map.controls[4].div.firstChild.nodeName, "A", "Permalink control creates div with 'a' inside." );
|
||||
map.destroy();
|
||||
}
|
||||
function test_Control_Permalink_base_with_query (t) {
|
||||
t.plan( 3 );
|
||||
@@ -147,6 +161,7 @@
|
||||
map.pan(5, 0, {animate:false});
|
||||
map.pan(-5, 0, {animate:false});
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '?'");
|
||||
map.destroy();
|
||||
|
||||
}
|
||||
|
||||
@@ -163,6 +178,7 @@
|
||||
map.pan(5, 0, {animate:false});
|
||||
OpenLayers.Util.getElement('edit_permalink').href = './edit.html?zoom=2&lat=0&lon=1.75781&layers=B';
|
||||
t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with existing zoom in base");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Control_Permalink_customized(t) {
|
||||
@@ -189,6 +205,7 @@
|
||||
|
||||
t.eq(this.map.controls[this.map.controls.length-1].CLASS_NAME, "CustomArgParser", "Custom ArgParser added correctly.");
|
||||
t.eq(control.div.firstChild.getAttribute("href"), "./edit.html?zoom=2&lat=0&lon=1.75781&layers=B&customParam=foo", "Custom parameter encoded correctly.");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Control_Permalink_createParams(t) {
|
||||
@@ -300,6 +317,7 @@
|
||||
|
||||
map.layers[1].setVisibility(false);
|
||||
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getParameterString(control.createParams()), "zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Control_Permalink_AnchorBaseElement (t) {
|
||||
@@ -320,7 +338,80 @@
|
||||
|
||||
map.layers[1].setVisibility(false);
|
||||
t.ok(OpenLayers.Util.isEquivalentUrl(OpenLayers.Util.getElement('permalink').href, location+"#zoom=2&lat=0&lon=1.75781&layers=BF"), 'setVisibility sets permalink');
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_center_from_map(t) {
|
||||
t.plan(7);
|
||||
|
||||
var previous = window.location.hash;
|
||||
window.location.hash = "";
|
||||
|
||||
var err;
|
||||
try {
|
||||
var map = new OpenLayers.Map({
|
||||
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
|
||||
controls: [
|
||||
new OpenLayers.Control.Permalink({anchor: true})
|
||||
],
|
||||
center: [1, 2],
|
||||
zoom: 3
|
||||
});
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
if (err) {
|
||||
t.fail("Map construction failure: " + err.message);
|
||||
} else {
|
||||
t.ok(true, "Map construction works");
|
||||
}
|
||||
|
||||
// confirm that map center is correctly set
|
||||
var center = map.getCenter();
|
||||
t.eq(center.lon, 1, "map x");
|
||||
t.eq(center.lat, 2, "map y")
|
||||
t.eq(map.getZoom(), 3, "map z");
|
||||
|
||||
// confirm that location from map options has been added to url
|
||||
var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
|
||||
t.eq(params.lon, "1", "url x");
|
||||
t.eq(params.lat, "2", "url y");
|
||||
t.eq(params.zoom, "3", "url z");
|
||||
|
||||
map.destroy();
|
||||
window.location.hash = previous;
|
||||
}
|
||||
|
||||
function test_center_from_url(t) {
|
||||
t.plan(6);
|
||||
|
||||
// In cases where the location is specified in the URL and given in
|
||||
// the map options, we respect the location in the URL.
|
||||
var previous = window.location.hash;
|
||||
window.location.hash = "#zoom=6&lat=5&lon=4&layers=B"
|
||||
|
||||
var map = new OpenLayers.Map({
|
||||
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})],
|
||||
controls: [new OpenLayers.Control.Permalink({anchor: true})],
|
||||
center: [0, 0],
|
||||
zoom: 0
|
||||
});
|
||||
|
||||
// confirm that map center is correctly set
|
||||
var center = map.getCenter();
|
||||
t.eq(center.lon, 4, "map x");
|
||||
t.eq(center.lat, 5, "map y")
|
||||
t.eq(map.getZoom(), 6, "map z");
|
||||
|
||||
var params = OpenLayers.Util.getParameters(window.location.hash.replace("#", "?"));
|
||||
t.eq(params.lon, "4", "x set");
|
||||
t.eq(params.lat, "5", "y set");
|
||||
t.eq(params.zoom, "6", "z set");
|
||||
|
||||
map.destroy();
|
||||
window.location.hash = previous;
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -475,6 +475,35 @@
|
||||
|
||||
}
|
||||
|
||||
function test_exceptions(t) {
|
||||
t.plan(1);
|
||||
var map = new OpenLayers.Map("map", {
|
||||
getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));}
|
||||
}
|
||||
);
|
||||
|
||||
var a = new OpenLayers.Layer.WMS("dummy","http://myhost/wms", {
|
||||
layers: "x",
|
||||
exceptions: "text/xml"
|
||||
});
|
||||
|
||||
map.addLayer(a);
|
||||
|
||||
var click = new OpenLayers.Control.WMSGetFeatureInfo({
|
||||
});
|
||||
|
||||
map.addControl(click);
|
||||
|
||||
var _request = OpenLayers.Request.GET;
|
||||
OpenLayers.Request.GET = function(options) {
|
||||
t.eq(options.params["EXCEPTIONS"], "text/xml", "Exceptions parameter taken from the WMS layer if provided");
|
||||
};
|
||||
click.activate();
|
||||
click.getInfoForClick({xy: {x: 50, y: 50}});
|
||||
OpenLayers.Request.GET = _request;
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_drillDown(t) {
|
||||
t.plan(6);
|
||||
var map = new OpenLayers.Map("map", {
|
||||
|
||||
81
tests/Control/Zoom.html
Normal file
81
tests/Control/Zoom.html
Normal file
@@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_constructor(t) {
|
||||
t.plan(5);
|
||||
|
||||
var control = new OpenLayers.Control.Zoom();
|
||||
t.ok(control instanceof OpenLayers.Control, "instance of Control");
|
||||
t.ok(control instanceof OpenLayers.Control.Zoom, "instance of Zoom");
|
||||
t.eq(control.displayClass, "olControlZoom", "displayClass");
|
||||
control.destroy();
|
||||
|
||||
control = new OpenLayers.Control.Zoom({
|
||||
zoomInText: "zoom in!",
|
||||
zoomOutText: "zoom out!"
|
||||
});
|
||||
t.eq(control.zoomInText, "zoom in!", "zoomInText");
|
||||
t.eq(control.zoomOutText, "zoom out!", "zoomOutText");
|
||||
control.destroy();
|
||||
}
|
||||
|
||||
function test_addControl(t) {
|
||||
t.plan(3);
|
||||
var map = new OpenLayers.Map("map");
|
||||
var control = new OpenLayers.Control.Zoom();
|
||||
map.addControl(control);
|
||||
t.ok(control.map === map, "Control.map set");
|
||||
t.ok(!!~OpenLayers.Util.indexOf(map.controls, control), "map.controls contains control");
|
||||
|
||||
control = new OpenLayers.Control.Zoom({zoomInId: "in", zoomOutId: "out"});
|
||||
map.addControl(control);
|
||||
var eventsEl = document.getElementById("out").parentNode;
|
||||
t.ok(control.events.element === eventsEl, "Events instance listens to custom div's parentNode");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_zoomIn(t) {
|
||||
t.plan(2);
|
||||
|
||||
var map = new OpenLayers.Map({
|
||||
div: "map",
|
||||
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})]
|
||||
});
|
||||
var control = new OpenLayers.Control.Zoom();
|
||||
map.addControl(control);
|
||||
map.setCenter([0, 0], 0);
|
||||
|
||||
t.eq(map.getZoom(), 0, "initial center");
|
||||
map.events.triggerEvent("buttonclick", {buttonElement: control.zoomInLink});
|
||||
t.eq(map.getZoom(), 1, "after zoom in");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_zoomOut(t) {
|
||||
t.plan(2);
|
||||
|
||||
var map = new OpenLayers.Map({
|
||||
div: "map",
|
||||
layers: [new OpenLayers.Layer(null, {isBaseLayer: true})]
|
||||
});
|
||||
var control = new OpenLayers.Control.Zoom();
|
||||
map.addControl(control);
|
||||
map.setCenter([0, 0], 1);
|
||||
|
||||
t.eq(map.getZoom(), 1, "initial center");
|
||||
map.events.triggerEvent("buttonclick", {buttonElement: control.zoomOutLink});
|
||||
t.eq(map.getZoom(), 0, "after zoom out");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 512px; height: 256px;"/>
|
||||
<div id="in">in</div><div id="out">out</out>
|
||||
</body>
|
||||
</html>
|
||||
@@ -27,9 +27,44 @@
|
||||
buttonClick.destroy();
|
||||
events.destroy();
|
||||
}
|
||||
|
||||
function test_getPressedButton(t) {
|
||||
t.plan(4);
|
||||
|
||||
// set up
|
||||
|
||||
events = new OpenLayers.Events({}, element);
|
||||
buttonClick = new OpenLayers.Events.buttonclick(events);
|
||||
|
||||
var button = document.createElement('button'),
|
||||
span1 = document.createElement('span'),
|
||||
span2 = document.createElement('span'),
|
||||
span3 = document.createElement('span');
|
||||
button.className = 'olButton';
|
||||
button.appendChild(span1);
|
||||
span1.appendChild(span2);
|
||||
span2.appendChild(span3);
|
||||
|
||||
t.ok(buttonClick.getPressedButton(button) === button,
|
||||
'getPressedButton returns button when element is button');
|
||||
t.ok(buttonClick.getPressedButton(span1) === button,
|
||||
'getPressedButton returns button when element is button descendant level 1');
|
||||
t.ok(buttonClick.getPressedButton(span2) === button,
|
||||
'getPressedButton returns button when element is button descendant level 2');
|
||||
t.eq(buttonClick.getPressedButton(span3), undefined,
|
||||
'getPressedButton returns undefined when element is button descendant level 3');
|
||||
|
||||
// test
|
||||
|
||||
|
||||
// tear down
|
||||
|
||||
buttonClick.destroy();
|
||||
events.destroy();
|
||||
}
|
||||
|
||||
function test_ButtonClick_buttonClick(t) {
|
||||
t.plan(23);
|
||||
t.plan(27);
|
||||
events = new OpenLayers.Events({}, element);
|
||||
events.on({
|
||||
"buttonclick": logEvent,
|
||||
@@ -38,7 +73,8 @@
|
||||
"click": logEvent,
|
||||
"dblclick": logEvent,
|
||||
"touchstart": logEvent,
|
||||
"touchend": logEvent
|
||||
"touchend": logEvent,
|
||||
"keydown": logEvent
|
||||
});
|
||||
buttonClick = events.extensions["buttonclick"];
|
||||
|
||||
@@ -111,12 +147,26 @@
|
||||
t.eq(log[1].type, "buttonclick", "buttonclick for 2nd click IE");
|
||||
|
||||
// rightclick
|
||||
log = []
|
||||
log = [];
|
||||
trigger({type: "mousedown", button: 2});
|
||||
trigger({type: "mouseup", button: 2});
|
||||
t.eq(log.length, 2, "two events fired for rightclick");
|
||||
t.eq(log[0].type, "mousedown", "mousedown from rightclick goes through");
|
||||
t.eq(log[1].type, "mouseup", "mouseup from rightclick goes through");
|
||||
|
||||
// keydown RETURN
|
||||
log = [];
|
||||
trigger({type: "keydown", keyCode: OpenLayers.Event.KEY_RETURN});
|
||||
trigger({type: "click"});
|
||||
t.eq(log.length, 1, "one event fired for RETURN keydown");
|
||||
t.eq(log[0].type, "buttonclick", "buttonclick for RETURN keydown");
|
||||
|
||||
// keydown SPACE
|
||||
log = [];
|
||||
trigger({type: "keydown", keyCode: OpenLayers.Event.KEY_SPACE});
|
||||
trigger({type: "click"});
|
||||
t.eq(log.length, 1, "one event fired for SPACE keydown");
|
||||
t.eq(log[0].type, "buttonclick", "buttonclick for SPACE keydown");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -198,21 +198,35 @@
|
||||
t.ok(style.t, "getStyle returns copy of style rather than reference");
|
||||
}
|
||||
function test_Format_KML_extendedData(t) {
|
||||
t.plan(2);
|
||||
t.plan(6);
|
||||
var f = new OpenLayers.Format.KML();
|
||||
var features = f.read(OpenLayers.Util.getElement("kml_extendeddata").value);
|
||||
t.eq(features[0].attributes.all_bridges.value, "3030", "read value from extendeddata correctly.");
|
||||
t.eq(features[0].attributes.all_bridges.displayName, "all bridges", "read displayName from extendeddata correctly.");
|
||||
t.eq(features[0].attributes.holeYardage.value, "234", "read value from extendeddata correctly.");
|
||||
t.eq(features[0].attributes.holeYardage.displayName, "<b><i>The yardage is </i></b>", "read displayName from extendeddata correctly.");
|
||||
t.eq(f.read(f.write(features[0]))[0].attributes.holeYardage.value, features[0].attributes.holeYardage.value, "attribute value written correctly");
|
||||
t.eq(f.read(f.write(features[0]))[0].attributes.holeYardage.displayName, features[0].attributes.holeYardage.displayName, "attribute displayName written correctly");
|
||||
f.kvpAttributes = true;
|
||||
features = f.read(OpenLayers.Util.getElement("kml_extendeddata").value);
|
||||
t.eq(features[0].attributes.holeYardage, "234", "read kvp value from extendeddata correctly.");
|
||||
t.eq(f.read(f.write(features[0]))[0].attributes.holeYardage, features[0].attributes.holeYardage, "kvp attribute value written correctly");
|
||||
}
|
||||
|
||||
function test_Format_KML_extendedData_SchemaData(t) {
|
||||
t.plan(4);
|
||||
t.plan(10);
|
||||
var f = new OpenLayers.Format.KML();
|
||||
var features = f.read(OpenLayers.Util.getElement("kml_extendeddata2").value);
|
||||
t.eq(features[0].attributes.TrailHeadName.value, "Pi in the sky", "read value from extendeddata (schema data) correctly.");
|
||||
t.eq(features[0].attributes.TrailHeadName.displayName, "TrailHeadName", "read displayName from extendeddata correctly");
|
||||
t.eq(features[0].attributes.ElevationGain.value, "10", "read value from extendeddata (schema data) correctly.");
|
||||
t.eq(features[0].attributes.ElevationGain.displayName, "ElevationGain", "read displayName from extendeddata correctly");
|
||||
t.eq(f.read(f.write(features[0]))[0].attributes.TrailHeadName.value, features[0].attributes.TrailHeadName.value, "attribute value from extendeddata (schema data) written correctly");
|
||||
t.eq(f.read(f.write(features[0]))[0].attributes.ElevationGain.value, features[0].attributes.ElevationGain.value, "attribute value from extendeddata (schema data) written correctly");
|
||||
f.kvpAttributes = true;
|
||||
features = f.read(OpenLayers.Util.getElement("kml_extendeddata2").value);
|
||||
t.eq(features[0].attributes.TrailHeadName, "Pi in the sky", "read kvp value from extendeddata (schema data) correctly.");
|
||||
t.eq(features[0].attributes.ElevationGain, "10", "read kvp value from extendeddata (schema data) correctly.");
|
||||
t.eq(f.read(f.write(features[0]))[0].attributes.TrailHeadName, features[0].attributes.TrailHeadName, "kvp attribute value from extendeddata (schema data) written correctly");
|
||||
t.eq(f.read(f.write(features[0]))[0].attributes.ElevationGain, features[0].attributes.ElevationGain, "kvp attribute value from extendeddata (schema data) written correctly");
|
||||
}
|
||||
|
||||
function test_Format_KML_placemarkName(t) {
|
||||
@@ -287,49 +301,61 @@
|
||||
</head>
|
||||
<body>
|
||||
<textarea id="kml_extendeddata" style="display:none">
|
||||
<kml xmlns="http://earth.google.com/kml/2.2">
|
||||
<Document>
|
||||
<Placemark>
|
||||
<styleUrl>#default</styleUrl>
|
||||
|
||||
|
||||
|
||||
|
||||
<ExtendedData>
|
||||
<Data name='all_bridges'>
|
||||
<displayName><![CDATA[all bridges]]></displayName>
|
||||
<value><![CDATA[3030]]></value>
|
||||
</Data>
|
||||
<Data name='latitude'>
|
||||
<displayName><![CDATA[latitude]]></displayName>
|
||||
<value><![CDATA[43]]></value>
|
||||
</Data>
|
||||
<Data name='longitude'>
|
||||
<displayName><![CDATA[longitude]]></displayName>
|
||||
<value><![CDATA[-107.55]]></value>
|
||||
</Data>
|
||||
<Data name='functionally_obsolete__percent'>
|
||||
<displayName><![CDATA[functionally obsolete, percent]]></displayName>
|
||||
<value><![CDATA[8]]></value>
|
||||
</Data>
|
||||
<Data name='structurally_deficient__percent'>
|
||||
<displayName><![CDATA[structurally deficient, percent]]></displayName>
|
||||
<value><![CDATA[13]]></value>
|
||||
</Data>
|
||||
<Data name='state'>
|
||||
<displayName><![CDATA[state]]></displayName>
|
||||
<value><![CDATA[Wyoming]]></value>
|
||||
</Data>
|
||||
</ExtendedData>
|
||||
|
||||
|
||||
<Point>
|
||||
<coordinates>-107.55,43.0</coordinates>
|
||||
</Point>
|
||||
|
||||
|
||||
</Placemark>
|
||||
</Document>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||
<Document>
|
||||
<name>Entity-Replacement</name>
|
||||
<Placemark>
|
||||
<name>Club house</name>
|
||||
<ExtendedData>
|
||||
<Data name="holeNumber">
|
||||
<displayName><![CDATA[
|
||||
<b>This is hole </b>
|
||||
]]></displayName>
|
||||
<value>1</value>
|
||||
</Data>
|
||||
<Data name="holePar">
|
||||
<displayName><![CDATA[
|
||||
<i>The par for this hole is </i>
|
||||
]]></displayName>
|
||||
<value>4</value>
|
||||
</Data>
|
||||
<Data name="holeYardage">
|
||||
<displayName><![CDATA[<b><i>The yardage is </i></b>]]></displayName>
|
||||
<value>234</value>
|
||||
</Data>
|
||||
</ExtendedData>
|
||||
<Point>
|
||||
<coordinates>-111.956,33.5043</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
<Placemark>
|
||||
<name>By the lake</name>
|
||||
<ExtendedData>
|
||||
<Data name="holeNumber">
|
||||
<displayName><![CDATA[
|
||||
<b>This is hole </b>
|
||||
]]></displayName>
|
||||
<value>5</value>
|
||||
</Data>
|
||||
<Data name="holePar">
|
||||
<displayName><![CDATA[
|
||||
<i>The par for this hole is </i>
|
||||
]]></displayName>
|
||||
<value>5</value>
|
||||
</Data>
|
||||
<Data name="holeYardage">
|
||||
<displayName><![CDATA[
|
||||
<b><i>The yardage is </i></b>
|
||||
]]></displayName>
|
||||
<value>523</value>
|
||||
</Data>
|
||||
</ExtendedData>
|
||||
<Point>
|
||||
<coordinates>-111.95,33.5024</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
</Document>
|
||||
</kml>
|
||||
</textarea>
|
||||
<textarea id="kml_extendeddata2" style="display:none">
|
||||
|
||||
@@ -47,6 +47,19 @@
|
||||
'<CssParameter name="font-weight">bold</CssParameter>' +
|
||||
'<CssParameter name="font-style">normal</CssParameter>' +
|
||||
'</Font>' +
|
||||
'<LabelPlacement>' +
|
||||
'<PointPlacement>' +
|
||||
'<AnchorPoint>' +
|
||||
'<AnchorPointX>0.5</AnchorPointX>' +
|
||||
'<AnchorPointY>0.5</AnchorPointY>' +
|
||||
'</AnchorPoint>' +
|
||||
'<Displacement>' +
|
||||
'<DisplacementX>5</DisplacementX>' +
|
||||
'<DisplacementY>5</DisplacementY>' +
|
||||
'</Displacement>' +
|
||||
'<Rotation>45</Rotation>' +
|
||||
'</PointPlacement>' +
|
||||
'</LabelPlacement>' +
|
||||
'<Halo>' +
|
||||
'<Radius>3</Radius>' +
|
||||
'<Fill>' +
|
||||
@@ -509,7 +522,57 @@
|
||||
t.xml_eq(got, exp, "duplicated rules to write zIndex as FeatureTypeStyle elements");
|
||||
|
||||
}
|
||||
|
||||
|
||||
function test_label_LinePlacement(t) {
|
||||
t.plan(1);
|
||||
var format = new OpenLayers.Format.SLD.v1_0_0({
|
||||
multipleSymbolizers: true
|
||||
});
|
||||
// labelPerpendicularOffset takes precedence over labelAlign
|
||||
var style = new OpenLayers.Style2({
|
||||
rules: [
|
||||
new OpenLayers.Rule({
|
||||
symbolizers: [
|
||||
new OpenLayers.Symbolizer.Line({
|
||||
strokeColor: "red",
|
||||
strokeWidth: 3
|
||||
}),
|
||||
new OpenLayers.Symbolizer.Text({
|
||||
label: "${FOO}",
|
||||
labelPerpendicularOffset: 10,
|
||||
labelAlign: "rb"
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
var got = format.writeNode("sld:UserStyle", style);
|
||||
var exp = readXML("label_lineplacement_test.sld").documentElement;
|
||||
t.xml_eq(got, exp, "LinePlacement written out correctly");
|
||||
}
|
||||
|
||||
function test_labelAlignToAnchorPosition(t) {
|
||||
t.plan(1);
|
||||
var format = new OpenLayers.Format.SLD.v1_0_0({
|
||||
multipleSymbolizers: true
|
||||
});
|
||||
var style = new OpenLayers.Style2({
|
||||
rules: [
|
||||
new OpenLayers.Rule({
|
||||
symbolizers: [
|
||||
new OpenLayers.Symbolizer.Text({
|
||||
label: "${FOO}",
|
||||
labelAlign: "rb"
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
var got = format.writeNode("sld:UserStyle", style);
|
||||
var exp = readXML("label_pointplacement_test.sld").documentElement;
|
||||
t.xml_eq(got, exp, "PointPlacement with labelAlign written out correctly");
|
||||
}
|
||||
|
||||
function test_read_FeatureTypeStyles(t) {
|
||||
|
||||
t.plan(13);
|
||||
@@ -585,7 +648,6 @@
|
||||
doc = readXML("polygon_labelhalo.sld");
|
||||
out = format.write(format.read(doc));
|
||||
t.xml_eq(out, doc.documentElement, "round-tripped polygon_labelhalo.sld");
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -867,5 +929,46 @@
|
||||
</sld:FeatureTypeStyle>
|
||||
</sld:UserStyle>
|
||||
--></div>
|
||||
<div id="label_lineplacement_test.sld"><!--
|
||||
<sld:UserStyle xmlns:sld="http://www.opengis.net/sld">
|
||||
<sld:FeatureTypeStyle>
|
||||
<sld:Rule>
|
||||
<sld:LineSymbolizer>
|
||||
<sld:Stroke>
|
||||
<sld:CssParameter name="stroke">red</sld:CssParameter>
|
||||
<sld:CssParameter name="stroke-width">3</sld:CssParameter>
|
||||
</sld:Stroke>
|
||||
</sld:LineSymbolizer>
|
||||
<sld:TextSymbolizer>
|
||||
<sld:Label><ogc:PropertyName xmlns:ogc="http://www.opengis.net/ogc">FOO</ogc:PropertyName></sld:Label>
|
||||
<sld:LabelPlacement>
|
||||
<sld:LinePlacement>
|
||||
<sld:PerpendicularOffset>10</sld:PerpendicularOffset>
|
||||
</sld:LinePlacement>
|
||||
</sld:LabelPlacement>
|
||||
</sld:TextSymbolizer>
|
||||
</sld:Rule>
|
||||
</sld:FeatureTypeStyle>
|
||||
</sld:UserStyle>
|
||||
--></div>
|
||||
<div id="label_pointplacement_test.sld"><!--
|
||||
<sld:UserStyle xmlns:sld="http://www.opengis.net/sld">
|
||||
<sld:FeatureTypeStyle>
|
||||
<sld:Rule>
|
||||
<sld:TextSymbolizer>
|
||||
<sld:Label><ogc:PropertyName xmlns:ogc="http://www.opengis.net/ogc">FOO</ogc:PropertyName></sld:Label>
|
||||
<sld:LabelPlacement>
|
||||
<sld:PointPlacement>
|
||||
<sld:AnchorPoint>
|
||||
<sld:AnchorPointX>1</sld:AnchorPointX>
|
||||
<sld:AnchorPointY>0</sld:AnchorPointY>
|
||||
</sld:AnchorPoint>
|
||||
</sld:PointPlacement>
|
||||
</sld:LabelPlacement>
|
||||
</sld:TextSymbolizer>
|
||||
</sld:Rule>
|
||||
</sld:FeatureTypeStyle>
|
||||
</sld:UserStyle>
|
||||
--></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -254,21 +254,40 @@
|
||||
t.plan(1);
|
||||
|
||||
var projections = {
|
||||
src: new OpenLayers.Projection("EPSG:4326"),
|
||||
dest: new OpenLayers.Projection("EPSG:900913")
|
||||
};
|
||||
|
||||
var points = {
|
||||
src: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-87.9, 41.9)),
|
||||
dest: new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-9784983.2393667, 5146011.6785665))
|
||||
};
|
||||
|
||||
var format = new OpenLayers.Format.WKT({
|
||||
externalProjection: projections["src"],
|
||||
internalProjection: projections["dest"]
|
||||
});
|
||||
var feature = format.read("GEOMETRYCOLLECTION(POINT(" + points["src"].geometry.x + " " + points["src"].geometry.y + "))")[0];
|
||||
t.eq(feature.geometry.toString(), points["dest"].geometry.toString(),
|
||||
src: new OpenLayers.Projection("EPSG:4326"),
|
||||
dest: new OpenLayers.Projection("EPSG:900913")
|
||||
},
|
||||
points = {
|
||||
src: new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Point(-87.9, 41.9)
|
||||
),
|
||||
dest: new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Point(-9784983.2393667, 5146011.6785665)
|
||||
)
|
||||
},
|
||||
format = new OpenLayers.Format.WKT({
|
||||
externalProjection: projections["src"],
|
||||
internalProjection: projections["dest"]
|
||||
}),
|
||||
gc_wkt_parts = [
|
||||
"GEOMETRYCOLLECTION(",
|
||||
"POINT(",
|
||||
points["src"].geometry.x,
|
||||
" ",
|
||||
points["src"].geometry.y,
|
||||
")",
|
||||
")"
|
||||
],
|
||||
feature = format.read( gc_wkt_parts.join("") )[0],
|
||||
gotGeom = feature.geometry,
|
||||
expectGeom = points["dest"].geometry,
|
||||
// we don't use geometry::toString because we might run into
|
||||
// precision issues
|
||||
precision = 7,
|
||||
got = gotGeom.x.toFixed(precision) + ' ' + gotGeom.y.toFixed(precision),
|
||||
expected = expectGeom.x.toFixed(precision) + ' ' + expectGeom.y.toFixed(precision);
|
||||
|
||||
t.eq(got, expected,
|
||||
"Geometry collections aren't transformed twice when reprojection.");
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
var uri = "http://foo.com";
|
||||
var prefix = "foo";
|
||||
var localName = "bar";
|
||||
var qualifiedName = prefix + ":" + name;
|
||||
var qualifiedName = prefix + ":" + localName;
|
||||
var node = format.createElementNS(uri, qualifiedName);
|
||||
t.eq(node.nodeType, 1,
|
||||
"node has correct type");
|
||||
|
||||
@@ -42,59 +42,103 @@
|
||||
}
|
||||
|
||||
function test_Handler_Keyboard_activate(t) {
|
||||
t.plan(8);
|
||||
t.plan(15);
|
||||
|
||||
var log;
|
||||
var map = new OpenLayers.Map('map');
|
||||
var control = new OpenLayers.Control();
|
||||
map.addControl(control);
|
||||
var handler = new OpenLayers.Handler.Keyboard(control);
|
||||
handler.active = true;
|
||||
var activated = handler.activate();
|
||||
t.ok(!activated,
|
||||
"activate returns false if the handler was already active");
|
||||
handler.active = false;
|
||||
handler.dragging = true;
|
||||
|
||||
// mock OpenLayers.Event.observe
|
||||
var old = OpenLayers.Event.stopObserving;
|
||||
var types = ["keydown", "keyup"];
|
||||
OpenLayers.Event.observe = function(obj, type, method) {
|
||||
t.ok(obj == document,
|
||||
"activate calls observing with correct object");
|
||||
var validType = (OpenLayers.Util.indexOf(types, type) != -1);
|
||||
log[type] = obj;
|
||||
var validType = OpenLayers.Util.indexOf(["keydown", "keyup"], type) != -1;
|
||||
t.ok(validType, "activate calls observe for " + type);
|
||||
t.ok(method == handler.eventListener,
|
||||
"activate calls observing with correct method");
|
||||
};
|
||||
|
||||
handler.active = true;
|
||||
var activated = handler.activate();
|
||||
t.ok(!activated,
|
||||
"activate returns false if the handler was already active");
|
||||
|
||||
log = {};
|
||||
handler.active = false;
|
||||
handler.observeElement = map.div;
|
||||
activated = handler.activate();
|
||||
t.ok(log['keydown'] == map.div,
|
||||
"activate calls observing for keydown with correct object");
|
||||
t.ok(log['keyup'] == map.div,
|
||||
"activate calls observing for keyup with correct object");
|
||||
t.ok(activated,
|
||||
"activate returns true if the handler was not already active");
|
||||
|
||||
log = {};
|
||||
handler.active = false;
|
||||
handler.observeElement = null;
|
||||
activated = handler.activate();
|
||||
t.ok(log['keydown'] == document,
|
||||
"activate calls observing for keydown with correct object");
|
||||
t.ok(log['keyup'] == document,
|
||||
"activate calls observing for keyup with correct object");
|
||||
t.ok(activated,
|
||||
"activate returns true if the handler was not already active");
|
||||
|
||||
OpenLayers.Event.observe = old;
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Handler_Keyboard_deactivate(t) {
|
||||
t.plan(8);
|
||||
t.plan(15);
|
||||
|
||||
var log;
|
||||
var map = new OpenLayers.Map('map');
|
||||
var control = new OpenLayers.Control();
|
||||
map.addControl(control);
|
||||
var handler = new OpenLayers.Handler.Keyboard(control);
|
||||
handler.active = false;
|
||||
var deactivated = handler.deactivate();
|
||||
t.ok(!deactivated,
|
||||
"deactivate returns false if the handler was not already active");
|
||||
handler.active = true;
|
||||
|
||||
// mock OpenLayers.Event.stopObserving
|
||||
var old = OpenLayers.Event.stopObserving;
|
||||
var types = ["keydown", "keyup"];
|
||||
OpenLayers.Event.stopObserving = function(obj, type, method) {
|
||||
t.ok(obj == document,
|
||||
"deactivate calls stopObserving with correct object");
|
||||
var validType = (OpenLayers.Util.indexOf(types, type) != -1);
|
||||
log[type] = obj;
|
||||
var validType = OpenLayers.Util.indexOf(["keydown", "keyup"], type) != -1;
|
||||
t.ok(validType, "deactivate calls stopObserving for " + type);
|
||||
t.ok(method == handler.eventListener,
|
||||
"deactivate calls stopObserving with correct method");
|
||||
};
|
||||
|
||||
handler.active = false;
|
||||
var deactivated = handler.deactivate();
|
||||
t.ok(!deactivated,
|
||||
"deactivate returns false if the handler was not already active");
|
||||
|
||||
log = {};
|
||||
handler.active = true;
|
||||
handler.observeElement = map.div;
|
||||
deactivated = handler.deactivate();
|
||||
t.ok(log['keydown'] == map.div,
|
||||
"deactivate calls stopObserving for keydown with correct object");
|
||||
t.ok(log['keyup'] == map.div,
|
||||
"deactivate calls stopObserving for keyup with correct object");
|
||||
t.ok(deactivated,
|
||||
"deactivate returns true if the handler was active already");
|
||||
|
||||
log = {};
|
||||
handler.active = true;
|
||||
handler.observeElement = document;
|
||||
deactivated = handler.deactivate();
|
||||
t.ok(log['keydown'] == document,
|
||||
"deactivate calls stopObserving for keydown with correct object");
|
||||
t.ok(log['keyup'] == document,
|
||||
"deactivate calls stopObserving for keyup with correct object");
|
||||
t.ok(deactivated,
|
||||
"deactivate returns true if the handler was active already");
|
||||
|
||||
OpenLayers.Event.stopObserving = old;
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -764,7 +764,7 @@
|
||||
}
|
||||
|
||||
function test_layer_setTileSize(t) {
|
||||
t.plan(6);
|
||||
t.plan(4);
|
||||
|
||||
layer = new OpenLayers.Layer();
|
||||
|
||||
@@ -784,7 +784,6 @@
|
||||
var size = new OpenLayers.Size(2,2);
|
||||
layer.setTileSize(size);
|
||||
t.ok(layer.tileSize.equals(size), "size paramater set correctly to layer's tile size");
|
||||
t.ok(layer.imageOffset == null, "imageOffset and imageSize null when no gutters")
|
||||
|
||||
//set on layer
|
||||
layer.tileSize = layerTileSize;
|
||||
@@ -803,10 +802,8 @@
|
||||
size = new OpenLayers.Size(10,100);
|
||||
layer.setTileSize(size);
|
||||
|
||||
var desiredImageOffset = new OpenLayers.Pixel(-15, -15);
|
||||
var desiredImageSize = new OpenLayers.Size(40, 130);
|
||||
|
||||
t.ok(layer.imageOffset.equals(desiredImageOffset), "image offset correctly calculated");
|
||||
t.ok(layer.imageSize.equals(desiredImageSize), "image size correctly calculated");
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@
|
||||
//initialize the layer using the JSON object from an arcgis server
|
||||
//SEE: ArcGISCache.json
|
||||
var layer = new OpenLayers.Layer.ArcGISCache(name, url, {
|
||||
layerInfo: layerInfo
|
||||
layerInfo: layerInfo,
|
||||
params: {foo: "bar"}
|
||||
});
|
||||
var map = new OpenLayers.Map('map', {
|
||||
maxExtent: layer.maxExtent,
|
||||
@@ -98,14 +99,14 @@
|
||||
}
|
||||
];
|
||||
|
||||
t.plan( urlSets.length );
|
||||
t.plan( urlSets.length );
|
||||
for(var i=0;i<urlSets.length;i++)
|
||||
{
|
||||
var o = urlSets[i];
|
||||
map.zoomToExtent(o.bounds, true);
|
||||
|
||||
var resultUrl = layer.getURL(o.bounds);
|
||||
t.ok( resultUrl == o.url, "correct tile returned for " + o.bounds);
|
||||
t.ok( resultUrl == o.url + "?foo=bar", "correct tile returned for " + o.bounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
|
||||
<script src="http://maps.google.com/maps/api/js?sensor=false&v=3.6"></script>
|
||||
<script src="../../OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
t.eq( layer.buffer, 0, "buffer default is 0");
|
||||
t.eq( layer.ratio, 1.5, "ratio default is 1.5");
|
||||
t.eq( layer.numLoadingTiles, 0, "numLoadingTiles starts at 0");
|
||||
t.eq( layer.tileClass, OpenLayers.Tile.Image, "tileClass default is OpenLayers.Tile.Image");
|
||||
t.ok( layer.tileClass === OpenLayers.Tile.Image, "tileClass default is OpenLayers.Tile.Image");
|
||||
|
||||
var obj = {};
|
||||
var func = function() {};
|
||||
@@ -63,7 +63,7 @@
|
||||
});
|
||||
map.addLayer(layer);
|
||||
|
||||
t.eq(layer.tileClass, myTileClass, "tileClass is set");
|
||||
t.ok(layer.tileClass === myTileClass, "tileClass is set");
|
||||
var instance = layer.addTile(new OpenLayers.Bounds(-10, 10, 50, 100),
|
||||
new OpenLayers.Pixel(10, 12));
|
||||
|
||||
@@ -226,9 +226,10 @@
|
||||
map.setCenter([-10, 0], 5);
|
||||
|
||||
var log = [];
|
||||
var origDeferMoveGriddedTiles = layer.deferMoveGriddedTiles;
|
||||
layer.deferMoveGriddedTiles = function() {
|
||||
log.push("deferMoveGriddedTiles");
|
||||
OpenLayers.Layer.WMS.prototype.deferMoveGriddedTiles.apply(this, arguments);
|
||||
origDeferMoveGriddedTiles.apply(this, arguments);
|
||||
}
|
||||
layer.moveGriddedTiles = function() {
|
||||
log.push("moveGriddedTiles");
|
||||
@@ -505,7 +506,7 @@
|
||||
}
|
||||
|
||||
function test_Layer_Grid_addTileMonitoringHooks(t) {
|
||||
t.plan(15);
|
||||
t.plan(17);
|
||||
|
||||
layer = new OpenLayers.Layer.Grid();
|
||||
layer.events = {
|
||||
@@ -518,6 +519,13 @@
|
||||
events: {
|
||||
register: function(name, obj, func) {
|
||||
g_registered[name] = [obj, func];
|
||||
},
|
||||
on: function(obj) {
|
||||
for (var o in obj) {
|
||||
if (obj.hasOwnProperty(o)) {
|
||||
tile.events.register(o, obj.scope, obj[o]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -550,6 +558,11 @@
|
||||
entry = g_registered["loadend"];
|
||||
t.ok( entry && entry[0] == layer && entry[1] == tile.onLoadEnd, "loadend correctly registered");
|
||||
|
||||
g_events = [];
|
||||
tile.onLoadError.apply(layer);
|
||||
t.eq(g_events[0][0], "tileerror", "tileerror triggered");
|
||||
t.ok(g_events[0][1].tile === tile, "tile passed as tile property to event object");
|
||||
|
||||
layer.numLoadingTiles = 2;
|
||||
g_events = [];
|
||||
tile.onLoadEnd.apply(layer);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
var options = { chicken: 151, foo: "bar" };
|
||||
|
||||
function test_Layer_HTTPRequest_constructor (t) {
|
||||
t.plan( 5 );
|
||||
t.plan( 6 );
|
||||
|
||||
layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
|
||||
|
||||
@@ -27,8 +27,11 @@
|
||||
t.ok( ((layer.params["map"] == '/mapdata/vmap_wms.map') &&
|
||||
(layer.params["layers"] == "basic") &&
|
||||
(layer.params["format"] == "image/png")), "layer.params correctly set" );
|
||||
|
||||
|
||||
|
||||
layer = new OpenLayers.Layer.HTTPRequest(name, url, null, {params: params});
|
||||
t.ok( ((layer.params["map"] == '/mapdata/vmap_wms.map') &&
|
||||
(layer.params["layers"] == "basic") &&
|
||||
(layer.params["format"] == "image/png")), "layer.params correctly set from options" );
|
||||
}
|
||||
|
||||
function test_Layer_HTTPRequest_clone (t) {
|
||||
|
||||
@@ -2000,6 +2000,23 @@
|
||||
t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct');
|
||||
}
|
||||
|
||||
function test_options(t) {
|
||||
t.plan(2);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
t.eq(map.options, {}, 'map.options is empty with no options');
|
||||
map.destroy();
|
||||
|
||||
var options = {
|
||||
resolutions: [1,2,3,5],
|
||||
projection: "EPSG:4326",
|
||||
units: 'm'
|
||||
};
|
||||
var map = new OpenLayers.Map('map', options);
|
||||
t.eq(map.options, options, 'map.options is a copy of the constructor option');
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_adjustZoom(t) {
|
||||
t.plan(4);
|
||||
var map = new OpenLayers.Map({
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
function test_initialize(t) {
|
||||
t.plan(3);
|
||||
|
||||
var protocol = new OpenLayers.Protocol.CSW({formatOptions: {foo: "bar"},});
|
||||
var protocol = new OpenLayers.Protocol.CSW({formatOptions: {foo: "bar"}});
|
||||
t.ok(protocol instanceof OpenLayers.Protocol.CSW.v2_0_2,
|
||||
"initialize returns instance of default versioned protocol");
|
||||
var format = protocol.format;
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
}
|
||||
|
||||
function test_createRequest(t) {
|
||||
t.plan(3);
|
||||
t.plan(4);
|
||||
var protocol = new OpenLayers.Protocol.Script({
|
||||
callbackKey: 'cb_key',
|
||||
callbackPrefix: 'cb_prefix:'
|
||||
@@ -155,7 +155,13 @@
|
||||
t.eq(script.id, 'OpenLayers_Protocol_Script_bar',
|
||||
'created script has a correct id');
|
||||
|
||||
protocol.callbackTemplate = "OpenLayers.Protocol.Script.registry.${id}";
|
||||
script = protocol.createRequest('http://bar_url/', {'k': 'bar_param'}, 'bar_callback');
|
||||
t.eq(script.src, 'http://bar_url/?k=bar_param&cb_key=cb_prefix%3AOpenLayers.Protocol.Script.registry.bar',
|
||||
'created script has a correct url with different template');
|
||||
|
||||
OpenLayers.Protocol.Script.register = _register;
|
||||
|
||||
}
|
||||
|
||||
function test_destroyRequest(t) {
|
||||
|
||||
@@ -336,12 +336,18 @@
|
||||
}
|
||||
|
||||
var num = cases.length;
|
||||
t.plan(num);
|
||||
t.plan(2 * num);
|
||||
var c, feature;
|
||||
for (var i=0; i<num; ++i) {
|
||||
c = cases[i];
|
||||
feature = layer.renderer.getFeatureIdFromEvent({xy: px(c.x, c.y)});
|
||||
t.eq(feature && feature.id, c.id, c.msg);
|
||||
|
||||
// Extra test: hit detection on an invisible canvas should return undefined
|
||||
layer.setVisibility(false);
|
||||
feature = layer.renderer.getFeatureIdFromEvent({xy: px(c.x, c.y)});
|
||||
t.eq(feature, undefined, c.msg + ' (invisible)');
|
||||
layer.setVisibility(true);
|
||||
}
|
||||
|
||||
map.destroy();
|
||||
|
||||
@@ -79,7 +79,9 @@
|
||||
// test extent changes
|
||||
var extent = new OpenLayers.Bounds(4,3,2,1);
|
||||
r.setExtent(extent);
|
||||
t.eq(r.root.getAttributeNS(null, "transform").replace(/ /g, ""), "translate(-6,-6)", "rendererRoot viewBox is correct after a new setExtent");
|
||||
var el = r.createNode("g");
|
||||
el.setAttributeNS(null, "transform", "translate(-6,-6)");
|
||||
t.eq(r.root.getAttributeNS(null, "transform"), el.getAttributeNS(null, "transform"), "rendererRoot viewBox is correct after a new setExtent");
|
||||
|
||||
OpenLayers.Renderer.Elements.prototype.setExtent =
|
||||
OpenLayers.Renderer.Elements.prototype._setExtent;
|
||||
|
||||
@@ -88,9 +88,26 @@
|
||||
strategy.update({force: true});
|
||||
var from = map.getProjectionObject();
|
||||
var to = layer.projection;
|
||||
t.eq(strategy.bounds.toString(), map.getExtent().transform(from, to).toString(), "[force update different proj] bounds transformed");
|
||||
|
||||
|
||||
var strategyBounds = strategy.bounds,
|
||||
mapExtent = map.getExtent().transform(from, to),
|
||||
// we don't use bounds::toString because we might run into
|
||||
// precision issues
|
||||
precision = 7,
|
||||
strategyBoundsGot = [
|
||||
strategyBounds.left.toFixed( precision ),
|
||||
strategyBounds.bottom.toFixed( precision ),
|
||||
strategyBounds.right.toFixed( precision ),
|
||||
strategyBounds.top.toFixed( precision )
|
||||
].join(','),
|
||||
mapExtentExpected = [
|
||||
mapExtent.left.toFixed( precision ),
|
||||
mapExtent.bottom.toFixed( precision ),
|
||||
mapExtent.right.toFixed( precision ),
|
||||
mapExtent.top.toFixed( precision )
|
||||
].join(',');
|
||||
t.eq(strategyBoundsGot, mapExtentExpected,
|
||||
"[force update different proj] bounds transformed");
|
||||
}
|
||||
|
||||
function test_events(t) {
|
||||
|
||||
@@ -141,7 +141,7 @@ Test.AnotherWay.quicksearch = function(){
|
||||
Test.AnotherWay.filterTestList = function(str){
|
||||
Test.AnotherWay.unfilterTestList();
|
||||
var re = new RegExp(str, 'i');
|
||||
var candidates = document.querySelectorAll('#testtable tr td:nth-child(2) a');
|
||||
var candidates = document.querySelectorAll('#testtable tr a');
|
||||
for (var idx = 0, len = candidates.length; idx<len; idx++) {
|
||||
var tr = candidates[idx].parentNode.parentNode;
|
||||
var html = candidates[idx].innerHTML;
|
||||
@@ -164,10 +164,10 @@ Test.AnotherWay.unfilterTestList = function() {
|
||||
};
|
||||
|
||||
// bind our quicksearch init method to body onload.
|
||||
(function(win){
|
||||
(function(win) {
|
||||
if (win.addEventListener) {
|
||||
win.addEventListener('load', Test.AnotherWay.bindQuicksearchListener);
|
||||
} else if (input.attachEvent) {
|
||||
} else if (win.attachEvent) {
|
||||
win.attachEvent('onload', Test.AnotherWay.bindQuicksearchListener);
|
||||
} else {
|
||||
win.onload = function(){
|
||||
|
||||
@@ -295,9 +295,6 @@
|
||||
t.ok(tile.layer.imageSize == null,
|
||||
"zero size gutter doesn't set image size");
|
||||
|
||||
t.ok(tile.layer.imageOffset == null,
|
||||
"zero size gutter doesn't set image offset");
|
||||
|
||||
var zero_gutter_bounds = tile.bounds;
|
||||
|
||||
map.destroy();
|
||||
@@ -312,8 +309,12 @@
|
||||
tile.size.h + (2 * gutter))),
|
||||
"gutter properly changes image size");
|
||||
|
||||
t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(-gutter, -gutter)),
|
||||
"gutter properly sets image offset");
|
||||
var offsetLeft = -(gutter / layer.tileSize.w * 100) | 0;
|
||||
var offsetTop = -(gutter / layer.tileSize.h * 100) | 0;
|
||||
t.eq(parseInt(tile.imgDiv.style.left, 10), offsetLeft,
|
||||
"gutter properly sets image left style");
|
||||
t.eq(parseInt(tile.imgDiv.style.top, 10), offsetTop,
|
||||
"gutter properly sets image top style");
|
||||
t.ok(tile.bounds.equals(zero_gutter_bounds),
|
||||
"gutter doesn't affect tile bounds");
|
||||
|
||||
@@ -374,7 +375,7 @@
|
||||
// test for https://github.com/openlayers/openlayers/pull/36
|
||||
// (more an integration test than a unit test)
|
||||
function test_olImageLoadError(t) {
|
||||
t.plan(2);
|
||||
t.plan(6);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var layer = new OpenLayers.Layer.WMS("invalid", "", {layers: 'basic'});
|
||||
@@ -385,10 +386,25 @@
|
||||
var bounds = new OpenLayers.Bounds(1, 2, 3, 4);
|
||||
|
||||
var tile = new OpenLayers.Tile.Image(layer, position, bounds, null, size);
|
||||
var log = [];
|
||||
tile.events.register("loaderror", this, function(e) {
|
||||
log.push([
|
||||
e.object.imgDiv.style.visibility,
|
||||
OpenLayers.Element.hasClass(e.object.imgDiv, 'olImageLoadError')
|
||||
]);
|
||||
});
|
||||
tile.events.register("loadend", this, function(e) {
|
||||
log.push(e);
|
||||
})
|
||||
tile.draw();
|
||||
|
||||
t.delay_call(0.1, function() {
|
||||
|
||||
|
||||
t.eq(log.length, 2, "loaderror and loadend events triggered");
|
||||
t.eq(log[0][0], "hidden", "tile still hidden when loaderror is triggered");
|
||||
t.eq(log[0][1], true, "tile has olImageLoadError class already when loaderror is triggered");
|
||||
t.ok(log[1].object === tile, "loadend event triggered after loaderror");
|
||||
|
||||
// check initial state
|
||||
t.ok(OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError'),
|
||||
'tile image has the olImageLoadError class (init state)');
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
|
||||
var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
|
||||
var isIE = (navigator.userAgent.indexOf("MSIE") != -1);
|
||||
var isIElt9 = (parseFloat(navigator.appVersion.split("MSIE")[1]) < 9);
|
||||
|
||||
var map, layer;
|
||||
var position = new OpenLayers.Pixel(20,30);
|
||||
@@ -96,17 +96,17 @@
|
||||
var eventPane = tile.frame.childNodes[0];
|
||||
|
||||
t.ok(OpenLayers.String.contains(eventPane.style.backgroundImage,
|
||||
tile.blankImageUrl),
|
||||
tile._blankImageUrl),
|
||||
"backgroundImage of eventPane is set.");
|
||||
t.eq(parseInt(eventPane.style.zIndex, 10), 1, "zIndex of eventPane is set.");
|
||||
if(isIE) {
|
||||
if(isIElt9) {
|
||||
t.ok(iFrame != null, "IFrame successfully created.");
|
||||
t.eq(iFrame.style.backgroundColor, '#ffffff', "backgroundColor correctly set.");
|
||||
t.eq(iFrame.style.filter, 'chroma(color=#FFFFFF)', "filter correctly set.");
|
||||
} else {
|
||||
t.ok(iFrame instanceof HTMLElement, "IFrame successfully created.");
|
||||
t.ok(true, 'Skip IFrame backgroundColor test outside IE');
|
||||
t.ok(true, 'Skip IFrame filter test outside IE');
|
||||
t.ok(true, 'Skip IFrame backgroundColor test outside IE < 9');
|
||||
t.ok(true, 'Skip IFrame filter test outside IE < 9');
|
||||
}
|
||||
t.eq( iFrame.scrolling, 'no', "no scrolling");
|
||||
t.eq( parseFloat(iFrame.marginWidth), 0, "no margin width");
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
<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). The panTo tests
|
||||
* here will test the fallback setTimeout implementation for animation.
|
||||
*/
|
||||
window.requestAnimationFrame =
|
||||
window.webkitRequestAnimationFrame =
|
||||
window.mozRequestAnimationFrame =
|
||||
window.oRequestAnimationFrame =
|
||||
window.msRequestAnimationFrame = null;
|
||||
</script>
|
||||
<script src="OLLoader.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
@@ -1120,7 +1120,31 @@
|
||||
t.eq(OpenLayers.Util.getFormattedLonLat(-181, "lon"), "179°00'00\"E", "crossing dateline from the west results in correct east coordinate");
|
||||
t.eq(OpenLayers.Util.getFormattedLonLat(181, "lon"), "179°00'00\"W", "crossing dateline from the east results in correct west coordinate");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To test that we can safely call OpenLayers.Util.extend with an Event
|
||||
* instance, we need to capture a real event.
|
||||
*/
|
||||
var loadEvent;
|
||||
window.onload = function(evt) {
|
||||
loadEvent = evt || window.event;
|
||||
}
|
||||
function test_extend_event(t) {
|
||||
t.plan(2);
|
||||
t.ok(loadEvent, "loadEvent recorded");
|
||||
var extended, err;
|
||||
try {
|
||||
extended = OpenLayers.Util.extend({foo: "bar"}, loadEvent);
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
if (err) {
|
||||
t.fail("Failed to extend with an event: " + err.message);
|
||||
} else {
|
||||
t.eq(extended && extended.foo, "bar", "extended with event");
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
map.addLayer(layer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = layer.grid[0][0];
|
||||
tile.draw(true); // the tile queue defers the drawing
|
||||
t.eq( tile.bounds.left, -22.5, "left side matches" );
|
||||
t.eq( tile.bounds.right, -11.25, "top side matches" );
|
||||
t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" );
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
map.addLayer(wmslayer);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
var tile = wmslayer.grid[0][0];
|
||||
tile.draw(true); // the tile queue defers the drawing
|
||||
t.eq( tile.bounds.left, -22.5, "left side matches" );
|
||||
t.eq( tile.bounds.right, -11.25, "right side matches" );
|
||||
t.eq( tile.bounds.bottom.toFixed(6), '11.178402', "bottom side matches" );
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
<li>Control/WMTSGetFeatureInfo.html</li>
|
||||
<li>Control/PanPanel.html</li>
|
||||
<li>Control/SLDSelect.html</li>
|
||||
<li>Control/Zoom.html</li>
|
||||
<li>Events.html</li>
|
||||
<li>Events/buttonclick.html</li>
|
||||
<li>Extras.html</li>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../../theme/default/style.css" type="text/css">
|
||||
<link rel="stylesheet" href="../../theme/default/google.css" type="text/css">
|
||||
<link rel="stylesheet" href="../../examples/style.css" type="text/css">
|
||||
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
|
||||
<script src="http://maps.google.com/maps/api/js?sensor=false&v=3.6"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
var map;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
padding: 0 0.5em 0.5em 0.5em;
|
||||
}
|
||||
</style>
|
||||
<script src="http://maps.google.com/maps/api/js?v=3.5&sensor=false"></script>
|
||||
<script src="http://maps.google.com/maps/api/js?v=3.6&sensor=false"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<link rel="stylesheet" href="../../theme/default/style.css" type="text/css">
|
||||
<link rel="stylesheet" href="../../theme/default/google.css" type="text/css">
|
||||
<link rel="stylesheet" href="../../examples/style.css" type="text/css">
|
||||
<script src="http://maps.google.com/maps/api/js?v=3.5&sensor=false"></script>
|
||||
<script src="http://maps.google.com/maps/api/js?v=3.6&sensor=false"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<title>Google v3 Resize Test</title>
|
||||
<link rel="stylesheet" href="../../theme/default/style.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../../examples/style.css" type="text/css" />
|
||||
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
|
||||
<script src="http://maps.google.com/maps/api/js?sensor=false&v=3.6"></script>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
var map;
|
||||
|
||||
Reference in New Issue
Block a user