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

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

Issue 1301583004: Revert of Delete dead signin code (SigninGlobalError) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/command_updater.h" 10 #include "chrome/browser/command_updater.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ui::ET_KEY_PRESSED, false, ui::VKEY_W, ui::EF_CONTROL_DOWN, 0))); 132 ui::ET_KEY_PRESSED, false, ui::VKEY_W, ui::EF_CONTROL_DOWN, 0)));
133 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( 133 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey(
134 IDC_FIND, content::NativeWebKeyboardEvent( 134 IDC_FIND, content::NativeWebKeyboardEvent(
135 ui::ET_KEY_PRESSED, false, ui::VKEY_F, ui::EF_CONTROL_DOWN, 0))); 135 ui::ET_KEY_PRESSED, false, ui::VKEY_F, ui::EF_CONTROL_DOWN, 0)));
136 #endif // USE_AURA 136 #endif // USE_AURA
137 } 137 }
138 138
139 TEST_F(BrowserCommandControllerTest, IncognitoCommands) { 139 TEST_F(BrowserCommandControllerTest, IncognitoCommands) {
140 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 140 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
141 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 141 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
142 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN));
142 143
143 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); 144 TestingProfile* testprofile = browser()->profile()->AsTestingProfile();
144 EXPECT_TRUE(testprofile); 145 EXPECT_TRUE(testprofile);
145 testprofile->SetGuestSession(true); 146 testprofile->SetGuestSession(true);
146 chrome::BrowserCommandController 147 chrome::BrowserCommandController
147 ::UpdateSharedCommandsForIncognitoAvailability( 148 ::UpdateSharedCommandsForIncognitoAvailability(
148 browser()->command_controller()->command_updater(), testprofile); 149 browser()->command_controller()->command_updater(), testprofile);
149 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 150 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
150 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 151 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
152 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN));
151 153
152 testprofile->SetGuestSession(false); 154 testprofile->SetGuestSession(false);
153 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(), 155 IncognitoModePrefs::SetAvailability(browser()->profile()->GetPrefs(),
154 IncognitoModePrefs::FORCED); 156 IncognitoModePrefs::FORCED);
155 chrome::BrowserCommandController 157 chrome::BrowserCommandController
156 ::UpdateSharedCommandsForIncognitoAvailability( 158 ::UpdateSharedCommandsForIncognitoAvailability(
157 browser()->command_controller()->command_updater(), testprofile); 159 browser()->command_controller()->command_updater(), testprofile);
158 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 160 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
159 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 161 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
162 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_SIGNIN));
160 } 163 }
161 164
162 TEST_F(BrowserCommandControllerTest, AppFullScreen) { 165 TEST_F(BrowserCommandControllerTest, AppFullScreen) {
163 // Enable for tabbed browser. 166 // Enable for tabbed browser.
164 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); 167 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
165 168
166 // Enabled for app windows. 169 // Enabled for app windows.
167 browser()->app_name_ = "app"; 170 browser()->app_name_ = "app";
168 ASSERT_TRUE(browser()->is_app()); 171 ASSERT_TRUE(browser()->is_app());
169 browser()->command_controller()->FullscreenStateChanged(); 172 browser()->command_controller()->FullscreenStateChanged();
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 414
412 // Guest Profiles disallow some options. 415 // Guest Profiles disallow some options.
413 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); 416 TestingProfile* testprofile = browser()->profile()->AsTestingProfile();
414 EXPECT_TRUE(testprofile); 417 EXPECT_TRUE(testprofile);
415 testprofile->SetGuestSession(true); 418 testprofile->SetGuestSession(true);
416 419
417 browser()->command_controller()->FullscreenStateChanged(); 420 browser()->command_controller()->FullscreenStateChanged();
418 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); 421 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS));
419 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); 422 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS));
420 } 423 }
424
425 TEST_F(BrowserCommandControllerTest, IncognitoModeOnSigninAllowedPrefChange) {
426 // Set up a profile with an off the record profile.
427 scoped_ptr<TestingProfile> profile1 = TestingProfile::Builder().Build();
428 Profile* profile2 = profile1->GetOffTheRecordProfile();
429
430 EXPECT_EQ(profile2->GetOriginalProfile(), profile1.get());
431
432 // Create a new browser based on the off the record profile.
433 Browser::CreateParams profile_params(profile1->GetOffTheRecordProfile(),
434 chrome::GetActiveDesktop());
435 scoped_ptr<Browser> browser2(
436 chrome::CreateBrowserWithTestWindowForParams(&profile_params));
437
438 chrome::BrowserCommandController command_controller(browser2.get());
439 const CommandUpdater* command_updater = command_controller.command_updater();
440
441 // Check that the SYNC_SETUP command is updated on preference change.
442 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
443 profile1->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
444 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
445 }
446
447 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) {
448 chrome::BrowserCommandController command_controller(browser());
449 const CommandUpdater* command_updater = command_controller.command_updater();
450
451 // Check that the SYNC_SETUP command is updated on preference change.
452 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
453 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
454 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
455 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698