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

Side by Side Diff: chrome/browser/ui/webui/sync_setup_handler_unittest.cc

Issue 12686006: Rename GoogleServiceAuthError::None() to AuthErrorNone() and LoginFailure::None() to LoginFailureNo… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 "chrome/browser/ui/webui/sync_setup_handler.h" 5 #include "chrome/browser/ui/webui/sync_setup_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if (!CommandLine::ForCurrentProcess()->HasSwitch( 353 if (!CommandLine::ForCurrentProcess()->HasSwitch(
354 switches::kUseClientLoginSigninFlow)) { 354 switches::kUseClientLoginSigninFlow)) {
355 CommandLine::ForCurrentProcess()->AppendSwitch( 355 CommandLine::ForCurrentProcess()->AppendSwitch(
356 switches::kUseClientLoginSigninFlow); 356 switches::kUseClientLoginSigninFlow);
357 } 357 }
358 } else { 358 } else {
359 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch( 359 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(
360 switches::kUseClientLoginSigninFlow)); 360 switches::kUseClientLoginSigninFlow));
361 } 361 }
362 362
363 error_ = GoogleServiceAuthError::None(); 363 error_ = GoogleServiceAuthError::AuthErrorNone();
364 profile_.reset(ProfileSyncServiceMock::MakeSignedInTestingProfile()); 364 profile_.reset(ProfileSyncServiceMock::MakeSignedInTestingProfile());
365 mock_pss_ = static_cast<ProfileSyncServiceMock*>( 365 mock_pss_ = static_cast<ProfileSyncServiceMock*>(
366 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 366 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
367 profile_.get(), 367 profile_.get(),
368 ProfileSyncServiceMock::BuildMockProfileSyncService)); 368 ProfileSyncServiceMock::BuildMockProfileSyncService));
369 mock_pss_->Initialize(); 369 mock_pss_->Initialize();
370 370
371 ON_CALL(*mock_pss_, GetPassphraseType()).WillByDefault( 371 ON_CALL(*mock_pss_, GetPassphraseType()).WillByDefault(
372 Return(syncer::IMPLICIT_PASSPHRASE)); 372 Return(syncer::IMPLICIT_PASSPHRASE));
373 ON_CALL(*mock_pss_, GetPassphraseTime()).WillByDefault( 373 ON_CALL(*mock_pss_, GetPassphraseTime()).WillByDefault(
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 // Verifies that the handler correctly handles a cancellation when 508 // Verifies that the handler correctly handles a cancellation when
509 // it is displaying the spinner to the user. 509 // it is displaying the spinner to the user.
510 TEST_P(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { 510 TEST_P(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) {
511 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 511 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
512 .WillRepeatedly(Return(true)); 512 .WillRepeatedly(Return(true));
513 mock_signin_->SetAuthenticatedUsername(kTestUser); 513 mock_signin_->SetAuthenticatedUsername(kTestUser);
514 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 514 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable())
515 .WillRepeatedly(Return(true)); 515 .WillRepeatedly(Return(true));
516 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 516 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
517 .WillRepeatedly(Return(false)); 517 .WillRepeatedly(Return(false));
518 error_ = GoogleServiceAuthError::None(); 518 error_ = GoogleServiceAuthError::AuthErrorNone();
519 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 519 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
520 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); 520 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false));
521 521
522 // We're simulating a user setting up sync, which would cause the backend to 522 // We're simulating a user setting up sync, which would cause the backend to
523 // kick off initialization, but not download user data types. The sync 523 // kick off initialization, but not download user data types. The sync
524 // backend will try to download control data types (e.g encryption info), but 524 // backend will try to download control data types (e.g encryption info), but
525 // that won't finish for this test as we're simulating cancelling while the 525 // that won't finish for this test as we're simulating cancelling while the
526 // spinner is showing. 526 // spinner is showing.
527 handler_->OpenSyncSetup(false); 527 handler_->OpenSyncSetup(false);
528 528
(...skipping 21 matching lines...) Expand all
550 // to showing a configuration page when signin completes successfully. 550 // to showing a configuration page when signin completes successfully.
551 TEST_P(SyncSetupHandlerTest, 551 TEST_P(SyncSetupHandlerTest,
552 DisplayConfigureWithBackendDisabledAndSigninSuccess) { 552 DisplayConfigureWithBackendDisabledAndSigninSuccess) {
553 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 553 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
554 .WillRepeatedly(Return(true)); 554 .WillRepeatedly(Return(true));
555 mock_signin_->SetAuthenticatedUsername(kTestUser); 555 mock_signin_->SetAuthenticatedUsername(kTestUser);
556 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 556 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable())
557 .WillRepeatedly(Return(true)); 557 .WillRepeatedly(Return(true));
558 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 558 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
559 .WillRepeatedly(Return(false)); 559 .WillRepeatedly(Return(false));
560 error_ = GoogleServiceAuthError::None(); 560 error_ = GoogleServiceAuthError::AuthErrorNone();
561 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 561 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
562 // Sync backend is stopped initially, and will start up. 562 // Sync backend is stopped initially, and will start up.
563 EXPECT_CALL(*mock_pss_, sync_initialized()) 563 EXPECT_CALL(*mock_pss_, sync_initialized())
564 .WillRepeatedly(Return(false)); 564 .WillRepeatedly(Return(false));
565 SetDefaultExpectationsForConfigPage(); 565 SetDefaultExpectationsForConfigPage();
566 566
567 handler_->OpenSyncSetup(false); 567 handler_->OpenSyncSetup(false);
568 568
569 // We expect a call to SyncSetupOverlay.showSyncSetupPage. Some variations of 569 // We expect a call to SyncSetupOverlay.showSyncSetupPage. Some variations of
570 // this test also include a call to OptionsPage.closeOverlay, that we ignore. 570 // this test also include a call to OptionsPage.closeOverlay, that we ignore.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 // before the user has continued on. 607 // before the user has continued on.
608 TEST_P(SyncSetupHandlerTest, 608 TEST_P(SyncSetupHandlerTest,
609 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { 609 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) {
610 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 610 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
611 .WillRepeatedly(Return(true)); 611 .WillRepeatedly(Return(true));
612 mock_signin_->SetAuthenticatedUsername(kTestUser); 612 mock_signin_->SetAuthenticatedUsername(kTestUser);
613 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 613 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable())
614 .WillRepeatedly(Return(true)); 614 .WillRepeatedly(Return(true));
615 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 615 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
616 .WillRepeatedly(Return(false)); 616 .WillRepeatedly(Return(false));
617 error_ = GoogleServiceAuthError::None(); 617 error_ = GoogleServiceAuthError::AuthErrorNone();
618 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 618 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
619 EXPECT_CALL(*mock_pss_, sync_initialized()) 619 EXPECT_CALL(*mock_pss_, sync_initialized())
620 .WillOnce(Return(false)) 620 .WillOnce(Return(false))
621 .WillRepeatedly(Return(true)); 621 .WillRepeatedly(Return(true));
622 SetDefaultExpectationsForConfigPage(); 622 SetDefaultExpectationsForConfigPage();
623 handler_->OpenSyncSetup(false); 623 handler_->OpenSyncSetup(false);
624 handler_->SigninSuccess(); 624 handler_->SigninSuccess();
625 625
626 // It's important to tell sync the user cancelled the setup flow before we 626 // It's important to tell sync the user cancelled the setup flow before we
627 // tell it we're through with the setup progress. 627 // tell it we're through with the setup progress.
628 testing::InSequence seq; 628 testing::InSequence seq;
629 EXPECT_CALL(*mock_pss_, DisableForUser()); 629 EXPECT_CALL(*mock_pss_, DisableForUser());
630 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); 630 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false));
631 631
632 handler_->CloseSyncSetup(); 632 handler_->CloseSyncSetup();
633 EXPECT_EQ(NULL, 633 EXPECT_EQ(NULL,
634 LoginUIServiceFactory::GetForProfile( 634 LoginUIServiceFactory::GetForProfile(
635 profile_.get())->current_login_ui()); 635 profile_.get())->current_login_ui());
636 } 636 }
637 637
638 TEST_P(SyncSetupHandlerTest, 638 TEST_P(SyncSetupHandlerTest,
639 DisplayConfigureWithBackendDisabledAndSigninFalied) { 639 DisplayConfigureWithBackendDisabledAndSigninFalied) {
640 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 640 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
641 .WillRepeatedly(Return(true)); 641 .WillRepeatedly(Return(true));
642 mock_signin_->SetAuthenticatedUsername(kTestUser); 642 mock_signin_->SetAuthenticatedUsername(kTestUser);
643 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) 643 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable())
644 .WillRepeatedly(Return(true)); 644 .WillRepeatedly(Return(true));
645 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) 645 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
646 .WillRepeatedly(Return(false)); 646 .WillRepeatedly(Return(false));
647 error_ = GoogleServiceAuthError::None(); 647 error_ = GoogleServiceAuthError::AuthErrorNone();
648 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); 648 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
649 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); 649 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false));
650 650
651 handler_->OpenSyncSetup(false); 651 handler_->OpenSyncSetup(false);
652 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 652 const TestWebUI::CallData& data = web_ui_.call_data()[0];
653 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); 653 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name);
654 std::string page; 654 std::string page;
655 ASSERT_TRUE(data.arg1->GetAsString(&page)); 655 ASSERT_TRUE(data.arg1->GetAsString(&page));
656 EXPECT_EQ(page, "spinner"); 656 EXPECT_EQ(page, "spinner");
657 GoogleServiceAuthError error( 657 GoogleServiceAuthError error(
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 dictionary, err, false, GoogleServiceAuthError::NONE, "", true, ""); 1269 dictionary, err, false, GoogleServiceAuthError::NONE, "", true, "");
1270 handler_->CloseSyncSetup(); 1270 handler_->CloseSyncSetup();
1271 EXPECT_EQ(NULL, 1271 EXPECT_EQ(NULL,
1272 LoginUIServiceFactory::GetForProfile( 1272 LoginUIServiceFactory::GetForProfile(
1273 profile_.get())->current_login_ui()); 1273 profile_.get())->current_login_ui());
1274 } 1274 }
1275 1275
1276 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam, 1276 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam,
1277 SyncSetupHandlerTest, 1277 SyncSetupHandlerTest,
1278 Values(true, false)); 1278 Values(true, false));
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_setup_handler.cc ('k') | google_apis/gaia/google_service_auth_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698