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

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: 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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/content_settings/cookie_settings.h" 10 #include "chrome/browser/content_settings/cookie_settings.h"
(...skipping 17 matching lines...) Expand all
28 #include "chrome/browser/ui/sync/one_click_signin_helper.h" 28 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
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/sync_driver/pref_names.h"
38 #include "content/public/browser/browser_context.h" 39 #include "content/public/browser/browser_context.h"
39 #include "content/public/browser/navigation_details.h" 40 #include "content/public/browser/navigation_details.h"
40 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
41 #include "content/public/common/frame_navigate_params.h" 42 #include "content/public/common/frame_navigate_params.h"
42 #include "content/public/common/url_constants.h" 43 #include "content/public/common/url_constants.h"
43 #include "content/public/test/mock_render_process_host.h" 44 #include "content/public/test/mock_render_process_host.h"
44 #include "grit/chromium_strings.h" 45 #include "grit/chromium_strings.h"
45 #include "grit/generated_resources.h" 46 #include "grit/generated_resources.h"
46 #include "testing/gtest/include/gtest/gtest.h" 47 #include "testing/gtest/include/gtest/gtest.h"
47 #include "ui/base/l10n/l10n_util.h" 48 #include "ui/base/l10n/l10n_util.h"
(...skipping 26 matching lines...) Expand all
74 google_services_username()->Init(prefs::kGoogleServicesUsername, 75 google_services_username()->Init(prefs::kGoogleServicesUsername,
75 pref_service); 76 pref_service);
76 reverse_autologin_enabled()->Init(prefs::kReverseAutologinEnabled, 77 reverse_autologin_enabled()->Init(prefs::kReverseAutologinEnabled,
77 pref_service); 78 pref_service);
78 one_click_signin_rejected_email_list()->Init( 79 one_click_signin_rejected_email_list()->Init(
79 prefs::kReverseAutologinRejectedEmailList, pref_service); 80 prefs::kReverseAutologinRejectedEmailList, pref_service);
80 81
81 google_services_username_pattern()->Init( 82 google_services_username_pattern()->Init(
82 prefs::kGoogleServicesUsernamePattern, local_state); 83 prefs::kGoogleServicesUsernamePattern, local_state);
83 84
84 sync_disabled()->Init(prefs::kSyncManaged, pref_service); 85 sync_disabled()->Init(sync_driver::prefs::kSyncManaged, pref_service);
85 86
86 signin_allowed()->Init(prefs::kSigninAllowed, pref_service); 87 signin_allowed()->Init(prefs::kSigninAllowed, pref_service);
87 88
88 set_signin_names_for_testing(new SigninNamesOnIOThread()); 89 set_signin_names_for_testing(new SigninNamesOnIOThread());
89 SetCookieSettingsForTesting(cookie_settings); 90 SetCookieSettingsForTesting(cookie_settings);
90 } 91 }
91 92
92 virtual ~TestProfileIOData() { 93 virtual ~TestProfileIOData() {
93 signin_names()->ReleaseResourcesOnUIThread(); 94 signin_names()->ReleaseResourcesOnUIThread();
94 } 95 }
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 EXPECT_FALSE(OneClickSigninHelper::CanOffer( 631 EXPECT_FALSE(OneClickSigninHelper::CanOffer(
631 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, 632 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL,
632 "user@gmail.com", NULL)); 633 "user@gmail.com", NULL));
633 634
634 // Reset the preference value to true. 635 // Reset the preference value to true.
635 profile()->GetTestingPrefService()->SetManagedPref( 636 profile()->GetTestingPrefService()->SetManagedPref(
636 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); 637 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true));
637 638
638 // Simulate a policy disabling sync by writing kSyncManaged directly. 639 // Simulate a policy disabling sync by writing kSyncManaged directly.
639 profile()->GetTestingPrefService()->SetManagedPref( 640 profile()->GetTestingPrefService()->SetManagedPref(
640 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); 641 sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true));
641 642
642 // Should still offer even if sync is disabled by policy. 643 // Should still offer even if sync is disabled by policy.
643 EXPECT_TRUE(OneClickSigninHelper::CanOffer( 644 EXPECT_TRUE(OneClickSigninHelper::CanOffer(
644 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL, 645 web_contents(), OneClickSigninHelper::CAN_OFFER_FOR_ALL,
645 "user@gmail.com", NULL)); 646 "user@gmail.com", NULL));
646 } 647 }
647 648
648 // Should not crash if a helper instance is not associated with an incognito 649 // Should not crash if a helper instance is not associated with an incognito
649 // web contents. 650 // web contents.
650 TEST_F(OneClickSigninHelperIncognitoTest, ShowInfoBarUIThreadIncognito) { 651 TEST_F(OneClickSigninHelperIncognitoTest, ShowInfoBarUIThreadIncognito) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 OneClickSigninHelper::CanOfferOnIOThreadImpl( 841 OneClickSigninHelper::CanOfferOnIOThreadImpl(
841 valid_gaia_url_, &request_, io_data.get())); 842 valid_gaia_url_, &request_, io_data.get()));
842 843
843 // Reset the preference. 844 // Reset the preference.
844 profile()->GetTestingPrefService()->SetManagedPref( 845 profile()->GetTestingPrefService()->SetManagedPref(
845 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true)); 846 prefs::kSigninAllowed, base::Value::CreateBooleanValue(true));
846 847
847 // Simulate a policy disabling sync by writing kSyncManaged directly. 848 // Simulate a policy disabling sync by writing kSyncManaged directly.
848 // We should still offer to sign in the browser. 849 // We should still offer to sign in the browser.
849 profile()->GetTestingPrefService()->SetManagedPref( 850 profile()->GetTestingPrefService()->SetManagedPref(
850 prefs::kSyncManaged, base::Value::CreateBooleanValue(true)); 851 sync_driver::prefs::kSyncManaged, base::Value::CreateBooleanValue(true));
851 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER, 852 EXPECT_EQ(OneClickSigninHelper::CAN_OFFER,
852 OneClickSigninHelper::CanOfferOnIOThreadImpl( 853 OneClickSigninHelper::CanOfferOnIOThreadImpl(
853 valid_gaia_url_, &request_, io_data.get())); 854 valid_gaia_url_, &request_, io_data.get()));
854 } 855 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698