blob: 17f7f46cd030fa17f917494fe16bc1b4abb7c2d6 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../../js/resources/js-test-post-function.js"></script>
<style type="text/css">
#touchtarget {
width: 100px;
height: 100px;
background: blue;
}
</style>
</head>
<body onload="runTest();">
<div id="touchtarget">
<p id="description"></p>
<div id="console"></div>
<script>
var clickEventsReceived = 0;
var expectedMouseEvents = 4;
var touchEventsReceived = 0;
var mouseEventsReceived = 0;
var eventTypes = [ 'mousemove', 'mousedown', 'mouseup', 'click' ];
function gestureEventCallback(event)
{
if (window.eventSender) {
shouldBeEqualToString('event.type', eventTypes[mouseEventsReceived]);
shouldBe('event.clientX', '10');
shouldBe('event.clientY', '12');
shouldBe("event.shiftKey", "true");
shouldBe("event.altKey", "true");
shouldBe("event.ctrlKey", "false");
shouldBe("event.metaKey", "false");
mouseEventsReceived++;
} else {
debug(event.type);
debug(event.clientX);
debug(event.clientY);
}
}
// Because we may not have a gesture recognizer, we send a key press
// event to end the test without temporal flakiness.
function quitKeyToEndTest(event) {
endTest();
}
// Log that we still got the touch events.
function touchEventCallback(event) {
touchEventsReceived++;
debug('have received: ' + touchEventsReceived + ' touch events');
return true;
}
function singleTouchSequence()
{
eventSender.clearTouchPoints();
eventSender.addTouchPoint(10, 12);
eventSender.touchStart();
// Insert some delay. NB: this value depends on minClickDownTime,
// maxClickDownTime from GestureRecognizerChromium.cpp
eventSender.leapForward(20);
eventSender.setTouchModifier("shift", true);
eventSender.setTouchModifier("alt", true);
eventSender.releaseTouchPoint(0);
eventSender.touchEnd();
}
function endTest()
{
if (mouseEventsReceived < expectedMouseEvents) {
debug('Gesture manager not implemented on this platform.');
}
// Bail.
successfullyParsed = true;
isSuccessfullyParsed();
layoutTestController.notifyDone();
}
function runTest() {
var div = document.getElementById('touchtarget');
div.addEventListener("mousedown", gestureEventCallback, false);
div.addEventListener("click", gestureEventCallback, false);
div.addEventListener("mouseup", gestureEventCallback, false);
div.addEventListener("mousemove", gestureEventCallback, false);
document.addEventListener("keydown", quitKeyToEndTest, false);
div.addEventListener("touchstart", touchEventCallback, false);
div.addEventListener("touchmove", touchEventCallback, false);
div.addEventListener("touchend", touchEventCallback, false);
if (window.layoutTestController)
layoutTestController.waitUntilDone();
if (window.eventSender) {
description("This tests basic single touch gesture generation.");
if (eventSender.clearTouchPoints) {
singleTouchSequence();
eventSender.leapForward(10);
eventSender.keyDown(' ');
} else {
endTest();
}
} else {
debug("This test requires DumpRenderTree. Tap on the blue rect to log.")
}
}
</script>
</body>
</html>