merge with trunk

This commit is contained in:
Bart van den Eijnden
2012-02-28 13:31:14 +01:00
119 changed files with 2543 additions and 855 deletions

View File

@@ -15,7 +15,8 @@
<script>
function test_all(t) {
t.plan(7);
t.plan(8);
t.ok(OpenLayers.Animation.isNative !== undefined, "isNative is set.");
t.open_window("Animation.html", function(win) {
win.requestFrame(t);
win.start(t);

View File

@@ -59,34 +59,7 @@
str = " ";
t.eq(OpenLayers.String.trim(str), "", "whitespace string is trimmed correctly");
}
function test_String_camelize(t) {
t.plan(7);
var str = "chickenhead";
t.eq(OpenLayers.String.camelize(str), "chickenhead", "string with no hyphens is left alone");
str = "chicken-head";
t.eq(OpenLayers.String.camelize(str), "chickenHead", "string with one middle hyphen is camelized correctly");
str = "chicken-head-man";
t.eq(OpenLayers.String.camelize(str), "chickenHeadMan", "string with multiple middle hyphens is camelized correctly");
str = "-chickenhead";
t.eq(OpenLayers.String.camelize(str), "Chickenhead", "string with starting hyphen is camelized correctly (capitalized)");
str = "-chicken-head-man";
t.eq(OpenLayers.String.camelize(str), "ChickenHeadMan", "string with starting hypen and multiple middle hyphens is camelized correctly");
str = "chicken-";
t.eq(OpenLayers.String.camelize(str), "chicken", "string ending in hyphen is camelized correctly (hyphen dropped)");
str = "chicken-head-man-";
t.eq(OpenLayers.String.camelize(str), "chickenHeadMan", "string with multiple middle hyphens and end hyphen is camelized correctly (end hyphen dropped)");
}
function test_String_format(t) {
var unchanged = [
"", "${ ", "${", " ${", "${${", "${}", "${${}}", " ${ ${",

View File

@@ -30,8 +30,9 @@
map.addLayer(new OpenLayers.Layer("name", {'attribution':'My layer 2!'}));
t.eq(control.div.innerHTML, 'My layer!, My layer 2!', "Attribution correct with two layers.");
control.separator = '|';
control.template = "Map Copyright (c) 2012 by Foo Bar; ${layers}";
map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer 3!'}));
t.eq(control.div.innerHTML, 'My layer!|My layer 2!|My layer 3!', "Attribution correct with three layers and diff seperator.");
t.eq(control.div.innerHTML, 'Map Copyright (c) 2012 by Foo Bar; My layer!|My layer 2!|My layer 3!', "Attribution correct with three layers and diff seperator.");
}

View File

@@ -3,7 +3,7 @@
<script src="../OLLoader.js"></script>
<script type="text/javascript">
function test_initialze(t) {
function test_initialize(t) {
t.plan(1);

View File

@@ -807,6 +807,25 @@
t.eq(control._originalGeometry, undefined, "original geometry deleted once it is set on the modified property");
}
function test_createVertices(t) {
t.plan(2);
var layer = new OpenLayers.Layer.Vector();
var control = new OpenLayers.Control.ModifyFeature(layer, {
createVertices: false
});
var line = new OpenLayers.Geometry.LineString([
new OpenLayers.Geometry.Point(5, 6),
new OpenLayers.Geometry.Point(7, 8),
new OpenLayers.Geometry.Point(9, 10)
]);
control.feature = new OpenLayers.Feature.Vector(line);
control.resetVertices();
t.eq(control.vertices.length, 3, "Correct vertices length with createVertices is false");
t.eq(control.virtualVertices.length, 0, "Correct virtual vertices length with createVertices is false");
control.destroy();
}
</script>
</head>
<body>

View File

@@ -291,18 +291,18 @@
t.plan(5);
var map = new OpenLayers.Map("map", {
getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));}
}
);
});
var geographic = new OpenLayers.Projection("EPSG:4326");
var a = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: "a,b,c,d",
styles: "a,b,c,d"
});
}, {projection: geographic});
var b = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: ["a","b","c","d"],
styles: ["a","b","c","d"]
});
}, {projection: geographic});
var c = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: ["a","b","c","d"]
@@ -310,13 +310,13 @@
var d = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: "a,b,c,d"
});
}, {projection: geographic});
var click = new OpenLayers.Control.WMSGetFeatureInfo({
featureType: 'type',
featureNS: 'ns',
layers: [a, b, c, d]
});
}, {projection: geographic});
map.addControl(click);
@@ -399,6 +399,7 @@
var c = new OpenLayers.Layer.WMS(
null, ["http://c.mirror/wms", "http://d.mirror/wms"], {layers: "c"}
);
map.addLayers([a, b, c]);
var control = new OpenLayers.Control.WMSGetFeatureInfo({
url: "http://host/wms",

View File

@@ -46,7 +46,7 @@
new OpenLayers.Feature.Vector(point2, {name: 'foo', description: 'bar'})
];
var data = parser.write(features);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wpt lon="-111.04" lat="45.68"><name>foo</name><desc>bar</desc></wpt><wpt lon="-112.04" lat="45.68"><name>foo</name><desc>bar</desc></wpt></gpx>', 'GPX serializes points correctly');
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wpt lon="-111.04" lat="45.68"><name>foo</name><desc>bar</desc></wpt><wpt lon="-112.04" lat="45.68"><name>foo</name><desc>bar</desc></wpt></gpx>', 'GPX serializes points correctly');
}
function test_Format_GPX_serialize_line(t) {
t.plan(1);
@@ -58,7 +58,7 @@
var line = new OpenLayers.Geometry.LineString([point, point2]);
var f = new OpenLayers.Feature.Vector(line, {name: 'foo', description: 'bar'});
var data = parser.write(f);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.04" lat="45.68"/><trkpt lon="-112.04" lat="45.68"/></trkseg></trk></gpx>', 'GPX serializes line correctly');
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.04" lat="45.68"/><trkpt lon="-112.04" lat="45.68"/></trkseg></trk></gpx>', 'GPX serializes line correctly');
}
function test_Format_GPX_serialize_lines(t) {
t.plan(1);
@@ -74,7 +74,7 @@
var f = new OpenLayers.Feature.Vector(line, {name: 'foo', description: 'bar'});
var f2 = new OpenLayers.Feature.Vector(line2, {name: 'dude', description: 'truite'});
var data = parser.write([f, f2]);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.04" lat="45.68"/><trkpt lon="-112.04" lat="45.68"/></trkseg></trk><trk><name>dude</name><desc>truite</desc><trkseg><trkpt lon="1" lat="2"/><trkpt lon="3" lat="4"/></trkseg></trk></gpx>', 'GPX serializes lines correctly');
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.04" lat="45.68"/><trkpt lon="-112.04" lat="45.68"/></trkseg></trk><trk><name>dude</name><desc>truite</desc><trkseg><trkpt lon="1" lat="2"/><trkpt lon="3" lat="4"/></trkseg></trk></gpx>', 'GPX serializes lines correctly');
}
function test_Format_GPX_serialize_multiline(t) {
t.plan(1);
@@ -90,7 +90,7 @@
var multiline = new OpenLayers.Geometry.MultiLineString([line, line2]);
var f = new OpenLayers.Feature.Vector(multiline, {name: 'foo', description: 'bar'});
var data = parser.write([f]);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.04" lat="45.68"/><trkpt lon="-112.04" lat="45.68"/></trkseg><trkseg><trkpt lon="1" lat="2"/><trkpt lon="3" lat="4"/></trkseg></trk></gpx>', 'GPX serializes multiline correctly');
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.04" lat="45.68"/><trkpt lon="-112.04" lat="45.68"/></trkseg><trkseg><trkpt lon="1" lat="2"/><trkpt lon="3" lat="4"/></trkseg></trk></gpx>', 'GPX serializes multiline correctly');
}
function test_Format_GPX_serialize_polygon(t) {
t.plan(1);
@@ -103,7 +103,7 @@
var polygon = new OpenLayers.Geometry.Polygon([linearRing]);
var f = new OpenLayers.Feature.Vector(polygon, {name: 'foo', description: 'bar'});
var data = parser.write([f]);
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.04" lat="45.68"/><trkpt lon="-112.04" lat="45.68"/><trkpt lon="-111.04" lat="45.68"/></trkseg></trk></gpx>', 'GPX serializes polygon correctly');
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><trk><name>foo</name><desc>bar</desc><trkseg><trkpt lon="-111.04" lat="45.68"/><trkpt lon="-112.04" lat="45.68"/><trkpt lon="-111.04" lat="45.68"/></trkseg></trk></gpx>', 'GPX serializes polygon correctly');
}
function test_Format_GPX_serialize_metadata(t) {
t.plan(1);
@@ -111,7 +111,7 @@
var parser = new OpenLayers.Format.GPX();
var data = parser.write([], {name: 'foo', desc: 'bar'});
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><metadata><name>foo</name><desc>bar</desc></metadata></gpx>', 'GPX serializes metadata correctly');
t.xml_eq(data, '<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OpenLayers" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><metadata><name>foo</name><desc>bar</desc></metadata></gpx>', 'GPX serializes metadata correctly');
}
</script>
</head>

