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

Unified Diff: chrome/browser/ui/browser_command_controller_unittest.cc

Issue 12088040: Add a SigninAllowed policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits and rebase to ToT. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | chrome/browser/ui/chrome_pages.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_command_controller_unittest.cc
diff --git a/chrome/browser/ui/browser_command_controller_unittest.cc b/chrome/browser/ui/browser_command_controller_unittest.cc
index 5f412bf848a07ce3842010126e9c78888bc5de31..2205e3bb3850755b55453c84d7ca0f6544e13516 100644
--- a/chrome/browser/ui/browser_command_controller_unittest.cc
+++ b/chrome/browser/ui/browser_command_controller_unittest.cc
@@ -6,10 +6,12 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/command_updater.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window_state.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/test_browser_window.h"
#include "chrome/test/base/testing_browser_process.h"
@@ -318,3 +320,53 @@ TEST_F(BrowserCommandControllerFullscreenTest,
EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU));
EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
}
+
+TEST_F(BrowserCommandControllerTest,
+ IncognitoModeOnSigninAllowedPrefChange) {
+ TestingProfileManager testing_profile_manager(
+ TestingBrowserProcess::GetGlobal());
+ ASSERT_TRUE(testing_profile_manager.SetUp());
+
+ // Set up a profile with an off the record profile.
+ TestingProfile* profile2 = new TestingProfile();
+ profile2->set_incognito(true);
+ TestingProfile* profile1 =
+ testing_profile_manager.CreateTestingProfile("p1");
+ profile2->SetOriginalProfile(profile1);
+ EXPECT_EQ(profile2->GetOriginalProfile(), profile1);
+ profile1->SetOffTheRecordProfile(profile2);
+ // Create a new browser based on the off the record profile.
+ Browser::CreateParams profile_params(profile2,
+ chrome::HOST_DESKTOP_TYPE_NATIVE);
+ scoped_ptr<Browser> browser2(
+ chrome::CreateBrowserWithTestWindowForParams(&profile_params));
+
+ ProfileManager* profile_manager = testing_profile_manager.profile_manager();
+ chrome::BrowserCommandController* command_controller =
+ new chrome::BrowserCommandController(browser2.get(), profile_manager);
+ const CommandUpdater* command_updater = command_controller->command_updater();
+
+ // Check that the SYNC_SETUP command is updated on preference change.
+ EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
+ profile1->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
+ EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
+ delete command_controller;
+ browser2.reset();
+ testing_profile_manager.DeleteTestingProfile("p1");
+}
+
+TEST_F(BrowserCommandControllerTest,
+ OnSigninAllowedPrefChange) {
+ TestingProfileManager testing_profile_manager(
+ TestingBrowserProcess::GetGlobal());
+ ASSERT_TRUE(testing_profile_manager.SetUp());
+ ProfileManager* profile_manager = testing_profile_manager.profile_manager();
+ chrome::BrowserCommandController command_controller(browser(),
+ profile_manager);
+ const CommandUpdater* command_updater = command_controller.command_updater();
+
+ // Check that the SYNC_SETUP command is updated on preference change.
+ EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
+ profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
+ EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
+}
« no previous file with comments | « chrome/browser/ui/browser_command_controller.cc ('k') | chrome/browser/ui/chrome_pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698