Chromium Code Reviews| Index: chrome/browser/global_keyboard_shortcuts_mac_browsertest.mm |
| diff --git a/chrome/browser/global_keyboard_shortcuts_mac_browsertest.mm b/chrome/browser/global_keyboard_shortcuts_mac_browsertest.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6d60be84229b0dba3044e399060a3bda37f962a4 |
| --- /dev/null |
| +++ b/chrome/browser/global_keyboard_shortcuts_mac_browsertest.mm |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "chrome/browser/global_keyboard_shortcuts_mac.h" |
| + |
| +#import <Cocoa/Cocoa.h> |
| + |
| +#include "base/run_loop.h" |
| +#include "chrome/browser/extensions/extension_browsertest.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_commands.h" |
| +#include "chrome/browser/ui/browser_window.h" |
| +#include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#import "ui/events/test/cocoa_test_event_utils.h" |
| + |
| +using cocoa_test_event_utils::SynthesizeKeyEvent; |
| + |
| +// Test that global keyboard shortcuts are handled by the native window. |
| +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.
|
| + NSWindow* ns_window = browser()->window()->GetNativeWindow(); |
| + TabStripModel* tab_strip = browser()->tab_strip_model(); |
| + |
| + // Set up window with 2 tabs. |
| + chrome::NewTab(browser()); |
| + EXPECT_EQ(2, tab_strip->count()); |
| + EXPECT_TRUE(tab_strip->IsTabSelected(1)); |
| + |
| + // Ctrl+Tab goes to the next tab, which loops back to the first tab. |
| + [ns_window performKeyEquivalent:SynthesizeKeyEvent( |
| + ns_window, true, ui::VKEY_TAB, NSControlKeyMask)]; |
| + EXPECT_TRUE(tab_strip->IsTabSelected(0)); |
| + |
| + // Cmd+2 goes to the second tab. |
| + [ns_window performKeyEquivalent:SynthesizeKeyEvent( |
| + ns_window, true, ui::VKEY_2, NSCommandKeyMask)]; |
| + EXPECT_TRUE(tab_strip->IsTabSelected(1)); |
| + |
| + // Cmd+{ goes to the previous tab. |
| + [ns_window performKeyEquivalent:SynthesizeKeyEvent( |
| + ns_window, true, ui::VKEY_OEM_4, NSShiftKeyMask | NSCommandKeyMask)]; |
| + EXPECT_TRUE(tab_strip->IsTabSelected(0)); |
| +} |