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

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

Issue 671653002: Standardize usage of virtual/override/final in chrome/browser/ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 prefs::kGoogleServicesUsernamePattern, local_state); 99 prefs::kGoogleServicesUsernamePattern, local_state);
100 100
101 sync_disabled()->Init(sync_driver::prefs::kSyncManaged, pref_service); 101 sync_disabled()->Init(sync_driver::prefs::kSyncManaged, pref_service);
102 102
103 signin_allowed()->Init(prefs::kSigninAllowed, pref_service); 103 signin_allowed()->Init(prefs::kSigninAllowed, pref_service);
104 104
105 set_signin_names_for_testing(new SigninNamesOnIOThread()); 105 set_signin_names_for_testing(new SigninNamesOnIOThread());
106 SetCookieSettingsForTesting(cookie_settings); 106 SetCookieSettingsForTesting(cookie_settings);
107 } 107 }
108 108
109 virtual ~TestProfileIOData() { 109 ~TestProfileIOData() override {
110 signin_names()->ReleaseResourcesOnUIThread(); 110 signin_names()->ReleaseResourcesOnUIThread();
111 } 111 }
112 112
113 // ProfileIOData overrides: 113 // ProfileIOData overrides:
114 virtual void InitializeInternal( 114 void InitializeInternal(ProfileParams* profile_params,
115 ProfileParams* profile_params, 115 content::ProtocolHandlerMap* protocol_handlers,
116 content::ProtocolHandlerMap* protocol_handlers, 116 content::URLRequestInterceptorScopedVector
117 content::URLRequestInterceptorScopedVector request_interceptors) 117 request_interceptors) const override {
118 const override {
119 NOTREACHED(); 118 NOTREACHED();
120 } 119 }
121 virtual void InitializeExtensionsRequestContext( 120 void InitializeExtensionsRequestContext(
122 ProfileParams* profile_params) const override { 121 ProfileParams* profile_params) const override {
123 NOTREACHED(); 122 NOTREACHED();
124 } 123 }
125 virtual net::URLRequestContext* InitializeAppRequestContext( 124 net::URLRequestContext* InitializeAppRequestContext(
126 net::URLRequestContext* main_context, 125 net::URLRequestContext* main_context,
127 const StoragePartitionDescriptor& details, 126 const StoragePartitionDescriptor& details,
128 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 127 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
129 protocol_handler_interceptor, 128 protocol_handler_interceptor,
130 content::ProtocolHandlerMap* protocol_handlers, 129 content::ProtocolHandlerMap* protocol_handlers,
131 content::URLRequestInterceptorScopedVector request_interceptors) 130 content::URLRequestInterceptorScopedVector request_interceptors)
132 const override { 131 const override {
133 NOTREACHED(); 132 NOTREACHED();
134 return NULL; 133 return NULL;
135 } 134 }
136 virtual net::URLRequestContext* InitializeMediaRequestContext( 135 net::URLRequestContext* InitializeMediaRequestContext(
137 net::URLRequestContext* original_context, 136 net::URLRequestContext* original_context,
138 const StoragePartitionDescriptor& details) const override { 137 const StoragePartitionDescriptor& details) const override {
139 NOTREACHED(); 138 NOTREACHED();
140 return NULL; 139 return NULL;
141 } 140 }
142 virtual net::URLRequestContext* 141 net::URLRequestContext* AcquireMediaRequestContext() const override {
143 AcquireMediaRequestContext() const override {
144 NOTREACHED(); 142 NOTREACHED();
145 return NULL; 143 return NULL;
146 } 144 }
147 virtual net::URLRequestContext* AcquireIsolatedAppRequestContext( 145 net::URLRequestContext* AcquireIsolatedAppRequestContext(
148 net::URLRequestContext* main_context, 146 net::URLRequestContext* main_context,
149 const StoragePartitionDescriptor& partition_descriptor, 147 const StoragePartitionDescriptor& partition_descriptor,
150 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 148 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
151 protocol_handler_interceptor, 149 protocol_handler_interceptor,
152 content::ProtocolHandlerMap* protocol_handlers, 150 content::ProtocolHandlerMap* protocol_handlers,
153 content::URLRequestInterceptorScopedVector request_interceptors) 151 content::URLRequestInterceptorScopedVector request_interceptors)
154 const override { 152 const override {
155 NOTREACHED(); 153 NOTREACHED();
156 return NULL; 154 return NULL;
157 } 155 }
158 virtual net::URLRequestContext* 156 net::URLRequestContext* AcquireIsolatedMediaRequestContext(
159 AcquireIsolatedMediaRequestContext( 157 net::URLRequestContext* app_context,
160 net::URLRequestContext* app_context, 158 const StoragePartitionDescriptor& partition_descriptor) const override {
161 const StoragePartitionDescriptor& partition_descriptor)
162 const override {
163 NOTREACHED(); 159 NOTREACHED();
164 return NULL; 160 return NULL;
165 } 161 }
166 }; 162 };
167 163
168 class TestURLRequest : public base::SupportsUserData { 164 class TestURLRequest : public base::SupportsUserData {
169 public: 165 public:
170 TestURLRequest() {} 166 TestURLRequest() {}
171 virtual ~TestURLRequest() {} 167 ~TestURLRequest() override {}
172 }; 168 };
173 169
174 class OneClickTestProfileSyncService : public TestProfileSyncService { 170 class OneClickTestProfileSyncService : public TestProfileSyncService {
175 public: 171 public:
176 virtual ~OneClickTestProfileSyncService() {} 172 ~OneClickTestProfileSyncService() override {}
177 173
178 // Helper routine to be used in conjunction with 174 // Helper routine to be used in conjunction with
179 // BrowserContextKeyedServiceFactory::SetTestingFactory(). 175 // BrowserContextKeyedServiceFactory::SetTestingFactory().
180 static KeyedService* Build(content::BrowserContext* profile) { 176 static KeyedService* Build(content::BrowserContext* profile) {
181 return new OneClickTestProfileSyncService(static_cast<Profile*>(profile)); 177 return new OneClickTestProfileSyncService(static_cast<Profile*>(profile));
182 } 178 }
183 179
184 // Need to control this for certain tests. 180 // Need to control this for certain tests.
185 virtual bool FirstSetupInProgress() const override { 181 bool FirstSetupInProgress() const override {
186 return first_setup_in_progress_; 182 return first_setup_in_progress_;
187 } 183 }
188 184
189 virtual bool SyncActive() const override { return sync_active_; } 185 bool SyncActive() const override { return sync_active_; }
190 186
191 // Controls return value of FirstSetupInProgress. Because some bits 187 // Controls return value of FirstSetupInProgress. Because some bits
192 // of UI depend on that value, it's useful to control it separately 188 // of UI depend on that value, it's useful to control it separately
193 // from the internal work and components that are triggered (such as 189 // from the internal work and components that are triggered (such as
194 // ReconfigureDataTypeManager) to facilitate unit tests. 190 // ReconfigureDataTypeManager) to facilitate unit tests.
195 void set_first_setup_in_progress(bool in_progress) { 191 void set_first_setup_in_progress(bool in_progress) {
196 first_setup_in_progress_ = in_progress; 192 first_setup_in_progress_ = in_progress;
197 } 193 }
198 194
199 void set_sync_active(bool active) { 195 void set_sync_active(bool active) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 void SubmitGAIAPassword(OneClickSigninHelper* helper); 237 void SubmitGAIAPassword(OneClickSigninHelper* helper);
242 238
243 SigninManagerMock* signin_manager_; 239 SigninManagerMock* signin_manager_;
244 FakeProfileOAuth2TokenService* fake_oauth2_token_service_; 240 FakeProfileOAuth2TokenService* fake_oauth2_token_service_;
245 241
246 protected: 242 protected:
247 GoogleServiceAuthError no_error_; 243 GoogleServiceAuthError no_error_;
248 244
249 private: 245 private:
250 // ChromeRenderViewHostTestHarness overrides: 246 // ChromeRenderViewHostTestHarness overrides:
251 virtual content::BrowserContext* CreateBrowserContext() override; 247 content::BrowserContext* CreateBrowserContext() override;
252 248
253 // The ID of the signin process the test will assume to be trusted. 249 // The ID of the signin process the test will assume to be trusted.
254 // By default, set to the test RenderProcessHost's process ID, but 250 // By default, set to the test RenderProcessHost's process ID, but
255 // overridden by SetTrustedSigninProcessID. 251 // overridden by SetTrustedSigninProcessID.
256 int trusted_signin_process_id_; 252 int trusted_signin_process_id_;
257 253
258 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelperTest); 254 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelperTest);
259 }; 255 };
260 256
261 OneClickSigninHelperTest::OneClickSigninHelperTest() 257 OneClickSigninHelperTest::OneClickSigninHelperTest()
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 CookieSettings::Factory::GetForProfile(profile()).get(); 376 CookieSettings::Factory::GetForProfile(profile()).get();
381 TestProfileIOData* io_data = new TestProfileIOData( 377 TestProfileIOData* io_data = new TestProfileIOData(
382 profile_type, pref_service, local_state, cookie_settings); 378 profile_type, pref_service, local_state, cookie_settings);
383 io_data->set_reverse_autologin_pending_email("user@gmail.com"); 379 io_data->set_reverse_autologin_pending_email("user@gmail.com");
384 return io_data; 380 return io_data;
385 } 381 }
386 382
387 class OneClickSigninHelperIncognitoTest : public OneClickSigninHelperTest { 383 class OneClickSigninHelperIncognitoTest : public OneClickSigninHelperTest {
388 protected: 384 protected:
389 // content::RenderViewHostTestHarness. 385 // content::RenderViewHostTestHarness.
390 virtual content::BrowserContext* CreateBrowserContext() override; 386 content::BrowserContext* CreateBrowserContext() override;
391 }; 387 };
392 388
393 content::BrowserContext* 389 content::BrowserContext*
394 OneClickSigninHelperIncognitoTest::CreateBrowserContext() { 390 OneClickSigninHelperIncognitoTest::CreateBrowserContext() {
395 // Simulate an incognito profile to run this test. RenderViewHostTestHarness 391 // Simulate an incognito profile to run this test. RenderViewHostTestHarness
396 // takes ownership of the return value, so it can't be a "proper" incognito 392 // takes ownership of the return value, so it can't be a "proper" incognito
397 // profile, since they are owned by their parent, non-incognito profile. 393 // profile, since they are owned by their parent, non-incognito profile.
398 scoped_ptr<TestingProfile> profile = TestingProfile::Builder().Build(); 394 scoped_ptr<TestingProfile> profile = TestingProfile::Builder().Build();
399 profile->ForceIncognito(true); 395 profile->ForceIncognito(true);
400 return profile.release(); 396 return profile.release();
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 args.email = "foo@gmail.com"; 975 args.email = "foo@gmail.com";
980 args.profile = profile(); 976 args.profile = profile();
981 MockStarterWrapper* wrapper = new MockStarterWrapper( 977 MockStarterWrapper* wrapper = new MockStarterWrapper(
982 args, OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); 978 args, OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS);
983 SetCookie("LSID=1234; domain=google.com; secure; httponly"); 979 SetCookie("LSID=1234; domain=google.com; secure; httponly");
984 980
985 EXPECT_CALL(*wrapper, DisplayErrorBubble(_)); 981 EXPECT_CALL(*wrapper, DisplayErrorBubble(_));
986 wrapper->Start(); 982 wrapper->Start();
987 base::RunLoop().RunUntilIdle(); 983 base::RunLoop().RunUntilIdle();
988 } 984 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698