OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #import "chrome/browser/global_keyboard_shortcuts_mac.h" | |
6 | |
7 #import <Cocoa/Cocoa.h> | |
8 | |
9 #include "base/run_loop.h" | |
10 #include "chrome/browser/extensions/extension_browsertest.h" | |
11 #include "chrome/browser/ui/browser.h" | |
12 #include "chrome/browser/ui/browser_commands.h" | |
13 #include "chrome/browser/ui/browser_window.h" | |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
15 #import "ui/events/test/cocoa_test_event_utils.h" | |
16 | |
17 using cocoa_test_event_utils::SynthesizeKeyEvent; | |
18 | |
19 // Test that global keyboard shortcuts are handled by the native window. | |
20 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, GlobalKeyboardShortcuts) { | |
tapted
2015/07/30 00:20:14
oops - I missed this. There should probably be a `
jackhou1
2015/07/30 01:45:57
Done.
| |
21 NSWindow* ns_window = browser()->window()->GetNativeWindow(); | |
22 TabStripModel* tab_strip = browser()->tab_strip_model(); | |
23 | |
24 // Set up window with 2 tabs. | |
25 chrome::NewTab(browser()); | |
26 EXPECT_EQ(2, tab_strip->count()); | |
27 EXPECT_TRUE(tab_strip->IsTabSelected(1)); | |
28 | |
29 // Ctrl+Tab goes to the next tab, which loops back to the first tab. | |
30 [ns_window performKeyEquivalent:SynthesizeKeyEvent( | |
31 ns_window, true, ui::VKEY_TAB, NSControlKeyMask)]; | |
32 EXPECT_TRUE(tab_strip->IsTabSelected(0)); | |
33 | |
34 // Cmd+2 goes to the second tab. | |
35 [ns_window performKeyEquivalent:SynthesizeKeyEvent( | |
36 ns_window, true, ui::VKEY_2, NSCommandKeyMask)]; | |
37 EXPECT_TRUE(tab_strip->IsTabSelected(1)); | |
38 | |
39 // Cmd+{ goes to the previous tab. | |
40 [ns_window performKeyEquivalent:SynthesizeKeyEvent( | |
41 ns_window, true, ui::VKEY_OEM_4, NSShiftKeyMask | NSCommandKeyMask)]; | |
42 EXPECT_TRUE(tab_strip->IsTabSelected(0)); | |
43 } | |
OLD | NEW |