diff options
Diffstat (limited to 'LayoutTests/fast/events')
6 files changed, 371 insertions, 0 deletions
diff --git a/LayoutTests/fast/events/touch/basic-multi-touch-events-limited-expected.txt b/LayoutTests/fast/events/touch/basic-multi-touch-events-limited-expected.txt new file mode 100644 index 0000000..1e603fb --- /dev/null +++ b/LayoutTests/fast/events/touch/basic-multi-touch-events-limited-expected.txt @@ -0,0 +1,97 @@ +This tests basic multi touch event support. This is a limited version of test basic-multi-touch-events.html that avoids the situation where one touch point is released while another is maintained. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS lastEvent.type is "touchstart" +PASS lastEvent.touches.length is 2 +PASS lastEvent.changedTouches.length is 2 +PASS lastEvent.targetTouches.length is 2 +PASS lastEvent.pageX is 0 +PASS lastEvent.pageY is 0 +PASS lastEvent.touches[0].pageX is 10 +PASS lastEvent.touches[0].pageY is 10 +PASS lastEvent.touches[0].clientX is 10 +PASS lastEvent.touches[0].clientY is 10 +PASS lastEvent.touches[0].identifier is 0 +PASS lastEvent.touches[1].pageX is 20 +PASS lastEvent.touches[1].pageY is 30 +PASS lastEvent.touches[1].clientX is 20 +PASS lastEvent.touches[1].clientY is 30 +PASS lastEvent.touches[1].identifier is 1 +PASS lastEvent.changedTouches[0].pageX is 10 +PASS lastEvent.changedTouches[0].pageY is 10 +PASS lastEvent.changedTouches[0].clientX is 10 +PASS lastEvent.changedTouches[0].clientY is 10 +PASS lastEvent.changedTouches[0].identifier is 0 +PASS lastEvent.changedTouches[1].pageX is 20 +PASS lastEvent.changedTouches[1].pageY is 30 +PASS lastEvent.changedTouches[1].clientX is 20 +PASS lastEvent.changedTouches[1].clientY is 30 +PASS lastEvent.changedTouches[1].identifier is 1 +PASS lastEvent.targetTouches[0].pageX is 10 +PASS lastEvent.targetTouches[0].pageY is 10 +PASS lastEvent.targetTouches[0].clientX is 10 +PASS lastEvent.targetTouches[0].clientY is 10 +PASS lastEvent.targetTouches[0].identifier is 0 +PASS lastEvent.targetTouches[1].pageX is 20 +PASS lastEvent.targetTouches[1].pageY is 30 +PASS lastEvent.targetTouches[1].clientX is 20 +PASS lastEvent.targetTouches[1].clientY is 30 +PASS lastEvent.targetTouches[1].identifier is 1 +PASS lastEvent.type is "touchmove" +PASS lastEvent.touches.length is 2 +PASS lastEvent.changedTouches.length is 2 +PASS lastEvent.targetTouches.length is 2 +PASS lastEvent.pageX is 0 +PASS lastEvent.pageY is 0 +PASS lastEvent.touches[0].pageX is 15 +PASS lastEvent.touches[0].pageY is 15 +PASS lastEvent.touches[0].clientX is 15 +PASS lastEvent.touches[0].clientY is 15 +PASS lastEvent.touches[0].identifier is 0 +PASS lastEvent.touches[1].pageX is 25 +PASS lastEvent.touches[1].pageY is 35 +PASS lastEvent.touches[1].clientX is 25 +PASS lastEvent.touches[1].clientY is 35 +PASS lastEvent.touches[1].identifier is 1 +PASS lastEvent.changedTouches[0].pageX is 15 +PASS lastEvent.changedTouches[0].pageY is 15 +PASS lastEvent.changedTouches[0].clientX is 15 +PASS lastEvent.changedTouches[0].clientY is 15 +PASS lastEvent.changedTouches[0].identifier is 0 +PASS lastEvent.changedTouches[1].pageX is 25 +PASS lastEvent.changedTouches[1].pageY is 35 +PASS lastEvent.changedTouches[1].clientX is 25 +PASS lastEvent.changedTouches[1].clientY is 35 +PASS lastEvent.changedTouches[1].identifier is 1 +PASS lastEvent.targetTouches[0].pageX is 15 +PASS lastEvent.targetTouches[0].pageY is 15 +PASS lastEvent.targetTouches[0].clientX is 15 +PASS lastEvent.targetTouches[0].clientY is 15 +PASS lastEvent.targetTouches[0].identifier is 0 +PASS lastEvent.targetTouches[1].pageX is 25 +PASS lastEvent.targetTouches[1].pageY is 35 +PASS lastEvent.targetTouches[1].clientX is 25 +PASS lastEvent.targetTouches[1].clientY is 35 +PASS lastEvent.targetTouches[1].identifier is 1 +PASS lastEvent.type is "touchend" +PASS lastEvent.touches.length is 0 +PASS lastEvent.changedTouches.length is 2 +PASS lastEvent.targetTouches.length is 0 +PASS lastEvent.pageX is 0 +PASS lastEvent.pageY is 0 +PASS lastEvent.changedTouches[0].pageX is 15 +PASS lastEvent.changedTouches[0].pageY is 15 +PASS lastEvent.changedTouches[0].clientX is 15 +PASS lastEvent.changedTouches[0].clientY is 15 +PASS lastEvent.changedTouches[0].identifier is 0 +PASS lastEvent.changedTouches[1].pageX is 25 +PASS lastEvent.changedTouches[1].pageY is 35 +PASS lastEvent.changedTouches[1].clientX is 25 +PASS lastEvent.changedTouches[1].clientY is 35 +PASS lastEvent.changedTouches[1].identifier is 1 +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/events/touch/basic-multi-touch-events-limited.html b/LayoutTests/fast/events/touch/basic-multi-touch-events-limited.html new file mode 100644 index 0000000..7ba39a8 --- /dev/null +++ b/LayoutTests/fast/events/touch/basic-multi-touch-events-limited.html @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +<script src="../../js/resources/js-test-post-function.js"></script> +<!-- + Touch tests that involve the ontouchstart, ontouchmove, ontouchend or ontouchcancel callbacks + should be written in an asynchronous fashion so they can be run on mobile platforms like Android. + This template will generate an asynchronous style test by using the js-test-post-function script. + You will need to invoke isSuccessfullyParsed() in your test script when the test completes. +--> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="script-tests/basic-multi-touch-events-limited.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/events/touch/script-tests/basic-multi-touch-events-limited.js b/LayoutTests/fast/events/touch/script-tests/basic-multi-touch-events-limited.js new file mode 100644 index 0000000..c807ae5 --- /dev/null +++ b/LayoutTests/fast/events/touch/script-tests/basic-multi-touch-events-limited.js @@ -0,0 +1,108 @@ +var div = document.createElement("div"); +div.id = "touchtarget"; +div.style.width = "100px"; +div.style.height = "100px"; +div.style.backgroundColor = "blue"; + +var lastEvent = null; +var touchEventsReceived = 0; +var EXPECTED_TOUCH_EVENTS_TOTAL = 3; + +function touchEventCallback() { + if (window.eventSender) { + lastEvent = event; + verifyTouch(touchEventsReceived++); + } else { + debug(event.type); + } + + if (window.layoutTestController && touchEventsReceived == EXPECTED_TOUCH_EVENTS_TOTAL) { + // If we've got here, we can safely say we were successfully parsed :) We need to + // call the isSucccessfullyParsed function to output the correct TEST COMPLETE + // footer message. + successfullyParsed = true; + isSuccessfullyParsed(); + layoutTestController.notifyDone(); + } +} + +div.addEventListener("touchstart", touchEventCallback, false); +div.addEventListener("touchmove", touchEventCallback, false); +div.addEventListener("touchend", touchEventCallback, false); +document.body.insertBefore(div, document.body.firstChild); + +function verifyTouchEvent(type, totalTouchCount, changedTouchCount, targetTouchCount) +{ + shouldBeEqualToString("lastEvent.type", type); + shouldBe("lastEvent.touches.length", totalTouchCount.toString()); + shouldBe("lastEvent.changedTouches.length", changedTouchCount.toString()); + shouldBe("lastEvent.targetTouches.length", targetTouchCount.toString()); + shouldBe("lastEvent.pageX", "0"); + shouldBe("lastEvent.pageY", "0"); +} + +function verifyTouchPoint(list, point, x, y, id) +{ + shouldBe("lastEvent." + list + "[" + point + "].pageX", x.toString()); + shouldBe("lastEvent." + list + "[" + point + "].pageY", y.toString()); + shouldBe("lastEvent." + list + "[" + point + "].clientX", x.toString()); + shouldBe("lastEvent." + list + "[" + point + "].clientY", y.toString()); + shouldBe("lastEvent." + list + "[" + point + "].identifier", id.toString()); +} + +function verifyTouch(which) { + switch (which) { + case 0: + verifyTouchEvent("touchstart", 2, 2, 2); + verifyTouchPoint("touches", 0, 10, 10, 0); + verifyTouchPoint("touches", 1, 20, 30, 1); + verifyTouchPoint("changedTouches", 0, 10, 10, 0); + verifyTouchPoint("changedTouches", 1, 20, 30, 1); + verifyTouchPoint("targetTouches", 0, 10, 10, 0); + verifyTouchPoint("targetTouches", 1, 20, 30, 1); + break; + case 1: + verifyTouchEvent("touchmove", 2, 2, 2); + verifyTouchPoint("touches", 0, 15, 15, 0); + verifyTouchPoint("touches", 1, 25, 35, 1); + verifyTouchPoint("changedTouches", 0, 15, 15, 0); + verifyTouchPoint("changedTouches", 1, 25, 35, 1); + verifyTouchPoint("targetTouches", 0, 15, 15, 0); + verifyTouchPoint("targetTouches", 1, 25, 35, 1); + break; + case 2: + verifyTouchEvent("touchend", 0, 2, 0); + verifyTouchPoint("changedTouches", 0, 15, 15, 0); + verifyTouchPoint("changedTouches", 1, 25, 35, 1); + break; + + default: testFailed("Wrong number of touch events! (" + which + ")"); + } +} + +function multiTouchSequence() +{ + eventSender.addTouchPoint(10, 10); + eventSender.addTouchPoint(20, 30); + eventSender.touchStart(); + + eventSender.updateTouchPoint(0, 15, 15); + eventSender.updateTouchPoint(1, 25, 35); + eventSender.touchMove(); + + eventSender.releaseTouchPoint(0); + eventSender.releaseTouchPoint(1); + eventSender.touchEnd(); +} + +if (window.eventSender) { + description("This tests basic multi touch event support. This is a limited version of test basic-multi-touch-events.html that avoids the situation where one touch point is released while another is maintained."); + + lastEvent = null; + eventSender.clearTouchPoints(); + multiTouchSequence(); +} else { + debug("This test requires DumpRenderTree. Tap on the blue rect to log.") +} + +var successfullyParsed = true; diff --git a/LayoutTests/fast/events/touch/script-tests/touch-target-limited.js b/LayoutTests/fast/events/touch/script-tests/touch-target-limited.js new file mode 100644 index 0000000..fd3400c --- /dev/null +++ b/LayoutTests/fast/events/touch/script-tests/touch-target-limited.js @@ -0,0 +1,103 @@ +var targetsDiv = document.createElement("div"); +targetsDiv.id = "targetsDiv"; + +var div1 = document.createElement("div"); +div1.id = "targetA"; +div1.style.width = "100px"; +div1.style.height = "100px"; +div1.style.backgroundColor = "blue"; + +var div2 = document.createElement("div"); +div2.id = "targetB"; +div2.style.width = "100px"; +div2.style.height = "100px"; +div2.style.backgroundColor = "green"; + +var touchStartCount = 0; +var touchMoveCount = 0; + +document.body.insertBefore(targetsDiv, document.getElementById('console')); +targetsDiv.appendChild(div1); +targetsDiv.appendChild(document.createElement('br')); +targetsDiv.appendChild(div2); + +function touchStartHandler() +{ + shouldBeEqualToString('event.type', 'touchstart'); + switch (touchStartCount) { + case 0: + shouldBeEqualToString('event.touches[0].target.id', div1.id); + shouldBeEqualToString('event.touches[1].target.id', div2.id); + break; + case 1: + shouldBeEqualToString('event.touches[0].target.id', div2.id); + shouldBeEqualToString('event.touches[1].target.id', div1.id); + break; + } + + touchStartCount++; +} + +function touchMoveHandler() +{ + shouldBeEqualToString('event.type', 'touchmove'); + switch (touchMoveCount) { + case 0: + case 1: + shouldBeEqualToString('event.touches[0].target.id', div1.id); + shouldBeEqualToString('event.touches[1].target.id', div2.id); + break; + case 2: + shouldBeEqualToString('event.touches[0].target.id', div2.id); + shouldBeEqualToString('event.touches[1].target.id', div1.id); + break; + } + + if (++touchMoveCount == 3) + { + successfullyParsed = true; + layoutTestController.notifyDone(); + isSuccessfullyParsed(); + } +} + +div1.addEventListener("touchstart", touchStartHandler, false); +div1.addEventListener("touchmove", touchMoveHandler, false); + +div2.addEventListener("touchstart", touchStartHandler, false); +div2.addEventListener("touchmove", touchMoveHandler, false); + +description("Tests that the target of touches match the element where the event originated, not where the touch is currently occurring. This is a limited version of test touch-target.html that avoids the situation where one touch point is released while another is maintained."); + +if (window.layoutTestController) { + layoutTestController.waitUntilDone(); +} + +if (window.eventSender) { + eventSender.clearTouchPoints(); + eventSender.addTouchPoint(50, 150); + eventSender.addTouchPoint(50, 250); + eventSender.touchStart(); + + eventSender.updateTouchPoint(0, 50, 250); + eventSender.updateTouchPoint(1, 50, 150); + eventSender.touchMove(); + + eventSender.updateTouchPoint(0, 1000, 1000); + eventSender.updateTouchPoint(1, 1000, 1000); + eventSender.touchMove(); + + eventSender.releaseTouchPoint(0); + eventSender.releaseTouchPoint(1); + eventSender.touchEnd(); + + eventSender.addTouchPoint(50, 250); + eventSender.addTouchPoint(50, 150); + eventSender.touchStart(); + + eventSender.updateTouchPoint(0, 500, 500); + eventSender.updateTouchPoint(1, 500, 500); + eventSender.touchMove(); +} else + debug('This test requires DRT.'); + diff --git a/LayoutTests/fast/events/touch/touch-target-limited-expected.txt b/LayoutTests/fast/events/touch/touch-target-limited-expected.txt new file mode 100644 index 0000000..0c1efd0 --- /dev/null +++ b/LayoutTests/fast/events/touch/touch-target-limited-expected.txt @@ -0,0 +1,25 @@ +Tests that the target of touches match the element where the event originated, not where the touch is currently occurring. This is a limited version of test touch-target.html that avoids the situation where one touch point is released while another is maintained. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + + +PASS event.type is "touchstart" +PASS event.touches[0].target.id is "targetA" +PASS event.touches[1].target.id is "targetB" +PASS event.type is "touchmove" +PASS event.touches[0].target.id is "targetA" +PASS event.touches[1].target.id is "targetB" +PASS event.type is "touchmove" +PASS event.touches[0].target.id is "targetA" +PASS event.touches[1].target.id is "targetB" +PASS event.type is "touchstart" +PASS event.touches[0].target.id is "targetB" +PASS event.touches[1].target.id is "targetA" +PASS event.type is "touchmove" +PASS event.touches[0].target.id is "targetB" +PASS event.touches[1].target.id is "targetA" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/events/touch/touch-target-limited.html b/LayoutTests/fast/events/touch/touch-target-limited.html new file mode 100644 index 0000000..f903842 --- /dev/null +++ b/LayoutTests/fast/events/touch/touch-target-limited.html @@ -0,0 +1,19 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +<script src="../../js/resources/js-test-post-function.js"></script> +<!-- + Touch tests that involve the ontouchstart, ontouchmove, ontouchend or ontouchcancel callbacks + should be written in an asynchronous fashion so they can be run on mobile platforms like Android. + This template will generate an asynchronous style test by using the js-test-post-function script. + You will need to invoke isSuccessfullyParsed() in your test script when the test completes. +--> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="script-tests/touch-target-limited.js"></script> +</body> +</html> |