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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper_unittest.cc

Issue 195873020: [Sync] Move SyncPrefs into sync_driver component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rerererebase Created 6 years, 9 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/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 18 matching lines...) Expand all
29 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 29 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
30 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 30 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 32 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
33 #include "chrome/test/base/testing_browser_process.h" 33 #include "chrome/test/base/testing_browser_process.h"
34 #include "chrome/test/base/testing_pref_service_syncable.h" 34 #include "chrome/test/base/testing_pref_service_syncable.h"
35 #include "chrome/test/base/testing_profile.h" 35 #include "chrome/test/base/testing_profile.h"
36 #include "chrome/test/base/testing_profile_manager.h" 36 #include "chrome/test/base/testing_profile_manager.h"
37 #include "components/autofill/core/common/password_form.h" 37 #include "components/autofill/core/common/password_form.h"
38 #include "components/signin/core/profile_oauth2_token_service.h" 38 #include "components/signin/core/profile_oauth2_token_service.h"
39 #include "components/sync_driver/pref_names.h"
39 #include "content/public/browser/browser_context.h" 40 #include "content/public/browser/browser_context.h"
40 #include "content/public/browser/navigation_details.h" 41 #include "content/public/browser/navigation_details.h"
41 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
42 #include "content/public/common/frame_navigate_params.h" 43 #include "content/public/common/frame_navigate_params.h"
43 #include "content/public/common/url_constants.h" 44 #include "content/public/common/url_constants.h"
44 #include "content/public/test/mock_render_process_host.h" 45 #include "content/public/test/mock_render_process_host.h"
45 #include "grit/chromium_strings.h" 46 #include "grit/chromium_strings.h"
46 #include "grit/generated_resources.h" 47 #include "grit/generated_resources.h"
47 #include "testing/gtest/include/gtest/gtest.h" 48 #include "testing/gtest/include/gtest/gtest.h"
48 #include "ui/base/l10n/l10n_util.h" 49 #include "ui/base/l10n/l10n_util.h"
(...skipping 27 matching lines...) Expand all
76 google_services_username()->Init(prefs::kGoogleServicesUsername, 77 google_services_username()->Init(prefs::kGoogleServicesUsername,
77 pref_service); 78 pref_service);
78 reverse_autologin_enabled()->Init(prefs::kReverseAutologinEnabled, 79 reverse_autologin_enabled()->Init(prefs::kReverseAutologinEnabled,
79 pref_service); 80 pref_service);
80 one_click_signin_rejected_email_list()->Init( 81 one_click_signin_rejected_email_list()->Init(
81 prefs::kReverseAutologinRejectedEmailList, pref_service); 82 prefs::kReverseAutologinRejectedEmailList, pref_service);
82 83
83 google_services_username_pattern()->Init( 84 google_services_username_pattern()->Init(
84 prefs::kGoogleServicesUsernamePattern, local_state); 85 prefs::kGoogleServicesUsernamePattern, local_state);
85 86
86 sync_disabled()->Init(prefs::kSyncManaged, pref_service); 87 sync_disabled()->Init(sync_driver::prefs::kSyncManaged, pref_service);
87 88
88 signin_allowed()->Init(prefs::kSigninAllowed, pref_service); 89 signin_allowed()->Init(prefs::kSigninAllowed, pref_service);
89 90
90 set_signin_names_for_testing(new SigninNamesOnIOThread()); 91 set_signin_names_for_testing(new SigninNamesOnIOThread());
91 SetCookieSettingsForTesting(cookie_settings); 92 SetCookieSettingsForTesting(cookie_settings);
92 } 93 }
93 94
94 virtual ~TestProfileIOData() { 95 virtual ~TestProfileIOData() {
95 signin_names()->ReleaseResourcesOnUIThread(); 96 signin_names()->ReleaseResourcesOnUIThread();
96 } 97 }
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 EXPECT_FALSE(OneClickSigninHelper::CanOffer( 633 EXPECT_FALSE(OneClickSigninHelper::CanOffer(
633 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, 634 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL,
634 "user@gmail.com", NULL)); 635 "user@gmail.com", NULL));
635 636
636 // Reset the preference value to true. 637 // Reset the preference value to true.
637 profile()->GetTestingPrefService()->SetManagedPref( 638 profile()->GetTestingPrefService()->SetManagedPref(
638 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); 639 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true));
639 640
640 // Simulate a policy disabling sync by writing kSyncManaged directly. 641 // Simulate a policy disabling sync by writing kSyncManaged directly.
641 profile()->GetTestingPrefService()->SetManagedPref( 642 profile()->GetTestingPrefService()->SetManagedPref(
642 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); 643 sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true));
643 644
644 // Should still offer even if sync is disabled by policy. 645 // Should still offer even if sync is disabled by policy.
645 EXPECT_TRUE(OneClickSigninHelper::CanOffer( 646 EXPECT_TRUE(OneClickSigninHelper::CanOffer(
646 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, 647 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL,
647 "user@gmail.com", NULL)); 648 "user@gmail.com", NULL));
648 } 649 }
649 650
650 // Should not crash if a helper instance is not associated with an incognito 651 // Should not crash if a helper instance is not associated with an incognito
651 // web contents. 652 // web contents.
652 TEST_F(OneClickSigninHelperIncognitoTest, ShowInfoBarUIThreadIncognito) { 653 TEST_F(OneClickSigninHelperIncognitoTest, ShowInfoBarUIThreadIncognito) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 OneClickSigninHelper::CanOfferOnIOThreadImpl( 853 OneClickSigninHelper::CanOfferOnIOThreadImpl(
853 valid_gaia_url_, &request_, io_data.get())); 854 valid_gaia_url_, &request_, io_data.get()));
854 855
855 // Reset the preference. 856 // Reset the preference.
856 profile()->GetTestingPrefService()->SetManagedPref( 857 profile()->GetTestingPrefService()->SetManagedPref(
857 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); 858 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true));
858 859
859 // Simulate a policy disabling sync by writing kSyncManaged directly. 860 // Simulate a policy disabling sync by writing kSyncManaged directly.
860 // We should still offer to sign in the browser. 861 // We should still offer to sign in the browser.
861 profile()->GetTestingPrefService()->SetManagedPref( 862 profile()->GetTestingPrefService()->SetManagedPref(
862 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); 863 sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true));
863 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, 864 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER,
864 OneClickSigninHelper::CanOfferOnIOThreadImpl( 865 OneClickSigninHelper::CanOfferOnIOThreadImpl(
865 valid_gaia_url_, &request_, io_data.get())); 866 valid_gaia_url_, &request_, io_data.get()));
866 } 867 }
867 868
868 869
869 class MockStarterWrapper 870 class MockStarterWrapper
870 : public testing::StrictMock<OneClickSigninHelper::SyncStarterWrapper> { 871 : public testing::StrictMock<OneClickSigninHelper::SyncStarterWrapper> {
871 public: 872 public:
872 MockStarterWrapper( 873 MockStarterWrapper(
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 args.email = "foo@gmail.com"; 1007 args.email = "foo@gmail.com";
1007 args.profile = profile(); 1008 args.profile = profile();
1008 MockStarterWrapper* wrapper = new MockStarterWrapper( 1009 MockStarterWrapper* wrapper = new MockStarterWrapper(
1009 args, OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); 1010 args, OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS);
1010 SetCookie("LSID=1234; domain=google.com; secure; httponly"); 1011 SetCookie("LSID=1234; domain=google.com; secure; httponly");
1011 1012
1012 EXPECT_CALL(*wrapper, DisplayErrorBubble(_)); 1013 EXPECT_CALL(*wrapper, DisplayErrorBubble(_));
1013 wrapper->Start(); 1014 wrapper->Start();
1014 base::RunLoop().RunUntilIdle(); 1015 base::RunLoop().RunUntilIdle();
1015 } 1016 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | chrome/browser/ui/sync/one_click_signin_sync_starter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698