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

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

Issue 372743004: ozone: Fix interactive_ui_tests build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 12 matching lines...) Expand all
23 #if defined(OS_MACOSX) 23 #if defined(OS_MACOSX)
24 #include <Carbon/Carbon.h> 24 #include <Carbon/Carbon.h>
25 25
26 #include "base/mac/scoped_cftyperef.h" 26 #include "base/mac/scoped_cftyperef.h"
27 #endif 27 #endif
28 28
29 namespace extensions { 29 namespace extensions {
30 30
31 typedef ExtensionApiTest GlobalCommandsApiTest; 31 typedef ExtensionApiTest GlobalCommandsApiTest;
32 32
33 #if defined(OS_LINUX) 33 #if defined(OS_LINUX) && defined(USE_X11)
sky 2014/07/09 20:17:49 Do we need the OS_LINUX conditions in the ifdefs h
34 // Send a simulated key press and release event, where |control|, |shift| or 34 // Send a simulated key press and release event, where |control|, |shift| or
35 // |alt| indicates whether the key is struck with corresponding modifier. 35 // |alt| indicates whether the key is struck with corresponding modifier.
36 void SendNativeKeyEventToXDisplay(ui::KeyboardCode key, 36 void SendNativeKeyEventToXDisplay(ui::KeyboardCode key,
37 bool control, 37 bool control,
38 bool shift, 38 bool shift,
39 bool alt) { 39 bool alt) {
40 Display* display = gfx::GetXDisplay(); 40 Display* display = gfx::GetXDisplay();
41 KeyCode ctrl_key_code = XKeysymToKeycode(display, XK_Control_L); 41 KeyCode ctrl_key_code = XKeysymToKeycode(display, XK_Control_L);
42 KeyCode shift_key_code = XKeysymToKeycode(display, XK_Shift_L); 42 KeyCode shift_key_code = XKeysymToKeycode(display, XK_Shift_L);
43 KeyCode alt_key_code = XKeysymToKeycode(display, XK_Alt_L); 43 KeyCode alt_key_code = XKeysymToKeycode(display, XK_Alt_L);
(...skipping 20 matching lines...) Expand all
64 // Simulate the keys being pressed. 64 // Simulate the keys being pressed.
65 for (KeyCodes::iterator it = key_codes.begin(); it != key_codes.end(); it++) 65 for (KeyCodes::iterator it = key_codes.begin(); it != key_codes.end(); it++)
66 XTestFakeKeyEvent(display, *it, True, CurrentTime); 66 XTestFakeKeyEvent(display, *it, True, CurrentTime);
67 67
68 // Simulate the keys being released. 68 // Simulate the keys being released.
69 for (KeyCodes::iterator it = key_codes.begin(); it != key_codes.end(); it++) 69 for (KeyCodes::iterator it = key_codes.begin(); it != key_codes.end(); it++)
70 XTestFakeKeyEvent(display, *it, False, CurrentTime); 70 XTestFakeKeyEvent(display, *it, False, CurrentTime);
71 71
72 XFlush(display); 72 XFlush(display);
73 } 73 }
74 #endif // OS_LINUX 74 #endif // OS_LINUX && USE_X11
75 75
76 #if defined(OS_MACOSX) 76 #if defined(OS_MACOSX)
77 using base::ScopedCFTypeRef; 77 using base::ScopedCFTypeRef;
78 78
79 void SendNativeCommandShift(int key_code) { 79 void SendNativeCommandShift(int key_code) {
80 CGEventSourceRef event_source = 80 CGEventSourceRef event_source =
81 CGEventSourceCreate(kCGEventSourceStateHIDSystemState); 81 CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
82 CGEventTapLocation event_tap_location = kCGHIDEventTap; 82 CGEventTapLocation event_tap_location = kCGHIDEventTap;
83 83
84 // Create the keyboard press events. 84 // Create the keyboard press events.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // incognito browser. Both shortcuts should have no effect (extension is not 145 // incognito browser. Both shortcuts should have no effect (extension is not
146 // loaded there). 146 // loaded there).
147 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 147 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
148 incognito_browser, ui::VKEY_1, true, true, false, false)); 148 incognito_browser, ui::VKEY_1, true, true, false, false));
149 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 149 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
150 incognito_browser, ui::VKEY_A, true, true, false, false)); 150 incognito_browser, ui::VKEY_A, true, true, false, false));
151 151
152 // Activate the shortcut (Ctrl+Shift+9). This should have an effect. 152 // Activate the shortcut (Ctrl+Shift+9). This should have an effect.
153 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 153 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
154 incognito_browser, ui::VKEY_9, true, true, false, false)); 154 incognito_browser, ui::VKEY_9, true, true, false, false));
155 #elif defined(OS_LINUX) 155 #elif defined(OS_LINUX) && defined(USE_X11)
156 // Create an incognito browser to capture the focus. 156 // Create an incognito browser to capture the focus.
157 CreateIncognitoBrowser(); 157 CreateIncognitoBrowser();
158 158
159 // On Linux, our infrastructure for sending keys just synthesize keyboard 159 // On Linux, our infrastructure for sending keys just synthesize keyboard
160 // event and send them directly to the specified window, without notifying the 160 // event and send them directly to the specified window, without notifying the
161 // X root window. It didn't work while testing global shortcut because the 161 // X root window. It didn't work while testing global shortcut because the
162 // stuff of global shortcut on Linux need to be notified when KeyPress event 162 // stuff of global shortcut on Linux need to be notified when KeyPress event
163 // is happening on X root window. So we simulate the keyboard input here. 163 // is happening on X root window. So we simulate the keyboard input here.
164 SendNativeKeyEventToXDisplay(ui::VKEY_1, true, true, false); 164 SendNativeKeyEventToXDisplay(ui::VKEY_1, true, true, false);
165 SendNativeKeyEventToXDisplay(ui::VKEY_A, true, true, false); 165 SendNativeKeyEventToXDisplay(ui::VKEY_A, true, true, false);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 false, 208 false,
209 false, 209 false,
210 false); 210 false);
211 211
212 // We should get two success result. 212 // We should get two success result.
213 ASSERT_TRUE(catcher.GetNextResult()); 213 ASSERT_TRUE(catcher.GetNextResult());
214 ASSERT_TRUE(catcher.GetNextResult()); 214 ASSERT_TRUE(catcher.GetNextResult());
215 } 215 }
216 216
217 } // namespace extensions 217 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698