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

Unified Diff: chrome/browser/ui/sync/one_click_signin_helper_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/sync/one_click_signin_helper.cc ('k') | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
diff --git a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
index 0d889188520644fa00d5d47b59e89295136ed41d..fe68163f6a7c0d10bf3bb4bf0eae955771d139dd 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
@@ -77,6 +77,8 @@ class TestProfileIOData : public ProfileIOData {
sync_disabled()->Init(prefs::kSyncManaged, pref_service);
+ signin_allowed()->Init(prefs::kSigninAllowed, pref_service);
+
set_signin_names_for_testing(new SigninNamesOnIOThread());
SetCookieSettingsForTesting(cookie_settings);
}
@@ -582,6 +584,18 @@ TEST_F(OneClickSigninHelperTest, CanOfferDisabledByPolicy) {
web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL,
"user@gmail.com", NULL));
+ // Simulate a policy disabling signin by writing kSigninAllowed directly.
+ profile_->GetTestingPrefService()->SetManagedPref(
+ prefs::kSigninAllowed, base::Value::CreateBooleanValue(false));
+
+ EXPECT_FALSE(OneClickSigninHelper::CanOffer(
+ web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL,
+ "user@gmail.com", NULL));
+
+ // Reset the preference value to true.
+ profile_->GetTestingPrefService()->SetManagedPref(
+ prefs::kSigninAllowed, base::Value::CreateBooleanValue(true));
+
// Simulate a policy disabling sync by writing kSyncManaged directly.
profile_->GetTestingPrefService()->SetManagedPref(
prefs::kSyncManaged, base::Value::CreateBooleanValue(true));
@@ -785,6 +799,18 @@ TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadDisabledByPolicy) {
OneClickSigninHelper::CanOfferOnIOThreadImpl(
valid_gaia_url_, "", &request_, io_data.get()));
+ // Simulate a policy disabling signin by writing kSigninAllowed directly.
+ // We should not offer to sign in the browser.
+ profile_->GetTestingPrefService()->SetManagedPref(
+ prefs::kSigninAllowed, base::Value::CreateBooleanValue(false));
+ EXPECT_EQ(OneClickSigninHelper::DONT_OFFER,
+ OneClickSigninHelper::CanOfferOnIOThreadImpl(
+ valid_gaia_url_, "", &request_, io_data.get()));
+
+ // Reset the preference.
+ profile_->GetTestingPrefService()->SetManagedPref(
+ prefs::kSigninAllowed, base::Value::CreateBooleanValue(true));
+
// Simulate a policy disabling sync by writing kSyncManaged directly.
// We should still offer to sign in the browser.
profile_->GetTestingPrefService()->SetManagedPref(
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | chrome/browser/ui/toolbar/wrench_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698