Chromium Code Reviews| 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 error_ = GoogleServiceAuthError::None(); | 531 error_ = GoogleServiceAuthError::None(); | 
| 532 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 532 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 
| 533 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); | 533 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); | 
| 534 | 534 | 
| 535 // We're simulating a user setting up sync, which would cause the backend to | 535 // We're simulating a user setting up sync, which would cause the backend to | 
| 536 // kick off initialization, but not download user data types. The sync | 536 // kick off initialization, but not download user data types. The sync | 
| 537 // backend will try to download control data types (e.g encryption info), but | 537 // backend will try to download control data types (e.g encryption info), but | 
| 538 // that won't finish for this test as we're simulating cancelling while the | 538 // that won't finish for this test as we're simulating cancelling while the | 
| 539 // spinner is showing. | 539 // spinner is showing. | 
| 540 handler_->OpenSyncSetup(false); | 540 handler_->OpenSyncSetup(false); | 
| 541 EXPECT_EQ(handler_.get(), | 541 | 
| 542 // When the SigninTracker is initialized here, a signin failure is triggered | |
| 543 // due to sync_initialized() returning false, causing the current login UI to | |
| 544 // be dismissed. | |
| 545 EXPECT_EQ(NULL, | |
| 542 LoginUIServiceFactory::GetForProfile( | 546 LoginUIServiceFactory::GetForProfile( | 
| 543 profile_.get())->current_login_ui()); | 547 profile_.get())->current_login_ui()); | 
| 544 ASSERT_EQ(1U, web_ui_.call_data().size()); | 548 | 
| 549 // We expect a call to SyncSetupOverlay.showSyncSetupPage. Some variations of | |
| 550 // this test also include a call to OptionsPage.closeOverlay, that we ignore. | |
| 551 ASSERT_LE(1U, web_ui_.call_data().size()); | |
| 
 
James Hawkins
2013/01/14 22:30:18
EXPECT_LE
Here and the other ASSERTs you added.
 
Raghu Simha
2013/01/14 22:45:47
Done.
 
 | |
| 552 | |
| 
 
Roger Tawa OOO till Jul 10th
2013/01/11 18:33:51
The web-base sign in flow does not use the webui.
 
Raghu Simha
2013/01/11 18:53:04
When I was debugging this test on the various buil
 
 | |
| 545 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 553 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 
| 546 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 554 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 
| 547 std::string page; | 555 std::string page; | 
| 548 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 556 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 
| 549 EXPECT_EQ(page, "spinner"); | 557 EXPECT_EQ(page, "spinner"); | 
| 550 // Cancelling the spinner dialog will cause CloseSyncSetup(). | 558 // Cancelling the spinner dialog will cause CloseSyncSetup(). | 
| 551 handler_->CloseSyncSetup(); | 559 handler_->CloseSyncSetup(); | 
| 552 EXPECT_EQ(NULL, | 560 EXPECT_EQ(NULL, | 
| 553 LoginUIServiceFactory::GetForProfile( | 561 LoginUIServiceFactory::GetForProfile( | 
| 554 profile_.get())->current_login_ui()); | 562 profile_.get())->current_login_ui()); | 
| (...skipping 11 matching lines...) Expand all Loading... | |
| 566 .WillRepeatedly(Return(false)); | 574 .WillRepeatedly(Return(false)); | 
| 567 error_ = GoogleServiceAuthError::None(); | 575 error_ = GoogleServiceAuthError::None(); | 
| 568 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 576 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 
| 569 // Sync backend is stopped initially, and will start up. | 577 // Sync backend is stopped initially, and will start up. | 
| 570 EXPECT_CALL(*mock_pss_, sync_initialized()) | 578 EXPECT_CALL(*mock_pss_, sync_initialized()) | 
| 571 .WillOnce(Return(false)) | 579 .WillOnce(Return(false)) | 
| 572 .WillRepeatedly(Return(true)); | 580 .WillRepeatedly(Return(true)); | 
| 573 SetDefaultExpectationsForConfigPage(); | 581 SetDefaultExpectationsForConfigPage(); | 
| 574 | 582 | 
| 575 handler_->OpenSyncSetup(false); | 583 handler_->OpenSyncSetup(false); | 
| 576 ASSERT_EQ(1U, web_ui_.call_data().size()); | 584 | 
| 585 // We expect a call to SyncSetupOverlay.showSyncSetupPage. Some variations of | |
| 586 // this test also include a call to OptionsPage.closeOverlay, that we ignore. | |
| 587 ASSERT_LE(1U, web_ui_.call_data().size()); | |
| 588 | |
| 577 const TestWebUI::CallData& data0 = web_ui_.call_data()[0]; | 589 const TestWebUI::CallData& data0 = web_ui_.call_data()[0]; | 
| 578 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data0.function_name); | 590 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data0.function_name); | 
| 579 std::string page; | 591 std::string page; | 
| 580 ASSERT_TRUE(data0.arg1->GetAsString(&page)); | 592 ASSERT_TRUE(data0.arg1->GetAsString(&page)); | 
| 581 EXPECT_EQ(page, "spinner"); | 593 EXPECT_EQ(page, "spinner"); | 
| 582 handler_->SigninSuccess(); | 594 handler_->SigninSuccess(); | 
| 595 | |
| 583 // On signin success, the dialog will proceed from spinner to configure sync | 596 // On signin success, the dialog will proceed from spinner to configure sync | 
| 584 // everything. | 597 // everything. There is no login UI once signin is successful. | 
| 585 EXPECT_EQ(handler_.get(), | 598 EXPECT_EQ(NULL, | 
| 586 LoginUIServiceFactory::GetForProfile( | 599 LoginUIServiceFactory::GetForProfile( | 
| 587 profile_.get())->current_login_ui()); | 600 profile_.get())->current_login_ui()); | 
| 588 ASSERT_EQ(2U, web_ui_.call_data().size()); | 601 | 
| 589 const TestWebUI::CallData& data1 = web_ui_.call_data()[1]; | 602 // We expect a second call to SyncSetupOverlay.showSyncSetupPage. Some | 
| 603 // variations of this test also include a call to OptionsPage.closeOverlay, | |
| 604 // that we ignore. | |
| 605 ASSERT_LE(2U, web_ui_.call_data().size()); | |
| 
 
