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

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: Extract managed user specific stuff into another changelist. 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
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 9cc87b7131a1490153969d97f5b4b1a8ccb9f499..04d1606ca3b5b711de55d21427f0867ec8f10dae 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/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
@@ -177,3 +179,52 @@ TEST_F(BrowserCommandControllerTest, AvatarMenuDisabledWhenOnlyOneProfile) {
testing_profile_manager.DeleteTestingProfile("p2");
}
+
+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::Builder profile_builder;
+ profile_builder.SetOffTheRecord();
+ scoped_ptr<TestingProfile> profile2 = profile_builder.Build();
+ TestingProfile* profile1 =
+ testing_profile_manager.CreateTestingProfile("p1");
+ profile2->SetOriginalProfile(profile1);
+ EXPECT_EQ(profile2->GetOriginalProfile(), profile1);
+ // Create a new browser based on the off the record profile.
+ scoped_ptr<Browser> browser2(
+ chrome::CreateBrowserWithTestWindowForProfile(profile2.get()));
+ profile1->SetOffTheRecordProfile(profile2.release());
+
+ 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));
+}

Powered by Google App Engine
This is Rietveld 408576698