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

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: 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/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 2c3d8394fd9738d30a97367d91aa1d487ee158ea..8b6811621ab0b52c11ce71e1ca1d0164c5694a0f 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
@@ -76,6 +76,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);
}
@@ -536,6 +538,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));
@@ -741,6 +755,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(

Powered by Google App Engine
This is Rietveld 408576698