Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: chrome/browser/chromeos/accessibility/sticky_keys_browsertest.cc

Issue 727583002: Regression: Search+Key pops up app launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: The StickyKeysBrowserTest.SearchLeftOmnibox test that used to fail was broken, used to assume the c… Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « athena/input/accelerator_manager_impl.cc ('k') | ui/base/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/shell.h" 5 #include "ash/shell.h"
6 #include "ash/sticky_keys/sticky_keys_controller.h" 6 #include "ash/sticky_keys/sticky_keys_controller.h"
7 #include "ash/sticky_keys/sticky_keys_overlay.h" 7 #include "ash/sticky_keys/sticky_keys_overlay.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 11 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/location_bar/location_bar.h" 15 #include "chrome/browser/ui/location_bar/location_bar.h"
16 #include "chrome/browser/ui/omnibox/omnibox_view.h" 16 #include "chrome/browser/ui/omnibox/omnibox_view.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/browser/ui/view_ids.h" 18 #include "chrome/browser/ui/view_ids.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/interactive_test_utils.h" 21 #include "chrome/test/base/interactive_test_utils.h"
22 #include "ui/aura/window_event_dispatcher.h" 22 #include "ui/aura/window_event_dispatcher.h"
23 #include "ui/events/keycodes/keyboard_codes.h" 23 #include "ui/events/keycodes/keyboard_codes.h"
24 #include "ui/events/test/event_generator.h"
24 #include "ui/gfx/native_widget_types.h" 25 #include "ui/gfx/native_widget_types.h"
25 26
26 namespace chromeos { 27 namespace chromeos {
27 28
28 class StickyKeysBrowserTest : public InProcessBrowserTest { 29 class StickyKeysBrowserTest : public InProcessBrowserTest {
29 protected: 30 protected:
30 StickyKeysBrowserTest() {} 31 StickyKeysBrowserTest() {}
31 virtual ~StickyKeysBrowserTest() {} 32 virtual ~StickyKeysBrowserTest() {}
32 33
33 void EnableStickyKeys() { 34 void EnableStickyKeys() {
34 AccessibilityManager::Get()->EnableStickyKeys(true); 35 AccessibilityManager::Get()->EnableStickyKeys(true);
35 } 36 }
36 37
37 void DisableStickyKeys() { 38 void DisableStickyKeys() {
38 AccessibilityManager::Get()->EnableStickyKeys(false); 39 AccessibilityManager::Get()->EnableStickyKeys(false);
39 } 40 }
40 41
41 ash::SystemTray* GetSystemTray() { 42 ash::SystemTray* GetSystemTray() {
42 return ash::Shell::GetInstance()->GetPrimarySystemTray(); 43 return ash::Shell::GetInstance()->GetPrimarySystemTray();
43 } 44 }
44 45
45 void SendKeyPress(ui::KeyboardCode key) { 46 void SendKeyPress(ui::KeyboardCode key) {
dmazzoni 2014/11/20 21:32:38 Your changes are fine, but I don't like that some
afakhry 2014/11/21 02:15:03 Done.
46 gfx::NativeWindow root_window = 47 gfx::NativeWindow root_window =
47 ash::Shell::GetInstance()->GetPrimaryRootWindow(); 48 ash::Shell::GetInstance()->GetPrimaryRootWindow();
48 ASSERT_TRUE( 49 ASSERT_TRUE(
49 ui_test_utils::SendKeyPressToWindowSync(root_window, 50 ui_test_utils::SendKeyPressToWindowSync(root_window,
50 key, 51 key,
51 false, // control 52 false, // control
52 false, // shift 53 false, // shift
53 false, // alt 54 false, // alt
54 false)); // command 55 false)); // command
55 } 56 }
56 57
58 ui::test::EventGenerator& GetEventGenerator() {
dmazzoni 2014/11/20 21:32:38 Please just move this to SetUp
afakhry 2014/11/21 02:15:03 Moved to SetUpOnMainThread() since SetUp() caused
afakhry 2014/11/21 02:15:03 Done.
59 if (!event_generator_) {
60 event_generator_.reset(
61 new ui::test::EventGenerator(browser()->window()->GetNativeWindow()));
62 }
63 return *event_generator_.get();
64 }
65
57 content::NotificationRegistrar registrar_; 66 content::NotificationRegistrar registrar_;
67 scoped_ptr<ui::test::EventGenerator> event_generator_;
58 68
59 DISALLOW_COPY_AND_ASSIGN(StickyKeysBrowserTest); 69 DISALLOW_COPY_AND_ASSIGN(StickyKeysBrowserTest);
60 }; 70 };
61 71
62 IN_PROC_BROWSER_TEST_F(StickyKeysBrowserTest, OpenTrayMenu) { 72 IN_PROC_BROWSER_TEST_F(StickyKeysBrowserTest, OpenTrayMenu) {
63 EnableStickyKeys(); 73 EnableStickyKeys();
64 74
65 // Open system tray bubble with shortcut. 75 // Open system tray bubble with shortcut.
66 SendKeyPress(ui::VKEY_MENU); // alt key. 76 SendKeyPress(ui::VKEY_MENU); // alt key.
67 SendKeyPress(ui::VKEY_SHIFT); 77 SendKeyPress(ui::VKEY_SHIFT);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 156
147 IN_PROC_BROWSER_TEST_F(StickyKeysBrowserTest, SearchLeftOmnibox) { 157 IN_PROC_BROWSER_TEST_F(StickyKeysBrowserTest, SearchLeftOmnibox) {
148 EnableStickyKeys(); 158 EnableStickyKeys();
149 159
150 OmniboxView* omnibox = 160 OmniboxView* omnibox =
151 browser()->window()->GetLocationBar()->GetOmniboxView(); 161 browser()->window()->GetLocationBar()->GetOmniboxView();
152 162
153 // Give the omnibox focus. 163 // Give the omnibox focus.
154 omnibox->ShowURL(); 164 omnibox->ShowURL();
155 165
166 ui::test::EventGenerator& generator = GetEventGenerator();
167
168 // Make sure that the AppList is not erronously displayed and the omnibox
169 // doesn't lost focus
170 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
171 EXPECT_TRUE(omnibox->GetNativeView()->HasFocus());
172
156 // Type 'foo'. 173 // Type 'foo'.
157 SendKeyPress(ui::VKEY_F); 174 generator.PressKey(ui::VKEY_F, ui::EF_NONE);
dmazzoni 2014/11/20 21:32:38 Just call generator_.PressKey, then there's no nee
158 SendKeyPress(ui::VKEY_O); 175 generator.ReleaseKey(ui::VKEY_F, ui::EF_NONE);
159 SendKeyPress(ui::VKEY_O); 176 generator.PressKey(ui::VKEY_O, ui::EF_NONE);
177 generator.ReleaseKey(ui::VKEY_O, ui::EF_NONE);
178 generator.PressKey(ui::VKEY_O, ui::EF_NONE);
179 generator.ReleaseKey(ui::VKEY_O, ui::EF_NONE);
160 180
161 // Verify the location of the caret. 181 // Verify the location of the caret.
162 size_t start, end; 182 size_t start, end;
163 omnibox->GetSelectionBounds(&start, &end); 183 omnibox->GetSelectionBounds(&start, &end);
164 ASSERT_EQ(3U, start); 184 ASSERT_EQ(3U, start);
165 ASSERT_EQ(3U, end); 185 ASSERT_EQ(3U, end);
166 186
187 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
188 EXPECT_TRUE(omnibox->GetNativeView()->HasFocus());
189
167 // Hit Home by sequencing Search (left Windows) and Left (arrow). 190 // Hit Home by sequencing Search (left Windows) and Left (arrow).
168 SendKeyPress(ui::VKEY_LWIN); 191 generator.PressKey(ui::VKEY_LWIN, ui::EF_NONE);
169 SendKeyPress(ui::VKEY_LEFT); 192 generator.ReleaseKey(ui::VKEY_LWIN, ui::EF_NONE);
193 generator.PressKey(ui::VKEY_LEFT, ui::EF_NONE);
194 generator.ReleaseKey(ui::VKEY_LEFT, ui::EF_NONE);
195
196 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
197 EXPECT_TRUE(omnibox->GetNativeView()->HasFocus());
170 198
171 // Verify caret moved to the beginning. 199 // Verify caret moved to the beginning.
172 omnibox->GetSelectionBounds(&start, &end); 200 omnibox->GetSelectionBounds(&start, &end);
173 ASSERT_EQ(0U, start); 201 ASSERT_EQ(0U, start);
174 ASSERT_EQ(0U, end); 202 ASSERT_EQ(0U, end);
175 } 203 }
176 204
177 IN_PROC_BROWSER_TEST_F(StickyKeysBrowserTest, OverlayShown) { 205 IN_PROC_BROWSER_TEST_F(StickyKeysBrowserTest, OverlayShown) {
178 const ui::KeyboardCode modifier_keys[] = { ui::VKEY_CONTROL, 206 const ui::KeyboardCode modifier_keys[] = { ui::VKEY_CONTROL,
179 ui::VKEY_SHIFT, 207 ui::VKEY_SHIFT,
(...skipping 26 matching lines...) Expand all
206 EXPECT_TRUE(sticky_keys_overlay->is_visible()); 234 EXPECT_TRUE(sticky_keys_overlay->is_visible());
207 DisableStickyKeys(); 235 DisableStickyKeys();
208 EXPECT_FALSE(controller->GetOverlayForTest()); 236 EXPECT_FALSE(controller->GetOverlayForTest());
209 for (auto key_code : modifier_keys) { 237 for (auto key_code : modifier_keys) {
210 SendKeyPress(key_code); 238 SendKeyPress(key_code);
211 EXPECT_FALSE(controller->GetOverlayForTest()); 239 EXPECT_FALSE(controller->GetOverlayForTest());
212 } 240 }
213 } 241 }
214 242
215 } // namespace chromeos 243 } // namespace chromeos
OLDNEW
« no previous file with comments | « athena/input/accelerator_manager_impl.cc ('k') | ui/base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698