View File

@@ -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>' +
@@ -177,7 +190,7 @@
t.eq(text.label, "A ${FOO} label", "(AAA161) first rule has proper text label");
t.eq(layer.userStyles[0].propertyStyles["label"], true, "label added to propertyStyles");
t.eq(text.fontFamily, "Arial", "(AAA161) first rule has proper font family");
t.eq(text.fillColor, "#000000", "(AAA161) first rule has proper text fill");
t.eq(text.fontColor, "#000000", "(AAA161) first rule has proper text fill");
t.eq(text.haloRadius, "3", "(AAA161) first rule has proper halo radius");
t.eq(text.haloColor, "#ffffff", "(AAA161) first rule has proper halo color");
@@ -347,7 +360,7 @@
"label": "This is the ${city} in ${state}.",
"fontFamily": "Arial",
"fontSize": 10,
"fillColor": "blue",
"fontColor": "blue",
"fontWeight": "bold",
"fontStyle": "normal",
"haloRadius": 2,
@@ -509,7 +522,55 @@
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
});
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
})
]
})
]
});
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 +646,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 +927,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>

View File

@@ -0,0 +1,114 @@
<html>
<head>
<script src="../../OLLoader.js"></script>
<script type="text/javascript">
var xml = new OpenLayers.Format.XML();
function readXML(id) {
return xml.read(document.getElementById(id).firstChild.nodeValue);
}
function test_VendorExtensions(t) {
var cases = [
"poly_label.sld"
];
var len = cases.length;
t.plan(len);
var format = new OpenLayers.Format.SLD({
profile: "GeoServer",
multipleSymbolizers: true,
namedLayersAsArray: true,
schemaLocation: "http://www.opengis.net/sld StyledLayerDescriptor.xsd"
});
var c, doc, data, out;
for (var i=0; i<len; ++i) {
c = cases[i];
doc = readXML(c);
data = format.read(doc);
out = format.write(data);
t.xml_eq(out, doc.documentElement, "round-tripped " + c);
}
}
</script>
</head>
<body>
<div id="poly_label.sld"><!--
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>Polygon with styled label</Name>
<UserStyle>
<Title>SLD Cook Book: Polygon with styled label</Title>
<FeatureTypeStyle>
<Rule>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#40FF40</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#FFFFFF</CssParameter>
<CssParameter name="stroke-width">2</CssParameter>
</Stroke>
</PolygonSymbolizer>
<TextSymbolizer>
<Label>
<ogc:PropertyName>name</ogc:PropertyName>
</Label>
<Font>
<CssParameter name="font-family">Arial</CssParameter>
<CssParameter name="font-size">11</CssParameter>
<CssParameter name="font-weight">bold</CssParameter>
<CssParameter name="font-style">normal</CssParameter>
</Font>
<Fill>
<CssParameter name="fill">#000000</CssParameter>
<CssParameter name="fill-opacity">0.5</CssParameter>
</Fill>
<Graphic>
<Mark>
<WellKnownName>square</WellKnownName>
<Fill>
<CssParameter name="fill">#59BF34</CssParameter>
<CssParameter name="fill-opacity">0.8</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#2D6917</CssParameter>
</Stroke>
</Mark>
<Size>24</Size>
</Graphic>
<Priority>
<ogc:PropertyName>population</ogc:PropertyName>
</Priority>
<VendorOption name="autoWrap">60</VendorOption>
<VendorOption name="followLine">true</VendorOption>
<VendorOption name="repeat">300</VendorOption>
<VendorOption name="maxDisplacement">150</VendorOption>
<VendorOption name="forceLeftToRight">false</VendorOption>
<VendorOption name="graphic-margin">3</VendorOption>
<VendorOption name="graphic-resize">stretch</VendorOption>
<VendorOption name="group">yes</VendorOption>
<VendorOption name="spaceAround">10</VendorOption>
<VendorOption name="labelAllGroup">true</VendorOption>
<VendorOption name="maxAngleDelta">15</VendorOption>
<VendorOption name="conflictResolution">false</VendorOption>
<VendorOption name="goodnessOfFit">0.3</VendorOption>
<VendorOption name="polygonAlign">mbr</VendorOption>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
--></div>
</body>
</html>

