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

Side by Side Diff: chrome/browser/ui/browser_command_controller_unittest.cc

Issue 1560293002: Rename KEY_ constants to avoid conflict with <linux/input.h> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments (Wez) Created 4 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/browser_command_controller.h" 5 #include "chrome/browser/ui/browser_command_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)))); 93 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN))));
94 #endif // OS_CHROMEOS 94 #endif // OS_CHROMEOS
95 95
96 #if defined(USE_AURA) 96 #if defined(USE_AURA)
97 // Ctrl+n, Ctrl+w are reserved while Ctrl+f is not. 97 // Ctrl+n, Ctrl+w are reserved while Ctrl+f is not.
98 98
99 // The content::NativeWebKeyboardEvent constructor is available only when 99 // The content::NativeWebKeyboardEvent constructor is available only when
100 // USE_AURA is #defined. 100 // USE_AURA is #defined.
101 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( 101 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
102 IDC_NEW_WINDOW, content::NativeWebKeyboardEvent(ui::KeyEvent( 102 IDC_NEW_WINDOW, content::NativeWebKeyboardEvent(ui::KeyEvent(
103 ui::ET_KEY_PRESSED, ui::VKEY_N, ui::DomCode::KEY_N, 103 ui::ET_KEY_PRESSED, ui::VKEY_N, ui::DomCode::US_N,
104 ui::EF_CONTROL_DOWN)))); 104 ui::EF_CONTROL_DOWN))));
105 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( 105 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
106 IDC_CLOSE_TAB, content::NativeWebKeyboardEvent(ui::KeyEvent( 106 IDC_CLOSE_TAB, content::NativeWebKeyboardEvent(ui::KeyEvent(
107 ui::ET_KEY_PRESSED, ui::VKEY_W, ui::DomCode::KEY_W, 107 ui::ET_KEY_PRESSED, ui::VKEY_W, ui::DomCode::US_W,
108 ui::EF_CONTROL_DOWN)))); 108 ui::EF_CONTROL_DOWN))));
109 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( 109 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
110 IDC_FIND, content::NativeWebKeyboardEvent( 110 IDC_FIND, content::NativeWebKeyboardEvent(
111 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_F, 111 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_F,
112 ui::DomCode::KEY_F, ui::EF_CONTROL_DOWN)))); 112 ui::DomCode::US_F, ui::EF_CONTROL_DOWN))));
113 #endif // USE_AURA 113 #endif // USE_AURA
114 } 114 }
115 115
116 TEST_F(BrowserCommandControllerTest, IsReservedCommandOrKeyIsApp) { 116 TEST_F(BrowserCommandControllerTest, IsReservedCommandOrKeyIsApp) {
117 browser()->app_name_ = "app"; 117 browser()->app_name_ = "app";
118 ASSERT_TRUE(browser()->is_app()); 118 ASSERT_TRUE(browser()->is_app());
119 119
120 // When is_app(), no keys are reserved. 120 // When is_app(), no keys are reserved.
121 #if defined(OS_CHROMEOS) 121 #if defined(OS_CHROMEOS)
122 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( 122 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
123 IDC_BACK, content::NativeWebKeyboardEvent(ui::KeyEvent( 123 IDC_BACK, content::NativeWebKeyboardEvent(ui::KeyEvent(
124 ui::ET_KEY_PRESSED, ui::VKEY_F1, ui::DomCode::F1, 0)))); 124 ui::ET_KEY_PRESSED, ui::VKEY_F1, ui::DomCode::F1, 0))));
125 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( 125 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
126 IDC_FORWARD, content::NativeWebKeyboardEvent(ui::KeyEvent( 126 IDC_FORWARD, content::NativeWebKeyboardEvent(ui::KeyEvent(
127 ui::ET_KEY_PRESSED, ui::VKEY_F2, ui::DomCode::F2, 0)))); 127 ui::ET_KEY_PRESSED, ui::VKEY_F2, ui::DomCode::F2, 0))));
128 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( 128 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
129 IDC_RELOAD, content::NativeWebKeyboardEvent(ui::KeyEvent( 129 IDC_RELOAD, content::NativeWebKeyboardEvent(ui::KeyEvent(
130 ui::ET_KEY_PRESSED, ui::VKEY_F3, ui::DomCode::F3, 0)))); 130 ui::ET_KEY_PRESSED, ui::VKEY_F3, ui::DomCode::F3, 0))));
131 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( 131 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
132 -1, content::NativeWebKeyboardEvent(ui::KeyEvent( 132 -1, content::NativeWebKeyboardEvent(ui::KeyEvent(
133 ui::ET_KEY_PRESSED, ui::VKEY_F4, ui::DomCode::F4, 0)))); 133 ui::ET_KEY_PRESSED, ui::VKEY_F4, ui::DomCode::F4, 0))));
134 #endif // OS_CHROMEOS 134 #endif // OS_CHROMEOS
135 135
136 #if defined(USE_AURA) 136 #if defined(USE_AURA)
137 // The content::NativeWebKeyboardEvent constructor is available only when 137 // The content::NativeWebKeyboardEvent constructor is available only when
138 // USE_AURA is #defined. 138 // USE_AURA is #defined.
139 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( 139 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
140 IDC_NEW_WINDOW, content::NativeWebKeyboardEvent(ui::KeyEvent( 140 IDC_NEW_WINDOW, content::NativeWebKeyboardEvent(ui::KeyEvent(
141 ui::ET_KEY_PRESSED, ui::VKEY_N, ui::DomCode::KEY_N, 141 ui::ET_KEY_PRESSED, ui::VKEY_N, ui::DomCode::US_N,
142 ui::EF_CONTROL_DOWN)))); 142 ui::EF_CONTROL_DOWN))));
143 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( 143 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
144 IDC_CLOSE_TAB, content::NativeWebKeyboardEvent(ui::KeyEvent( 144 IDC_CLOSE_TAB, content::NativeWebKeyboardEvent(ui::KeyEvent(
145 ui::ET_KEY_PRESSED, ui::VKEY_W, ui::DomCode::KEY_W, 145 ui::ET_KEY_PRESSED, ui::VKEY_W, ui::DomCode::US_W,
146 ui::EF_CONTROL_DOWN)))); 146 ui::EF_CONTROL_DOWN))));
147 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( 147 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
148 IDC_FIND, content::NativeWebKeyboardEvent( 148 IDC_FIND, content::NativeWebKeyboardEvent(
149 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_F, 149 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_F,
150 ui::DomCode::KEY_F, ui::EF_CONTROL_DOWN)))); 150 ui::DomCode::US_F, ui::EF_CONTROL_DOWN))));
151 #endif // USE_AURA 151 #endif // USE_AURA
152 } 152 }
153 153
154 TEST_F(BrowserCommandControllerTest, IncognitoCommands) { 154 TEST_F(BrowserCommandControllerTest, IncognitoCommands) {
155 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 155 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
156 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 156 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
157 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN)); 157 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN));
158 158
159 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); 159 TestingProfile* testprofile = browser()->profile()->AsTestingProfile();
160 EXPECT_TRUE(testprofile); 160 EXPECT_TRUE(testprofile);
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 422
423 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { 423 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) {
424 chrome::BrowserCommandController command_controller(browser()); 424 chrome::BrowserCommandController command_controller(browser());
425 const CommandUpdater* command_updater = command_controller.command_updater(); 425 const CommandUpdater* command_updater = command_controller.command_updater();
426 426
427 // Check that the SYNC_SETUP command is updated on preference change. 427 // Check that the SYNC_SETUP command is updated on preference change.
428 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 428 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
429 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); 429 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
430 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); 430 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
431 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698