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

Side by Side Diff: chrome/browser/ui/webui/settings/people_handler_unittest.cc

Issue 1536593004: Settings People Revamp: Implement Chrome Profile name/icon selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 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/ui/webui/settings/people_handler.h" 5 #include "chrome/browser/ui/webui/settings/people_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/browser/signin/fake_signin_manager_builder.h" 18 #include "chrome/browser/signin/fake_signin_manager_builder.h"
19 #include "chrome/browser/signin/signin_error_controller_factory.h" 19 #include "chrome/browser/signin/signin_error_controller_factory.h"
20 #include "chrome/browser/signin/signin_manager_factory.h" 20 #include "chrome/browser/signin/signin_manager_factory.h"
21 #include "chrome/browser/sync/profile_sync_service_factory.h" 21 #include "chrome/browser/sync/profile_sync_service_factory.h"
22 #include "chrome/browser/sync/profile_sync_test_util.h" 22 #include "chrome/browser/sync/profile_sync_test_util.h"
23 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 23 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
24 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 24 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/test/base/scoped_testing_local_state.h" 27 #include "chrome/test/base/scoped_testing_local_state.h"
28 #include "chrome/test/base/testing_browser_process.h" 28 #include "chrome/test/base/testing_browser_process.h"
29 #include "chrome/test/base/testing_profile.h" 29 #include "chrome/test/base/testing_profile.h"
30 #include "chrome/test/base/testing_profile_manager.h"
30 #include "components/signin/core/browser/fake_auth_status_provider.h" 31 #include "components/signin/core/browser/fake_auth_status_provider.h"
31 #include "components/signin/core/browser/signin_manager.h" 32 #include "components/signin/core/browser/signin_manager.h"
32 #include "components/sync_driver/sync_prefs.h" 33 #include "components/sync_driver/sync_prefs.h"
34 #include "components/syncable_prefs/pref_service_syncable.h"
33 #include "content/public/browser/web_ui.h" 35 #include "content/public/browser/web_ui.h"
34 #include "content/public/test/test_browser_thread.h" 36 #include "content/public/test/test_browser_thread.h"
35 #include "content/public/test/test_browser_thread_bundle.h" 37 #include "content/public/test/test_browser_thread_bundle.h"
36 #include "content/public/test/test_web_ui.h" 38 #include "content/public/test/test_web_ui.h"
37 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
38 #include "ui/base/layout.h" 40 #include "ui/base/layout.h"
39 41
40 using ::testing::_; 42 using ::testing::_;
41 using ::testing::Mock; 43 using ::testing::Mock;
42 using ::testing::Return; 44 using ::testing::Return;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 180
179 // The boolean parameter indicates whether the test is run with ClientOAuth 181 // The boolean parameter indicates whether the test is run with ClientOAuth
180 // or not. The test parameter is a bool: whether or not to test with/ 182 // or not. The test parameter is a bool: whether or not to test with/
181 // /ClientLogin enabled or not. 183 // /ClientLogin enabled or not.
182 class PeopleHandlerTest : public testing::Test { 184 class PeopleHandlerTest : public testing::Test {
183 public: 185 public:
184 PeopleHandlerTest() : error_(GoogleServiceAuthError::NONE) {} 186 PeopleHandlerTest() : error_(GoogleServiceAuthError::NONE) {}
185 void SetUp() override { 187 void SetUp() override {
186 error_ = GoogleServiceAuthError::AuthErrorNone(); 188 error_ = GoogleServiceAuthError::AuthErrorNone();
187 189
188 TestingProfile::Builder builder; 190 profile_manager_.reset(
189 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), 191 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
190 BuildFakeSigninManagerBase); 192 ASSERT_TRUE(profile_manager_->SetUp());
191 profile_ = builder.Build(); 193
194 TestingProfile::TestingFactories testing_factories;
195 testing_factories.push_back(std::make_pair(
196 SigninManagerFactory::GetInstance(), BuildFakeSigninManagerBase));
197 profile_ = profile_manager_->CreateTestingProfile(
198 "Person 1", nullptr, base::UTF8ToUTF16("Person 1"), 0, std::string(),
199 testing_factories);
192 200
193 // Sign in the user. 201 // Sign in the user.
194 mock_signin_ = static_cast<SigninManagerBase*>( 202 mock_signin_ = static_cast<SigninManagerBase*>(
195 SigninManagerFactory::GetForProfile(profile_.get())); 203 SigninManagerFactory::GetForProfile(profile_));
196 std::string username = GetTestUser(); 204 std::string username = GetTestUser();
197 if (!username.empty()) 205 if (!username.empty())
198 mock_signin_->SetAuthenticatedAccountInfo(username, username); 206 mock_signin_->SetAuthenticatedAccountInfo(username, username);
199 207
200 mock_pss_ = static_cast<ProfileSyncServiceMock*>( 208 mock_pss_ = static_cast<ProfileSyncServiceMock*>(
201 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 209 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
202 profile_.get(), BuildMockProfileSyncService)); 210 profile_, BuildMockProfileSyncService));
203 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 211 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
204 ON_CALL(*mock_pss_, GetPassphraseType()).WillByDefault( 212 ON_CALL(*mock_pss_, GetPassphraseType()).WillByDefault(
205 Return(syncer::IMPLICIT_PASSPHRASE)); 213 Return(syncer::IMPLICIT_PASSPHRASE));
206 ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault( 214 ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault(
207 Return(base::Time())); 215 Return(base::Time()));
208 ON_CALL(*mock_pss_, GetRegisteredDataTypes()) 216 ON_CALL(*mock_pss_, GetRegisteredDataTypes())
209 .WillByDefault(Return(syncer::ModelTypeSet())); 217 .WillByDefault(Return(syncer::ModelTypeSet()));
210 218
211 mock_pss_->Initialize(); 219 mock_pss_->Initialize();
212 220
213 handler_.reset(new TestingPeopleHandler(&web_ui_, profile_.get())); 221 handler_.reset(new TestingPeopleHandler(&web_ui_, profile_));
214 } 222 }
215 223
216 // Setup the expectations for calls made when displaying the config page. 224 // Setup the expectations for calls made when displaying the config page.
217 void SetDefaultExpectationsForConfigPage() { 225 void SetDefaultExpectationsForConfigPage() {
218 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 226 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
219 EXPECT_CALL(*mock_pss_, GetRegisteredDataTypes()) 227 EXPECT_CALL(*mock_pss_, GetRegisteredDataTypes())
220 .WillRepeatedly(Return(GetAllTypes())); 228 .WillRepeatedly(Return(GetAllTypes()));
221 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()) 229 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes())
222 .WillRepeatedly(Return(GetAllTypes())); 230 .WillRepeatedly(Return(GetAllTypes()));
223 EXPECT_CALL(*mock_pss_, GetActiveDataTypes()) 231 EXPECT_CALL(*mock_pss_, GetActiveDataTypes())
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", 271 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage",
264 data.function_name()); 272 data.function_name());
265 273
266 std::string page; 274 std::string page;
267 ASSERT_TRUE(data.arg1()->GetAsString(&page)); 275 ASSERT_TRUE(data.arg1()->GetAsString(&page));
268 EXPECT_EQ(page, "spinner"); 276 EXPECT_EQ(page, "spinner");
269 // Cancelling the spinner dialog will cause CloseSyncSetup(). 277 // Cancelling the spinner dialog will cause CloseSyncSetup().
270 handler_->CloseSyncSetup(); 278 handler_->CloseSyncSetup();
271 EXPECT_EQ(NULL, 279 EXPECT_EQ(NULL,
272 LoginUIServiceFactory::GetForProfile( 280 LoginUIServiceFactory::GetForProfile(
273 profile_.get())->current_login_ui()); 281 profile_)->current_login_ui());
274 } 282 }
275 283
276 // It's difficult to notify sync listeners when using a ProfileSyncServiceMock 284 // It's difficult to notify sync listeners when using a ProfileSyncServiceMock
277 // so this helper routine dispatches an OnStateChanged() notification to the 285 // so this helper routine dispatches an OnStateChanged() notification to the
278 // SyncStartupTracker. 286 // SyncStartupTracker.
279 void NotifySyncListeners() { 287 void NotifySyncListeners() {
280 if (handler_->sync_startup_tracker_) 288 if (handler_->sync_startup_tracker_)
281 handler_->sync_startup_tracker_->OnStateChanged(); 289 handler_->sync_startup_tracker_->OnStateChanged();
282 } 290 }
283 291
284 virtual std::string GetTestUser() { 292 virtual std::string GetTestUser() {
285 return std::string(kTestUser); 293 return std::string(kTestUser);
286 } 294 }
287 295
288 content::TestBrowserThreadBundle thread_bundle_; 296 content::TestBrowserThreadBundle thread_bundle_;
289 scoped_ptr<Profile> profile_; 297 scoped_ptr<TestingProfileManager> profile_manager_;
298 Profile* profile_;
290 ProfileSyncServiceMock* mock_pss_; 299 ProfileSyncServiceMock* mock_pss_;
291 GoogleServiceAuthError error_; 300 GoogleServiceAuthError error_;
292 SigninManagerBase* mock_signin_; 301 SigninManagerBase* mock_signin_;
293 content::TestWebUI web_ui_; 302 content::TestWebUI web_ui_;
294 scoped_ptr<TestingPeopleHandler> handler_; 303 scoped_ptr<TestingPeopleHandler> handler_;
295 }; 304 };
296 305
297 class PeopleHandlerFirstSigninTest : public PeopleHandlerTest { 306 class PeopleHandlerFirstSigninTest : public PeopleHandlerTest {
298 std::string GetTestUser() override { return std::string(); } 307 std::string GetTestUser() override { return std::string(); }
299 }; 308 };
300 309
301 TEST_F(PeopleHandlerTest, Basic) { 310 TEST_F(PeopleHandlerTest, Basic) {
302 } 311 }
303 312
304 #if !defined(OS_CHROMEOS) 313 #if !defined(OS_CHROMEOS)
305 TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) { 314 TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) {
306 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); 315 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
307 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 316 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
308 .WillRepeatedly(Return(false)); 317 .WillRepeatedly(Return(false));
309 // Ensure that the user is not signed in before calling |HandleStartSignin()|. 318 // Ensure that the user is not signed in before calling |HandleStartSignin()|.
310 SigninManager* manager = static_cast<SigninManager*>(mock_signin_); 319 SigninManager* manager = static_cast<SigninManager*>(mock_signin_);
311 manager->SignOut(signin_metrics::SIGNOUT_TEST); 320 manager->SignOut(signin_metrics::SIGNOUT_TEST);
312 handler_->HandleStartSignin(NULL); 321 handler_->HandleStartSignin(NULL);
313 322
314 // Sync setup hands off control to the gaia login tab. 323 // Sync setup hands off control to the gaia login tab.
315 EXPECT_EQ(NULL, 324 EXPECT_EQ(NULL,
316 LoginUIServiceFactory::GetForProfile( 325 LoginUIServiceFactory::GetForProfile(
317 profile_.get())->current_login_ui()); 326 profile_)->current_login_ui());
318 327
319 ASSERT_FALSE(handler_->is_configuring_sync()); 328 ASSERT_FALSE(handler_->is_configuring_sync());
320 329
321 handler_->CloseSyncSetup(); 330 handler_->CloseSyncSetup();
322 EXPECT_EQ(NULL, 331 EXPECT_EQ(NULL,
323 LoginUIServiceFactory::GetForProfile( 332 LoginUIServiceFactory::GetForProfile(
324 profile_.get())->current_login_ui()); 333 profile_)->current_login_ui());
325 } 334 }
326 335
327 TEST_F(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn) { 336 TEST_F(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn) {
328 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); 337 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
329 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 338 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
330 .WillRepeatedly(Return(false)); 339 .WillRepeatedly(Return(false));
331 handler_->HandleShowSetupUI(NULL); 340 handler_->HandleShowSetupUI(NULL);
332 341
333 // We expect a call to settings.SyncPrivateApi.showSyncSetupPage. 342 // We expect a call to settings.SyncPrivateApi.showSyncSetupPage.
334 ASSERT_EQ(1U, web_ui_.call_data().size()); 343 ASSERT_EQ(1U, web_ui_.call_data().size());
335 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 344 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
336 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name()); 345 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name());
337 346
338 ASSERT_FALSE(handler_->is_configuring_sync()); 347 ASSERT_FALSE(handler_->is_configuring_sync());
339 EXPECT_EQ(NULL, 348 EXPECT_EQ(NULL,
340 LoginUIServiceFactory::GetForProfile( 349 LoginUIServiceFactory::GetForProfile(
341 profile_.get())->current_login_ui()); 350 profile_)->current_login_ui());
342 } 351 }
343 #endif // !defined(OS_CHROMEOS) 352 #endif // !defined(OS_CHROMEOS)
344 353
345 // Verifies that the sync setup is terminated correctly when the 354 // Verifies that the sync setup is terminated correctly when the
346 // sync is disabled. 355 // sync is disabled.
347 TEST_F(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled) { 356 TEST_F(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled) {
348 EXPECT_CALL(*mock_pss_, IsManaged()).WillRepeatedly(Return(true)); 357 EXPECT_CALL(*mock_pss_, IsManaged()).WillRepeatedly(Return(true));
349 handler_->HandleShowSetupUI(NULL); 358 handler_->HandleShowSetupUI(NULL);
350 359
351 // Sync setup is closed when sync is disabled. 360 // Sync setup is closed when sync is disabled.
352 EXPECT_EQ(NULL, 361 EXPECT_EQ(NULL,
353 LoginUIServiceFactory::GetForProfile( 362 LoginUIServiceFactory::GetForProfile(
354 profile_.get())->current_login_ui()); 363 profile_)->current_login_ui());
355 ASSERT_FALSE(handler_->is_configuring_sync()); 364 ASSERT_FALSE(handler_->is_configuring_sync());
356 } 365 }
357 366
358 // Verifies that the handler correctly handles a cancellation when 367 // Verifies that the handler correctly handles a cancellation when
359 // it is displaying the spinner to the user. 368 // it is displaying the spinner to the user.
360 TEST_F(PeopleHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { 369 TEST_F(PeopleHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) {
361 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 370 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
362 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 371 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
363 .WillRepeatedly(Return(false)); 372 .WillRepeatedly(Return(false));
364 error_ = GoogleServiceAuthError::AuthErrorNone(); 373 error_ = GoogleServiceAuthError::AuthErrorNone();
365 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); 374 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
366 375
367 // We're simulating a user setting up sync, which would cause the backend to 376 // We're simulating a user setting up sync, which would cause the backend to
368 // kick off initialization, but not download user data types. The sync 377 // kick off initialization, but not download user data types. The sync
369 // backend will try to download control data types (e.g encryption info), but 378 // backend will try to download control data types (e.g encryption info), but
370 // that won't finish for this test as we're simulating cancelling while the 379 // that won't finish for this test as we're simulating cancelling while the
371 // spinner is showing. 380 // spinner is showing.
372 handler_->HandleShowSetupUI(NULL); 381 handler_->HandleShowSetupUI(NULL);
373 382
374 EXPECT_EQ(handler_.get(), 383 EXPECT_EQ(handler_.get(),
375 LoginUIServiceFactory::GetForProfile( 384 LoginUIServiceFactory::GetForProfile(
376 profile_.get())->current_login_ui()); 385 profile_)->current_login_ui());
377 386
378 ExpectSpinnerAndClose(); 387 ExpectSpinnerAndClose();
379 } 388 }
380 389
381 // Verifies that the handler correctly transitions from showing the spinner 390 // Verifies that the handler correctly transitions from showing the spinner
382 // to showing a configuration page when sync setup completes successfully. 391 // to showing a configuration page when sync setup completes successfully.
383 TEST_F(PeopleHandlerTest, 392 TEST_F(PeopleHandlerTest,
384 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) { 393 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) {
385 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 394 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
386 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 395 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 452
444 // It's important to tell sync the user cancelled the setup flow before we 453 // It's important to tell sync the user cancelled the setup flow before we
445 // tell it we're through with the setup progress. 454 // tell it we're through with the setup progress.
446 testing::InSequence seq; 455 testing::InSequence seq;
447 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); 456 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA));
448 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); 457 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false));
449 458
450 handler_->CloseSyncSetup(); 459 handler_->CloseSyncSetup();
451 EXPECT_EQ(NULL, 460 EXPECT_EQ(NULL,
452 LoginUIServiceFactory::GetForProfile( 461 LoginUIServiceFactory::GetForProfile(
453 profile_.get())->current_login_ui()); 462 profile_)->current_login_ui());
454 } 463 }
455 464
456 TEST_F(PeopleHandlerTest, 465 TEST_F(PeopleHandlerTest,
457 DisplayConfigureWithBackendDisabledAndSigninFailed) { 466 DisplayConfigureWithBackendDisabledAndSigninFailed) {
458 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 467 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
459 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 468 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
460 .WillRepeatedly(Return(false)); 469 .WillRepeatedly(Return(false));
461 error_ = GoogleServiceAuthError::AuthErrorNone(); 470 error_ = GoogleServiceAuthError::AuthErrorNone();
462 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); 471 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
463 472
464 handler_->OpenSyncSetup(nullptr); 473 handler_->OpenSyncSetup(nullptr);
465 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 474 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
466 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name()); 475 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name());
467 std::string page; 476 std::string page;
468 ASSERT_TRUE(data.arg1()->GetAsString(&page)); 477 ASSERT_TRUE(data.arg1()->GetAsString(&page));
469 EXPECT_EQ(page, "spinner"); 478 EXPECT_EQ(page, "spinner");
470 Mock::VerifyAndClearExpectations(mock_pss_); 479 Mock::VerifyAndClearExpectations(mock_pss_);
471 error_ = GoogleServiceAuthError( 480 error_ = GoogleServiceAuthError(
472 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 481 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
473 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 482 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
474 NotifySyncListeners(); 483 NotifySyncListeners();
475 484
476 // On failure, the dialog will be closed. 485 // On failure, the dialog will be closed.
477 EXPECT_EQ(NULL, 486 EXPECT_EQ(NULL,
478 LoginUIServiceFactory::GetForProfile( 487 LoginUIServiceFactory::GetForProfile(
479 profile_.get())->current_login_ui()); 488 profile_)->current_login_ui());
480 } 489 }
481 490
482 #if !defined(OS_CHROMEOS) 491 #if !defined(OS_CHROMEOS)
483 492
484 class PeopleHandlerNonCrosTest : public PeopleHandlerTest { 493 class PeopleHandlerNonCrosTest : public PeopleHandlerTest {
485 public: 494 public:
486 PeopleHandlerNonCrosTest() {} 495 PeopleHandlerNonCrosTest() {}
487 }; 496 };
488 497
489 TEST_F(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure) { 498 TEST_F(PeopleHandlerNonCrosTest, HandleGaiaAuthFailure) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 759
751 // We do not display signin on chromeos in the case of auth error. 760 // We do not display signin on chromeos in the case of auth error.
752 TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) { 761 TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
753 // Initialize the system to a signed in state, but with an auth error. 762 // Initialize the system to a signed in state, but with an auth error.
754 error_ = GoogleServiceAuthError( 763 error_ = GoogleServiceAuthError(
755 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 764 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
756 765
757 SetupInitializedProfileSyncService(); 766 SetupInitializedProfileSyncService();
758 mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser); 767 mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser);
759 FakeAuthStatusProvider provider( 768 FakeAuthStatusProvider provider(
760 SigninErrorControllerFactory::GetForProfile(profile_.get())); 769 SigninErrorControllerFactory::GetForProfile(profile_));
761 provider.SetAuthError(kTestUser, error_); 770 provider.SetAuthError(kTestUser, error_);
762 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 771 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
763 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 772 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
764 .WillRepeatedly(Return(false)); 773 .WillRepeatedly(Return(false));
765 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 774 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
766 .WillRepeatedly(Return(false)); 775 .WillRepeatedly(Return(false));
767 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); 776 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
768 777
769 #if defined(OS_CHROMEOS) 778 #if defined(OS_CHROMEOS)
770 // On ChromeOS, auth errors are ignored - instead we just try to start the 779 // On ChromeOS, auth errors are ignored - instead we just try to start the
771 // sync backend (which will fail due to the auth error). This should only 780 // sync backend (which will fail due to the auth error). This should only
772 // happen if the user manually navigates to chrome://settings/syncSetup - 781 // happen if the user manually navigates to chrome://settings/syncSetup -
773 // clicking on the button in the UI will sign the user out rather than 782 // clicking on the button in the UI will sign the user out rather than
774 // displaying a spinner. Should be no visible UI on ChromeOS in this case. 783 // displaying a spinner. Should be no visible UI on ChromeOS in this case.
775 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile( 784 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(
776 profile_.get())->current_login_ui()); 785 profile_)->current_login_ui());
777 #else 786 #else
778 787
779 // On ChromeOS, this should display the spinner while we try to startup the 788 // On ChromeOS, this should display the spinner while we try to startup the
780 // sync backend, and on desktop this displays the login dialog. 789 // sync backend, and on desktop this displays the login dialog.
781 handler_->OpenSyncSetup(nullptr); 790 handler_->OpenSyncSetup(nullptr);
782 791
783 // Sync setup is closed when re-auth is in progress. 792 // Sync setup is closed when re-auth is in progress.
784 EXPECT_EQ(NULL, 793 EXPECT_EQ(NULL,
785 LoginUIServiceFactory::GetForProfile( 794 LoginUIServiceFactory::GetForProfile(
786 profile_.get())->current_login_ui()); 795 profile_)->current_login_ui());
787 796
788 ASSERT_FALSE(handler_->is_configuring_sync()); 797 ASSERT_FALSE(handler_->is_configuring_sync());
789 #endif 798 #endif
790 } 799 }
791 800
792 TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) { 801 TEST_F(PeopleHandlerTest, ShowSetupSyncEverything) {
793 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) 802 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
794 .WillRepeatedly(Return(false)); 803 .WillRepeatedly(Return(false));
795 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) 804 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
796 .WillRepeatedly(Return(false)); 805 .WillRepeatedly(Return(false));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 syncer::ModelTypeSet types; 864 syncer::ModelTypeSet types;
856 types.Put(it.Get()); 865 types.Put(it.Get());
857 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). 866 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()).
858 WillRepeatedly(Return(types)); 867 WillRepeatedly(Return(types));
859 868
860 // This should display the sync setup dialog (not login). 869 // This should display the sync setup dialog (not login).
861 handler_->OpenSyncSetup(nullptr); 870 handler_->OpenSyncSetup(nullptr);
862 871
863 ExpectConfig(); 872 ExpectConfig();
864 // Close the config overlay. 873 // Close the config overlay.
865 LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed( 874 LoginUIServiceFactory::GetForProfile(profile_)->LoginUIClosed(
866 handler_.get()); 875 handler_.get());
867 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; 876 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
868 const base::DictionaryValue* dictionary = nullptr; 877 const base::DictionaryValue* dictionary = nullptr;
869 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); 878 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
870 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); 879 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types);
871 Mock::VerifyAndClearExpectations(mock_pss_); 880 Mock::VerifyAndClearExpectations(mock_pss_);
872 // Clean up so we can loop back to display the dialog again. 881 // Clean up so we can loop back to display the dialog again.
873 web_ui_.ClearTrackedCalls(); 882 web_ui_.ClearTrackedCalls();
874 } 883 }
875 } 884 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); 981 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
973 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); 982 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
974 handler_->HandleConfigure(&list_args); 983 handler_->HandleConfigure(&list_args);
975 984
976 // Ensure that we navigated to the "done" state since we don't need a 985 // Ensure that we navigated to the "done" state since we don't need a
977 // passphrase. 986 // passphrase.
978 ExpectDone(); 987 ExpectDone();
979 } 988 }
980 989
981 } // namespace settings 990 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/people_handler.cc ('k') | chrome/browser/ui/webui/settings/settings_manage_profile_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698