Pullup changes for RC3:
* KML Examples broken (Closes #1001) * drag handler doesn't reset properties on left or improperly modified mousedown (Closes #1003) * Text nodes limited to 4096 in length (Closes #1006) * KML/GML Attribute CDATA Parsing (Closes #1007) * Control.MousePosition (Closes #1008) git-svn-id: http://svn.openlayers.org/branches/openlayers/2.5@4432 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
45
tests/Control/test_MousePosition.html
Normal file
45
tests/Control/test_MousePosition.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function test_MousePosition_constructor(t) {
|
||||
t.plan(2);
|
||||
|
||||
var control = new OpenLayers.Control.MousePosition();
|
||||
t.ok(control instanceof OpenLayers.Control.MousePosition, "new OpenLayers.Control.MousePosition returns object");
|
||||
t.eq(control.displayClass, "olControlMousePosition", "displayClass set correctly");
|
||||
}
|
||||
|
||||
function test_MousePosition_destroy(t) {
|
||||
t.plan(1);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var control = new OpenLayers.Control.MousePosition();
|
||||
map.addControl(control);
|
||||
|
||||
var listeners = map.events.listeners.mousemove.length;
|
||||
control.destroy();
|
||||
|
||||
t.eq(map.events.listeners.mousemove.length, listeners - 1, "mousemove event is unregistered");
|
||||
}
|
||||
|
||||
function test_MousePosition_addControl(t) {
|
||||
t.plan(4);
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var control = new OpenLayers.Control.MousePosition();
|
||||
map.addControl(control);
|
||||
|
||||
t.ok(control.map === map, "Control.map is set to the map object");
|
||||
t.ok(map.controls[map.controls.length - 1] === 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");
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" style="width: 1024px; height: 512px;"/>
|
||||
</body>
|
||||
</html>
|
||||
@@ -147,13 +147,14 @@
|
||||
t.eq(data[0].geometry.components.length, 2, "rings length correct");
|
||||
}
|
||||
function test_Format_GML_read_attributes(t) {
|
||||
t.plan(1);
|
||||
t.plan(2);
|
||||
var parser = new OpenLayers.Format.GML();
|
||||
data = parser.read(test_content[0]);
|
||||
t.eq(data[0].attributes['NAME'], "WY", "Simple Attribute data is read correctly.");
|
||||
t.eq(data[0].attributes['LONGNAME'], "Wyoming", "Attribute data is read from CDATA node correctly.");
|
||||
}
|
||||
|
||||
var test_content = ['<?xml version="1.0" encoding="utf-8" ?>\n<ogr:FeatureCollection\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://ogr.maptools.org/ testoutput.xsd"\n xmlns:ogr="http://ogr.maptools.org/"\n xmlns:gml="http://www.opengis.net/gml">\n <gml:boundedBy>\n <gml:Box>\n <gml:coord><gml:X>-1254041.389711702</gml:X><gml:Y>250906.9515983529</gml:Y></gml:coord>\n <gml:coord><gml:X>-634517.1199908922</gml:X><gml:Y>762236.2940800377</gml:Y></gml:coord>\n </gml:Box>\n </gml:boundedBy> \n <gml:featureMember>\n <ogr:states fid="F0">\n <ogr:geometryProperty><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>\n <ogr:NAME>WY</ogr:NAME>\n </ogr:states>\n </gml:featureMember>\n</ogr:FeatureCollection>\n',
|
||||
var test_content = ['<?xml version="1.0" encoding="utf-8" ?>\n<ogr:FeatureCollection\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://ogr.maptools.org/ testoutput.xsd"\n xmlns:ogr="http://ogr.maptools.org/"\n xmlns:gml="http://www.opengis.net/gml">\n <gml:boundedBy>\n <gml:Box>\n <gml:coord><gml:X>-1254041.389711702</gml:X><gml:Y>250906.9515983529</gml:Y></gml:coord>\n <gml:coord><gml:X>-634517.1199908922</gml:X><gml:Y>762236.2940800377</gml:Y></gml:coord>\n </gml:Box>\n </gml:boundedBy> \n <gml:featureMember>\n <ogr:states fid="F0">\n <ogr:geometryProperty><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-634517.11999089224,691849.77929356066,0 -653761.64509297756,471181.53429472551,0 -673343.60852865304,250906.9515983529,0 -1088825.734430399,299284.85108220269,0 -1254041.3897117018,324729.27754874947,0 -1235750.4212498858,434167.33911316615,0 -1190777.7803201093,704392.96327195223,0 -1181607.835811228,762236.29408003774,0 -634517.11999089224,691849.77929356066,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>\n <ogr:NAME>WY</ogr:NAME>\n <ogr:LONGNAME><![CDATA[Wyoming]]></ogr:LONGNAME>\n </ogr:states>\n </gml:featureMember>\n</ogr:FeatureCollection>\n',
|
||||
'<wfs:FeatureCollection' +
|
||||
' xmlns:fs="http://example.com/featureserver"' +
|
||||
' xmlns:wfs="http://www.opengis.net/wfs"' +
|
||||
|
||||
@@ -28,6 +28,15 @@
|
||||
"read geometry collection");
|
||||
}
|
||||
|
||||
function test_Format_KML_readCdataAttributes(t) {
|
||||
t.plan(2);
|
||||
var cdata = '<kml xmlns="http://earth.google.com/kml/2.0"><Document><Placemark><name><![CDATA[Pezinok]]></name><description><![CDATA[Full of text.]]></description><styleUrl>#rel1.0</styleUrl><Point> <coordinates>17.266666, 48.283333</coordinates></Point></Placemark></Document></kml>';
|
||||
var features = (new OpenLayers.Format.KML()).read(cdata);
|
||||
t.eq(features[0].attributes.description, "Full of text.", "Description attribute in cdata read correctly");
|
||||
t.eq(features[0].attributes.name, "Pezinok", "title attribute in cdata read correctly");
|
||||
|
||||
}
|
||||
|
||||
function test_Format_KML_write(t) {
|
||||
// make sure id, name, and description are preserved
|
||||
t.plan(1);
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
}
|
||||
|
||||
function test_Handler_Drag_callbacks(t) {
|
||||
t.plan(27);
|
||||
t.plan(33);
|
||||
|
||||
var map = new OpenLayers.Map('map', {controls: []});
|
||||
|
||||
@@ -115,10 +115,41 @@
|
||||
var handler = new OpenLayers.Handler.Drag(control, callbacks);
|
||||
handler.activate();
|
||||
|
||||
// test mousedown
|
||||
var oldIsLeftClick = OpenLayers.Event.isLeftClick;
|
||||
var oldStop = OpenLayers.Event.stop;
|
||||
var oldCheckModifiers = handler.checkModifiers;
|
||||
|
||||
// test mousedown with right click
|
||||
OpenLayers.Event.isLeftClick = function() {
|
||||
return false;
|
||||
}
|
||||
handler.checkModifiers = function() {
|
||||
return true;
|
||||
}
|
||||
handler.started = true;
|
||||
handler.start = {x: "foo", y: "bar"};
|
||||
handler.last = {x: "foo", y: "bar"};
|
||||
map.events.triggerEvent("mousedown", testEvents.down);
|
||||
t.ok(!handler.started, "right-click sets started to false");
|
||||
t.eq(handler.start, null, "right-click sets start to null");
|
||||
t.eq(handler.last, null, "right-click sets last to null");
|
||||
|
||||
// test mousedown with improper modifier
|
||||
OpenLayers.Event.isLeftClick = function() {
|
||||
return true;
|
||||
}
|
||||
handler.checkModifiers = function() {
|
||||
return false;
|
||||
}
|
||||
handler.started = true;
|
||||
handler.start = {x: "foo", y: "bar"};
|
||||
handler.last = {x: "foo", y: "bar"};
|
||||
map.events.triggerEvent("mousedown", testEvents.down);
|
||||
t.ok(!handler.started, "bad modifier sets started to false");
|
||||
t.eq(handler.start, null, "bad modifier sets start to null");
|
||||
t.eq(handler.last, null, "bad modifier sets last to null");
|
||||
|
||||
// test mousedown
|
||||
handler.checkModifiers = function(evt) {
|
||||
t.ok(evt.xy.x == testEvents.down.xy.x &&
|
||||
evt.xy.y == testEvents.down.xy.y,
|
||||
@@ -151,8 +182,9 @@
|
||||
t.ok(handler.last.x == testEvents.down.xy.x &&
|
||||
handler.last.y == testEvents.down.xy.y,
|
||||
"mouse down sets handler.last correctly");
|
||||
|
||||
OpenLayers.Event.stop = oldStop;
|
||||
OpenLayers.Event.isLeftClick = oldIsLeftClick;
|
||||
OpenLayers.Event.stop = oldStop;
|
||||
handler.checkModifiers = oldCheckModifiers;
|
||||
|
||||
// test mousemove
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
<li>Control/test_OverviewMap.html</li>
|
||||
<li>Control/test_NavToolbar.html</li>
|
||||
<li>Control/test_MouseToolbar.html</li>
|
||||
<li>Control/test_MousePosition.html</li>
|
||||
<li>Control/test_LayerSwitcher.html</li>
|
||||
<li>Control/test_Panel.html</li>
|
||||
<li>Control/test_PanZoom.html</li>
|
||||
|
||||
Reference in New Issue
Block a user