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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "chrome/browser/content_settings/cookie_settings.h" 7 #include "chrome/browser/content_settings/cookie_settings.h"
8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/prefs/pref_service_syncable.h" 10 #include "chrome/browser/prefs/pref_service_syncable.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 CreateSigninManager(false, ""); 526 CreateSigninManager(false, "");
527 527
528 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). 528 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)).
529 WillRepeatedly(Return(true)); 529 WillRepeatedly(Return(true));
530 530
531 EnableOneClick(true); 531 EnableOneClick(true);
532 EXPECT_TRUE(OneClickSigninHelper::CanOffer( 532 EXPECT_TRUE(OneClickSigninHelper::CanOffer(
533 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, 533 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL,
534 "user@gmail.com", NULL)); 534 "user@gmail.com", NULL));
535 535
536 // Simulate a policy disabling signin by writing kSigninAllowed directly.
537 profile_->GetTestingPrefService()->SetManagedPref(
538 prefs::kSigninAllowed, base::Value::CreateBooleanValue(false));
539
540 EXPECT_FALSE(OneClickSigninHelper::CanOffer(
541 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL,
542 "user@gmail.com", NULL));
543
544 // Reset the preference value to true.
545 profile_->GetTestingPrefService()->SetManagedPref(
546 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true));
547
536 // Simulate a policy disabling sync by writing kSyncManaged directly. 548 // Simulate a policy disabling sync by writing kSyncManaged directly.
537 profile_->GetTestingPrefService()->SetManagedPref( 549 profile_->GetTestingPrefService()->SetManagedPref(
538 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); 550 prefs::kSyncManaged, base::Value::CreateBooleanValue(true));
539 551
540 // Should still offer even if sync is disabled by policy. 552 // Should still offer even if sync is disabled by policy.
541 EXPECT_TRUE(OneClickSigninHelper::CanOffer( 553 EXPECT_TRUE(OneClickSigninHelper::CanOffer(
542 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, 554 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL,
543 "user@gmail.com", NULL)); 555 "user@gmail.com", NULL));
544 } 556 }
545 557
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 OneClickSigninHelper::CanOfferOnIOThreadImpl( 695 OneClickSigninHelper::CanOfferOnIOThreadImpl(
684 valid_gaia_url_, "", &request_, io_data.get())); 696 valid_gaia_url_, "", &request_, io_data.get()));
685 } 697 }
686 698
687 TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadDisabledByPolicy) { 699 TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadDisabledByPolicy) {
688 scoped_ptr<TestProfileIOData> io_data(CreateTestProfileIOData(false)); 700 scoped_ptr<TestProfileIOData> io_data(CreateTestProfileIOData(false));
689 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, 701 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER,
690 OneClickSigninHelper::CanOfferOnIOThreadImpl( 702 OneClickSigninHelper::CanOfferOnIOThreadImpl(
691 valid_gaia_url_, "", &request_, io_data.get())); 703 valid_gaia_url_, "", &request_, io_data.get()));
692 704
705 // Simulate a policy disabling signin by writing kSigninAllowed directly.
706 // We should not offer to sign in the browser.
707 profile_->GetTestingPrefService()->SetManagedPref(
708 prefs::kSigninAllowed, base::Value::CreateBooleanValue(false));
709 EXPECT_EQ(OneClickSigninHelper::DONT_OFFER,
710 OneClickSigninHelper::CanOfferOnIOThreadImpl(
711 valid_gaia_url_, "", &request_, io_data.get()));
712
713 // Reset the preference.
714 profile_->GetTestingPrefService()->SetManagedPref(
715 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true));
716
693 // Simulate a policy disabling sync by writing kSyncManaged directly. 717 // Simulate a policy disabling sync by writing kSyncManaged directly.
694 // We should still offer to sign in the browser. 718 // We should still offer to sign in the browser.
695 profile_->GetTestingPrefService()->SetManagedPref( 719 profile_->GetTestingPrefService()->SetManagedPref(
696 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); 720 prefs::kSyncManaged, base::Value::CreateBooleanValue(true));
697 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, 721 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER,
698 OneClickSigninHelper::CanOfferOnIOThreadImpl( 722 OneClickSigninHelper::CanOfferOnIOThreadImpl(
699 valid_gaia_url_, "", &request_, io_data.get())); 723 valid_gaia_url_, "", &request_, io_data.get()));
700 } 724 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698