Raghu Simha
2013/01/11 18:53:04
At this spot, the size of call_data() was 3 for we
 
 | |
| 606 const TestWebUI::CallData& data1 = web_ui_.call_data().back(); | |
| 590 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data1.function_name); | 607 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data1.function_name); | 
| 591 ASSERT_TRUE(data1.arg1->GetAsString(&page)); | 608 ASSERT_TRUE(data1.arg1->GetAsString(&page)); | 
| 592 EXPECT_EQ(page, "configure"); | 609 EXPECT_EQ(page, "configure"); | 
| 593 DictionaryValue* dictionary; | 610 DictionaryValue* dictionary; | 
| 594 ASSERT_TRUE(data1.arg2->GetAsDictionary(&dictionary)); | 611 ASSERT_TRUE(data1.arg2->GetAsDictionary(&dictionary)); | 
| 595 CheckBool(dictionary, "passphraseFailed", false); | 612 CheckBool(dictionary, "passphraseFailed", false); | 
| 596 CheckBool(dictionary, "showSyncEverythingPage", true); | 613 CheckBool(dictionary, "showSyncEverythingPage", true); | 
| 597 CheckBool(dictionary, "syncAllDataTypes", true); | 614 CheckBool(dictionary, "syncAllDataTypes", true); | 
| 598 CheckBool(dictionary, "encryptAllData", false); | 615 CheckBool(dictionary, "encryptAllData", false); | 
| 599 CheckBool(dictionary, "usePassphrase", false); | 616 CheckBool(dictionary, "usePassphrase", false); | 
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1259 dictionary, err, false, GoogleServiceAuthError::NONE, "", true, ""); | 1276 dictionary, err, false, GoogleServiceAuthError::NONE, "", true, ""); | 
| 1260 handler_->CloseSyncSetup(); | 1277 handler_->CloseSyncSetup(); | 
| 1261 EXPECT_EQ(NULL, | 1278 EXPECT_EQ(NULL, | 
| 1262 LoginUIServiceFactory::GetForProfile( | 1279 LoginUIServiceFactory::GetForProfile( | 
| 1263 profile_.get())->current_login_ui()); | 1280 profile_.get())->current_login_ui()); | 
| 1264 } | 1281 } | 
| 1265 | 1282 | 
| 1266 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam, | 1283 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam, | 
| 1267 SyncSetupHandlerTest, | 1284 SyncSetupHandlerTest, | 
| 1268 Values(true, false)); | 1285 Values(true, false)); | 
| OLD | NEW |