Roll WebRTC 5699->5721.
[chromium-blink-merge.git] / chrome / browser / ui / browser_command_controller_unittest.cc
blobb6ad670514160fae75e0266b3efb27bea30b891d
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/browser_command_controller.h"
7 #include "base/command_line.h"
8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/command_updater.h"
11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/profiles/profiles_state.h"
13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/browser_window_state.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h"
18 #include "chrome/common/profile_management_switches.h"
19 #include "chrome/test/base/browser_with_test_window_test.h"
20 #include "chrome/test/base/test_browser_window.h"
21 #include "chrome/test/base/testing_browser_process.h"
22 #include "chrome/test/base/testing_profile_manager.h"
23 #include "content/public/browser/native_web_keyboard_event.h"
24 #include "ui/events/keycodes/keyboard_codes.h"
26 typedef BrowserWithTestWindowTest BrowserCommandControllerTest;
28 TEST_F(BrowserCommandControllerTest, IsReservedCommandOrKey) {
29 #if defined(OS_CHROMEOS)
30 // F1-3 keys are reserved Chrome accelerators on Chrome OS.
31 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
32 IDC_BACK, content::NativeWebKeyboardEvent(
33 ui::ET_KEY_PRESSED, false, ui::VKEY_BROWSER_BACK, 0, 0)));
34 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
35 IDC_FORWARD, content::NativeWebKeyboardEvent(
36 ui::ET_KEY_PRESSED, false, ui::VKEY_BROWSER_FORWARD, 0, 0)));
37 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
38 IDC_RELOAD, content::NativeWebKeyboardEvent(
39 ui::ET_KEY_PRESSED, false, ui::VKEY_BROWSER_REFRESH, 0, 0)));
41 // When there are modifier keys pressed, don't reserve.
42 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
43 IDC_RELOAD_IGNORING_CACHE, content::NativeWebKeyboardEvent(
44 ui::ET_KEY_PRESSED, false, ui::VKEY_F3, ui::EF_SHIFT_DOWN, 0)));
45 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
46 IDC_RELOAD_IGNORING_CACHE, content::NativeWebKeyboardEvent(
47 ui::ET_KEY_PRESSED, false, ui::VKEY_F3, ui::EF_CONTROL_DOWN, 0)));
48 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
49 IDC_FULLSCREEN, content::NativeWebKeyboardEvent(
50 ui::ET_KEY_PRESSED, false, ui::VKEY_F4, ui::EF_SHIFT_DOWN, 0)));
52 // F4-10 keys are not reserved since they are Ash accelerators.
53 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
54 -1, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
55 ui::VKEY_F4, 0, 0)));
56 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
57 -1, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
58 ui::VKEY_F5, 0, 0)));
59 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
60 -1, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
61 ui::VKEY_F6, 0, 0)));
62 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
63 -1, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
64 ui::VKEY_F7, 0, 0)));
65 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
66 -1, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
67 ui::VKEY_F8, 0, 0)));
68 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
69 -1, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
70 ui::VKEY_F9, 0, 0)));
71 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
72 -1, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
73 ui::VKEY_F10, 0, 0)));
75 // Shift+Control+Alt+F3 is also an Ash accelerator. Don't reserve it.
76 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
77 -1, content::NativeWebKeyboardEvent(
78 ui::ET_KEY_PRESSED, false,
79 ui::VKEY_F3,
80 ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, 0)));
81 #endif // OS_CHROMEOS
83 #if defined(USE_AURA)
84 // Ctrl+n, Ctrl+w are reserved while Ctrl+f is not.
86 // The content::NativeWebKeyboardEvent constructor is available only when
87 // USE_AURA is #defined.
88 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
89 IDC_NEW_WINDOW, content::NativeWebKeyboardEvent(
90 ui::ET_KEY_PRESSED, false, ui::VKEY_N, ui::EF_CONTROL_DOWN, 0)));
91 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
92 IDC_CLOSE_TAB, content::NativeWebKeyboardEvent(
93 ui::ET_KEY_PRESSED, false, ui::VKEY_W, ui::EF_CONTROL_DOWN, 0)));
94 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
95 IDC_FIND, content::NativeWebKeyboardEvent(
96 ui::ET_KEY_PRESSED, false, ui::VKEY_F, ui::EF_CONTROL_DOWN, 0)));
97 #endif // USE_AURA
100 TEST_F(BrowserCommandControllerTest, IsReservedCommandOrKeyIsApp) {
101 browser()->app_name_ = "app";
102 ASSERT_TRUE(browser()->is_app());
104 // When is_app(), no keys are reserved.
105 #if defined(OS_CHROMEOS)
106 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
107 IDC_BACK, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
108 ui::VKEY_F1, 0, 0)));
109 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
110 IDC_FORWARD, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
111 ui::VKEY_F2, 0, 0)));
112 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
113 IDC_RELOAD, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
114 ui::VKEY_F3, 0, 0)));
115 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
116 -1, content::NativeWebKeyboardEvent(ui::ET_KEY_PRESSED, false,
117 ui::VKEY_F4, 0, 0)));
118 #endif // OS_CHROMEOS
120 #if defined(USE_AURA)
121 // The content::NativeWebKeyboardEvent constructor is available only when
122 // USE_AURA is #defined.
123 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
124 IDC_NEW_WINDOW, content::NativeWebKeyboardEvent(
125 ui::ET_KEY_PRESSED, false, ui::VKEY_N, ui::EF_CONTROL_DOWN, 0)));
126 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
127 IDC_CLOSE_TAB, content::NativeWebKeyboardEvent(
128 ui::ET_KEY_PRESSED, false, ui::VKEY_W, ui::EF_CONTROL_DOWN, 0)));
129 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
130 IDC_FIND, content::NativeWebKeyboardEvent(
131 ui::ET_KEY_PRESSED, false, ui::VKEY_F, ui::EF_CONTROL_DOWN, 0)));
132 #endif // USE_AURA
135 TEST_F(BrowserCommandControllerTest, AppFullScreen) {
136 // Enable for tabbed browser.
137 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
139 // Enabled for app windows.
140 browser()->app_name_ = "app";
141 ASSERT_TRUE(browser()->is_app());
142 browser()->command_controller()->FullscreenStateChanged();
143 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
146 TEST_F(BrowserCommandControllerTest, OldAvatarMenuDisabledWhenOnlyOneProfile) {
147 #if defined(OS_CHROMEOS)
148 // TODO(nkostylev): Cleanup this code once multi-profiles are enabled by
149 // default on CrOS. http://crbug.com/351655
150 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles);
151 #endif
153 if (!profiles::IsMultipleProfilesEnabled())
154 return;
156 EXPECT_FALSE(switches::IsNewProfileManagement());
158 TestingProfileManager testing_profile_manager(
159 TestingBrowserProcess::GetGlobal());
160 ASSERT_TRUE(testing_profile_manager.SetUp());
161 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
163 chrome::BrowserCommandController command_controller(browser(),
164 profile_manager);
165 const CommandUpdater* command_updater = command_controller.command_updater();
167 testing_profile_manager.CreateTestingProfile("p1");
168 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles());
169 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
171 testing_profile_manager.CreateTestingProfile("p2");
172 ASSERT_EQ(2U, profile_manager->GetNumberOfProfiles());
173 #if defined(OS_CHROMEOS)
174 // Chrome OS uses system tray menu to handle multi-profiles.
175 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
176 #else
177 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
178 #endif
180 testing_profile_manager.DeleteTestingProfile("p1");
181 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles());
182 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
184 testing_profile_manager.DeleteTestingProfile("p2");
187 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) {
188 #if defined(OS_CHROMEOS)
189 // TODO(nkostylev): Cleanup this code once multi-profiles are enabled by
190 // default on CrOS. http://crbug.com/351655
191 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles);
192 #endif
194 if (!profiles::IsMultipleProfilesEnabled())
195 return;
197 // The command line is reset at the end of every test by the test suite.
198 CommandLine::ForCurrentProcess()->AppendSwitch(
199 switches::kNewProfileManagement);
200 EXPECT_TRUE(switches::IsNewProfileManagement());
202 TestingProfileManager testing_profile_manager(
203 TestingBrowserProcess::GetGlobal());
204 ASSERT_TRUE(testing_profile_manager.SetUp());
205 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
207 chrome::BrowserCommandController command_controller(browser(),
208 profile_manager);
209 const CommandUpdater* command_updater = command_controller.command_updater();
211 testing_profile_manager.CreateTestingProfile("p1");
212 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles());
213 #if defined(OS_CHROMEOS)
214 // Chrome OS uses system tray menu to handle multi-profiles.
215 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
216 #else
217 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
218 #endif
219 testing_profile_manager.DeleteTestingProfile("p1");
222 TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledInGuestMode) {
223 #if defined(OS_CHROMEOS)
224 // TODO(nkostylev): Cleanup this code once multi-profiles are enabled by
225 // default on CrOS. http://crbug.com/351655
226 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles);
227 #endif
229 if (!profiles::IsMultipleProfilesEnabled())
230 return;
232 // The command line is reset at the end of every test by the test suite.
233 CommandLine::ForCurrentProcess()->AppendSwitch(
234 switches::kNewProfileManagement);
235 EXPECT_TRUE(switches::IsNewProfileManagement());
237 TestingProfileManager testing_profile_manager(
238 TestingBrowserProcess::GetGlobal());
239 ASSERT_TRUE(testing_profile_manager.SetUp());
240 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
242 // Set up guest a profile.
243 TestingProfile::Builder guest_builder;
244 guest_builder.SetIncognito(); // Guest profiles are off the record.
245 guest_builder.SetGuestSession();
246 guest_builder.SetPath(ProfileManager::GetGuestProfilePath());
247 scoped_ptr<TestingProfile>guest_profile = guest_builder.Build();
249 ASSERT_TRUE(guest_profile->IsGuestSession());
251 // Create a new browser based on the guest profile.
252 Browser::CreateParams profile_params(guest_profile.get(),
253 chrome::GetActiveDesktop());
254 scoped_ptr<Browser> guest_browser(
255 chrome::CreateBrowserWithTestWindowForParams(&profile_params));
256 chrome::BrowserCommandController command_controller(guest_browser.get(),
257 profile_manager);
258 const CommandUpdater* command_updater = command_controller.command_updater();
259 #if defined(OS_CHROMEOS)
260 // Chrome OS uses system tray menu to handle multi-profiles.
261 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
262 #else
263 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
264 #endif
267 TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) {
268 #if defined(OS_CHROMEOS)
269 // TODO(nkostylev): Cleanup this code once multi-profiles are enabled by
270 // default on CrOS. http://crbug.com/351655
271 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles);
272 #endif
274 if (!profiles::IsMultipleProfilesEnabled())
275 return;
277 TestingProfileManager testing_profile_manager(
278 TestingBrowserProcess::GetGlobal());
279 ASSERT_TRUE(testing_profile_manager.SetUp());
281 // Set up a profile with an off the record profile.
282 TestingProfile::Builder normal_builder;
283 scoped_ptr<TestingProfile> original_profile = normal_builder.Build();
285 // Create a new browser based on the off the record profile.
286 Browser::CreateParams profile_params(
287 original_profile->GetOffTheRecordProfile(), chrome::GetActiveDesktop());
288 scoped_ptr<Browser> otr_browser(
289 chrome::CreateBrowserWithTestWindowForParams(&profile_params));
291 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
292 chrome::BrowserCommandController command_controller(otr_browser.get(),
293 profile_manager);
294 const CommandUpdater* command_updater = command_controller.command_updater();
296 // The old style avatar menu should be disabled.
297 EXPECT_FALSE(switches::IsNewProfileManagement());
298 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
300 // The new style avatar menu should also be disabled.
301 // The command line is reset at the end of every test by the test suite.
302 CommandLine::ForCurrentProcess()->AppendSwitch(
303 switches::kNewProfileManagement);
304 EXPECT_TRUE(switches::IsNewProfileManagement());
305 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
308 //////////////////////////////////////////////////////////////////////////////
310 // A test browser window that can toggle fullscreen state.
311 class FullscreenTestBrowserWindow : public TestBrowserWindow {
312 public:
313 FullscreenTestBrowserWindow() : fullscreen_(false) {}
314 virtual ~FullscreenTestBrowserWindow() {}
316 // TestBrowserWindow overrides:
317 virtual bool ShouldHideUIForFullscreen() const OVERRIDE {
318 return fullscreen_;
320 virtual bool IsFullscreen() const OVERRIDE {
321 return fullscreen_;
323 virtual void EnterFullscreen(
324 const GURL& url, FullscreenExitBubbleType type) OVERRIDE {
325 fullscreen_ = true;
327 virtual void ExitFullscreen() OVERRIDE {
328 fullscreen_ = false;
331 private:
332 bool fullscreen_;
334 DISALLOW_COPY_AND_ASSIGN(FullscreenTestBrowserWindow);
337 // Test that uses FullscreenTestBrowserWindow for its window.
338 class BrowserCommandControllerFullscreenTest
339 : public BrowserWithTestWindowTest {
340 public:
341 BrowserCommandControllerFullscreenTest() {}
342 virtual ~BrowserCommandControllerFullscreenTest() {}
344 // BrowserWithTestWindowTest overrides:
345 virtual BrowserWindow* CreateBrowserWindow() OVERRIDE {
346 return new FullscreenTestBrowserWindow;
349 private:
350 DISALLOW_COPY_AND_ASSIGN(BrowserCommandControllerFullscreenTest);
353 TEST_F(BrowserCommandControllerFullscreenTest,
354 UpdateCommandsForFullscreenMode) {
355 // Defaults for a tabbed browser.
356 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL));
357 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB));
358 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR));
359 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION));
360 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH));
361 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR));
362 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE));
363 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE));
364 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS));
365 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU));
366 #if defined(GOOGLE_CHROME_BUILD)
367 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK));
368 #endif
369 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
370 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
371 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES));
372 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS));
373 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT));
374 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU));
375 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
377 // Simulate going fullscreen.
378 chrome::ToggleFullscreenMode(browser());
379 ASSERT_TRUE(browser()->window()->IsFullscreen());
380 browser()->command_controller()->FullscreenStateChanged();
382 // Most commands are disabled in fullscreen.
383 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL));
384 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB));
385 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR));
386 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION));
387 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH));
388 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR));
389 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE));
390 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE));
391 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS));
392 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU));
393 #if defined(GOOGLE_CHROME_BUILD)
394 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK));
395 #endif
396 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
397 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
398 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES));
399 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS));
400 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ABOUT));
401 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU));
402 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
404 // Exit fullscreen.
405 chrome::ToggleFullscreenMode(browser());
406 ASSERT_FALSE(browser()->window()->IsFullscreen());
407 browser()->command_controller()->FullscreenStateChanged();
408 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL));
409 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB));
410 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR));
411 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION));
412 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH));
413 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR));
414 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE));
415 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE));
416 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS));
417 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU));
418 #if defined(GOOGLE_CHROME_BUILD)
419 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK));
420 #endif
421 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
422 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
423 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES));
424 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS));
425 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT));
426 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU));
427 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
430 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) {
431 TestingProfileManager testing_profile_manager(
432 TestingBrowserProcess::GetGlobal());
433 ASSERT_TRUE(testing_profile_manager.SetUp());
435 // Set up a profile with an off the record profile.
436 TestingProfile::Builder builder;
437 builder.SetIncognito();
438 scoped_ptr<TestingProfile> profile2(builder.Build());
439 TestingProfile::Builder builder2;
440 scoped_ptr<TestingProfile> profile1 = builder2.Build();
441 profile2->SetOriginalProfile(profile1.get());
442 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get());
443 profile1->SetOffTheRecordProfile(profile2.PassAs<Profile>());
445 // Create a new browser based on the off the record profile.
446 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile(),
447 chrome::GetActiveDesktop());
448 scoped_ptr<Browser> browser2(
449 chrome::CreateBrowserWithTestWindowForParams(&profile_params));
451 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
452 chrome::BrowserCommandController command_controller(browser2.get(),
453 profile_manager);
454 const CommandUpdater* command_updater = command_controller.command_updater();
456 // Check that the SYNC_SETUP command is updated on preference change.
457 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
458 profile1->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
459 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
462 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) {
463 TestingProfileManager testing_profile_manager(
464 TestingBrowserProcess::GetGlobal());
465 ASSERT_TRUE(testing_profile_manager.SetUp());
466 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
467 chrome::BrowserCommandController command_controller(browser(),
468 profile_manager);
469 const CommandUpdater* command_updater = command_controller.command_updater();
471 // Check that the SYNC_SETUP command is updated on preference change.
472 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
473 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
474 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));