OLD | NEW |
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/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "base/prefs/scoped_user_pref_update.h" | 6 #include "base/prefs/scoped_user_pref_update.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). | 626 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). |
627 WillRepeatedly(Return(true)); | 627 WillRepeatedly(Return(true)); |
628 | 628 |
629 EnableOneClick(true); | 629 EnableOneClick(true); |
630 EXPECT_TRUE(OneClickSigninHelper::CanOffer( | 630 EXPECT_TRUE(OneClickSigninHelper::CanOffer( |
631 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, | 631 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, |
632 "user@gmail.com", NULL)); | 632 "user@gmail.com", NULL)); |
633 | 633 |
634 // Simulate a policy disabling signin by writing kSigninAllowed directly. | 634 // Simulate a policy disabling signin by writing kSigninAllowed directly. |
635 profile()->GetTestingPrefService()->SetManagedPref( | 635 profile()->GetTestingPrefService()->SetManagedPref( |
636 prefs::kSigninAllowed, base::Value::CreateBooleanValue(false)); | 636 prefs::kSigninAllowed, new base::FundamentalValue(false)); |
637 | 637 |
638 EXPECT_FALSE(OneClickSigninHelper::CanOffer( | 638 EXPECT_FALSE(OneClickSigninHelper::CanOffer( |
639 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, | 639 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, |
640 "user@gmail.com", NULL)); | 640 "user@gmail.com", NULL)); |
641 | 641 |
642 // Reset the preference value to true. | 642 // Reset the preference value to true. |
643 profile()->GetTestingPrefService()->SetManagedPref( | 643 profile()->GetTestingPrefService()->SetManagedPref( |
644 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); | 644 prefs::kSigninAllowed, new base::FundamentalValue(true)); |
645 | 645 |
646 // Simulate a policy disabling sync by writing kSyncManaged directly. | 646 // Simulate a policy disabling sync by writing kSyncManaged directly. |
647 profile()->GetTestingPrefService()->SetManagedPref( | 647 profile()->GetTestingPrefService()->SetManagedPref( |
648 sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); | 648 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(true)); |
649 | 649 |
650 // Should still offer even if sync is disabled by policy. | 650 // Should still offer even if sync is disabled by policy. |
651 EXPECT_TRUE(OneClickSigninHelper::CanOffer( | 651 EXPECT_TRUE(OneClickSigninHelper::CanOffer( |
652 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, | 652 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, |
653 "user@gmail.com", NULL)); | 653 "user@gmail.com", NULL)); |
654 } | 654 } |
655 | 655 |
656 // Should not crash if a helper instance is not associated with an incognito | 656 // Should not crash if a helper instance is not associated with an incognito |
657 // web contents. | 657 // web contents. |
658 TEST_F(OneClickSigninHelperIncognitoTest, ShowInfoBarUIThreadIncognito) { | 658 TEST_F(OneClickSigninHelperIncognitoTest, ShowInfoBarUIThreadIncognito) { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadDisabledByPolicy) { | 846 TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadDisabledByPolicy) { |
847 scoped_ptr<TestProfileIOData> io_data( | 847 scoped_ptr<TestProfileIOData> io_data( |
848 CreateTestProfileIOData(Profile::REGULAR_PROFILE)); | 848 CreateTestProfileIOData(Profile::REGULAR_PROFILE)); |
849 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, | 849 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, |
850 OneClickSigninHelper::CanOfferOnIOThreadImpl( | 850 OneClickSigninHelper::CanOfferOnIOThreadImpl( |
851 valid_gaia_url_, &request_, io_data.get())); | 851 valid_gaia_url_, &request_, io_data.get())); |
852 | 852 |
853 // Simulate a policy disabling signin by writing kSigninAllowed directly. | 853 // Simulate a policy disabling signin by writing kSigninAllowed directly. |
854 // We should not offer to sign in the browser. | 854 // We should not offer to sign in the browser. |
855 profile()->GetTestingPrefService()->SetManagedPref( | 855 profile()->GetTestingPrefService()->SetManagedPref( |
856 prefs::kSigninAllowed, base::Value::CreateBooleanValue(false)); | 856 prefs::kSigninAllowed, new base::FundamentalValue(false)); |
857 EXPECT_EQ(OneClickSigninHelper::DONT_OFFER, | 857 EXPECT_EQ(OneClickSigninHelper::DONT_OFFER, |
858 OneClickSigninHelper::CanOfferOnIOThreadImpl( | 858 OneClickSigninHelper::CanOfferOnIOThreadImpl( |
859 valid_gaia_url_, &request_, io_data.get())); | 859 valid_gaia_url_, &request_, io_data.get())); |
860 | 860 |
861 // Reset the preference. | 861 // Reset the preference. |
862 profile()->GetTestingPrefService()->SetManagedPref( | 862 profile()->GetTestingPrefService()->SetManagedPref( |
863 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); | 863 prefs::kSigninAllowed, new base::FundamentalValue(true)); |
864 | 864 |
865 // Simulate a policy disabling sync by writing kSyncManaged directly. | 865 // Simulate a policy disabling sync by writing kSyncManaged directly. |
866 // We should still offer to sign in the browser. | 866 // We should still offer to sign in the browser. |
867 profile()->GetTestingPrefService()->SetManagedPref( | 867 profile()->GetTestingPrefService()->SetManagedPref( |
868 sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); | 868 sync_driver::prefs::kSyncManaged, new base::FundamentalValue(true)); |
869 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, | 869 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, |
870 OneClickSigninHelper::CanOfferOnIOThreadImpl( | 870 OneClickSigninHelper::CanOfferOnIOThreadImpl( |
871 valid_gaia_url_, &request_, io_data.get())); | 871 valid_gaia_url_, &request_, io_data.get())); |
872 } | 872 } |
873 | 873 |
874 | 874 |
875 class MockStarterWrapper | 875 class MockStarterWrapper |
876 : public testing::StrictMock<OneClickSigninHelper::SyncStarterWrapper> { | 876 : public testing::StrictMock<OneClickSigninHelper::SyncStarterWrapper> { |
877 public: | 877 public: |
878 MockStarterWrapper( | 878 MockStarterWrapper( |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 args.email = "foo@gmail.com"; | 1012 args.email = "foo@gmail.com"; |
1013 args.profile = profile(); | 1013 args.profile = profile(); |
1014 MockStarterWrapper* wrapper = new MockStarterWrapper( | 1014 MockStarterWrapper* wrapper = new MockStarterWrapper( |
1015 args, OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 1015 args, OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
1016 SetCookie("LSID=1234; domain=google.com; secure; httponly"); | 1016 SetCookie("LSID=1234; domain=google.com; secure; httponly"); |
1017 | 1017 |
1018 EXPECT_CALL(*wrapper, DisplayErrorBubble(_)); | 1018 EXPECT_CALL(*wrapper, DisplayErrorBubble(_)); |
1019 wrapper->Start(); | 1019 wrapper->Start(); |
1020 base::RunLoop().RunUntilIdle(); | 1020 base::RunLoop().RunUntilIdle(); |
1021 } | 1021 } |
OLD | NEW |