Making events easier to test.

This should make it more straightforward to test the new event properties being sent with loadend on BBOX and Fixed strategies (see #624).
This commit is contained in:
tschaub
2012-08-08 11:23:02 -06:00
parent 49227967bc
commit 4ae9f6878d
2 changed files with 29 additions and 29 deletions

View File

@@ -112,11 +112,9 @@
function test_events(t) {
t.plan(3);
var log = {
loadstart: 0,
loadend: 0
};
t.plan(5);
var log = [];
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector(null, {
@@ -128,27 +126,29 @@
}),
isBaseLayer: true,
eventListeners: {
loadstart: function() {
++log.loadstart;
loadstart: function(event) {
log.push(event);
},
loadend: function() {
++log.loadend;
loadend: function(event) {
log.push(event);
}
}
});
map.addLayer(layer);
map.zoomToMaxExtent();
t.eq(log.length, 2, "2 events logged");
t.eq(log[0].type, "loadstart", "loadstart first");
t.eq(log[1].type, "loadend", "loadend second");
t.eq(log.loadstart, 1, "loadstart triggered");
t.eq(log.loadend, 1, "loadend triggered");
log = {};
var calls = [];
layer.protocol.read = function(obj) {
log.obj = obj;
calls.push(obj);
}
layer.refresh({force: true, whee: 'chicken'});
t.eq(log.obj && log.obj.whee, "chicken", "properties passed to read on refresh correctly.");
t.eq(calls.length, 1, "1 call to read");
t.eq(calls[0].whee, "chicken", "properties passed to read");
map.destroy();

View File

@@ -62,12 +62,9 @@
function test_events(t) {
t.plan(3);
t.plan(5);
var log = {
loadstart: 0,
loadend: 0
};
var log = [];
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector(null, {
@@ -79,11 +76,11 @@
}),
isBaseLayer: true,
eventListeners: {
loadstart: function() {
++log.loadstart;
loadstart: function(event) {
log.push(event);
},
loadend: function() {
++log.loadend;
loadend: function(event) {
log.push(event);
}
}
});
@@ -91,15 +88,18 @@
map.addLayer(layer);
map.zoomToMaxExtent();
t.eq(log.loadstart, 1, "loadstart triggered");
t.eq(log.loadend, 1, "loadend triggered");
var log = {};
t.eq(log.length, 2, "2 events logged");
t.eq(log[0].type, "loadstart", "loadstart first");
t.eq(log[1].type, "loadend", "loadend second");
var calls = [];
layer.protocol.read = function(obj) {
log.obj = obj;
calls.push(obj);
}
layer.refresh({whee: 'chicken'});
t.eq(log.obj && log.obj.whee, "chicken", "properties passed to read on refresh correctly.");
t.eq(calls.length, 1, "1 call to read");
t.eq(calls[0].whee, "chicken", "properties passed to read");
map.destroy();