Commit 1b891ab3 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

PerformAction API supports two pointer up actions in different ticks

In ChromeDriver PerformAction API, we used to release all the touch
points all once, because Devtool Input.dispatchTouchEvent API's
touchEnd event will release all the touch points.
https://chromedevtools.github.io/devtools-protocol/tot/
Input#method-dispatchTouchEvent

In order to just release one touch point, we have to send touchMove event
excluding the touch point we want to release from touch points list, so
Devtool Input.dispatchTouchEvent will send a pointerup event for this
touch point.

Bug: 1020674
Change-Id: Iba44ef480284b44f914378374bc14d63cf66a5c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1958163Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723137}
parent 66ab0c77
......@@ -625,14 +625,18 @@ Status WebViewImpl::DispatchTouchEventWithMultiPoints(
params.SetString("type", type);
if (type == "touchStart" || type == "touchMove") {
point_list->Append(GenerateTouchPoint(event));
for (auto point = touch_points_.begin(); point != touch_points_.end();
++point) {
if (point->first != event.id) {
point_list->Append(GenerateTouchPoint(point->second));
}
} else {
if (touch_count < events.size() || touch_points_.size() > 1)
params.SetString("type", "touchMove");
}
for (auto point = touch_points_.begin(); point != touch_points_.end();
++point) {
if (point->first != event.id) {
point_list->Append(GenerateTouchPoint(point->second));
}
touch_points_[event.id] = event;
}
touch_points_[event.id] = event;
params.Set("touchPoints", std::move(point_list));
if (async_dispatch_events || touch_count < events.size()) {
......@@ -645,10 +649,7 @@ Status WebViewImpl::DispatchTouchEventWithMultiPoints(
return status;
if (type != "touchStart" && type != "touchMove") {
for (auto point = touch_points_.begin(); point != touch_points_.end();) {
point = touch_points_.erase(point);
}
break;
touch_points_.erase(event.id);
}
touch_count++;
}
......
......@@ -1518,7 +1518,7 @@ Status ExecutePerformActions(Session* session,
if (has_touch_start[id]) {
if (event.type == kPause)
event.type = kTouchMove;
event.id = dispatch_touch_events.size();
event.id = j;
dispatch_touch_events.push_back(event);
}
if (j == last_touch_index) {
......
<!DOCTYPE html>
<meta charset="utf-8">
<title>TestDriver actions: two touch points with one moving one pause</title>
<script src="/resources/testharness.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>
<style>
div#test1{
position: fixed;
top: 0;
left: 0;
width: 100px;
height: 100px;
background-color: blue;
}
</style>
<div id="test1">
</div>
<script>
let event_type = [];
let event_id = [];
async_test(t => {
let test1 = document.getElementById("test1");
document.getElementById("test1").addEventListener("pointerdown",
e => {event_type.push(e.type); event_id.push(e.pointerId);});
document.getElementById("test1").addEventListener("pointerup",
e => {event_type.push(e.type); event_id.push(e.pointerId);});
document.getElementById("test1").addEventListener("pointermove",
e => {event_type.push(e.type); event_id.push(e.pointerId);});
let actions = new test_driver.Actions()
.addPointer("touchPointer1", "touch")
.addPointer("touchPointer2", "touch")
.pointerMove(0, 0, {origin: test1, sourceName: "touchPointer1"})
.pointerMove(10, 0, {origin: test1, sourceName: "touchPointer2"})
.pointerDown({sourceName: "touchPointer1"})
.pointerDown({sourceName: "touchPointer2"})
.pointerUp({sourceName: "touchPointer1"})
.pointerMove(10, 10, {origin: test1, sourceName: "touchPointer2"})
.pointerUp({sourceName: "touchPointer2"});
actions.send()
.then(t.step_func_done(() => {
assert_array_equals(event_type, ["pointerdown", "pointerdown", "pointerup", "pointermove", "pointerup"]);
assert_array_equals(event_id, [2, 3, 2, 3, 3]);
}))
.catch(e => t.step_func(() => assert_unreached("Actions sequence failed " + e)));
});
</script>
<!DOCTYPE html>
<meta charset="utf-8">
<title>TestDriver actions: two touch points with one moving one pause</title>
<script src="/resources/testharness.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>
<style>
div#test1{
position: fixed;
top: 0;
left: 0;
width: 100px;
height: 100px;
background-color: blue;
}
</style>
<div id="test1">
</div>
<script>
let event_type = [];
let event_id = [];
async_test(t => {
let test1 = document.getElementById("test1");
document.getElementById("test1").addEventListener("pointerdown",
e => {event_type.push(e.type); event_id.push(e.pointerId);});
document.getElementById("test1").addEventListener("pointerup",
e => {event_type.push(e.type); event_id.push(e.pointerId);});
document.getElementById("test1").addEventListener("pointermove",
e => {event_type.push(e.type); event_id.push(e.pointerId);});
let actions = new test_driver.Actions()
.addPointer("touchPointer1", "touch")
.addPointer("touchPointer2", "touch")
.pointerMove(0, 0, {origin: test1, sourceName: "touchPointer1"})
.pointerMove(10, 0, {origin: test1, sourceName: "touchPointer2"})
.pointerDown({sourceName: "touchPointer1"})
.pointerDown({sourceName: "touchPointer2"})
.pointerMove(10, 10, {origin: test1, sourceName: "touchPointer1"})
.pointerUp({sourceName: "touchPointer2"})
.pointerUp({sourceName: "touchPointer1"});
actions.send()
.then(t.step_func_done(() => {
assert_array_equals(event_type, ["pointerdown", "pointerdown", "pointermove", "pointerup", "pointerup"]);
assert_array_equals(event_id, [2, 3, 2, 3, 2]);
}))
.catch(e => t.step_func(() => assert_unreached("Actions sequence failed " + e)));
});
</script>
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