Commit b1ba120f authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Modify the web platform tests with mouse inputs to use TestDriver

Since we have implemented test_driver Actions API, we will replace
chrome.gpuBenchmarking.pointerActionSequence with this Actions API in
all the tests. This CL will just replace the web platform tests with
mouse inputs.

Bug: 893480
Change-Id: Ie4eb7f4b8aaf23b2664182c5b8e814c7113dcf9a
Reviewed-on: https://chromium-review.googlesource.com/c/1296823
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610898}
parent d8d233ac
...@@ -2120,7 +2120,6 @@ virtual/speech-with-unified-autoplay/external/wpt/speech-api/SpeechRecognition-a ...@@ -2120,7 +2120,6 @@ virtual/speech-with-unified-autoplay/external/wpt/speech-api/SpeechRecognition-a
virtual/speech-with-unified-autoplay/external/wpt/speech-api/SpeechRecognition-onerror-manual.https.html [ WontFix ] virtual/speech-with-unified-autoplay/external/wpt/speech-api/SpeechRecognition-onerror-manual.https.html [ WontFix ]
virtual/speech-with-unified-autoplay/external/wpt/speech-api/SpeechRecognition-onresult-manual.https.html [ WontFix ] virtual/speech-with-unified-autoplay/external/wpt/speech-api/SpeechRecognition-onresult-manual.https.html [ WontFix ]
virtual/speech-with-unified-autoplay/external/wpt/speech-api/SpeechRecognition-stop-manual.https.html [ WontFix ] virtual/speech-with-unified-autoplay/external/wpt/speech-api/SpeechRecognition-stop-manual.https.html [ WontFix ]
external/wpt/pointerevents/pointerevent_pointermove-manual.html [ WontFix ]
[ Retina ] external/wpt/pointerevents/pointerevent_touch-action-table-test_touch-manual.html [ WontFix ] [ Retina ] external/wpt/pointerevents/pointerevent_touch-action-table-test_touch-manual.html [ WontFix ]
# ====== Tests incompatible with the default Site Isolation from here ====== # ====== Tests incompatible with the default Site Isolation from here ======
......
This is a testharness.js-based test.
FAIL TestDriver actions: element position assert_array_equals: property 0, expected 50 but got 0
Harness: the test ran to completion.
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css"> <link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<!-- Additional helper script for common checks across event types --> <!-- Additional helper script for common checks across event types -->
<script type="text/javascript" src="pointerevent_support.js"></script> <script type="text/javascript" src="pointerevent_support.js"></script>
</head> </head>
...@@ -84,6 +87,8 @@ ...@@ -84,6 +87,8 @@
test_pointermove0.done(); test_pointermove0.done();
event_log.push('pointermove@target0'); event_log.push('pointermove@target0');
pointermoveNoCaptureGot0 = true; pointermoveNoCaptureGot0 = true;
// Second dispatch a pointer move to target1.
new test_driver.Actions().pointerMove(0, 0, {origin: target1}).send();
} }
if(isPointerCapture) { if(isPointerCapture) {
if(!pointermoveCaptureGot0) { if(!pointermoveCaptureGot0) {
...@@ -99,6 +104,8 @@ ...@@ -99,6 +104,8 @@
}, "pointermove received for captured element while out of it"); }, "pointermove received for captured element while out of it");
event_log.push('pointermove@target0'); event_log.push('pointermove@target0');
pointermoveCaptureGot0 = true; pointermoveCaptureGot0 = true;
// Fourth dispatch a pointer move to target0.
new test_driver.Actions().pointerMove(0, 0, {origin: target0}).send();
} }
if((event.clientX > target0.getBoundingClientRect().left)&& if((event.clientX > target0.getBoundingClientRect().left)&&
(event.clientX < target0.getBoundingClientRect().right)&& (event.clientX < target0.getBoundingClientRect().right)&&
...@@ -114,6 +121,9 @@ ...@@ -114,6 +121,9 @@
} }
}); });
// First dispatch a pointer move to target0.
new test_driver.Actions().pointerMove(0, 0, {origin: target0}).send();
on_event(target1, "pointermove", function (event) { on_event(target1, "pointermove", function (event) {
if(isPointerCapture == true) { if(isPointerCapture == true) {
test(function() { test(function() {
...@@ -124,6 +134,14 @@ ...@@ -124,6 +134,14 @@
test_pointermove1.done(); test_pointermove1.done();
event_log.push('pointermove@target1'); event_log.push('pointermove@target1');
pointermoveNoCaptureGot1 = true; pointermoveNoCaptureGot1 = true;
// Third, drag the mouse from btnCapture, target1 to target0.
new test_driver.Actions()
.pointerMove(0, 0, {origin: btnCapture})
.pointerDown()
.pointerMove(0, 0, {origin: target1})
.pointerMove(0, 0, {origin: target0})
.pointerUp()
.send();
} }
}); });
} }
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css"> <link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<!-- Additional helper script for common checks across event types --> <!-- Additional helper script for common checks across event types -->
<script type="text/javascript" src="pointerevent_support.js"></script> <script type="text/javascript" src="pointerevent_support.js"></script>
</head> </head>
...@@ -32,6 +35,9 @@ ...@@ -32,6 +35,9 @@
eventTested = true; eventTested = true;
} }
}); });
// Inject the inputs to run this test.
new test_driver.Actions().pointerMove(0, 0, {origin: target0}).send();
} }
</script> </script>
<h1>Pointer Events pointermove Tests</h1> <h1>Pointer Events pointermove Tests</h1>
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
<!-- /resources/testharness.js --> <!-- /resources/testharness.js -->
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<!-- Additional helper script for common checks across event types --> <!-- Additional helper script for common checks across event types -->
<script type="text/javascript" src="pointerevent_support.js"></script> <script type="text/javascript" src="pointerevent_support.js"></script>
<script type="text/javascript"> <script type="text/javascript">
...@@ -46,6 +49,14 @@ ...@@ -46,6 +49,14 @@
}); });
test_pointerEvent.done(); // complete test test_pointerEvent.done(); // complete test
}); });
// Dispatch a mouse drag in target0.
new test_driver.Actions()
.pointerMove(0, 0, {origin: target0})
.pointerDown()
.pointerMove(3, 3, {origin: target0})
.pointerUp()
.send();
} }
</script> </script>
</head> </head>
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css"> <link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<!-- Additional helper script for common checks across event types --> <!-- Additional helper script for common checks across event types -->
<script type="text/javascript" src="pointerevent_support.js"></script> <script type="text/javascript" src="pointerevent_support.js"></script>
</head> </head>
...@@ -64,6 +67,15 @@ ...@@ -64,6 +67,15 @@
test_pointermove.done(); test_pointermove.done();
eventTested = true; eventTested = true;
}); });
// Click on both left and middle buttons.
var actions = new test_driver.Actions();
actions.pointerMove(0, 0, {origin: target0, button: actions.ButtonType.LEFT})
.pointerDown({button: actions.ButtonType.LEFT})
.pointerDown({button: actions.ButtonType.MIDDLE})
.pointerUp({button: actions.ButtonType.MIDDLE})
.pointerUp({button: actions.ButtonType.LEFT})
.send();
} }
</script> </script>
<h1>Pointer Events pointermove on button state changes Tests</h1> <h1>Pointer Events pointermove on button state changes Tests</h1>
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width">
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="pointerevent_support.js"></script> <script src="pointerevent_support.js"></script>
</head> </head>
<body onload="run()"> <body onload="run()">
...@@ -33,8 +36,13 @@ ...@@ -33,8 +36,13 @@
on_event(target0, "pointerover", function (event) { on_event(target0, "pointerover", function (event) {
detected_pointertypes[event.pointerType] = true; detected_pointertypes[event.pointerType] = true;
target0.setPointerCapture(event.pointerId); target0.setPointerCapture(event.pointerId);
// After we receive a pointerover event, dispatch a pointer move to move out of target0.
new test_driver.Actions().pointerMove(0, 0).send();
}); });
// First dispatch a pointer move to target0.
new test_driver.Actions().pointerMove(0, 0, {origin: target0}).send();
// When the setPointerCapture method is invoked, if the specified pointer is not in active button state, then the method must have no effect on subsequent pointer events. // When the setPointerCapture method is invoked, if the specified pointer is not in active button state, then the method must have no effect on subsequent pointer events.
// TA: 13.2 // TA: 13.2
on_event(target0, "pointerout", function (event) { on_event(target0, "pointerout", function (event) {
......
...@@ -22,6 +22,14 @@ ...@@ -22,6 +22,14 @@
} }
Actions.prototype = { Actions.prototype = {
ButtonType: {
LEFT: 0,
MIDDLE: 1,
RIGHT: 2,
BACK: 3,
FORWARD: 4,
},
/** /**
* Generate the action sequence suitable for passing to * Generate the action sequence suitable for passing to
* test_driver.action_sequence * test_driver.action_sequence
...@@ -98,7 +106,7 @@ ...@@ -98,7 +106,7 @@
* @returns {Actions} * @returns {Actions}
*/ */
addKeyboard: function(name, set=true) { addKeyboard: function(name, set=true) {
this.createSource("key", name, true); this.createSource("key", name);
if (set) { if (set) {
this.setKeyboard(name); this.setKeyboard(name);
} }
...@@ -125,7 +133,7 @@ ...@@ -125,7 +133,7 @@
* @returns {Actions} * @returns {Actions}
*/ */
addPointer: function(name, pointerType="mouse", set=true) { addPointer: function(name, pointerType="mouse", set=true) {
this.createSource("pointer", name, true, {pointerType: pointerType}); this.createSource("pointer", name, {pointerType: pointerType});
if (set) { if (set) {
this.setPointer(name); this.setPointer(name);
} }
...@@ -225,7 +233,7 @@ ...@@ -225,7 +233,7 @@
* pointer source * pointer source
* @returns {Actions} * @returns {Actions}
*/ */
pointerDown: function({button=0, sourceName=null}={}) { pointerDown: function({button=this.ButtonType.LEFT, sourceName=null}={}) {
let source = this.getSource("pointer", sourceName); let source = this.getSource("pointer", sourceName);
source.pointerDown(this, button); source.pointerDown(this, button);
return this; return this;
...@@ -239,7 +247,7 @@ ...@@ -239,7 +247,7 @@
* source * source
* @returns {Actions} * @returns {Actions}
*/ */
pointerUp: function({button=0, sourceName=null}={}) { pointerUp: function({button=this.ButtonType.LEFT, sourceName=null}={}) {
let source = this.getSource("pointer", sourceName); let source = this.getSource("pointer", sourceName);
source.pointerUp(this, button); source.pointerUp(this, button);
return this; return this;
......
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
* @returns {Promise} fufiled after the actions are performed, or rejected in * @returns {Promise} fufiled after the actions are performed, or rejected in
* the cases the WebDriver command errors * the cases the WebDriver command errors
*/ */
action_sequence(actions) { action_sequence: function(actions) {
return window.test_driver_internal.action_sequence(actions); return window.test_driver_internal.action_sequence(actions);
} }
}; };
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
<link rel="author" title="Google" href="http://www.google.com/" /> <link rel="author" title="Google" href="http://www.google.com/" />
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script> <script>
var testMouseUp = async_test('Tests that the mouseup is preventable.'); var testMouseUp = async_test('Tests that the mouseup is preventable.');
var received_back = false; var received_back = false;
...@@ -24,10 +27,21 @@ ...@@ -24,10 +27,21 @@
testMouseUp.done(); testMouseUp.done();
} }
}); });
function inject_input() {
// First click on back button and then forward button.
var actions = new test_driver.Actions();
actions.pointerMove(0, 0, {origin: target})
.pointerDown({button: actions.ButtonType.BACK})
.pointerUp({button: actions.ButtonType.BACK})
.pointerDown({button: actions.ButtonType.FORWARD})
.pointerUp({button: actions.ButtonType.FORWARD})
.send();
}
</script> </script>
</head> </head>
<body id="target"> <body id="target" onload="inject_input()">
<h4>Test Description: Tests that the mouseup event is prevented. <h4>Test Description: Tests that the mouseup event is prevented.
<ol> <ol>
<li>Click the back mouse button</li> <li>Click the back mouse button</li>
......
importAutomationScript('/pointerevents/pointerevent_common_input.js');
function inject_input() {
return mouseMoveIntoTarget('#target0').then(function() {
return mouseMoveIntoTarget('#target1');
}).then(function() {
return mouseDragInTargets(['#btnCapture', '#target1', '#target0']);
}).then(function() {
// To handle delayed capturing.
return mouseMoveIntoTarget('#target0');
});
}
importAutomationScript('/pointerevents/pointerevent_common_input.js');
function inject_input() {
return mouseDragInTarget('#target0');
}
importAutomationScript('/pointerevents/pointerevent_common_input.js');
function inject_input() {
return mouseChordedButtonPress('#target0');
}
\ No newline at end of file
importAutomationScript('/pointerevents/pointerevent_common_input.js');
function inject_input() {
return mouseMoveIntoTarget('#target0').then(function() {
return mouseMoveToDocument();
});
}
importAutomationScript('/pointerevents/pointerevent_common_input.js');
function inject_input() {
return mouseClickInTarget('#target', undefined, /* back button */ 3).then(function() {
return mouseClickInTarget('#target', undefined, /* forward button */ 4);
});
}
...@@ -82,10 +82,15 @@ ...@@ -82,10 +82,15 @@
var didScrollIntoView = false; var didScrollIntoView = false;
for (let i = 0; i < actions.length; i++) { for (let i = 0; i < actions.length; i++) {
var last_x_position = 0;
var last_y_position = 0;
for (let j = 0; j < actions[i].actions.length; j++) { for (let j = 0; j < actions[i].actions.length; j++) {
if ('origin' in actions[i].actions[j]) { if ('origin' in actions[i].actions[j]) {
if (actions[i].actions[j].origin == "viewport") if (actions[i].actions[j].origin == "viewport") {
last_x_position = actions[i].actions[j].x;
last_y_position = actions[i].actions[j].y;
continue; continue;
}
if (actions[i].actions[j].origin == "pointer") if (actions[i].actions[j].origin == "pointer")
return Promise.reject(new Error("pointer origin is not supported right now")); return Promise.reject(new Error("pointer origin is not supported right now"));
...@@ -113,10 +118,13 @@ ...@@ -113,10 +118,13 @@
var rect = element.getClientRects()[0]; var rect = element.getClientRects()[0];
var centerPoint = getInViewCenterPoint(rect); var centerPoint = getInViewCenterPoint(rect);
var x = centerPoint[0]; last_x_position = actions[i].actions[j].x + centerPoint[0];
var y = centerPoint[1]; last_y_position = actions[i].actions[j].y + centerPoint[1];
actions[i].actions[j].x += x; }
actions[i].actions[j].y += y;
if (actions[i].actions[j].type == "pointerDown" || actions[i].actions[j].type == "pointerMove") {
actions[i].actions[j].x = last_x_position;
actions[i].actions[j].y = last_y_position;
} }
} }
} }
......
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