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

Side by Side Diff: chrome/browser/signin/cross_device_promo_unittest.cc

Issue 2459823002: [Sync] Rename syncable_prefs to sync_preferences. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/signin/cross_device_promo.h" 5 #include "chrome/browser/signin/cross_device_promo.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/signin/signin_manager_factory.h" 24 #include "chrome/browser/signin/signin_manager_factory.h"
25 #include "chrome/browser/signin/test_signin_client_builder.h" 25 #include "chrome/browser/signin/test_signin_client_builder.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/test/base/testing_browser_process.h" 27 #include "chrome/test/base/testing_browser_process.h"
28 #include "chrome/test/base/testing_profile.h" 28 #include "chrome/test/base/testing_profile.h"
29 #include "chrome/test/base/testing_profile_manager.h" 29 #include "chrome/test/base/testing_profile_manager.h"
30 #include "components/signin/core/browser/fake_gaia_cookie_manager_service.h" 30 #include "components/signin/core/browser/fake_gaia_cookie_manager_service.h"
31 #include "components/signin/core/browser/signin_manager.h" 31 #include "components/signin/core/browser/signin_manager.h"
32 #include "components/signin/core/browser/signin_metrics.h" 32 #include "components/signin/core/browser/signin_metrics.h"
33 #include "components/signin/core/browser/test_signin_client.h" 33 #include "components/signin/core/browser/test_signin_client.h"
34 #include "components/syncable_prefs/pref_service_syncable.h" 34 #include "components/sync_preferences/pref_service_syncable.h"
35 #include "components/syncable_prefs/testing_pref_service_syncable.h" 35 #include "components/sync_preferences/testing_pref_service_syncable.h"
36 #include "components/variations/entropy_provider.h" 36 #include "components/variations/entropy_provider.h"
37 #include "components/variations/variations_associated_data.h" 37 #include "components/variations/variations_associated_data.h"
38 #include "content/public/test/test_browser_thread_bundle.h" 38 #include "content/public/test/test_browser_thread_bundle.h"
39 #include "google_apis/gaia/gaia_constants.h" 39 #include "google_apis/gaia/gaia_constants.h"
40 #include "google_apis/gaia/gaia_urls.h" 40 #include "google_apis/gaia/gaia_urls.h"
41 #include "net/url_request/test_url_fetcher_factory.h" 41 #include "net/url_request/test_url_fetcher_factory.h"
42 #include "testing/gtest/include/gtest/gtest.h" 42 #include "testing/gtest/include/gtest/gtest.h"
43 43
44 namespace { 44 namespace {
45 45
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // Destroys any variations which might be defined, and starts fresh. 93 // Destroys any variations which might be defined, and starts fresh.
94 void ResetFieldTrialList(); 94 void ResetFieldTrialList();
95 95
96 // Defines a default set of variation parameters for promo initialization. 96 // Defines a default set of variation parameters for promo initialization.
97 void InitPromoVariation(); 97 void InitPromoVariation();
98 98
99 CrossDevicePromo* promo() { return cross_device_promo_; } 99 CrossDevicePromo* promo() { return cross_device_promo_; }
100 TestingProfile* profile() { return profile_; } 100 TestingProfile* profile() { return profile_; }
101 FakeSigninManagerForTesting* signin_manager() { return signin_manager_; } 101 FakeSigninManagerForTesting* signin_manager() { return signin_manager_; }
102 base::HistogramTester* histogram_tester() { return &histogram_tester_; } 102 base::HistogramTester* histogram_tester() { return &histogram_tester_; }
103 syncable_prefs::TestingPrefServiceSyncable* prefs() { return pref_service_; } 103 sync_preferences::TestingPrefServiceSyncable* prefs() {
104 return pref_service_;
105 }
104 FakeGaiaCookieManagerService* cookie_manager_service() { 106 FakeGaiaCookieManagerService* cookie_manager_service() {
105 return cookie_manager_service_; 107 return cookie_manager_service_;
106 } 108 }
107 net::FakeURLFetcherFactory* fetcher_factory() { 109 net::FakeURLFetcherFactory* fetcher_factory() {
108 return &fake_url_fetcher_factory_; 110 return &fake_url_fetcher_factory_;
109 } 111 }
110 112
111 private: 113 private:
112 content::TestBrowserThreadBundle bundle_; 114 content::TestBrowserThreadBundle bundle_;
113 CrossDevicePromo* cross_device_promo_; 115 CrossDevicePromo* cross_device_promo_;
114 TestingProfile* profile_; 116 TestingProfile* profile_;
115 FakeSigninManagerForTesting* signin_manager_; 117 FakeSigninManagerForTesting* signin_manager_;
116 FakeGaiaCookieManagerService* cookie_manager_service_; 118 FakeGaiaCookieManagerService* cookie_manager_service_;
117 syncable_prefs::TestingPrefServiceSyncable* pref_service_; 119 sync_preferences::TestingPrefServiceSyncable* pref_service_;
118 std::unique_ptr<TestingProfileManager> testing_profile_manager_; 120 std::unique_ptr<TestingProfileManager> testing_profile_manager_;
119 base::HistogramTester histogram_tester_; 121 base::HistogramTester histogram_tester_;
120 std::unique_ptr<base::FieldTrialList> field_trial_list_; 122 std::unique_ptr<base::FieldTrialList> field_trial_list_;
121 net::FakeURLFetcherFactory fake_url_fetcher_factory_; 123 net::FakeURLFetcherFactory fake_url_fetcher_factory_;
122 124
123 DISALLOW_COPY_AND_ASSIGN(CrossDevicePromoTest); 125 DISALLOW_COPY_AND_ASSIGN(CrossDevicePromoTest);
124 }; 126 };
125 127
126 CrossDevicePromoTest::CrossDevicePromoTest() : fake_url_fetcher_factory_(NULL) { 128 CrossDevicePromoTest::CrossDevicePromoTest() : fake_url_fetcher_factory_(NULL) {
127 ResetFieldTrialList(); 129 ResetFieldTrialList();
128 } 130 }
129 131
130 void CrossDevicePromoTest::SetUp() { 132 void CrossDevicePromoTest::SetUp() {
131 testing_profile_manager_.reset( 133 testing_profile_manager_.reset(
132 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 134 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
133 ASSERT_TRUE(testing_profile_manager_.get()->SetUp()); 135 ASSERT_TRUE(testing_profile_manager_.get()->SetUp());
134 136
135 TestingProfile::TestingFactories factories; 137 TestingProfile::TestingFactories factories;
136 factories.push_back(std::make_pair(ChromeSigninClientFactory::GetInstance(), 138 factories.push_back(std::make_pair(ChromeSigninClientFactory::GetInstance(),
137 signin::BuildTestSigninClient)); 139 signin::BuildTestSigninClient));
138 factories.push_back( 140 factories.push_back(
139 std::make_pair(GaiaCookieManagerServiceFactory::GetInstance(), 141 std::make_pair(GaiaCookieManagerServiceFactory::GetInstance(),
140 BuildFakeGaiaCookieManagerService)); 142 BuildFakeGaiaCookieManagerService));
141 factories.push_back(std::make_pair(SigninManagerFactory::GetInstance(), 143 factories.push_back(std::make_pair(SigninManagerFactory::GetInstance(),
142 BuildFakeSigninManagerBase)); 144 BuildFakeSigninManagerBase));
143 145
144 pref_service_ = new syncable_prefs::TestingPrefServiceSyncable(); 146 pref_service_ = new sync_preferences::TestingPrefServiceSyncable();
145 chrome::RegisterUserProfilePrefs(pref_service_->registry()); 147 chrome::RegisterUserProfilePrefs(pref_service_->registry());
146 148
147 profile_ = testing_profile_manager_.get()->CreateTestingProfile( 149 profile_ = testing_profile_manager_.get()->CreateTestingProfile(
148 "name", 150 "name",
149 base::WrapUnique<syncable_prefs::PrefServiceSyncable>(pref_service_), 151 base::WrapUnique<sync_preferences::PrefServiceSyncable>(pref_service_),
150 base::UTF8ToUTF16("name"), 0, std::string(), factories); 152 base::UTF8ToUTF16("name"), 0, std::string(), factories);
151 153
152 cookie_manager_service_ = static_cast<FakeGaiaCookieManagerService*>( 154 cookie_manager_service_ = static_cast<FakeGaiaCookieManagerService*>(
153 GaiaCookieManagerServiceFactory::GetForProfile(profile())); 155 GaiaCookieManagerServiceFactory::GetForProfile(profile()));
154 cookie_manager_service_->Init(&fake_url_fetcher_factory_); 156 cookie_manager_service_->Init(&fake_url_fetcher_factory_);
155 157
156 signin_manager_ = static_cast<FakeSigninManagerForTesting*>( 158 signin_manager_ = static_cast<FakeSigninManagerForTesting*>(
157 SigninManagerFactory::GetForProfile(profile())); 159 SigninManagerFactory::GetForProfile(profile()));
158 160
159 cross_device_promo_ = CrossDevicePromoFactory::GetForProfile(profile()); 161 cross_device_promo_ = CrossDevicePromoFactory::GetForProfile(profile());
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 EXPECT_EQ(2, prefs()->GetInteger(prefs::kCrossDevicePromoNumDevices)); 670 EXPECT_EQ(2, prefs()->GetInteger(prefs::kCrossDevicePromoNumDevices));
669 EXPECT_EQ(device2_last_active.ToInternalValue(), 671 EXPECT_EQ(device2_last_active.ToInternalValue(),
670 prefs()->GetInt64(prefs::kCrossDevicePromoLastDeviceActiveTime)); 672 prefs()->GetInt64(prefs::kCrossDevicePromoLastDeviceActiveTime));
671 EXPECT_TRUE(prefs()->GetBoolean(prefs::kCrossDevicePromoShouldBeShown)); 673 EXPECT_TRUE(prefs()->GetBoolean(prefs::kCrossDevicePromoShouldBeShown));
672 test_two_devices.ExpectUniqueSample("Signin.XDevicePromo.Eligibility", 674 test_two_devices.ExpectUniqueSample("Signin.XDevicePromo.Eligibility",
673 signin_metrics::ELIGIBLE, 1); 675 signin_metrics::ELIGIBLE, 1);
674 EXPECT_TRUE(observer.is_eligible()); 676 EXPECT_TRUE(observer.is_eligible());
675 EXPECT_EQ(1, observer.times_set_eligible()); 677 EXPECT_EQ(1, observer.times_set_eligible());
676 } 678 }
677 } 679 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/cross_device_promo_factory.cc ('k') | chrome/browser/signin/easy_unlock_service_unittest_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698