Commit e757880f authored by benm@google.com's avatar benm@google.com
Browse files

Refactor and split up basic-touch-events test

https://bugs.webkit.org/show_bug.cgi?id=34476

Reviewed by Simon Hausmann.

Split the basic-touch-events test into two separate tests, one for single and another for multi touch. Also refactor the tests to run in an asynchronous manner.

* fast/events/touch/basic-multi-touch-events.html: Copied from LayoutTests/fast/events/touch/basic-touch-events.html. Tests the same multi touch tests cases from the old basic-touch-events test.
* fast/events/touch/basic-multi-touch-events-expected.txt: Added.
* fast/events/touch/script-tests/basic-multi-touch-events.js: Added.
* fast/events/touch/basic-single-touch-events.html: Copied from LayoutTests/fast/events/touch/basic-touch-events.html. Tests the same single touch tests cases from the old basic-touch-events test.
* fast/events/touch/script-tests/basic-single-touch-events.js: Added.
* fast/events/touch/basic-single-touch-events-expected.txt: Added. 
* fast/events/touch/basic-touch-events.html: Removed.
* fast/events/touch/script-tests/basic-touch-events.js: Removed.
* fast/events/touch/basic-touch-events-expected.txt: Removed.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54817 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9fbb6c25
2010-02-16 Ben Murdoch <benm@google.com>
Reviewed by Simon Hausmann.
Refactor and split up basic-touch-events test
https://bugs.webkit.org/show_bug.cgi?id=34476
Split the basic-touch-events test into two separate tests, one for single and another for multi touch. Also refactor the tests to run in an asynchronous manner.
* fast/events/touch/basic-multi-touch-events.html: Copied from LayoutTests/fast/events/touch/basic-touch-events.html. Tests the same multi touch tests cases from the old basic-touch-events test.
* fast/events/touch/basic-multi-touch-events-expected.txt: Added.
* fast/events/touch/script-tests/basic-multi-touch-events.js: Added.
* fast/events/touch/basic-single-touch-events.html: Copied from LayoutTests/fast/events/touch/basic-touch-events.html. Tests the same single touch tests cases from the old basic-touch-events test.
* fast/events/touch/script-tests/basic-single-touch-events.js: Added.
* fast/events/touch/basic-single-touch-events-expected.txt: Added.
* fast/events/touch/basic-touch-events.html: Removed.
* fast/events/touch/script-tests/basic-touch-events.js: Removed.
* fast/events/touch/basic-touch-events-expected.txt: Removed.
2010-02-15 Dan Bernstein <mitz@apple.com>
Reviewed by Simon Fraser.
......
This tests basic touch event support.
single touch sequence
PASS lastEvent.type is "touchstart"
PASS lastEvent.touches.length is 1
PASS lastEvent.changedTouches.length is 1
PASS lastEvent.targetTouches.length is 1
PASS lastEvent.shiftKey is false
PASS lastEvent.touches[0].target.id is "touchtarget"
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.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.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.type is "touchmove"
PASS lastEvent.touches.length is 1
PASS lastEvent.changedTouches.length is 1
PASS lastEvent.targetTouches.length is 1
PASS lastEvent.touches[0].pageX is 20
PASS lastEvent.touches[0].pageY is 15
PASS lastEvent.touches[0].clientX is 20
PASS lastEvent.touches[0].clientY is 15
PASS lastEvent.touches[0].identifier is 0
PASS lastEvent.shiftKey is true
PASS lastEvent.altKey is true
PASS lastEvent.ctrlKey is false
PASS lastEvent.metaKey is false
PASS lastEvent.type is "touchend"
PASS lastEvent.touches.length is 0
PASS lastEvent.changedTouches.length is 1
PASS lastEvent.targetTouches.length is 0
PASS lastEvent.changedTouches[0].pageX is 20
PASS lastEvent.changedTouches[0].pageY is 15
PASS lastEvent.changedTouches[0].clientX is 20
PASS lastEvent.changedTouches[0].clientY is 15
PASS lastEvent.changedTouches[0].identifier is 0
PASS lastEvent.shiftKey is false
PASS lastEvent.altKey is false
This tests basic multi touch event support.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
multi touch sequence
Two touchpoints pressed
PASS lastEvent.type is "touchstart"
......@@ -131,17 +89,6 @@ PASS lastEvent.changedTouches[0].pageY is 30
PASS lastEvent.changedTouches[0].clientX is 20
PASS lastEvent.changedTouches[0].clientY is 30
PASS lastEvent.changedTouches[0].identifier is 1
verify touch targets
PASS lastEvent.type is "touchstart"
PASS lastEvent.touches.length is 1
PASS lastEvent.changedTouches.length is 1
PASS lastEvent.targetTouches.length is 1
PASS lastEvent.targetTouches[0].target.tagName is "DIV"
PASS lastEvent.type is "touchmove"
PASS lastEvent.touches.length is 1
PASS lastEvent.changedTouches.length is 1
PASS lastEvent.targetTouches.length is 0
PASS lastEvent.touches[0].target.tagName is "HTML"
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,11 +3,12 @@
<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>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/basic-touch-events.js"></script>
<script src="../../js/resources/js-test-post.js"></script>
<script src="script-tests/basic-multi-touch-events.js"></script>
</body>
</html>
This tests basic single touch event support.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS lastEvent.type is "touchstart"
PASS lastEvent.touches.length is 1
PASS lastEvent.changedTouches.length is 1
PASS lastEvent.targetTouches.length is 1
PASS lastEvent.shiftKey is false
PASS lastEvent.touches[0].target.id is "touchtarget"
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.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.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.type is "touchmove"
PASS lastEvent.touches.length is 1
PASS lastEvent.changedTouches.length is 1
PASS lastEvent.targetTouches.length is 1
PASS lastEvent.touches[0].pageX is 20
PASS lastEvent.touches[0].pageY is 15
PASS lastEvent.touches[0].clientX is 20
PASS lastEvent.touches[0].clientY is 15
PASS lastEvent.touches[0].identifier is 0
PASS lastEvent.shiftKey is true
PASS lastEvent.altKey is true
PASS lastEvent.ctrlKey is false
PASS lastEvent.metaKey is false
PASS lastEvent.type is "touchend"
PASS lastEvent.touches.length is 0
PASS lastEvent.changedTouches.length is 1
PASS lastEvent.targetTouches.length is 0
PASS lastEvent.changedTouches[0].pageX is 20
PASS lastEvent.changedTouches[0].pageY is 15
PASS lastEvent.changedTouches[0].clientX is 20
PASS lastEvent.changedTouches[0].clientY is 15
PASS lastEvent.changedTouches[0].identifier is 0
PASS lastEvent.shiftKey is false
PASS lastEvent.altKey is false
PASS lastEvent.type is "touchstart"
PASS lastEvent.touches.length is 1
PASS lastEvent.changedTouches.length is 1
PASS lastEvent.targetTouches.length is 1
PASS lastEvent.targetTouches[0].target.tagName is "DIV"
PASS lastEvent.type is "touchmove"
PASS lastEvent.touches.length is 1
PASS lastEvent.changedTouches.length is 1
PASS lastEvent.targetTouches.length is 0
PASS lastEvent.touches[0].target.tagName is "HTML"
PASS successfullyParsed is true
TEST COMPLETE
<!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>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/basic-single-touch-events.js"></script>
</body>
</html>
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 = 4;
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());
}
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, 1, 2);
verifyTouchPoint("touches", 0, 15, 15, 0);
verifyTouchPoint("changedTouches", 0, 15, 15, 0);
verifyTouchPoint("touches", 1, 20, 30, 1);
break;
case 2:
verifyTouchEvent("touchend", 1, 1, 1);
verifyTouchPoint("touches", 0, 20, 30, 1);
verifyTouchPoint("changedTouches", 0, 15, 15, 0);
verifyTouchPoint("targetTouches", 0, 20, 30, 1);
break;
case 3:
verifyTouchEvent("touchend", 0, 1, 0);
verifyTouchPoint("changedTouches", 0, 20, 30, 1);
break;
default: testFailed("Wrong number of touch events! (" + which + ")");
}
}
function multiTouchSequence()
{
debug("multi touch sequence");
debug("Two touchpoints pressed");
eventSender.addTouchPoint(10, 10);
eventSender.addTouchPoint(20, 30);
eventSender.touchStart();
debug("First touchpoint moved");
eventSender.updateTouchPoint(0, 15, 15);
eventSender.touchMove();
debug("First touchpoint is released");
eventSender.releaseTouchPoint(0);
eventSender.touchEnd();
debug("Last remaining touchpoint is released");
eventSender.releaseTouchPoint(0);
eventSender.touchEnd();
}
if (window.eventSender) {
description("This tests basic multi touch event support.");
lastEvent = null;
eventSender.clearTouchPoints();
multiTouchSequence();
} else {
debug("This test requires DumpRenderTree. Tap on the blue rect to log.")
}
var successfullyParsed = true;
description = "This tests basic touch event support.";
var div = document.createElement("div");
div.id = "touchtarget";
div.style.width = "100px";
......@@ -7,18 +5,30 @@ div.style.height = "100px";
div.style.backgroundColor = "blue";
var lastEvent = null;
var touchEventsReceived = 0;
var EXPECTED_TOUCH_EVENTS_TOTAL = 5;
function appendEventLog() {
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", appendEventLog, false);
div.addEventListener("touchmove", appendEventLog, false);
div.addEventListener("touchend", appendEventLog, false);
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)
......@@ -38,111 +48,79 @@ function verifyTouchPoint(list, point, x, y, id)
shouldBe("lastEvent." + list + "[" + point + "].identifier", id.toString());
}
function verifyTouch(which) {
switch (which) {
case 0:
verifyTouchEvent("touchstart", 1, 1, 1);
shouldBe("lastEvent.shiftKey", "false");
shouldBeEqualToString("lastEvent.touches[0].target.id", "touchtarget");
verifyTouchPoint("touches", 0, 10, 10, 0);
verifyTouchPoint("changedTouches", 0, 10, 10, 0);
verifyTouchPoint("targetTouches", 0, 10, 10, 0);
break;
case 1:
verifyTouchEvent("touchmove", 1, 1, 1);
verifyTouchPoint("touches", 0, 20, 15, 0);
shouldBe("lastEvent.shiftKey", "true");
shouldBe("lastEvent.altKey", "true");
shouldBe("lastEvent.ctrlKey", "false");
shouldBe("lastEvent.metaKey", "false");
break;
case 2:
verifyTouchEvent("touchend", 0, 1, 0);
verifyTouchPoint("changedTouches", 0, 20, 15, 0);
shouldBe("lastEvent.shiftKey", "false");
shouldBe("lastEvent.altKey", "false");
break;
case 3:
verifyTouchEvent("touchstart", 1, 1, 1);
shouldBeEqualToString("lastEvent.targetTouches[0].target.tagName", "DIV");
break;
case 4:
verifyTouchEvent("touchmove", 1, 1, 0);
shouldBeEqualToString("lastEvent.touches[0].target.tagName", "HTML");
break;
default: testFailed("Wrong number of touch events! (" + which + ")");
}
}
function singleTouchSequence()
{
debug("single touch sequence");
eventSender.addTouchPoint(10, 10);
eventSender.touchStart();
verifyTouchEvent("touchstart", 1, 1, 1);
shouldBe("lastEvent.shiftKey", "false");
shouldBeEqualToString("lastEvent.touches[0].target.id", "touchtarget");
verifyTouchPoint("touches", 0, 10, 10, 0);
verifyTouchPoint("changedTouches", 0, 10, 10, 0);
verifyTouchPoint("targetTouches", 0, 10, 10, 0);
eventSender.updateTouchPoint(0, 20, 15);
eventSender.setTouchModifier("shift", true);
eventSender.setTouchModifier("alt", true);
eventSender.touchMove();
verifyTouchEvent("touchmove", 1, 1, 1);
verifyTouchPoint("touches", 0, 20, 15, 0);
shouldBe("lastEvent.shiftKey", "true");
shouldBe("lastEvent.altKey", "true");
shouldBe("lastEvent.ctrlKey", "false");
shouldBe("lastEvent.metaKey", "false");
eventSender.setTouchModifier("shift", false);
eventSender.setTouchModifier("alt", false);
eventSender.releaseTouchPoint(0);
eventSender.touchEnd();
verifyTouchEvent("touchend", 0, 1, 0);
verifyTouchPoint("changedTouches", 0, 20, 15, 0);
shouldBe("lastEvent.shiftKey", "false");
shouldBe("lastEvent.altKey", "false");
}
function multiTouchSequence()
{
debug("multi touch sequence");
debug("Two touchpoints pressed");
eventSender.addTouchPoint(10, 10);
eventSender.addTouchPoint(20, 30);
eventSender.touchStart();
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);
debug("First touchpoint moved");
eventSender.updateTouchPoint(0, 15, 15);
eventSender.touchMove();
verifyTouchEvent("touchmove", 2, 1, 2);
verifyTouchPoint("touches", 0, 15, 15, 0);
verifyTouchPoint("changedTouches", 0, 15, 15, 0);
verifyTouchPoint("touches", 1, 20, 30, 1);
debug("First touchpoint is released");
eventSender.releaseTouchPoint(0);
eventSender.touchEnd();
verifyTouchEvent("touchend", 1, 1, 1);
verifyTouchPoint("touches", 0, 20, 30, 1);
verifyTouchPoint("changedTouches", 0, 15, 15, 0);
verifyTouchPoint("targetTouches", 0, 20, 30, 1);
debug("Last remaining touchpoint is released");
eventSender.releaseTouchPoint(0);
eventSender.touchEnd();
verifyTouchEvent("touchend", 0, 1, 0);
verifyTouchPoint("changedTouches", 0, 20, 30, 1);
}
function touchTargets()
{
debug("verify touch targets");
eventSender.addTouchPoint(10, 10);
eventSender.touchStart();
verifyTouchEvent("touchstart", 1, 1, 1);
shouldBeEqualToString("lastEvent.targetTouches[0].target.tagName", "DIV");
eventSender.updateTouchPoint(0, 1000, 1000);
eventSender.touchMove();
verifyTouchEvent("touchmove", 1, 1, 0);
shouldBeEqualToString("lastEvent.touches[0].target.tagName", "HTML");
}
if (window.layoutTestController)
layoutTestController.waitUntilDone();
if (window.eventSender) {
debug(description);
description("This tests basic single touch event support.");
lastEvent = null;
eventSender.clearTouchPoints();
singleTouchSequence();
lastEvent = null;
eventSender.clearTouchPoints();
multiTouchSequence();
lastEvent = null;
eventSender.clearTouchPoints();
touchTargets();
......@@ -151,4 +129,4 @@ if (window.eventSender) {
debug("This test requires DumpRenderTree. Tap on the blue rect to log.")
}
var successfullyParsed = true;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment