Making the canvas renderer keep track of a pending redraw. With this change we properly redraw even if the last feature in a batch has no geometry. p=me,ahocevar r=ahocevar (closes #3225)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11860 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2011-04-03 05:04:17 +00:00
parent 62dd64c1c9
commit cf311ee532
2 changed files with 76 additions and 4 deletions

View File

@@ -150,6 +150,68 @@
t.eq(r.resolution, null, "resolution nullified");
t.eq(r.map, null, "map nullified");
}
function test_pendingRedraw(t) {
if (!supported) {
t.plan(0);
return;
}
t.plan(4);
var layer = new OpenLayers.Layer.Vector(null, {
isBaseLayer: true,
renderers: ["Canvas"]
});
var map = new OpenLayers.Map({
div: "map",
controls: [],
layers: [layer],
center: new OpenLayers.LonLat(0, 0),
zoom: 0
});
var count = 0;
var redraw = layer.renderer.redraw;
layer.renderer.redraw = function() {
++count;
redraw.apply(this, arguments);
}
// add one point feature and confirm redraw is called once
count = 0;
layer.addFeatures([
new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 0))
]);
t.eq(count, 1, "redraw called once after adding one point feature");
// add one feature with no geometry and confirm redraw is not called
count = 0;
layer.addFeatures([
new OpenLayers.Feature.Vector()
]);
t.eq(count, 0, "redraw is not called when adding a feature with no geometry");
// add one point feature, one feature with no geom, and one point feature and confirm redraw is called once
count = 0;
layer.addFeatures([
new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(1, 0)),
new OpenLayers.Feature.Vector(),
new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 1))
]);
t.eq(count, 1, "redraw called once after adding three features where middle one has no geometry");
// add two point features and one feature with no geom, and confirm redraw is called once
count = 0;
layer.addFeatures([
new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(1, 0)),
new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(0, 1)),
new OpenLayers.Feature.Vector()
]);
t.eq(count, 1, "redraw called once after adding three features where last one has no geometry");
map.destroy();
}
function test_hitDetection(t) {
if (!supported) {