OLD | NEW |
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" |
11 #include "ui/base/base_window.h" | 11 #include "ui/base/base_window.h" |
| 12 #include "ui/base/test/ui_controls.h" |
12 | 13 |
13 #if defined(OS_LINUX) | 14 #if defined(OS_LINUX) |
14 #include <X11/Xlib.h> | 15 #include <X11/Xlib.h> |
15 #include <X11/extensions/XTest.h> | 16 #include <X11/extensions/XTest.h> |
16 #include <X11/keysym.h> | 17 #include <X11/keysym.h> |
17 | 18 |
18 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 19 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
19 #include "ui/gfx/x/x11_types.h" | 20 #include "ui/gfx/x/x11_types.h" |
20 #endif | 21 #endif |
21 | 22 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 SendNativeKeyEventToXDisplay(ui::VKEY_A, true, true, false); | 122 SendNativeKeyEventToXDisplay(ui::VKEY_A, true, true, false); |
122 SendNativeKeyEventToXDisplay(ui::VKEY_9, true, true, false); | 123 SendNativeKeyEventToXDisplay(ui::VKEY_9, true, true, false); |
123 #endif | 124 #endif |
124 | 125 |
125 // If this fails, it might be because the global shortcut failed to work, | 126 // If this fails, it might be because the global shortcut failed to work, |
126 // but it might also be because the non-global shortcuts unexpectedly | 127 // but it might also be because the non-global shortcuts unexpectedly |
127 // worked. | 128 // worked. |
128 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 129 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
129 } | 130 } |
130 | 131 |
| 132 #if defined(OS_WIN) |
| 133 // The feature is only fully implemented on Windows, other platforms coming. |
| 134 #define MAYBE_GlobalDuplicatedMediaKey GlobalDuplicatedMediaKey |
| 135 #else |
| 136 #define MAYBE_GlobalDuplicatedMediaKey DISABLED_GlobalDuplicatedMediaKey |
| 137 #endif |
| 138 |
| 139 IN_PROC_BROWSER_TEST_F(GlobalCommandsApiTest, MAYBE_GlobalDuplicatedMediaKey) { |
| 140 FeatureSwitch::ScopedOverride enable_global_commands( |
| 141 FeatureSwitch::global_commands(), true); |
| 142 |
| 143 ResultCatcher catcher; |
| 144 ASSERT_TRUE(RunExtensionTest("keybinding/global_media_keys_0")) << message_; |
| 145 ASSERT_TRUE(catcher.GetNextResult()); |
| 146 ASSERT_TRUE(RunExtensionTest("keybinding/global_media_keys_1")) << message_; |
| 147 ASSERT_TRUE(catcher.GetNextResult()); |
| 148 |
| 149 Browser* incognito_browser = CreateIncognitoBrowser(); // Ditto. |
| 150 WindowController* controller = |
| 151 incognito_browser->extension_window_controller(); |
| 152 |
| 153 ui_controls::SendKeyPress(controller->window()->GetNativeWindow(), |
| 154 ui::VKEY_MEDIA_NEXT_TRACK, |
| 155 false, |
| 156 false, |
| 157 false, |
| 158 false); |
| 159 |
| 160 // We should get two success result. |
| 161 ASSERT_TRUE(catcher.GetNextResult()); |
| 162 ASSERT_TRUE(catcher.GetNextResult()); |
| 163 } |
| 164 |
131 } // namespace extensions | 165 } // namespace extensions |
OLD | NEW |