Commit cf2b255e authored by dmazzoni@chromium.org's avatar dmazzoni@chromium.org

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

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

Cr-Commit-Position: refs/heads/master@{#291547}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291547 0039d316-1c4b-4281-b951-d872f2087c98
parent dda4562f
...@@ -60,11 +60,24 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest { ...@@ -60,11 +60,24 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
} }
void SendKeyPress(ui::KeyboardCode key) { void SendKeyPress(ui::KeyboardCode key) {
gfx::NativeWindow root_window = ASSERT_NO_FATAL_FAILURE(
ash::Shell::GetInstance()->GetPrimaryRootWindow(); ASSERT_TRUE(
ASSERT_TRUE( ui_test_utils::SendKeyPressToWindowSync(
ui_test_utils::SendKeyPressToWindowSync( NULL, key, false, false, false, false)));
root_window, 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) { void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) {
...@@ -238,6 +251,93 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) { ...@@ -238,6 +251,93 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
EXPECT_EQ("z", monitor.GetNextUtterance()); EXPECT_EQ("z", monitor.GetNextUtterance());
} }
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, 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());
}
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, 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());
}
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, 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) { IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
......
...@@ -56,7 +56,6 @@ class UIControlsX11 : public UIControlsAura { ...@@ -56,7 +56,6 @@ class UIControlsX11 : public UIControlsAura {
bool shift, bool shift,
bool alt, bool alt,
bool command) OVERRIDE { bool command) OVERRIDE {
DCHECK(!command); // No command key on Aura
return SendKeyPressNotifyWhenDone( return SendKeyPressNotifyWhenDone(
window, key, control, shift, alt, command, base::Closure()); window, key, control, shift, alt, command, base::Closure());
} }
...@@ -68,7 +67,6 @@ class UIControlsX11 : public UIControlsAura { ...@@ -68,7 +67,6 @@ class UIControlsX11 : public UIControlsAura {
bool alt, bool alt,
bool command, bool command,
const base::Closure& closure) OVERRIDE { const base::Closure& closure) OVERRIDE {
DCHECK(!command); // No command key on Aura
XEvent xevent = {0}; XEvent xevent = {0};
xevent.xkey.type = KeyPress; xevent.xkey.type = KeyPress;
if (control) if (control)
...@@ -77,6 +75,8 @@ class UIControlsX11 : public UIControlsAura { ...@@ -77,6 +75,8 @@ class UIControlsX11 : public UIControlsAura {
SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask); SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask);
if (alt) if (alt)
SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask); SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask);
if (command)
SetKeycodeAndSendThenMask(&xevent, XK_Super_L, Mod4Mask);
xevent.xkey.keycode = xevent.xkey.keycode =
XKeysymToKeycode(gfx::GetXDisplay(), XKeysymToKeycode(gfx::GetXDisplay(),
ui::XKeysymForWindowsKeyCode(key, shift)); ui::XKeysymForWindowsKeyCode(key, shift));
...@@ -91,6 +91,8 @@ class UIControlsX11 : public UIControlsAura { ...@@ -91,6 +91,8 @@ class UIControlsX11 : public UIControlsAura {
UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L);
if (control) if (control)
UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L); UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L);
if (command)
UnmaskAndSetKeycodeThenSend(&xevent, Mod4Mask, XK_Super_L);
DCHECK(!xevent.xkey.state); DCHECK(!xevent.xkey.state);
RunClosureAfterAllPendingUIEvents(closure); RunClosureAfterAllPendingUIEvents(closure);
return true; 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