Commit 91703961 authored by dmazzoni's avatar dmazzoni Committed by Commit bot

Add test for ChromeVox keyboard commands.

This is just a couple of quick sanity checks to prevent future regressions
like the one in the linked bug. It tests both a Search+Shift shortcut and
the corresponding Prefix Key shortcut.

Adds support for sending the meta modifier key in
aura/x11 tests.

BUG=404470

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=291547

Committed: https://chromium.googlesource.com/chromium/src/+/8cab2737f1cb6e6011b0946f6bef5027868602c0

Review URL: https://codereview.chromium.org/490443002

Cr-Commit-Position: refs/heads/master@{#293687}
parent 410d6b1f
......@@ -60,11 +60,24 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
}
void SendKeyPress(ui::KeyboardCode key) {
gfx::NativeWindow root_window =
ash::Shell::GetInstance()->GetPrimaryRootWindow();
ASSERT_TRUE(
ui_test_utils::SendKeyPressToWindowSync(
root_window, key, false, false, false, false));
ASSERT_NO_FATAL_FAILURE(
ASSERT_TRUE(
ui_test_utils::SendKeyPressToWindowSync(
NULL, key, false, false, false, false)));
}
void SendKeyPressWithControl(ui::KeyboardCode key) {
ASSERT_NO_FATAL_FAILURE(
ASSERT_TRUE(
ui_test_utils::SendKeyPressToWindowSync(
NULL, key, true, false, false, false)));
}
void SendKeyPressWithSearchAndShift(ui::KeyboardCode key) {
ASSERT_NO_FATAL_FAILURE(
ASSERT_TRUE(
ui_test_utils::SendKeyPressToWindowSync(
NULL, key, false, true, false, true)));
}
void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) {
......@@ -238,6 +251,111 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
EXPECT_EQ("z", monitor.GetNextUtterance());
}
// http://crbug.com/410534
#if defined(USE_OZONE)
#define MAYBE_ChromeVoxShiftSearch DISABLED_ChromeVoxShiftSearch
#else
#define MAYBE_ChromeVoxShiftSearch ChromeVoxShiftSearch
#endif
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxShiftSearch) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
SpeechMonitor monitor;
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
ui_test_utils::NavigateToURL(
browser(),
GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
while (true) {
std::string utterance = monitor.GetNextUtterance();
if (utterance == "Click me")
break;
}
EXPECT_EQ("Button", monitor.GetNextUtterance());
// Press Search+Shift+/ to enter ChromeVox's "find in page".
SendKeyPressWithSearchAndShift(ui::VKEY_OEM_2);
EXPECT_EQ("Find in page.", monitor.GetNextUtterance());
EXPECT_EQ("Enter a search query.", monitor.GetNextUtterance());
}
// http://crbug.com/410534
#if defined(USE_OZONE)
#define MAYBE_ChromeVoxPrefixKey DISABLED_ChromeVoxPrefixKey
#else
#define MAYBE_ChromeVoxPrefixKey ChromeVoxPrefixKey
#endif
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxPrefixKey) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
SpeechMonitor monitor;
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
ui_test_utils::NavigateToURL(
browser(),
GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
while (true) {
std::string utterance = monitor.GetNextUtterance();
if (utterance == "Click me")
break;
}
EXPECT_EQ("Button", monitor.GetNextUtterance());
// Press the prefix key Ctrl+';' followed by '/'
// to enter ChromeVox's "find in page".
SendKeyPressWithControl(ui::VKEY_OEM_1);
SendKeyPress(ui::VKEY_OEM_2);
EXPECT_EQ("Find in page.", monitor.GetNextUtterance());
EXPECT_EQ("Enter a search query.", monitor.GetNextUtterance());
}
// http://crbug.com/410534
#if defined(USE_OZONE)
#define MAYBE_ChromeVoxNavigateAndSelect DISABLED_ChromeVoxNavigateAndSelect
#else
#define MAYBE_ChromeVoxNavigateAndSelect ChromeVoxNavigateAndSelect
#endif
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, MAYBE_ChromeVoxNavigateAndSelect) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
SpeechMonitor monitor;
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
ui_test_utils::NavigateToURL(
browser(),
GURL("data:text/html;charset=utf-8,"
"<h1>Title</h1>"
"<button autofocus>Click me</button>"));
while (true) {
std::string utterance = monitor.GetNextUtterance();
if (utterance == "Click me")
break;
}
EXPECT_EQ("Button", monitor.GetNextUtterance());
// Press Search+Shift+Up to navigate to the previous item.
SendKeyPressWithSearchAndShift(ui::VKEY_UP);
EXPECT_EQ("Title", monitor.GetNextUtterance());
EXPECT_EQ("Heading 1", monitor.GetNextUtterance());
// Press Search+Shift+S to select the text.
SendKeyPressWithSearchAndShift(ui::VKEY_S);
EXPECT_EQ("Start selection", monitor.GetNextUtterance());
EXPECT_EQ("Title", monitor.GetNextUtterance());
EXPECT_EQ(", selected", monitor.GetNextUtterance());
// Press again to end the selection.
SendKeyPressWithSearchAndShift(ui::VKEY_S);
EXPECT_EQ("End selection", monitor.GetNextUtterance());
EXPECT_EQ("Title", monitor.GetNextUtterance());
}
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
......
......@@ -56,7 +56,6 @@ class UIControlsX11 : public UIControlsAura {
bool shift,
bool alt,
bool command) OVERRIDE {
DCHECK(!command); // No command key on Aura
return SendKeyPressNotifyWhenDone(
window, key, control, shift, alt, command, base::Closure());
}
......@@ -68,7 +67,6 @@ class UIControlsX11 : public UIControlsAura {
bool alt,
bool command,
const base::Closure& closure) OVERRIDE {
DCHECK(!command); // No command key on Aura
XEvent xevent = {0};
xevent.xkey.type = KeyPress;
if (control)
......@@ -77,6 +75,8 @@ class UIControlsX11 : public UIControlsAura {
SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask);
if (alt)
SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask);
if (command)
SetKeycodeAndSendThenMask(&xevent, XK_Super_L, Mod4Mask);
xevent.xkey.keycode =
XKeysymToKeycode(gfx::GetXDisplay(),
ui::XKeysymForWindowsKeyCode(key, shift));
......@@ -91,6 +91,8 @@ class UIControlsX11 : public UIControlsAura {
UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L);
if (control)
UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L);
if (command)
UnmaskAndSetKeycodeThenSend(&xevent, Mod4Mask, XK_Super_L);
DCHECK(!xevent.xkey.state);
RunClosureAfterAllPendingUIEvents(closure);
return true;
......
......@@ -55,6 +55,11 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
PostKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_MENU, flags);
}
if (command) {
flags |= ui::EF_COMMAND_DOWN;
PostKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_LWIN, flags);
}
PostKeyEvent(ui::ET_KEY_PRESSED, key, flags);
PostKeyEvent(ui::ET_KEY_RELEASED, key, flags);
......@@ -73,6 +78,11 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
PostKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_CONTROL, flags);
}
if (command) {
flags &= ~ui::EF_COMMAND_DOWN;
PostKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_LWIN, flags);
}
RunClosureAfterAllPendingUIEvents(closure);
return true;
}
......
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