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

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: Add tests and link UpdateLogin to kSigninAllowed pref. 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..a6eaa23d4d6afc3d3c87fc5ac0662b146df01cb4 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,51 @@ 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* profile1 =
+ testing_profile_manager.CreateTestingProfile("p1");
+ TestingProfile* profile2 = new TestingProfile();
+ profile2->set_incognito(true);
Andrew T Wilson (Slow) 2013/02/07 10:08:11 nit: This is the wrong way to create an incognito
Adrian Kuegel 2013/02/07 11:09:21 Done.
+ profile2->SetOriginalProfile(profile1);
+ EXPECT_EQ(profile2->GetOriginalProfile(), profile1);
+ profile1->SetOffTheRecordProfile(profile2);
+
+ // Create a new browser based on the off the record profile.
+ scoped_ptr<Browser> browser2(
+ chrome::CreateBrowserWithTestWindowForProfile(profile2));
+ 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