Spoken Feedback Browsertest: AddBookmark test and some structural changes

- restructured existing code to allow some tests to run in only normal mode
- added AddBookmark test to check ChromeVox while adding a bookmark
- switched SendKeyPress to SendKeyPressToWindowSync throughout all tests
- reordered expected ChromeVox messages and reenabled TypeInOmnibox test

BUG=None
TEST=this
R=dmazzoni@chromium.org
NOTRY=true

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278304 0039d316-1c4b-4281-b951-d872f2087c98
parent d2b32fde
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/ui_test_utils.h" #include "chrome/test/base/ui_test_utils.h"
#include "chromeos/chromeos_switches.h" #include "chromeos/chromeos_switches.h"
...@@ -37,7 +38,80 @@ using extensions::api::braille_display_private::StubBrailleController; ...@@ -37,7 +38,80 @@ using extensions::api::braille_display_private::StubBrailleController;
namespace chromeos { namespace chromeos {
// //
// Spoken feedback tests in a normal browser window. // Spoken feedback tests only in a logged in user's window.
//
class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {
protected:
LoggedInSpokenFeedbackTest() {}
virtual ~LoggedInSpokenFeedbackTest() {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
AccessibilityManager::SetBrailleControllerForTest(&braille_controller_);
}
virtual void CleanUpOnMainThread() OVERRIDE {
AccessibilityManager::SetBrailleControllerForTest(NULL);
}
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));
}
private:
StubBrailleController braille_controller_;
DISALLOW_COPY_AND_ASSIGN(LoggedInSpokenFeedbackTest);
};
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());
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());
SendKeyPress(ui::VKEY_F);
EXPECT_EQ("f", monitor.GetNextUtterance());
SendKeyPress(ui::VKEY_O);
EXPECT_EQ("o", monitor.GetNextUtterance());
SendKeyPress(ui::VKEY_O);
EXPECT_EQ("o", 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*"));
SendKeyPress(ui::VKEY_RETURN);
// Focus bookmarks bar and listen for "foo".
chrome::ExecuteCommand(browser(), IDC_FOCUS_BOOKMARKS);
while (true) {
std::string utterance = monitor.GetNextUtterance();
VLOG(0) << "Got utterance: " << utterance;
if (utterance == "Bookmarks,")
break;
}
EXPECT_EQ("foo,", monitor.GetNextUtterance());
EXPECT_EQ("button", monitor.GetNextUtterance());
}
//
// Spoken feedback tests in both a logged in browser window and guest mode.
// //
enum SpokenFeedbackTestVariant { enum SpokenFeedbackTestVariant {
...@@ -46,20 +120,12 @@ enum SpokenFeedbackTestVariant { ...@@ -46,20 +120,12 @@ enum SpokenFeedbackTestVariant {
}; };
class SpokenFeedbackTest class SpokenFeedbackTest
: public InProcessBrowserTest, : public LoggedInSpokenFeedbackTest,
public ::testing::WithParamInterface<SpokenFeedbackTestVariant> { public ::testing::WithParamInterface<SpokenFeedbackTestVariant> {
protected: protected:
SpokenFeedbackTest() {} SpokenFeedbackTest() {}
virtual ~SpokenFeedbackTest() {} virtual ~SpokenFeedbackTest() {}
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
AccessibilityManager::SetBrailleControllerForTest(&braille_controller_);
}
virtual void CleanUpOnMainThread() OVERRIDE {
AccessibilityManager::SetBrailleControllerForTest(NULL);
}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
if (GetParam() == kTestAsGuestUser) { if (GetParam() == kTestAsGuestUser) {
command_line->AppendSwitch(chromeos::switches::kGuestSession); command_line->AppendSwitch(chromeos::switches::kGuestSession);
...@@ -70,10 +136,6 @@ class SpokenFeedbackTest ...@@ -70,10 +136,6 @@ class SpokenFeedbackTest
chromeos::UserManager::kGuestUserName); chromeos::UserManager::kGuestUserName);
} }
} }
private:
StubBrailleController braille_controller_;
DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackTest);
}; };
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
...@@ -106,8 +168,7 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) { ...@@ -106,8 +168,7 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) {
EXPECT_EQ("button", monitor.GetNextUtterance()); EXPECT_EQ("button", monitor.GetNextUtterance());
} }
// Disabled for flakiness: http://crbug.com/359204 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) {
IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_TypeInOmnibox) {
EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
SpeechMonitor monitor; SpeechMonitor monitor;
...@@ -115,32 +176,33 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_TypeInOmnibox) { ...@@ -115,32 +176,33 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_TypeInOmnibox) {
true, ash::A11Y_NOTIFICATION_NONE); true, ash::A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
// Wait for ChromeVox to finish speaking.
chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION);
gfx::NativeWindow window = ash::Shell::GetInstance()->GetPrimaryRootWindow();
ui_controls::SendKeyPress(window, ui::VKEY_X, false, false, false, false);
while (true) { while (true) {
std::string utterance = monitor.GetNextUtterance(); std::string utterance = monitor.GetNextUtterance();
VLOG(0) << "Got utterance: " << utterance; VLOG(0) << "Got utterance: " << utterance;
if (utterance == "x") if (utterance == "text box")
break; break;
} }
ui_controls::SendKeyPress(window, ui::VKEY_Y, false, false, false, false); SendKeyPress(ui::VKEY_X);
EXPECT_EQ("x", monitor.GetNextUtterance());
SendKeyPress(ui::VKEY_Y);
EXPECT_EQ("y", monitor.GetNextUtterance()); EXPECT_EQ("y", monitor.GetNextUtterance());
ui_controls::SendKeyPress(window, ui::VKEY_Z, false, false, false, false); SendKeyPress(ui::VKEY_Z);
EXPECT_EQ("z", monitor.GetNextUtterance()); EXPECT_EQ("z", monitor.GetNextUtterance());
ui_controls::SendKeyPress(window, ui::VKEY_BACK, false, false, false, false); SendKeyPress(ui::VKEY_BACK);
EXPECT_EQ("z", monitor.GetNextUtterance()); EXPECT_EQ("z", monitor.GetNextUtterance());
} }
// //
// Spoken feedback tests that run in guest mode. // Spoken feedback tests that run only in guest mode.
// //
class GuestSpokenFeedbackTest : public SpokenFeedbackTest { class GuestSpokenFeedbackTest : public LoggedInSpokenFeedbackTest {
protected: protected:
GuestSpokenFeedbackTest() {} GuestSpokenFeedbackTest() {}
virtual ~GuestSpokenFeedbackTest() {} virtual ~GuestSpokenFeedbackTest() {}
...@@ -214,7 +276,9 @@ IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) { ...@@ -214,7 +276,9 @@ IN_PROC_BROWSER_TEST_F(OobeSpokenFeedbackTest, DISABLED_SpokenFeedbackInOobe) {
EXPECT_EQ("Select your language:", monitor.GetNextUtterance()); EXPECT_EQ("Select your language:", monitor.GetNextUtterance());
EXPECT_EQ("English ( United States)", monitor.GetNextUtterance()); EXPECT_EQ("English ( United States)", monitor.GetNextUtterance());
EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *")); EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "Combo box * of *"));
ui_controls::SendKeyPress(window, ui::VKEY_TAB, false, false, false, false); 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:", monitor.GetNextUtterance());
} }
......
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