Skip to content

Commit

Permalink
Fix SimulateKeyPress test function to be able to generate lower-case …
Browse files Browse the repository at this point in the history
…input.

Currently the function always generates capital letters regardless of the parameters.

Change-Id: I7b1f11743c3ba2463e7fd5268d29400d3c71792b
Reviewed-on: https://chromium-review.googlesource.com/1056533
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558640}
  • Loading branch information
Vasilii Sukhanov authored and Commit Bot committed May 15, 2018
1 parent 39970a7 commit 886f65d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/site_per_process_interactive_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
// take time to propagate to the renderer's main thread.
content::DOMMessageQueue msg_queue;
std::string reply;
SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('f'),
SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('F'),
ui::DomCode::US_F, ui::VKEY_F, false, false, false, false);
EXPECT_TRUE(msg_queue.WaitForMessage(&reply));
EXPECT_EQ("\"F\"", reply);
Expand Down
11 changes: 9 additions & 2 deletions content/public/test/browser_test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,15 @@ void BuildSimpleWebKeyEvent(blink::WebInputEvent::Type type,

if (type == blink::WebInputEvent::kChar ||
type == blink::WebInputEvent::kRawKeyDown) {
event->text[0] = key_code;
event->unmodified_text[0] = key_code;
// |key| is the only parameter that contains information about the case of
// the character. Use it to be able to generate lower case input.
if (key.IsCharacter()) {
event->text[0] = key.ToCharacter();
event->unmodified_text[0] = key.ToCharacter();
} else {
event->text[0] = key_code;
event->unmodified_text[0] = key_code;
}
}
}

Expand Down

0 comments on commit 886f65d

Please sign in to comment.