summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam <jam@chromium.org>2014-09-24 23:43:32 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-25 06:43:47 +0000
commit1ed0acfc528fb52602d776d22ade9ad50c23f614 (patch)
treeec25eaacf55e9c774c149e201381e40da46a23af
parentab32c4d3fbac8f6992863e52c372d0b0be6252d3 (diff)
downloadchromium_src-1ed0acfc528fb52602d776d22ade9ad50c23f614.zip
chromium_src-1ed0acfc528fb52602d776d22ade9ad50c23f614.tar.gz
chromium_src-1ed0acfc528fb52602d776d22ade9ad50c23f614.tar.bz2
Revert of Revert of Add test for ChromeVox keyboard commands. (patchset #1 id:1 of https://codereview.chromium.org/603823002/)
Reason for revert: sorry I reverted this incorrectly, the problem was that the isolate needed a nacl file. I'm not sure why it only needed it on debug cros and not release. I landed it in https://codereview.chromium.org/597283004/ Original issue's description: > Revert of Add test for ChromeVox keyboard commands. (patchset #21 id:390004 of https://codereview.chromium.org/490443002/) > > Reason for revert: > flakes, see http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%281%29/builds/31850 > > failures: > TestAsNormalAndGuestUser/SpokenFeedbackTest.ChromeVoxPrefixKey/0 > TestAsNormalAndGuestUser/SpokenFeedbackTest.ChromeVoxPrefixKey/1 > TestAsNormalAndGuestUser/SpokenFeedbackTest.ChromeVoxShiftSearch/1 > TestAsNormalAndGuestUser/SpokenFeedbackTest.ChromeVoxShiftSearch/0 > LoggedInSpokenFeedbackTest.AddBookmark > > Original issue's description: > > 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 > > > > Committed: https://crrev.com/91703961c10dfa0f452999ed7cb87945ea817362 > > Cr-Commit-Position: refs/heads/master@{#293687} > > > > Committed: https://crrev.com/15ea141544fedaf306c94890b5be19b7c5df885a > > Cr-Commit-Position: refs/heads/master@{#296074} > > TBR=dtseng@chromium.org,sky@chromium.org,dmazzoni@chromium.org > NOTREECHECKS=true > NOTRY=true > BUG=404470 > > Committed: https://crrev.com/14e5bdf573d0621dfdd553888a5d3c557fb699a0 > Cr-Commit-Position: refs/heads/master@{#296627} TBR=dtseng@chromium.org,sky@chromium.org,dmazzoni@chromium.org NOTREECHECKS=true NOTRY=true BUG=404470 Review URL: https://codereview.chromium.org/600373002 Cr-Commit-Position: refs/heads/master@{#296670}
-rw-r--r--chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc181
-rw-r--r--ui/aura/test/ui_controls_factory_ozone.cc12
2 files changed, 138 insertions, 55 deletions
diff --git a/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc b/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc
index ef47ced..c4b85ce 100644
--- a/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc
+++ b/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -60,11 +61,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) {
@@ -92,6 +106,37 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
"cvox.ChromeVox.earcons.playEarcon = function() {};");
}
+ void LoadChromeVoxAndThenNavigateToURL(const GURL& url) {
+ // The goal of this helper function is to avoid race conditions between
+ // the page loading and the ChromeVox extension loading and fully
+ // initializing. To do this, we first load a test url that repeatedly
+ // asks ChromeVox to speak 'ready', then we load ChromeVox and block
+ // until we get that 'ready' speech.
+
+ ui_test_utils::NavigateToURL(
+ browser(),
+ GURL("data:text/html;charset=utf-8,"
+ "<script>"
+ "window.setInterval(function() {"
+ " try {"
+ " cvox.Api.speak('ready');"
+ " } catch (e) {}"
+ "}, 100);"
+ "</script>"));
+ EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
+ AccessibilityManager::Get()->EnableSpokenFeedback(
+ true, ash::A11Y_NOTIFICATION_NONE);
+
+ // Block until we get "ready".
+ while (speech_monitor_.GetNextUtterance() != "ready") {
+ }
+
+ // Now load the requested url.
+ ui_test_utils::NavigateToURL(browser(), url);
+ }
+
+ SpeechMonitor speech_monitor_;
+
private:
StubBrailleController braille_controller_;
DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest);
@@ -100,52 +145,51 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(LoggedInSpokenFeedbackTest, AddBookmark) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
- SpeechMonitor monitor;
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
- EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
+ EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
DisableEarcons();
chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR);
// Create a bookmark with title "foo".
chrome::ExecuteCommand(browser(), IDC_BOOKMARK_PAGE);
- EXPECT_EQ("Bookmark added!,", monitor.GetNextUtterance());
- EXPECT_EQ("about blank,", monitor.GetNextUtterance());
- EXPECT_EQ("Bookmark name,", monitor.GetNextUtterance());
- EXPECT_EQ("text box", monitor.GetNextUtterance());
+ EXPECT_EQ("Bookmark added!,", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("about blank,", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("Bookmark name,", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("text box", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_F);
- EXPECT_EQ("f", monitor.GetNextUtterance());
+ EXPECT_EQ("f", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_O);
- EXPECT_EQ("o", monitor.GetNextUtterance());
+ EXPECT_EQ("o", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_O);
- EXPECT_EQ("o", monitor.GetNextUtterance());
+ EXPECT_EQ("o", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_TAB);
- EXPECT_EQ("Bookmarks bar,", monitor.GetNextUtterance());
- EXPECT_EQ("Bookmark folder,", monitor.GetNextUtterance());
- EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "combo box*"));
+ EXPECT_EQ("Bookmarks bar,", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("Bookmark folder,", speech_monitor_.GetNextUtterance());
+ EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "combo box*"));
SendKeyPress(ui::VKEY_RETURN);
- EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*"));
+ EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
// Wait for active window change to be announced to avoid interference from
// that below.
- while (monitor.GetNextUtterance() != "window about blank tab") {
+ while (speech_monitor_.GetNextUtterance() != "window about blank tab") {
// Do nothing.
}
// Focus bookmarks bar and listen for "foo".
chrome::ExecuteCommand(browser(), IDC_FOCUS_BOOKMARKS);
while (true) {
- std::string utterance = monitor.GetNextUtterance();
+ std::string utterance = speech_monitor_.GetNextUtterance();
VLOG(0) << "Got utterance: " << utterance;
if (utterance == "Bookmarks,")
break;
}
- EXPECT_EQ("foo,", monitor.GetNextUtterance());
- EXPECT_EQ("button", monitor.GetNextUtterance());
+ EXPECT_EQ("foo,", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
}
//
@@ -185,66 +229,96 @@ INSTANTIATE_TEST_CASE_P(
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
- SpeechMonitor monitor;
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
- EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
+ EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
}
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
- SpeechMonitor monitor;
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
- EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
+ EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
DisableEarcons();
chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
// Might be "Google Chrome Toolbar" or "Chromium Toolbar".
- EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*"));
- EXPECT_EQ("Reload,", monitor.GetNextUtterance());
- EXPECT_EQ("button", monitor.GetNextUtterance());
+ EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
+ EXPECT_EQ("Reload,", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
}
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
- SpeechMonitor monitor;
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
- EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
+ EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
DisableEarcons();
// Wait for ChromeVox to finish speaking.
chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION);
while (true) {
- std::string utterance = monitor.GetNextUtterance();
+ std::string utterance = speech_monitor_.GetNextUtterance();
VLOG(0) << "Got utterance: " << utterance;
if (utterance == "text box")
break;
}
SendKeyPress(ui::VKEY_X);
- EXPECT_EQ("x", monitor.GetNextUtterance());
+ EXPECT_EQ("x", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_Y);
- EXPECT_EQ("y", monitor.GetNextUtterance());
+ EXPECT_EQ("y", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_Z);
- EXPECT_EQ("z", monitor.GetNextUtterance());
+ EXPECT_EQ("z", speech_monitor_.GetNextUtterance());
SendKeyPress(ui::VKEY_BACK);
- EXPECT_EQ("z", monitor.GetNextUtterance());
+ EXPECT_EQ("z", speech_monitor_.GetNextUtterance());
+}
+
+IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxShiftSearch) {
+ LoadChromeVoxAndThenNavigateToURL(
+ GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
+ while (true) {
+ std::string utterance = speech_monitor_.GetNextUtterance();
+ if (utterance == "Click me")
+ break;
+ }
+ EXPECT_EQ("Button", speech_monitor_.GetNextUtterance());
+
+ // Press Search+Shift+/ to enter ChromeVox's "find in page".
+ SendKeyPressWithSearchAndShift(ui::VKEY_OEM_2);
+ EXPECT_EQ("Find in page.", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance());
+}
+
+IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, ChromeVoxPrefixKey) {
+ LoadChromeVoxAndThenNavigateToURL(
+ GURL("data:text/html;charset=utf-8,<button autofocus>Click me</button>"));
+ while (true) {
+ std::string utterance = speech_monitor_.GetNextUtterance();
+ if (utterance == "Click me")
+ break;
+ }
+ EXPECT_EQ("Button", speech_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.", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("Enter a search query.", speech_monitor_.GetNextUtterance());
}
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
- SpeechMonitor monitor;
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
- EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
+ EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
DisableEarcons();
SimulateTouchScreenInChromeVox();
@@ -254,10 +328,10 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TouchExploreStatusTray) {
ash::SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray();
tray->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true);
- EXPECT_EQ("Status tray,", monitor.GetNextUtterance());
- EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "time*,"));
- EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Battery*,"));
- EXPECT_EQ("button", monitor.GetNextUtterance());
+ EXPECT_EQ("Status tray,", speech_monitor_.GetNextUtterance());
+ EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "time*,"));
+ EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "Battery*,"));
+ EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
}
//
@@ -284,17 +358,16 @@ class GuestSpokenFeedbackTest : public LoggedInSpokenFeedbackTest {
IN_PROC_BROWSER_TEST_F(GuestSpokenFeedbackTest, FocusToolbar) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
- SpeechMonitor monitor;
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
- EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
+ EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
DisableEarcons();
chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR);
// Might be "Google Chrome Toolbar" or "Chromium Toolbar".
- EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*"));
- EXPECT_EQ("Reload,", monitor.GetNextUtterance());
- EXPECT_EQ("button", monitor.GetNextUtterance());
+ EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(), "*oolbar*"));
+ EXPECT_EQ("Reload,", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("button", speech_monitor_.GetNextUtterance());
}
//
@@ -317,6 +390,8 @@ class OobeSpokenFeedbackTest : public InProcessBrowserTest {
SetProfileForTest(ProfileHelper::GetSigninProfile());
}
+ SpeechMonitor speech_monitor_;
+
private:
DISALLOW_COPY_AND_ASSIGN(OobeSpokenFeedbackTest);
};
@@ -331,18 +406,18 @@ IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) {
views::Widget* widget = web_ui_login_view->GetWidget();
gfx::NativeWindow window = widget->GetNativeWindow();
- SpeechMonitor monitor;
AccessibilityManager::Get()->EnableSpokenFeedback(
true, ash::A11Y_NOTIFICATION_NONE);
- EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
+ EXPECT_TRUE(speech_monitor_.SkipChromeVoxEnabledMessage());
- EXPECT_EQ("Select your language:", monitor.GetNextUtterance());
- EXPECT_EQ("English ( United States)", monitor.GetNextUtterance());
- EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *"));
+ EXPECT_EQ("Select your language:", speech_monitor_.GetNextUtterance());
+ EXPECT_EQ("English ( United States)", speech_monitor_.GetNextUtterance());
+ EXPECT_TRUE(MatchPattern(speech_monitor_.GetNextUtterance(),
+ "Combo box * of *"));
ASSERT_TRUE(
ui_test_utils::SendKeyPressToWindowSync(
window, ui::VKEY_TAB, false, false, false, false));
- EXPECT_EQ("Select your keyboard:", monitor.GetNextUtterance());
+ EXPECT_EQ("Select your keyboard:", speech_monitor_.GetNextUtterance());
}
} // namespace chromeos
diff --git a/ui/aura/test/ui_controls_factory_ozone.cc b/ui/aura/test/ui_controls_factory_ozone.cc
index 5179360..4c5330c 100644
--- a/ui/aura/test/ui_controls_factory_ozone.cc
+++ b/ui/aura/test/ui_controls_factory_ozone.cc
@@ -36,8 +36,6 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
bool alt,
bool command,
const base::Closure& closure) OVERRIDE {
- DCHECK(!command); // No command key on Aura
-
int flags = button_down_mask_;
if (control) {
@@ -55,6 +53,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 +76,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;
}