OLD | NEW |
---|---|
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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 490 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
491 .WillRepeatedly(Return(true)); | 491 .WillRepeatedly(Return(true)); |
492 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 492 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
493 .WillRepeatedly(Return(true)); | 493 .WillRepeatedly(Return(true)); |
494 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 494 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
495 .WillRepeatedly(Return(false)); | 495 .WillRepeatedly(Return(false)); |
496 error_ = GoogleServiceAuthError::None(); | 496 error_ = GoogleServiceAuthError::None(); |
497 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 497 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
498 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); | 498 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); |
499 | 499 |
500 // We're simulating a user setting up sync, which would cause the backend to | |
501 // kick off initialization, but not download user data types. It will try to | |
James Hawkins
2012/11/30 19:54:08
Does 'it' refer to the backend here?
tim (not reviewing)
2012/11/30 20:08:08
Yeah. Changed to make it more obvious.
| |
502 // download control data types (e.g encryption info), but that won't finish | |
503 // for this test as we're simulating cancelling while the spinner is showing. | |
500 handler_->OpenSyncSetup(false); | 504 handler_->OpenSyncSetup(false); |
501 EXPECT_EQ(handler_.get(), | 505 EXPECT_EQ(handler_.get(), |
502 LoginUIServiceFactory::GetForProfile( | 506 LoginUIServiceFactory::GetForProfile( |
503 profile_.get())->current_login_ui()); | 507 profile_.get())->current_login_ui()); |
504 ASSERT_EQ(1U, web_ui_.call_data().size()); | 508 ASSERT_EQ(1U, web_ui_.call_data().size()); |
505 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 509 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
506 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 510 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
507 std::string page; | 511 std::string page; |
508 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 512 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
509 EXPECT_EQ(page, "spinner"); | 513 EXPECT_EQ(page, "spinner"); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 EXPECT_EQ(page, "configure"); | 554 EXPECT_EQ(page, "configure"); |
551 DictionaryValue* dictionary; | 555 DictionaryValue* dictionary; |
552 ASSERT_TRUE(data1.arg2->GetAsDictionary(&dictionary)); | 556 ASSERT_TRUE(data1.arg2->GetAsDictionary(&dictionary)); |
553 CheckBool(dictionary, "passphraseFailed", false); | 557 CheckBool(dictionary, "passphraseFailed", false); |
554 CheckBool(dictionary, "showSyncEverythingPage", true); | 558 CheckBool(dictionary, "showSyncEverythingPage", true); |
555 CheckBool(dictionary, "syncAllDataTypes", true); | 559 CheckBool(dictionary, "syncAllDataTypes", true); |
556 CheckBool(dictionary, "encryptAllData", false); | 560 CheckBool(dictionary, "encryptAllData", false); |
557 CheckBool(dictionary, "usePassphrase", false); | 561 CheckBool(dictionary, "usePassphrase", false); |
558 } | 562 } |
559 | 563 |
564 // Same as above, except cancel after the sync backend has initialized but | |
James Hawkins
2012/11/30 19:54:08
Optional nit: Copy/paste part of the test descript
tim (not reviewing)
2012/11/30 20:08:08
Done.
| |
565 // before the user has continued on. | |
566 TEST_F(SyncSetupHandlerTest, | |
567 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { | |
568 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | |
569 .WillRepeatedly(Return(true)); | |
570 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | |
571 .WillRepeatedly(Return(true)); | |
572 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | |
573 .WillRepeatedly(Return(false)); | |
574 error_ = GoogleServiceAuthError::None(); | |
575 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | |
576 EXPECT_CALL(*mock_pss_, sync_initialized()) | |
577 .WillOnce(Return(false)) | |
578 .WillRepeatedly(Return(true)); | |
579 SetDefaultExpectationsForConfigPage(); | |
580 handler_->OpenSyncSetup(false); | |
581 handler_->SigninSuccess(); | |
582 | |
583 // It's important to tell sync the user cancelled the setup flow before we | |
584 // tell it we're through with the setup progress. | |
585 testing::InSequence seq; | |
586 EXPECT_CALL(*mock_pss_, DisableForUser()); | |
587 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); | |
588 | |
589 handler_->CloseSyncSetup(); | |
590 EXPECT_EQ(NULL, | |
591 LoginUIServiceFactory::GetForProfile( | |
592 profile_.get())->current_login_ui()); | |
593 } | |
594 | |
560 TEST_F(SyncSetupHandlerTest, | 595 TEST_F(SyncSetupHandlerTest, |
561 DisplayConfigureWithBackendDisabledAndSigninFalied) { | 596 DisplayConfigureWithBackendDisabledAndSigninFalied) { |
562 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 597 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
563 .WillRepeatedly(Return(true)); | 598 .WillRepeatedly(Return(true)); |
564 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) | 599 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
565 .WillRepeatedly(Return(true)); | 600 .WillRepeatedly(Return(true)); |
566 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 601 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
567 .WillRepeatedly(Return(false)); | 602 .WillRepeatedly(Return(false)); |
568 error_ = GoogleServiceAuthError::None(); | 603 error_ = GoogleServiceAuthError::None(); |
569 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 604 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1148 DictionaryValue* dictionary; | 1183 DictionaryValue* dictionary; |
1149 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1184 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1150 std::string err = l10n_util::GetStringUTF8(IDS_SYNC_LOGIN_NAME_PROHIBITED); | 1185 std::string err = l10n_util::GetStringUTF8(IDS_SYNC_LOGIN_NAME_PROHIBITED); |
1151 CheckShowSyncSetupArgs( | 1186 CheckShowSyncSetupArgs( |
1152 dictionary, err, false, GoogleServiceAuthError::NONE, "", true, ""); | 1187 dictionary, err, false, GoogleServiceAuthError::NONE, "", true, ""); |
1153 handler_->CloseSyncSetup(); | 1188 handler_->CloseSyncSetup(); |
1154 EXPECT_EQ(NULL, | 1189 EXPECT_EQ(NULL, |
1155 LoginUIServiceFactory::GetForProfile( | 1190 LoginUIServiceFactory::GetForProfile( |
1156 profile_.get())->current_login_ui()); | 1191 profile_.get())->current_login_ui()); |
1157 } | 1192 } |
OLD | NEW |