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

Chromedriver] Fix PerformAction to support multi touch points cases

For the multiple touch points case, if we have one point move and the
other point stay still, such as
point 1: pointerdown, pause, pointerup
point 2: pointerdown, pointermove, pointerup
We should send five touch point events of "pointerdown", "pointerdown",
"pointermove", "pointerup", "pointerup" with pointer id 1, 2, 2, 1, 2.


Bug: 1020674
Change-Id: I7bdb49b7b37d4f83ef976750e106cbd27afc9e74
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900632Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715739}
parent 41856b65
...@@ -603,11 +603,12 @@ Status WebViewImpl::DispatchTouchEventWithMultiPoints( ...@@ -603,11 +603,12 @@ Status WebViewImpl::DispatchTouchEventWithMultiPoints(
return Status(kOk); return Status(kOk);
base::DictionaryValue params; base::DictionaryValue params;
std::string type = GetAsString(events.front().type);
params.SetString("type", type);
std::unique_ptr<base::ListValue> point_list(new base::ListValue); std::unique_ptr<base::ListValue> point_list(new base::ListValue);
Status status(kOk); Status status(kOk);
for (auto it = events.begin(); it != events.end(); ++it) { for (auto it = events.begin(); it != events.end(); ++it) {
std::string type = GetAsString(it->type);
if (!type.empty())
params.SetString("type", type);
if (type == "touchStart" || type == "touchMove") { if (type == "touchStart" || type == "touchMove") {
std::unique_ptr<base::DictionaryValue> point = GenerateTouchPoint(*it); std::unique_ptr<base::DictionaryValue> point = GenerateTouchPoint(*it);
point_list->Append(std::move(point)); point_list->Append(std::move(point));
......
<!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"})
.pause(0, "pointer", {sourceName: "touchPointer1"})
.pointerMove(0, 10, {origin: test1, sourceName: "touchPointer2"})
.pointerUp({sourceName: "touchPointer1"})
.pointerUp({sourceName: "touchPointer2"});
actions.send()
.then(t.step_func_done(() => {assert_array_equals(event_type, ["pointerdown", "pointerdown", "pointermove", "pointerup", "pointerup"]);
assert_array_equals(event_id, [2, 3, 3, 2, 3]);}))
.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