Commit 727282ef authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Try to use SendCommandAndIgnoreResponse when dispatching events

We are proposing to use SendCommandAndIgnoreResponse to dispatch event
to avoid waiting for the reply of sending events, so that we can
dispatch more than one events in one tick.

In order to control the time to send events we need to use tick
duration for every tick, it can come from pause action or pointermove
action. We have add a default tick duration right now that we will
dispatch events in one tick per frame, but changing the tick duration
in the Action API will control how many ticks in one frame, so that we
can control how often we want to dispatch events.

Bug: 606367
Change-Id: Ib4745d37181de0724fe5e84fa32d893840ace910
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1752338
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692232}
parent b54a5d84
......@@ -532,7 +532,8 @@ Status WebViewImpl::DispatchMouseEvents(const std::list<MouseEvent>& events,
params.SetInteger("buttons", it->buttons);
params.SetInteger("clickCount", it->click_count);
params.SetString("pointerType", GetAsString(it->pointer_type));
Status status = client_->SendCommand("Input.dispatchMouseEvent", params);
Status status = client_->SendCommandAndIgnoreResponse(
"Input.dispatchMouseEvent", params);
if (status.IsError())
return status;
}
......@@ -556,7 +557,8 @@ Status WebViewImpl::DispatchTouchEvent(const TouchEvent& event) {
point_list->Append(std::move(point));
}
params.Set("touchPoints", std::move(point_list));
return client_->SendCommand("Input.dispatchTouchEvent", params);
return client_->SendCommandAndIgnoreResponse("Input.dispatchTouchEvent",
params);
}
Status WebViewImpl::DispatchTouchEvents(const std::list<TouchEvent>& events) {
......@@ -604,7 +606,8 @@ Status WebViewImpl::DispatchKeyEvents(const std::list<KeyEvent>& events) {
else
params.SetInteger("location", it->location);
}
Status status = client_->SendCommand("Input.dispatchKeyEvent", params);
Status status =
client_->SendCommandAndIgnoreResponse("Input.dispatchKeyEvent", params);
if (status.IsError())
return status;
}
......
......@@ -780,6 +780,10 @@ class ChromeDriverTest(ChromeDriverBaseTestWithWebServer):
'});'
'return div;')
actions = ({"actions": [{
"actions": [{"duration": 32, "type": "pause"}],
"id": "0",
"type": "none"
}, {
"type":"pointer",
"actions":[{"type": "pointerMove", "x": 10, "y": 10}],
"parameters": {"pointerType": "mouse"},
......@@ -839,6 +843,12 @@ class ChromeDriverTest(ChromeDriverBaseTestWithWebServer):
# Move to center of target element and drag it to a new location.
actions = ({'actions': [{
"actions": [{"duration": 32, "type": "pause"},
{"duration": 32, "type": "pause"},
{"duration": 32, "type": "pause"}],
"id": "0",
"type": "none"
}, {
'type': 'pointer',
'actions': [
{'type': 'pointerMove', 'x': 100, 'y': 100},
......@@ -854,6 +864,10 @@ class ChromeDriverTest(ChromeDriverBaseTestWithWebServer):
# Without releasing mouse button, should continue the drag.
actions = ({'actions': [{
"actions": [{"duration": 32, "type": "pause"}],
"id": "0",
"type": "none"
}, {
'type': 'pointer',
'actions': [
{'type': 'pointerMove', 'x': 30, 'y': 40, 'origin': 'pointer'}
......@@ -867,6 +881,11 @@ class ChromeDriverTest(ChromeDriverBaseTestWithWebServer):
# Releasing mouse button stops the drag.
actions = ({'actions': [{
"actions": [{"duration": 32, "type": "pause"},
{"duration": 32, "type": "pause"}],
"id": "0",
"type": "none"
}, {
'type': 'pointer',
'actions': [
{'type': 'pointerUp', 'button': 0},
......
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