Skip to content

Commit

Permalink
inputs: Add lacros browser test for sending backspace keys.
Browse files Browse the repository at this point in the history
Bug: b/264825502
Change-Id: I29df0f632aa48176955ff85c35d31699f7153498
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4199115
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1098411}
  • Loading branch information
darrnshn authored and Chromium LUCI CQ committed Jan 29, 2023
1 parent e311734 commit ce330cd
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions chrome/browser/lacros/input_method_lacros_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,45 @@ IN_PROC_BROWSER_TEST_F(InputMethodLacrosBrowserTest,
"abc", gfx::Range(3)));
}

IN_PROC_BROWSER_TEST_F(InputMethodLacrosBrowserTest,
SendBackspaceDeletesNonEmptyTextField) {
mojo::Remote<InputMethodTestInterface> input_method =
BindInputMethodTestInterface(
{InputMethodTestInterface::MethodMinVersions::kWaitForFocusMinVersion,
InputMethodTestInterface::MethodMinVersions::
kKeyEventHandledMinVersion});
if (!input_method.is_bound()) {
GTEST_SKIP() << "Unsupported ash version";
}
const std::string id = RenderAutofocusedInputFieldInLacros(browser());
ASSERT_TRUE(SetInputFieldText(GetActiveWebContents(browser()), id, "hello",
gfx::Range(3)));
InputMethodTestInterfaceAsyncWaiter input_method_async_waiter(
input_method.get());
input_method_async_waiter.WaitForFocus();

SendKeyEventSync(input_method_async_waiter,
CreateKeyPressEvent('\b', ui::DomCode::BACKSPACE));
SendKeyEventSync(input_method_async_waiter,
CreateKeyReleaseEvent('\b', ui::DomCode::BACKSPACE));
EXPECT_TRUE(WaitUntilInputFieldHasText(GetActiveWebContents(browser()), id,
"helo", gfx::Range(2)));

SendKeyEventSync(input_method_async_waiter,
CreateKeyPressEvent('\b', ui::DomCode::BACKSPACE));
SendKeyEventSync(input_method_async_waiter,
CreateKeyReleaseEvent('\b', ui::DomCode::BACKSPACE));
EXPECT_TRUE(WaitUntilInputFieldHasText(GetActiveWebContents(browser()), id,
"hlo", gfx::Range(1)));

SendKeyEventSync(input_method_async_waiter,
CreateKeyPressEvent('\b', ui::DomCode::BACKSPACE));
SendKeyEventSync(input_method_async_waiter,
CreateKeyReleaseEvent('\b', ui::DomCode::BACKSPACE));
EXPECT_TRUE(WaitUntilInputFieldHasText(GetActiveWebContents(browser()), id,
"lo", gfx::Range(0)));
}

IN_PROC_BROWSER_TEST_F(InputMethodLacrosBrowserTest,
SetCompositionWhileHandlingKeyEvent) {
mojo::Remote<InputMethodTestInterface> input_method =
Expand Down

0 comments on commit ce330cd

Please sign in to comment.