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

Side by Side Diff: chrome/browser/extensions/extension_commands_global_registry_apitest.cc

Issue 350943003: Support global keyboard commands on Chrome OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address various comments. Created 6 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 #include "chrome/browser/extensions/window_controller.h" 6 #include "chrome/browser/extensions/window_controller.h"
7 #include "chrome/browser/ui/browser_window.h" 7 #include "chrome/browser/ui/browser_window.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" 8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/test/base/interactive_test_utils.h" 9 #include "chrome/test/base/interactive_test_utils.h"
10 #include "content/public/test/browser_test_utils.h" 10 #include "content/public/test/browser_test_utils.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 CGEventPost(event_tap_location, shift_down); 104 CGEventPost(event_tap_location, shift_down);
105 CGEventPost(event_tap_location, key_down); 105 CGEventPost(event_tap_location, key_down);
106 CGEventPost(event_tap_location, key_up); 106 CGEventPost(event_tap_location, key_up);
107 CGEventPost(event_tap_location, shift_up); 107 CGEventPost(event_tap_location, shift_up);
108 CGEventPost(event_tap_location, command_up); 108 CGEventPost(event_tap_location, command_up);
109 109
110 CFRelease(event_source); 110 CFRelease(event_source);
111 } 111 }
112 #endif 112 #endif
113 113
114 #if defined(OS_CHROMEOS)
115 // Fully implemented everywhere except Chrome OS.
116 #define MAYBE_GlobalCommand DISABLED_GlobalCommand
117 #else
118 #define MAYBE_GlobalCommand GlobalCommand
119 #endif
120
121 // Test the basics of global commands and make sure they work when Chrome 114 // Test the basics of global commands and make sure they work when Chrome
122 // doesn't have focus. Also test that non-global commands are not treated as 115 // doesn't have focus. Also test that non-global commands are not treated as
123 // global and that keys beyond Ctrl+Shift+[0..9] cannot be auto-assigned by an 116 // global and that keys beyond Ctrl+Shift+[0..9] cannot be auto-assigned by an
124 // extension. 117 // extension.
125 IN_PROC_BROWSER_TEST_F(GlobalCommandsApiTest, MAYBE_GlobalCommand) { 118 IN_PROC_BROWSER_TEST_F(GlobalCommandsApiTest, GlobalCommand) {
126 FeatureSwitch::ScopedOverride enable_global_commands(
127 FeatureSwitch::global_commands(), true);
128
129 // Load the extension in the non-incognito browser. 119 // Load the extension in the non-incognito browser.
130 ResultCatcher catcher; 120 ResultCatcher catcher;
131 ASSERT_TRUE(RunExtensionTest("keybinding/global")) << message_; 121 ASSERT_TRUE(RunExtensionTest("keybinding/global")) << message_;
132 ASSERT_TRUE(catcher.GetNextResult()); 122 ASSERT_TRUE(catcher.GetNextResult());
133 123
134 #if defined(OS_WIN) 124 #if defined(OS_WIN) || defined(OS_CHROMEOS)
Finnur 2014/06/27 11:10:57 Yay! I was hoping something like this would do the
dtseng 2014/07/07 18:17:19 Sorry for the late update on this (just back from
135 // Our infrastructure for sending keys expects a browser to send them to, but 125 // Our infrastructure for sending keys expects a browser to send them to, but
136 // to properly test global shortcuts you need to send them to another target. 126 // to properly test global shortcuts you need to send them to another target.
137 // So, create an incognito browser to use as a target to send the shortcuts 127 // So, create an incognito browser to use as a target to send the shortcuts
138 // to. It will ignore all of them and allow us test whether the global 128 // to. It will ignore all of them and allow us test whether the global
139 // shortcut really is global in nature and also that the non-global shortcut 129 // shortcut really is global in nature and also that the non-global shortcut
140 // is non-global. 130 // is non-global.
141 Browser* incognito_browser = CreateIncognitoBrowser(); 131 Browser* incognito_browser = CreateIncognitoBrowser();
142 132
143 // Try to activate the non-global shortcut (Ctrl+Shift+1) and the 133 // Try to activate the non-global shortcut (Ctrl+Shift+1) and the
144 // non-assignable shortcut (Ctrl+Shift+A) by sending the keystrokes to the 134 // non-assignable shortcut (Ctrl+Shift+A) by sending the keystrokes to the
(...skipping 28 matching lines...) Expand all
173 SendNativeCommandShift(kVK_ANSI_A); 163 SendNativeCommandShift(kVK_ANSI_A);
174 SendNativeCommandShift(kVK_ANSI_9); 164 SendNativeCommandShift(kVK_ANSI_9);
175 #endif 165 #endif
176 166
177 // If this fails, it might be because the global shortcut failed to work, 167 // If this fails, it might be because the global shortcut failed to work,
178 // but it might also be because the non-global shortcuts unexpectedly 168 // but it might also be because the non-global shortcuts unexpectedly
179 // worked. 169 // worked.
180 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 170 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
181 } 171 }
182 172
183 #if defined(OS_WIN) 173 #if defined(OS_WIN)
Finnur 2014/06/27 11:10:57 What was the outcome of the experiment to run this
David Tseng 2014/06/28 14:17:50 It does pass; I'll enable the test for Chrome OS a
Finnur 2014/06/30 10:39:44 Yeah, when I wrote that comment, the other platfor
184 // The feature is only fully implemented on Windows, other platforms coming. 174 // The feature is only fully implemented on Windows, other platforms coming.
185 // TODO(smus): On mac, SendKeyPress must first support media keys. 175 // TODO(smus): On mac, SendKeyPress must first support media keys.
186 #define MAYBE_GlobalDuplicatedMediaKey GlobalDuplicatedMediaKey 176 #define MAYBE_GlobalDuplicatedMediaKey GlobalDuplicatedMediaKey
187 #else 177 #else
188 #define MAYBE_GlobalDuplicatedMediaKey DISABLED_GlobalDuplicatedMediaKey 178 #define MAYBE_GlobalDuplicatedMediaKey DISABLED_GlobalDuplicatedMediaKey
189 #endif 179 #endif
190 180
191 IN_PROC_BROWSER_TEST_F(GlobalCommandsApiTest, MAYBE_GlobalDuplicatedMediaKey) { 181 IN_PROC_BROWSER_TEST_F(GlobalCommandsApiTest, MAYBE_GlobalDuplicatedMediaKey) {
192 FeatureSwitch::ScopedOverride enable_global_commands(
193 FeatureSwitch::global_commands(), true);
194
195 ResultCatcher catcher; 182 ResultCatcher catcher;
196 ASSERT_TRUE(RunExtensionTest("keybinding/global_media_keys_0")) << message_; 183 ASSERT_TRUE(RunExtensionTest("keybinding/global_media_keys_0")) << message_;
197 ASSERT_TRUE(catcher.GetNextResult()); 184 ASSERT_TRUE(catcher.GetNextResult());
198 ASSERT_TRUE(RunExtensionTest("keybinding/global_media_keys_1")) << message_; 185 ASSERT_TRUE(RunExtensionTest("keybinding/global_media_keys_1")) << message_;
199 ASSERT_TRUE(catcher.GetNextResult()); 186 ASSERT_TRUE(catcher.GetNextResult());
200 187
201 Browser* incognito_browser = CreateIncognitoBrowser(); // Ditto. 188 Browser* incognito_browser = CreateIncognitoBrowser(); // Ditto.
202 WindowController* controller = 189 WindowController* controller =
203 incognito_browser->extension_window_controller(); 190 incognito_browser->extension_window_controller();
204 191
205 ui_controls::SendKeyPress(controller->window()->GetNativeWindow(), 192 ui_controls::SendKeyPress(controller->window()->GetNativeWindow(),
206 ui::VKEY_MEDIA_NEXT_TRACK, 193 ui::VKEY_MEDIA_NEXT_TRACK,
207 false, 194 false,
208 false, 195 false,
209 false, 196 false,
210 false); 197 false);
211 198
212 // We should get two success result. 199 // We should get two success result.
213 ASSERT_TRUE(catcher.GetNextResult()); 200 ASSERT_TRUE(catcher.GetNextResult());
214 ASSERT_TRUE(catcher.GetNextResult()); 201 ASSERT_TRUE(catcher.GetNextResult());
215 } 202 }
216 203
217 } // namespace extensions 204 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698