OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <queue> | 5 #include <queue> |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
11 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 11 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
12 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" | 12 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" |
13 #include "chrome/browser/chromeos/login/login_display_host.h" | 13 #include "chrome/browser/chromeos/login/login_display_host.h" |
14 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 14 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
15 #include "chrome/browser/chromeos/login/user_manager.h" | 15 #include "chrome/browser/chromeos/login/user_manager.h" |
16 #include "chrome/browser/chromeos/login/webui_login_view.h" | 16 #include "chrome/browser/chromeos/login/webui_login_view.h" |
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
18 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con
troller.h" | 18 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con
troller.h" |
19 #include "chrome/browser/speech/tts_controller.h" | 19 #include "chrome/browser/speech/tts_controller.h" |
20 #include "chrome/browser/speech/tts_platform.h" | 20 #include "chrome/browser/speech/tts_platform.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_commands.h" | 22 #include "chrome/browser/ui/browser_commands.h" |
23 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
| 24 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
25 #include "chrome/test/base/testing_profile.h" | 26 #include "chrome/test/base/testing_profile.h" |
26 #include "chrome/test/base/ui_test_utils.h" | 27 #include "chrome/test/base/ui_test_utils.h" |
27 #include "chromeos/chromeos_switches.h" | 28 #include "chromeos/chromeos_switches.h" |
28 #include "content/public/common/url_constants.h" | 29 #include "content/public/common/url_constants.h" |
29 #include "content/public/test/test_utils.h" | 30 #include "content/public/test/test_utils.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
31 #include "ui/base/test/ui_controls.h" | 32 #include "ui/base/test/ui_controls.h" |
32 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
33 | 34 |
34 using extensions::api::braille_display_private::StubBrailleController; | 35 using extensions::api::braille_display_private::StubBrailleController; |
35 | 36 |
36 namespace chromeos { | 37 namespace chromeos { |
37 | 38 |
38 // | 39 // |
39 // Spoken feedback tests in a normal browser window. | 40 // Spoken feedback tests in a normal browser window. |
40 // | 41 // |
41 | 42 |
42 class SpokenFeedbackTest : public InProcessBrowserTest { | 43 enum SpokenFeedbackTestVariant { |
| 44 kTestAsNormalUser, |
| 45 kTestAsGuestUser |
| 46 }; |
| 47 |
| 48 class SpokenFeedbackTest |
| 49 : public InProcessBrowserTest, |
| 50 public ::testing::WithParamInterface<SpokenFeedbackTestVariant> { |
43 protected: | 51 protected: |
44 SpokenFeedbackTest() {} | 52 SpokenFeedbackTest() {} |
45 virtual ~SpokenFeedbackTest() {} | 53 virtual ~SpokenFeedbackTest() {} |
46 | 54 |
47 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 55 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
48 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); | 56 AccessibilityManager::SetBrailleControllerForTest(&braille_controller_); |
49 } | 57 } |
50 | 58 |
51 virtual void CleanUpOnMainThread() OVERRIDE { | 59 virtual void CleanUpOnMainThread() OVERRIDE { |
52 AccessibilityManager::SetBrailleControllerForTest(NULL); | 60 AccessibilityManager::SetBrailleControllerForTest(NULL); |
53 } | 61 } |
54 | 62 |
| 63 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 64 if (GetParam() == kTestAsGuestUser) { |
| 65 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
| 66 command_line->AppendSwitch(::switches::kIncognito); |
| 67 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, |
| 68 "user"); |
| 69 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, |
| 70 chromeos::UserManager::kGuestUserName); |
| 71 } |
| 72 } |
| 73 |
55 private: | 74 private: |
56 StubBrailleController braille_controller_; | 75 StubBrailleController braille_controller_; |
57 DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackTest); | 76 DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackTest); |
58 }; | 77 }; |
59 | 78 |
60 IN_PROC_BROWSER_TEST_F(SpokenFeedbackTest, EnableSpokenFeedback) { | 79 INSTANTIATE_TEST_CASE_P( |
| 80 TestAsNormalAndGuestUser, |
| 81 SpokenFeedbackTest, |
| 82 ::testing::Values(kTestAsNormalUser, |
| 83 kTestAsGuestUser)); |
| 84 |
| 85 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, EnableSpokenFeedback) { |
61 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 86 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
62 | 87 |
63 SpeechMonitor monitor; | 88 SpeechMonitor monitor; |
64 AccessibilityManager::Get()->EnableSpokenFeedback( | 89 AccessibilityManager::Get()->EnableSpokenFeedback( |
65 true, ash::A11Y_NOTIFICATION_NONE); | 90 true, ash::A11Y_NOTIFICATION_NONE); |
66 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | 91 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); |
67 } | 92 } |
68 | 93 |
69 IN_PROC_BROWSER_TEST_F(SpokenFeedbackTest, FocusToolbar) { | 94 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, FocusToolbar) { |
70 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 95 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
71 | 96 |
72 SpeechMonitor monitor; | 97 SpeechMonitor monitor; |
73 AccessibilityManager::Get()->EnableSpokenFeedback( | 98 AccessibilityManager::Get()->EnableSpokenFeedback( |
74 true, ash::A11Y_NOTIFICATION_NONE); | 99 true, ash::A11Y_NOTIFICATION_NONE); |
75 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | 100 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); |
76 | 101 |
77 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); | 102 chrome::ExecuteCommand(browser(), IDC_FOCUS_TOOLBAR); |
78 // Might be "Google Chrome Toolbar" or "Chromium Toolbar". | 103 // Might be "Google Chrome Toolbar" or "Chromium Toolbar". |
79 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*")); | 104 EXPECT_TRUE(MatchPattern(monitor.GetNextUtterance(), "*oolbar*")); |
80 EXPECT_EQ("Reload,", monitor.GetNextUtterance()); | 105 EXPECT_EQ("Reload,", monitor.GetNextUtterance()); |
81 EXPECT_EQ("button", monitor.GetNextUtterance()); | 106 EXPECT_EQ("button", monitor.GetNextUtterance()); |
82 } | 107 } |
83 | 108 |
84 IN_PROC_BROWSER_TEST_F(SpokenFeedbackTest, TypeInOmnibox) { | 109 IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, TypeInOmnibox) { |
85 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); | 110 EXPECT_FALSE(AccessibilityManager::Get()->IsSpokenFeedbackEnabled()); |
86 | 111 |
87 SpeechMonitor monitor; | 112 SpeechMonitor monitor; |
88 AccessibilityManager::Get()->EnableSpokenFeedback( | 113 AccessibilityManager::Get()->EnableSpokenFeedback( |
89 true, ash::A11Y_NOTIFICATION_NONE); | 114 true, ash::A11Y_NOTIFICATION_NONE); |
90 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); | 115 EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage()); |
91 | 116 |
92 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); | 117 chrome::ExecuteCommand(browser(), IDC_FOCUS_LOCATION); |
93 | 118 |
94 gfx::NativeWindow window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); | 119 gfx::NativeWindow window = ash::Shell::GetInstance()->GetPrimaryRootWindow(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 ui_controls::SendKeyPress(window, ui::VKEY_TAB, false, false, false, false); | 178 ui_controls::SendKeyPress(window, ui::VKEY_TAB, false, false, false, false); |
154 } while (monitor.GetNextUtterance() != "Continue"); | 179 } while (monitor.GetNextUtterance() != "Continue"); |
155 | 180 |
156 // If we keep tabbing, we should eventually reach the Shut Down button too. | 181 // If we keep tabbing, we should eventually reach the Shut Down button too. |
157 do { | 182 do { |
158 ui_controls::SendKeyPress(window, ui::VKEY_TAB, false, false, false, false); | 183 ui_controls::SendKeyPress(window, ui::VKEY_TAB, false, false, false, false); |
159 } while (monitor.GetNextUtterance() != "Shut down"); | 184 } while (monitor.GetNextUtterance() != "Shut down"); |
160 } | 185 } |
161 | 186 |
162 } // namespace chromeos | 187 } // namespace chromeos |
OLD | NEW |