diff --git a/tests/test_Handler.html b/tests/test_Handler.html index 4b44dc10e0..1979ebee95 100644 --- a/tests/test_Handler.html +++ b/tests/test_Handler.html @@ -22,20 +22,87 @@ } function test_Handler_activate(t) { - t.plan(1); + t.plan(42); var map = new OpenLayers.Map('map'); var control = new OpenLayers.Control(); map.addControl(control); - var callbacks = {foo: "bar"}; - var handler = new OpenLayers.Handler(control, callbacks); + var events = ["mouseover", "mouseout", "mousedown", + "mouseup", "mousemove", "click", + "dblclick", "resize", "focus", "blur"]; + + var handler = new OpenLayers.Handler(control); handler.active = true; - t.ok(!handler.activate(), + var activated = handler.activate(); + t.ok(!activated, "activate returns false if the handler is already active"); + handler.active = false; + map.events.registerPriority = function(type, obj, func) { + t.ok(OpenLayers.Util.indexOf(events, type) > -1, + "activate calls registerPriority with browser event: " + type); + t.eq(typeof func, "function", + "activate calls registerPriority with a function"); + t.eq(func(), type, + "activate calls registerPriority with the correct method"); + t.eq(obj["CLASS_NAME"], "OpenLayers.Handler", + "activate calls registerPriority with the handler"); + } + + // set browser event like properties on the handler + for(var i=0; i -1, + "deactivate calls unregister with browser event: " + type); + t.eq(typeof func, "function", + "activate calls unregister with a function"); + t.eq(func(), type, + "activate calls unregister with the correct method"); + t.eq(obj["CLASS_NAME"], "OpenLayers.Handler", + "activate calls unregister with the handler"); + } + + // set browser event like properties on the handler + for(var i=0; i