Using real pixels in tests so we get distanceTo method.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11558 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+15
-10
@@ -2,6 +2,11 @@
|
|||||||
<head>
|
<head>
|
||||||
<script src="../OLLoader.js"></script>
|
<script src="../OLLoader.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function px(x, y) {
|
||||||
|
return new OpenLayers.Pixel(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
function test_Handler_Click_constructor(t) {
|
function test_Handler_Click_constructor(t) {
|
||||||
t.plan(3);
|
t.plan(3);
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
@@ -155,7 +160,7 @@
|
|||||||
map.events.triggerEvent("dblclick", testEvt);
|
map.events.triggerEvent("dblclick", testEvt);
|
||||||
|
|
||||||
// set up for double click with double true - one test here
|
// set up for double click with double true - one test here
|
||||||
handler.double = true;
|
handler["double"] = true;
|
||||||
handler.callbacks = {
|
handler.callbacks = {
|
||||||
"click": function(evt) {
|
"click": function(evt) {
|
||||||
t.fail("(dblclick w/ double true) click should not be called here");
|
t.fail("(dblclick w/ double true) click should not be called here");
|
||||||
@@ -169,7 +174,7 @@
|
|||||||
map.events.triggerEvent("dblclick", testEvt);
|
map.events.triggerEvent("dblclick", testEvt);
|
||||||
|
|
||||||
// set up for two clicks with double true - 6 tests here (with timeout ones from above)
|
// set up for two clicks with double true - 6 tests here (with timeout ones from above)
|
||||||
handler.double = true;
|
handler["double"] = true;
|
||||||
handler.callbacks = {
|
handler.callbacks = {
|
||||||
"click": function(evt) {
|
"click": function(evt) {
|
||||||
t.ok(evt != null, "(two clicks w/ double true) click will not be called here if next three tests pass");
|
t.ok(evt != null, "(two clicks w/ double true) click will not be called here if next three tests pass");
|
||||||
@@ -195,11 +200,11 @@
|
|||||||
});
|
});
|
||||||
handler.activate();
|
handler.activate();
|
||||||
var downEvt = {
|
var downEvt = {
|
||||||
xy: new OpenLayers.Pixel(0, 0)
|
xy: px(0, 0)
|
||||||
};
|
};
|
||||||
map.events.triggerEvent("mousedown", downEvt);
|
map.events.triggerEvent("mousedown", downEvt);
|
||||||
var clickEvt = {
|
var clickEvt = {
|
||||||
xy: new OpenLayers.Pixel(0, 1)
|
xy: px(0, 1)
|
||||||
};
|
};
|
||||||
// mouse moves one pixel, click should be called
|
// mouse moves one pixel, click should be called
|
||||||
handler.callbacks = {
|
handler.callbacks = {
|
||||||
@@ -213,7 +218,7 @@
|
|||||||
// mouse moves 3x3 pixels, click should not be called
|
// mouse moves 3x3 pixels, click should not be called
|
||||||
map.events.triggerEvent("mousedown", downEvt);
|
map.events.triggerEvent("mousedown", downEvt);
|
||||||
var clickEvt = {
|
var clickEvt = {
|
||||||
xy: new OpenLayers.Pixel(3, 3)
|
xy: px(3, 3)
|
||||||
};
|
};
|
||||||
// mouse moves one pixel, click should be called
|
// mouse moves one pixel, click should be called
|
||||||
handler.callbacks = {
|
handler.callbacks = {
|
||||||
@@ -315,7 +320,7 @@
|
|||||||
// test
|
// test
|
||||||
|
|
||||||
log = null;
|
log = null;
|
||||||
handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
|
handler.touchstart({xy: px(1, 1), touches: ["foo"]});
|
||||||
handler.touchend({touches: ["foo"]});
|
handler.touchend({touches: ["foo"]});
|
||||||
|
|
||||||
t.delay_call(1, function() {
|
t.delay_call(1, function() {
|
||||||
@@ -354,9 +359,9 @@
|
|||||||
// test
|
// test
|
||||||
|
|
||||||
log = {};
|
log = {};
|
||||||
handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
|
handler.touchstart({xy: px(1, 1), touches: ["foo"]});
|
||||||
handler.touchend({});
|
handler.touchend({});
|
||||||
handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
|
handler.touchstart({xy: px(1, 1), touches: ["foo"]});
|
||||||
handler.touchend({type: "click"});
|
handler.touchend({type: "click"});
|
||||||
|
|
||||||
t.eq(!!handler.down.touches, true, "Handler down touches property should be truthy");
|
t.eq(!!handler.down.touches, true, "Handler down touches property should be truthy");
|
||||||
@@ -395,9 +400,9 @@
|
|||||||
// test
|
// test
|
||||||
|
|
||||||
log = {};
|
log = {};
|
||||||
handler.touchstart({xy: {x: 1, y: 1}, touches: [{clientX:0, clientY:10}]});
|
handler.touchstart({xy: px(1, 1), touches: [{clientX:0, clientY:10}]});
|
||||||
handler.touchend({});
|
handler.touchend({});
|
||||||
handler.touchstart({xy: {x: 1, y: 1}, touches: [{clientX:0, clientY:10}]});
|
handler.touchstart({xy: px(1, 1), touches: [{clientX:0, clientY:10}]});
|
||||||
handler.touchend({});
|
handler.touchend({});
|
||||||
|
|
||||||
t.eq(log.click, undefined, "click callback not called");
|
t.eq(log.click, undefined, "click callback not called");
|
||||||
|
|||||||
Reference in New Issue
Block a user