View File

@@ -41,7 +41,7 @@
// Chromium 10: left is 0
var testdiv = OpenLayers.Util.createDiv('testdiv', new OpenLayers.Pixel(5, 5));
map.div.appendChild(testdiv);
var left = parseInt(OpenLayers.Element.getStyle(testdiv, 'border-left-width'));
var left = parseInt(OpenLayers.Element.getStyle(testdiv, 'borderLeftWidth'));
map.div.removeChild(testdiv);
var testAll = !isNaN(left);

View File

@@ -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();
}

View File

@@ -268,10 +268,10 @@
map.destroy();
map = new OpenLayers.Map("map");
layer = new OpenLayers.Layer("test", {projection: "EPSG:4326"});
layer = new OpenLayers.Layer("test", {projection: "unknown"});
map.addLayer(layer);
t.eq(layer.alwaysInRange, true,
"alwaysInRange true if only get projection.");
"alwaysInRange true if unknown projection is set.");
map.destroy();
map = new OpenLayers.Map("map");
@@ -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");
}

View File

@@ -4,6 +4,9 @@
<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;

View File

@@ -2,6 +2,10 @@
<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;
@@ -67,6 +71,26 @@
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);
@@ -189,13 +213,36 @@
function test_Layer_Grid_moveTo(t) {
t.plan(14);
t.plan(17);
var origIsNative = OpenLayers.Animation.isNative;
OpenLayers.Animation.isNative = false;
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.WMS(name, url, params);
layer.destroy = function() {}; //we're going to do funky things with the grid
layer.applyBackBuffer = function() {}; // backbuffering isn't under test here
map.addLayer(layer);
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(0.1, function() {
t.eq(log[2], "deferMoveGriddedTiles", "tiles moved after tileLoadingDelay");
});
//make sure null bounds doesnt cause script error.
// no test necessary, just action
@@ -204,7 +251,6 @@
layer.moveTo(); //checks to make sure null bounds doesnt break us
//observing globals
layer.initSingleTile = function(bounds) {
g_WhichFunc = "InitSingle";
@@ -214,10 +260,13 @@
g_WhichFunc = "InitGridded";
g_Bounds = bounds;
};
layer._moveGriddedTiles = function() {
layer.moveGriddedTiles = function() {
g_WhichFunc = "MoveGridded";
g_Bounds = layer.map.getExtent();
};
layer.deferMoveGriddedTiles = function() {
g_WhichFunc = "DeferMoveGridded";
}
var clearTestBounds = function() {
g_WhichFunc = null;
g_Bounds = null;
@@ -307,7 +356,7 @@
//gridded
layer.grid = [ [ {} ] ];
layer.grid = [ [ {position: new OpenLayers.Pixel(0,0)} ] ];
layer.singleTile = false;
//regular move
@@ -315,11 +364,8 @@
tilesBounds = new OpenLayers.Bounds(10,10,120,120);
g_WhichFunc = null;
layer.moveTo(null, zoomChanged);
t.eq(g_WhichFunc, null, "moveGriddedTiles is delayed - not called yet");
t.delay_call(0.2, function() {
t.ok(g_WhichFunc == "MoveGridded", "if tiles not drastically out of bounds, we call moveGriddedTile()");
t.ok(g_Bounds.equals(b), "if tiles not drastically out of bounds, we call moveGriddedTile() with correct bounds");
});
t.eq(g_WhichFunc, "MoveGridded", "if tiles not drastically out of bounds, we call moveGriddedTile()");
t.ok(g_Bounds.equals(b), "if tiles not drastically out of bounds, we call moveGriddedTile() with correct bounds");
// drastic pan
clearTestBounds();
@@ -328,6 +374,7 @@
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
@@ -459,12 +506,12 @@
}
function test_Layer_Grid_addTileMonitoringHooks(t) {
t.plan(14);
t.plan(15);
layer = new OpenLayers.Layer.Grid();
layer.events = {
'triggerEvent': function(str) {
g_events.push(str);
'triggerEvent': function(str, evt) {
g_events.push([str, evt]);
}
}
@@ -490,7 +537,7 @@
g_events = [];
tile.onLoadStart.apply(layer);
t.eq(g_events[0], "loadstart", "loadstart event triggered when numLoadingTiles is 0");
t.eq(g_events[0][0], "loadstart", "loadstart event triggered when numLoadingTiles is 0");
t.eq(layer.numLoadingTiles, 1, "numLoadingTiles incremented");
g_events = [];
@@ -507,7 +554,8 @@
layer.numLoadingTiles = 2;
g_events = [];
tile.onLoadEnd.apply(layer);
t.eq(g_events[0], "tileloaded", "tileloaded triggered when numLoadingTiles is > 0");
t.eq(g_events[0][0], "tileloaded", "tileloaded triggered when numLoadingTiles is > 0");
t.ok(g_events[0][1].tile === tile, "tile passed as tile property to event object");
t.eq(g_events.length, 1, "loadend event not triggered when numLoadingTiles is > 0");
t.eq(layer.numLoadingTiles, 1, "numLoadingTiles decremented");
@@ -515,8 +563,8 @@
g_events = [];
layer.grid = [[{}]]; // to prevent error in updateBackBuffer
tile.onLoadEnd.apply(layer);
t.eq(g_events[0], "tileloaded", "tileloaded triggered when numLoadingTiles is 0");
t.eq(g_events[1], "loadend", "loadend event triggered when numLoadingTiles is 0");
t.eq(g_events[0][0], "tileloaded", "tileloaded triggered when numLoadingTiles is 0");
t.eq(g_events[1][0], "loadend", "loadend event triggered when numLoadingTiles is 0");
t.eq(layer.numLoadingTiles, 0, "numLoadingTiles decremented");
}

View File

@@ -6,6 +6,9 @@
<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;

View File

@@ -178,7 +178,7 @@
var map = new OpenLayers.Map({
div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset)
maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
});
var layer = new OpenLayers.Layer.TMS("TMS", "", {
layername: "basic",
@@ -200,7 +200,7 @@
var map = new OpenLayers.Map({
div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset)
maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
});
var layer = new OpenLayers.Layer.TMS("TMS", "", {
layername: "basic",

View File

@@ -5,6 +5,9 @@
<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;
@@ -385,6 +388,7 @@
var map = new OpenLayers.Map({
div: "map",
maxExtent: new OpenLayers.Bounds(-185, -95, 185, 95),
maxResolution: 1.40625,
layers: [dummy, unconstrained, constrained],
center: new OpenLayers.LonLat(0, 0),
zoom: 1

View File

@@ -136,7 +136,8 @@
layer: "world",
style: "blue_marble",
matrixSet: "arcgis_online",
tileSize: new OpenLayers.Size(512, 512),
tileSize: new OpenLayers.Size(512, 512),
maxResolution: 1.40625,
requestEncoding: "REST"
});
map.addLayer(layer1);
@@ -156,7 +157,8 @@
layer: "world",
style: "blue_marble",
matrixSet: "arcgis_online",
tileSize: new OpenLayers.Size(512, 512),
tileSize: new OpenLayers.Size(512, 512),
maxResolution: 1.40625,
requestEncoding: "REST"
});
map.addLayer(layer1);

View File

@@ -2,6 +2,9 @@
<head>
<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;
@@ -127,7 +130,7 @@
}
function test_Layer_WrapDateLine_WMS (t) {
t.plan( 3 );
t.plan( 4 );
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
layer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true,encodeBBOX:true, buffer: 2});
@@ -135,13 +138,14 @@
m.addLayer(layer);
m.zoomToMaxExtent();
t.eq(layer.grid[3][0].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=&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "cell [3][0] is wrapped around the world.");
t.eq(layer.grid[0][0].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=&SRS=EPSG%3A4326&BBOX=0%2C450%2C180%2C630&WIDTH=256&HEIGHT=256", "cell [0][0] is wrapped around the world lon, but not lat");
t.eq(layer.grid[0][3].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=&SRS=EPSG%3A4326&BBOX=-180%2C450%2C0%2C630&WIDTH=256&HEIGHT=256", "cell [3][0] is not wrapped at all.");
t.eq(layer.grid[3][1].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=&SRS=EPSG%3A4326&BBOX=-180%2C-90%2C0%2C90&WIDTH=256&HEIGHT=256", "cell [3][1] is wrapped around the world.");
t.eq(layer.grid[3][2].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=&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "cell [3][2] is not wrapped at all.");
t.ok(layer.grid[0][2].url == null, "no latitudinal wrapping - tile not loaded if outside maxExtent");
m.destroy();
}
function test_Layer_WrapDateLine_KaMap (t) {
t.plan( 3 );
t.plan( 4 );
var layer = new OpenLayers.Layer.KaMap( "Blue Marble NG",
"http://www.openlayers.org/world/index.php",
@@ -150,13 +154,14 @@
var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}});
m.addLayer(layer);
m.zoomToMaxExtent();
t.eq(layer.grid[0][0].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-1280&l=0&s=221471921.25", "grid[0][0] kamap is okay");
t.eq(layer.grid[0][3].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-1280&l=-256&s=221471921.25", "grid[0][3] kamap is okay");
t.eq(layer.grid[3][0].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=-512&l=0&s=221471921.25", "grid[3][0] is okay");
t.eq(layer.grid[5][7].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=0&l=-256&s=221471921.25", "grid[5][7] kamap is okay");
t.eq(layer.grid[5][6].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=0&l=0&s=221471921.25", "grid[5][6] kamap is okay");
t.eq(layer.grid[5][5].url, "http://www.openlayers.org/world/index.php?g=satellite&map=world&i=jpeg&t=0&l=-256&s=221471921.25", "grid[5][5] is okay");
t.ok(layer.grid[7][6].url == null, "no latitudinal wrapping - tile not loaded if outside maxExtent");
m.destroy();
}
function test_Layer_WrapDateLine_WMS_Overlay (t) {
t.plan( 3 );
t.plan( 4 );
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
baselayer = new OpenLayers.Layer.WMS(name, url, params, {'wrapDateLine':true, buffer: 2});
var layer = new OpenLayers.Layer.WMS( "DM Solutions Demo",
@@ -168,9 +173,10 @@
var m = new OpenLayers.Map('map', {adjustZoom: function(z) {return z;}});
m.addLayers([baselayer,layer]);
m.zoomToMaxExtent();
t.eq(layer.grid[0][0].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=0%2C450%2C180%2C630&WIDTH=256&HEIGHT=256", "grid[0][0] wms overlay is okay");
t.eq(layer.grid[0][3].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=-180%2C450%2C0%2C630&WIDTH=256&HEIGHT=256", "grid[0][3] wms overlay is okay");
t.eq(layer.grid[3][0].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "grid[3][0] wms overlay okay");
t.eq(layer.grid[3][0].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "grid[0][0] wms overlay is okay");
t.eq(layer.grid[3][1].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=-180%2C-90%2C0%2C90&WIDTH=256&HEIGHT=256", "grid[0][3] wms overlay is okay");
t.eq(layer.grid[3][2].url, "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?LAYERS=bathymetry%2Cland_fn%2Cpark%2Cdrain_fn%2Cdrainage%2Cprov_bound%2Cfedlimit%2Crail%2Croad%2Cpopplace&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=0%2C-90%2C180%2C90&WIDTH=256&HEIGHT=256", "grid[3][0] wms overlay okay");
t.ok(layer.grid[0][2].url == null, "no latitudinal wrapping - tile not loaded if outside maxExtent");
m.destroy();
}

View File

@@ -195,7 +195,7 @@
var map = new OpenLayers.Map({
div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset)
maxResolution: 1.40625 / Math.pow(2, offset)
});
var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset});
map.addLayer(layer);
@@ -211,7 +211,7 @@
var map = new OpenLayers.Map({
div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset)
maxResolution: 1.40625 / Math.pow(2, offset)
});
var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset});
map.addLayer(layer);

View File

@@ -302,7 +302,7 @@
function test_fromWMSLayer(t) {
t.plan(9);
var map = new OpenLayers.Map("map", {
projection: "EPSG:1234"
projection: "CRS:84"
});
var layer = new OpenLayers.Layer.WMS("foo", "htttp://foo/ows",
{layers: "topp:states"}
@@ -312,7 +312,7 @@
t.eq(protocol.url, "htttp://foo/ows", "url taken from wms layer");
t.eq(protocol.featurePrefix, "topp", "feature prefix correctly extracted");
t.eq(protocol.featureType, "states", "typeName correctly extracted");
t.eq(protocol.srsName, "EPSG:1234", "srsName set correctly");
t.eq(protocol.srsName, "CRS:84", "srsName set correctly");
t.eq(protocol.version, "1.1.0", "version set correctly");
t.eq(protocol.format.geometryName, null, "format's geometryName set to null");

View File

@@ -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();

View File

@@ -33,7 +33,7 @@
}
function test_update(t) {
t.plan(5);
t.plan(7);
// Create a dummy layer that can act as the map base layer.
// This will be unnecessary if #1921 is addressed (allowing
@@ -43,9 +43,10 @@
var strategy = new OpenLayers.Strategy.BBOX({
ratio: 1 // makes for easier comparison to map bounds
});
var log = [];
var layer = new OpenLayers.Layer.Vector(null, {
isBaseLayer: true,
protocol: new OpenLayers.Protocol(),
protocol: new OpenLayers.Protocol({abort: function(response) { log.push(response); }}),
strategies: [strategy]
});
@@ -61,7 +62,14 @@
* should be removed when the issue(s) described in #1835 are addressed.
*/
strategy.update({force: true});
strategy.response = {};
strategy.update({force: true});
t.eq(log.length, 1, "Response aborted");
log = [];
strategy.update({force: true});
strategy.update({force: true, noAbort: true});
t.eq(log.length, 0, "Response not aborted when noAbort is true");
// test that the strategy bounds were set
t.ok(map.getExtent().equals(strategy.bounds), "[set center] bounds set to map extent");

View File

@@ -59,6 +59,39 @@
tearDown();
}
function test_Tile_draw(t) {
t.plan(6);
setUp();
var position = new OpenLayers.Pixel(10,20);
var bounds = new OpenLayers.Bounds(1,2,3,4);
var url = "bobob";
var size = new OpenLayers.Size(5,6);
tile = new OpenLayers.Tile(layer, position, bounds, url, size);
var log = [];
tile.clear = function() {
log.push("clear");
}
tile.draw();
t.eq(log.length, 1, "Tile cleared before drawing");
log = [];
tile.events.register("beforedraw", this, function() {
log.push("beforedraw");
return false;
});
var drawn = tile.draw();
t.eq(log[0], "clear", "tile cleared");
t.eq(log[1], "beforedraw", "beforedraw event fired");
t.eq(drawn, false, "tile not drawn when beforedraw listener returns false");
drawn = tile.draw(true);
t.eq(log.length, 2, "no beforedraw event fired and tile not cleared when draw called with 'deferred' argument set to true");
t.eq(drawn, true, "tile drawn when draw called with 'deferred' argument set to true");
tearDown();
}
function test_Tile_destroy(t) {
t.plan( 6 );

View File

@@ -2,6 +2,9 @@
<head>
<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 tile;
@@ -292,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();
@@ -309,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");
@@ -399,6 +403,31 @@
map.destroy();
});
}
function test_getCanvasContext(t) {
if (!OpenLayers.CANVAS_SUPPORTED) {
t.plan(0);
} else {
t.plan(1);
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0, 0), 5);
t.delay_call(5, function() {
var tile = layer.grid[0][0];
if (tile.isLoading) {
t.ok(false, "test_getCanvasContext timeout");
} else {
t.ok(tile.getCanvasContext() instanceof CanvasRenderingContext2D,
"getCanvasContext() returns CanvasRenderingContext2D instance");
}
map.destroy();
});
}
}
</script>
</head>

View File

@@ -2,6 +2,9 @@
<head>
<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 isOpera = (navigator.userAgent.indexOf("Opera") != -1);
var isIE = (navigator.userAgent.indexOf("MSIE") != -1);

View File

@@ -0,0 +1,40 @@
<html>
<head>
<script src="../../OLLoader.js"></script>
<script src="../../../lib/deprecated.js"></script>
<script type="text/javascript">
function test_String_camelize(t) {
t.plan(7);
var str = "chickenhead";
t.eq(OpenLayers.String.camelize(str), "chickenhead", "string with no hyphens is left alone");
str = "chicken-head";
t.eq(OpenLayers.String.camelize(str), "chickenHead", "string with one middle hyphen is camelized correctly");
str = "chicken-head-man";
t.eq(OpenLayers.String.camelize(str), "chickenHeadMan", "string with multiple middle hyphens is camelized correctly");
str = "-chickenhead";
t.eq(OpenLayers.String.camelize(str), "Chickenhead", "string with starting hyphen is camelized correctly (capitalized)");
str = "-chicken-head-man";
t.eq(OpenLayers.String.camelize(str), "ChickenHeadMan", "string with starting hypen and multiple middle hyphens is camelized correctly");
str = "chicken-";
t.eq(OpenLayers.String.camelize(str), "chicken", "string ending in hyphen is camelized correctly (hyphen dropped)");
str = "chicken-head-man-";
t.eq(OpenLayers.String.camelize(str), "chickenHeadMan", "string with multiple middle hyphens and end hyphen is camelized correctly (end hyphen dropped)");
}
</script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,40 @@
<html>
<head>
<script src="../../OLLoader.js"></script>
<script src="../../../lib/deprecated.js"></script>
<script type="text/javascript">
function test_String_camelize(t) {
t.plan(7);
var str = "chickenhead";
t.eq(OpenLayers.String.camelize(str), "chickenhead", "string with no hyphens is left alone");
str = "chicken-head";
t.eq(OpenLayers.String.camelize(str), "chickenHead", "string with one middle hyphen is camelized correctly");
str = "chicken-head-man";
t.eq(OpenLayers.String.camelize(str), "chickenHeadMan", "string with multiple middle hyphens is camelized correctly");
str = "-chickenhead";
t.eq(OpenLayers.String.camelize(str), "Chickenhead", "string with starting hyphen is camelized correctly (capitalized)");
str = "-chicken-head-man";
t.eq(OpenLayers.String.camelize(str), "ChickenHeadMan", "string with starting hypen and multiple middle hyphens is camelized correctly");
str = "chicken-";
t.eq(OpenLayers.String.camelize(str), "chicken", "string ending in hyphen is camelized correctly (hyphen dropped)");
str = "chicken-head-man-";
t.eq(OpenLayers.String.camelize(str), "chickenHeadMan", "string with multiple middle hyphens and end hyphen is camelized correctly (end hyphen dropped)");
}
</script>
</head>
<body>
</body>
</html>

View File

@@ -5,6 +5,9 @@
<script src="../../../../lib/deprecated.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;

View File

@@ -73,6 +73,7 @@
<li>Format/Text.html</li>
<li>Format/SLD.html</li>
<li>Format/SLD/v1_0_0.html</li>
<li>Format/SLD/v1_0_0_GeoServer.html</li>
<li>Format/Filter.html</li>
<li>Format/Filter/v1.html</li>
<li>Format/Filter/v1_0_0.html</li>
@@ -224,6 +225,7 @@
<li>deprecated/Ajax.html</li>
<li>deprecated/BaseTypes/Class.html</li>
<li>deprecated/BaseTypes/Element.html</li>
<li>deprecated/BaseTypes/String.html</li>
<li>deprecated/Control/MouseToolbar.html</li>
<li>deprecated/Geometry/Rectangle.html</li>
<li>deprecated/Layer/GML.html</li>