| 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/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 WillRepeatedly(Return(GetAllTypes())); | 326 WillRepeatedly(Return(GetAllTypes())); |
| 327 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). | 327 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). |
| 328 WillRepeatedly(Return(GetAllTypes())); | 328 WillRepeatedly(Return(GetAllTypes())); |
| 329 EXPECT_CALL(*mock_pss_, EncryptEverythingEnabled()). | 329 EXPECT_CALL(*mock_pss_, EncryptEverythingEnabled()). |
| 330 WillRepeatedly(Return(false)); | 330 WillRepeatedly(Return(false)); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void SetupInitializedProfileSyncService() { | 333 void SetupInitializedProfileSyncService() { |
| 334 // An initialized ProfileSyncService will have already completed sync setup | 334 // An initialized ProfileSyncService will have already completed sync setup |
| 335 // and will have an initialized sync backend. | 335 // and will have an initialized sync backend. |
| 336 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 336 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
| 337 .WillRepeatedly(Return(true)); |
| 338 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
| 337 .WillRepeatedly(Return(true)); | 339 .WillRepeatedly(Return(true)); |
| 338 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 340 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 339 .WillRepeatedly(Return(true)); | 341 .WillRepeatedly(Return(true)); |
| 340 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 342 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
| 341 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(true)); | 343 EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(true)); |
| 342 } | 344 } |
| 343 | 345 |
| 344 void ExpectConfig() { | 346 void ExpectConfig() { |
| 345 ASSERT_EQ(1U, web_ui_.call_data().size()); | 347 ASSERT_EQ(1U, web_ui_.call_data().size()); |
| 346 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 348 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 366 TestWebUI web_ui_; | 368 TestWebUI web_ui_; |
| 367 scoped_ptr<TestingSyncSetupHandler> handler_; | 369 scoped_ptr<TestingSyncSetupHandler> handler_; |
| 368 }; | 370 }; |
| 369 | 371 |
| 370 | 372 |
| 371 TEST_F(SyncSetupHandlerTest, Basic) { | 373 TEST_F(SyncSetupHandlerTest, Basic) { |
| 372 } | 374 } |
| 373 | 375 |
| 374 #if !defined(OS_CHROMEOS) | 376 #if !defined(OS_CHROMEOS) |
| 375 TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) { | 377 TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) { |
| 376 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 378 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
| 379 .WillRepeatedly(Return(false)); |
| 380 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
| 377 .WillRepeatedly(Return(false)); | 381 .WillRepeatedly(Return(false)); |
| 378 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 382 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 379 .WillRepeatedly(Return(false)); | 383 .WillRepeatedly(Return(false)); |
| 380 handler_->OpenSyncSetup(false); | 384 handler_->OpenSyncSetup(false); |
| 381 EXPECT_EQ(handler_.get(), | 385 EXPECT_EQ(handler_.get(), |
| 382 LoginUIServiceFactory::GetForProfile( | 386 LoginUIServiceFactory::GetForProfile( |
| 383 profile_.get())->current_login_ui()); | 387 profile_.get())->current_login_ui()); |
| 384 ASSERT_EQ(1U, web_ui_.call_data().size()); | 388 ASSERT_EQ(1U, web_ui_.call_data().size()); |
| 385 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 389 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
| 386 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 390 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
| 387 std::string page; | 391 std::string page; |
| 388 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 392 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
| 389 EXPECT_EQ(page, "login"); | 393 EXPECT_EQ(page, "login"); |
| 390 // Now make sure that the appropriate params are being passed. | 394 // Now make sure that the appropriate params are being passed. |
| 391 DictionaryValue* dictionary; | 395 DictionaryValue* dictionary; |
| 392 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 396 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 393 CheckShowSyncSetupArgs( | 397 CheckShowSyncSetupArgs( |
| 394 dictionary, "", false, GoogleServiceAuthError::NONE, "", true, ""); | 398 dictionary, "", false, GoogleServiceAuthError::NONE, "", true, ""); |
| 395 handler_->CloseSyncSetup(); | 399 handler_->CloseSyncSetup(); |
| 396 EXPECT_EQ(NULL, | 400 EXPECT_EQ(NULL, |
| 397 LoginUIServiceFactory::GetForProfile( | 401 LoginUIServiceFactory::GetForProfile( |
| 398 profile_.get())->current_login_ui()); | 402 profile_.get())->current_login_ui()); |
| 399 } | 403 } |
| 400 | 404 |
| 401 TEST_F(SyncSetupHandlerTest, DisplayForceLogin) { | 405 TEST_F(SyncSetupHandlerTest, DisplayForceLogin) { |
| 402 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 406 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
| 407 .WillRepeatedly(Return(false)); |
| 408 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
| 403 .WillRepeatedly(Return(false)); | 409 .WillRepeatedly(Return(false)); |
| 404 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 410 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 405 .WillRepeatedly(Return(true)); | 411 .WillRepeatedly(Return(true)); |
| 406 // This should display the login UI even though sync setup has already | 412 // This should display the login UI even though sync setup has already |
| 407 // completed. | 413 // completed. |
| 408 handler_->OpenSyncSetup(true); | 414 handler_->OpenSyncSetup(true); |
| 409 EXPECT_EQ(handler_.get(), | 415 EXPECT_EQ(handler_.get(), |
| 410 LoginUIServiceFactory::GetForProfile( | 416 LoginUIServiceFactory::GetForProfile( |
| 411 profile_.get())->current_login_ui()); | 417 profile_.get())->current_login_ui()); |
| 412 ASSERT_EQ(1U, web_ui_.call_data().size()); | 418 ASSERT_EQ(1U, web_ui_.call_data().size()); |
| 413 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 419 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
| 414 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 420 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
| 415 std::string page; | 421 std::string page; |
| 416 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 422 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
| 417 EXPECT_EQ(page, "login"); | 423 EXPECT_EQ(page, "login"); |
| 418 // Now make sure that the appropriate params are being passed. | 424 // Now make sure that the appropriate params are being passed. |
| 419 DictionaryValue* dictionary; | 425 DictionaryValue* dictionary; |
| 420 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 426 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 421 CheckShowSyncSetupArgs( | 427 CheckShowSyncSetupArgs( |
| 422 dictionary, "", false, GoogleServiceAuthError::NONE, "", true, ""); | 428 dictionary, "", false, GoogleServiceAuthError::NONE, "", true, ""); |
| 423 handler_->CloseSyncSetup(); | 429 handler_->CloseSyncSetup(); |
| 424 EXPECT_EQ(NULL, | 430 EXPECT_EQ(NULL, |
| 425 LoginUIServiceFactory::GetForProfile( | 431 LoginUIServiceFactory::GetForProfile( |
| 426 profile_.get())->current_login_ui()); | 432 profile_.get())->current_login_ui()); |
| 427 } | 433 } |
| 428 | 434 |
| 429 TEST_F(SyncSetupHandlerTest, HandleGaiaAuthFailure) { | 435 TEST_F(SyncSetupHandlerTest, HandleGaiaAuthFailure) { |
| 430 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 436 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
| 437 .WillRepeatedly(Return(false)); |
| 438 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
| 431 .WillRepeatedly(Return(false)); | 439 .WillRepeatedly(Return(false)); |
| 432 EXPECT_CALL(*mock_pss_, unrecoverable_error_detected()) | 440 EXPECT_CALL(*mock_pss_, unrecoverable_error_detected()) |
| 433 .WillRepeatedly(Return(false)); | 441 .WillRepeatedly(Return(false)); |
| 434 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 442 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 435 .WillRepeatedly(Return(false)); | 443 .WillRepeatedly(Return(false)); |
| 436 // Open the web UI. | 444 // Open the web UI. |
| 437 handler_->OpenSyncSetup(false); | 445 handler_->OpenSyncSetup(false); |
| 438 // Fake a failed signin attempt. | 446 // Fake a failed signin attempt. |
| 439 handler_->TryLogin(kTestUser, kTestPassword, "", ""); | 447 handler_->TryLogin(kTestUser, kTestPassword, "", ""); |
| 440 GoogleServiceAuthError error( | 448 GoogleServiceAuthError error( |
| 441 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 449 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 442 handler_->SigninFailed(error); | 450 handler_->SigninFailed(error); |
| 443 ASSERT_EQ(2U, web_ui_.call_data().size()); | 451 ASSERT_EQ(2U, web_ui_.call_data().size()); |
| 444 // Validate the second JS call (the first call was already tested by | 452 // Validate the second JS call (the first call was already tested by |
| 445 // the DisplayBasicLogin test). | 453 // the DisplayBasicLogin test). |
| 446 const TestWebUI::CallData& data = web_ui_.call_data()[1]; | 454 const TestWebUI::CallData& data = web_ui_.call_data()[1]; |
| 447 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 455 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
| 448 std::string page; | 456 std::string page; |
| 449 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 457 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
| 450 EXPECT_EQ(page, "login"); | 458 EXPECT_EQ(page, "login"); |
| 451 // Now make sure that the appropriate params are being passed. | 459 // Now make sure that the appropriate params are being passed. |
| 452 DictionaryValue* dictionary; | 460 DictionaryValue* dictionary; |
| 453 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 461 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 454 CheckShowSyncSetupArgs( | 462 CheckShowSyncSetupArgs( |
| 455 dictionary, "", false, GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, | 463 dictionary, "", false, GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, |
| 456 kTestUser, true, ""); | 464 kTestUser, true, ""); |
| 457 } | 465 } |
| 458 | 466 |
| 459 TEST_F(SyncSetupHandlerTest, HandleCaptcha) { | 467 TEST_F(SyncSetupHandlerTest, HandleCaptcha) { |
| 460 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 468 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
| 469 .WillRepeatedly(Return(false)); |
| 470 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
| 461 .WillRepeatedly(Return(false)); | 471 .WillRepeatedly(Return(false)); |
| 462 EXPECT_CALL(*mock_pss_, unrecoverable_error_detected()) | 472 EXPECT_CALL(*mock_pss_, unrecoverable_error_detected()) |
| 463 .WillRepeatedly(Return(false)); | 473 .WillRepeatedly(Return(false)); |
| 464 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 474 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 465 .WillRepeatedly(Return(false)); | 475 .WillRepeatedly(Return(false)); |
| 466 // Open the web UI. | 476 // Open the web UI. |
| 467 handler_->OpenSyncSetup(false); | 477 handler_->OpenSyncSetup(false); |
| 468 // Fake a failed signin attempt that requires a captcha. | 478 // Fake a failed signin attempt that requires a captcha. |
| 469 handler_->TryLogin(kTestUser, kTestPassword, "", ""); | 479 handler_->TryLogin(kTestUser, kTestPassword, "", ""); |
| 470 GoogleServiceAuthError error = | 480 GoogleServiceAuthError error = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 481 EXPECT_EQ(page, "login"); | 491 EXPECT_EQ(page, "login"); |
| 482 // Now make sure that the appropriate params are being passed. | 492 // Now make sure that the appropriate params are being passed. |
| 483 DictionaryValue* dictionary; | 493 DictionaryValue* dictionary; |
| 484 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 494 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 485 CheckShowSyncSetupArgs( | 495 CheckShowSyncSetupArgs( |
| 486 dictionary, "", false, GoogleServiceAuthError::CAPTCHA_REQUIRED, | 496 dictionary, "", false, GoogleServiceAuthError::CAPTCHA_REQUIRED, |
| 487 kTestUser, true, kTestCaptchaImageUrl); | 497 kTestUser, true, kTestCaptchaImageUrl); |
| 488 } | 498 } |
| 489 | 499 |
| 490 TEST_F(SyncSetupHandlerTest, HandleFatalError) { | 500 TEST_F(SyncSetupHandlerTest, HandleFatalError) { |
| 491 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 501 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
| 502 .WillRepeatedly(Return(false)); |
| 503 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
| 492 .WillRepeatedly(Return(false)); | 504 .WillRepeatedly(Return(false)); |
| 493 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 505 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 494 .WillRepeatedly(Return(false)); | 506 .WillRepeatedly(Return(false)); |
| 495 handler_->ShowFatalError(); | 507 handler_->ShowFatalError(); |
| 496 ASSERT_EQ(1U, web_ui_.call_data().size()); | 508 ASSERT_EQ(1U, web_ui_.call_data().size()); |
| 497 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 509 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
| 498 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 510 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
| 499 std::string page; | 511 std::string page; |
| 500 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 512 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
| 501 EXPECT_EQ(page, "login"); | 513 EXPECT_EQ(page, "login"); |
| 502 // Now make sure that the appropriate params are being passed. | 514 // Now make sure that the appropriate params are being passed. |
| 503 DictionaryValue* dictionary; | 515 DictionaryValue* dictionary; |
| 504 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 516 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 505 CheckShowSyncSetupArgs( | 517 CheckShowSyncSetupArgs( |
| 506 dictionary, "", true, GoogleServiceAuthError::NONE, "", true, ""); | 518 dictionary, "", true, GoogleServiceAuthError::NONE, "", true, ""); |
| 507 } | 519 } |
| 508 #endif // !OS_CHROMEOS | 520 #endif // !OS_CHROMEOS |
| 509 | 521 |
| 510 #if !defined(OS_CHROMEOS) | 522 #if !defined(OS_CHROMEOS) |
| 511 // TODO(kochi): We need equivalent tests for ChromeOS. | 523 // TODO(kochi): We need equivalent tests for ChromeOS. |
| 512 TEST_F(SyncSetupHandlerTest, UnrecoverableErrorInitializingSync) { | 524 TEST_F(SyncSetupHandlerTest, UnrecoverableErrorInitializingSync) { |
| 513 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 525 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
| 526 .WillRepeatedly(Return(false)); |
| 527 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
| 514 .WillRepeatedly(Return(false)); | 528 .WillRepeatedly(Return(false)); |
| 515 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 529 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 516 .WillRepeatedly(Return(false)); | 530 .WillRepeatedly(Return(false)); |
| 517 // Open the web UI. | 531 // Open the web UI. |
| 518 handler_->OpenSyncSetup(false); | 532 handler_->OpenSyncSetup(false); |
| 519 ASSERT_EQ(1U, web_ui_.call_data().size()); | 533 ASSERT_EQ(1U, web_ui_.call_data().size()); |
| 520 // Fake a successful GAIA request (gaia credentials valid, but signin not | 534 // Fake a successful GAIA request (gaia credentials valid, but signin not |
| 521 // complete yet). | 535 // complete yet). |
| 522 handler_->TryLogin(kTestUser, kTestPassword, "", ""); | 536 handler_->TryLogin(kTestUser, kTestPassword, "", ""); |
| 523 handler_->GaiaCredentialsValid(); | 537 handler_->GaiaCredentialsValid(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 540 EXPECT_EQ(page, "login"); | 554 EXPECT_EQ(page, "login"); |
| 541 // Now make sure that the appropriate params are being passed. | 555 // Now make sure that the appropriate params are being passed. |
| 542 DictionaryValue* dictionary; | 556 DictionaryValue* dictionary; |
| 543 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 557 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 544 CheckShowSyncSetupArgs( | 558 CheckShowSyncSetupArgs( |
| 545 dictionary, "", true, GoogleServiceAuthError::NONE, | 559 dictionary, "", true, GoogleServiceAuthError::NONE, |
| 546 kTestUser, true, ""); | 560 kTestUser, true, ""); |
| 547 } | 561 } |
| 548 | 562 |
| 549 TEST_F(SyncSetupHandlerTest, GaiaErrorInitializingSync) { | 563 TEST_F(SyncSetupHandlerTest, GaiaErrorInitializingSync) { |
| 550 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 564 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
| 565 .WillRepeatedly(Return(false)); |
| 566 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
| 551 .WillRepeatedly(Return(false)); | 567 .WillRepeatedly(Return(false)); |
| 552 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 568 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 553 .WillRepeatedly(Return(false)); | 569 .WillRepeatedly(Return(false)); |
| 554 // Open the web UI. | 570 // Open the web UI. |
| 555 handler_->OpenSyncSetup(false); | 571 handler_->OpenSyncSetup(false); |
| 556 ASSERT_EQ(1U, web_ui_.call_data().size()); | 572 ASSERT_EQ(1U, web_ui_.call_data().size()); |
| 557 // Fake a successful GAIA request (gaia credentials valid, but signin not | 573 // Fake a successful GAIA request (gaia credentials valid, but signin not |
| 558 // complete yet). | 574 // complete yet). |
| 559 handler_->TryLogin(kTestUser, kTestPassword, "", ""); | 575 handler_->TryLogin(kTestUser, kTestPassword, "", ""); |
| 560 handler_->GaiaCredentialsValid(); | 576 handler_->GaiaCredentialsValid(); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 ExpectConfig(); | 803 ExpectConfig(); |
| 788 } | 804 } |
| 789 | 805 |
| 790 #if !defined(OS_CHROMEOS) | 806 #if !defined(OS_CHROMEOS) |
| 791 TEST_F(SyncSetupHandlerTest, ShowSyncSetupWithAuthError) { | 807 TEST_F(SyncSetupHandlerTest, ShowSyncSetupWithAuthError) { |
| 792 // Initialize the system to a signed in state, but with an auth error. | 808 // Initialize the system to a signed in state, but with an auth error. |
| 793 error_ = GoogleServiceAuthError( | 809 error_ = GoogleServiceAuthError( |
| 794 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 810 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 795 SetupInitializedProfileSyncService(); | 811 SetupInitializedProfileSyncService(); |
| 796 mock_signin_->SetAuthenticatedUsername(kTestUser); | 812 mock_signin_->SetAuthenticatedUsername(kTestUser); |
| 797 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 813 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
| 814 .WillRepeatedly(Return(true)); |
| 815 EXPECT_CALL(*mock_pss_, IsSyncTokenAvailable()) |
| 798 .WillRepeatedly(Return(true)); | 816 .WillRepeatedly(Return(true)); |
| 799 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 817 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
| 800 .WillRepeatedly(Return(false)); | 818 .WillRepeatedly(Return(false)); |
| 801 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 819 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
| 802 .WillRepeatedly(Return(false)); | 820 .WillRepeatedly(Return(false)); |
| 803 // This should display the login dialog (not login). | 821 // This should display the login dialog (not login). |
| 804 handler_->OpenSyncSetup(false); | 822 handler_->OpenSyncSetup(false); |
| 805 | 823 |
| 806 EXPECT_EQ(handler_.get(), | 824 EXPECT_EQ(handler_.get(), |
| 807 LoginUIServiceFactory::GetForProfile( | 825 LoginUIServiceFactory::GetForProfile( |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 978 |
| 961 // This should display the sync setup dialog (not login). | 979 // This should display the sync setup dialog (not login). |
| 962 handler_->OpenSyncSetup(false); | 980 handler_->OpenSyncSetup(false); |
| 963 | 981 |
| 964 ExpectConfig(); | 982 ExpectConfig(); |
| 965 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 983 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
| 966 DictionaryValue* dictionary; | 984 DictionaryValue* dictionary; |
| 967 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 985 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 968 CheckBool(dictionary, "encryptAllData", true); | 986 CheckBool(dictionary, "encryptAllData", true); |
| 969 } | 987 } |
| OLD | NEW |