Commit 2576e02f authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

[ChromeDriver] Support triple click in Chromedriver PerformActions

When we are using PerformActions from ChromeDriver to simulate three
mouse click, it only set the click count to 2, not 3, so this test fails
third_party/blink/web_tests/external/wpt/webdriver/tests/perform_actions
/pointer_tripleclick.py.

PerformActions should keep the mouse click count and decide if we should
increase the count or set to 1 when we have a mouse press based on the
interval of two mouse presses and difference between the current mouse
positions and the last one.

Bug: 1119679
Change-Id: I2b941c5d295cdd457109c8866c55e02bb2360555
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2366655Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800201}
parent 520e7d85
...@@ -1492,6 +1492,7 @@ Status ExecutePerformActions(Session* session, ...@@ -1492,6 +1492,7 @@ Status ExecutePerformActions(Session* session,
std::map<std::string, bool> has_touch_start; std::map<std::string, bool> has_touch_start;
std::map<std::string, int> buttons; std::map<std::string, int> buttons;
std::map<std::string, std::string> button_type; std::map<std::string, std::string> button_type;
std::map<std::string, int> click_counts;
int viewport_width = 0, viewport_height = 0; int viewport_width = 0, viewport_height = 0;
int init_x = 0, init_y = 0; int init_x = 0, init_y = 0;
...@@ -1561,10 +1562,12 @@ Status ExecutePerformActions(Session* session, ...@@ -1561,10 +1562,12 @@ Status ExecutePerformActions(Session* session,
std::string pointer_type; std::string pointer_type;
action->GetString("pointerType", &pointer_type); action->GetString("pointerType", &pointer_type);
if (pointer_type == "mouse" || pointer_type == "pen") if (pointer_type == "mouse" || pointer_type == "pen") {
buttons[id] = input_state->FindKey("pressed")->GetInt(); buttons[id] = input_state->FindKey("pressed")->GetInt();
else if (pointer_type == "touch") click_counts[id] = 0;
} else if (pointer_type == "touch") {
has_touch_start[id] = false; has_touch_start[id] = false;
}
} }
} }
...@@ -1688,6 +1691,7 @@ Status ExecutePerformActions(Session* session, ...@@ -1688,6 +1691,7 @@ Status ExecutePerformActions(Session* session,
} else if (buttons[id] == 0) { } else if (buttons[id] == 0) {
button_type[id].clear(); button_type[id].clear();
} }
MouseEvent event(StringToMouseEventType(action_type), MouseEvent event(StringToMouseEventType(action_type),
StringToMouseButton(button_type[id]), StringToMouseButton(button_type[id]),
action_locations[id].x(), action_locations[id].x(),
...@@ -1701,7 +1705,8 @@ Status ExecutePerformActions(Session* session, ...@@ -1701,7 +1705,8 @@ Status ExecutePerformActions(Session* session,
event.x, event.y, session->mouse_position.x, event.x, event.y, session->mouse_position.x,
session->mouse_position.y, session->click_count, session->mouse_position.y, session->click_count,
timestamp, session->mouse_click_timestamp); timestamp, session->mouse_click_timestamp);
event.click_count = is_repeated_click ? 2 : 1; click_counts[id] = is_repeated_click ? ++click_counts[id] : 1;
event.click_count = click_counts[id];
buttons[id] |= StringToModifierMouseButton(button_type[id]); buttons[id] |= StringToModifierMouseButton(button_type[id]);
session->mouse_position = WebPoint(event.x, event.y); session->mouse_position = WebPoint(event.x, event.y);
session->click_count = event.click_count; session->click_count = event.click_count;
......
...@@ -4,7 +4,7 @@ from tests.support.inline import inline ...@@ -4,7 +4,7 @@ from tests.support.inline import inline
lots_of_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor "\ lots_of_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor "\
"incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud "\ "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud "\
" exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." "exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
def test_tripleclick_at_coordinates(session, mouse_chain): def test_tripleclick_at_coordinates(session, mouse_chain):
......
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