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 using GlobalKeyboardShortcutsTest = ExtensionBrowserTest; |
| 20 |
| 21 // Test that global keyboard shortcuts are handled by the native window. |
| 22 IN_PROC_BROWSER_TEST_F(GlobalKeyboardShortcutsTest, SwitchTabsMac) { |
| 23 NSWindow* ns_window = browser()->window()->GetNativeWindow(); |
| 24 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 25 |
| 26 // Set up window with 2 tabs. |
| 27 chrome::NewTab(browser()); |
| 28 EXPECT_EQ(2, tab_strip->count()); |
| 29 EXPECT_TRUE(tab_strip->IsTabSelected(1)); |
| 30 |
| 31 // Ctrl+Tab goes to the next tab, which loops back to the first tab. |
| 32 [ns_window performKeyEquivalent:SynthesizeKeyEvent( |
| 33 ns_window, true, ui::VKEY_TAB, NSControlKeyMask)]; |
| 34 EXPECT_TRUE(tab_strip->IsTabSelected(0)); |
| 35 |
| 36 // Cmd+2 goes to the second tab. |
| 37 [ns_window performKeyEquivalent:SynthesizeKeyEvent( |
| 38 ns_window, true, ui::VKEY_2, NSCommandKeyMask)]; |
| 39 EXPECT_TRUE(tab_strip->IsTabSelected(1)); |
| 40 |
| 41 // Cmd+{ goes to the previous tab. |
| 42 [ns_window performKeyEquivalent:SynthesizeKeyEvent( |
| 43 ns_window, true, ui::VKEY_OEM_4, NSShiftKeyMask | NSCommandKeyMask)]; |
| 44 EXPECT_TRUE(tab_strip->IsTabSelected(0)); |
| 45 } |
OLD | NEW |