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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 TEST_F(SyncSetupHandlerTest, Basic) { | 371 TEST_F(SyncSetupHandlerTest, Basic) { |
372 } | 372 } |
373 | 373 |
374 #if !defined(OS_CHROMEOS) | 374 #if !defined(OS_CHROMEOS) |
375 TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) { | 375 TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) { |
376 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 376 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) |
377 .WillRepeatedly(Return(false)); | 377 .WillRepeatedly(Return(false)); |
378 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 378 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
379 .WillRepeatedly(Return(false)); | 379 .WillRepeatedly(Return(false)); |
380 handler_->OpenSyncSetup(false); | 380 handler_->OpenSyncSetup(false); |
381 EXPECT_EQ(&web_ui_, | 381 EXPECT_EQ(handler_.get(), |
382 LoginUIServiceFactory::GetForProfile( | 382 LoginUIServiceFactory::GetForProfile( |
383 profile_.get())->current_login_ui()); | 383 profile_.get())->current_login_ui()); |
384 ASSERT_EQ(1U, web_ui_.call_data().size()); | 384 ASSERT_EQ(1U, web_ui_.call_data().size()); |
385 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 385 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
386 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 386 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
387 std::string page; | 387 std::string page; |
388 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 388 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
389 EXPECT_EQ(page, "login"); | 389 EXPECT_EQ(page, "login"); |
390 // Now make sure that the appropriate params are being passed. | 390 // Now make sure that the appropriate params are being passed. |
391 DictionaryValue* dictionary; | 391 DictionaryValue* dictionary; |
392 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 392 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
393 CheckShowSyncSetupArgs( | 393 CheckShowSyncSetupArgs( |
394 dictionary, "", false, GoogleServiceAuthError::NONE, "", true, ""); | 394 dictionary, "", false, GoogleServiceAuthError::NONE, "", true, ""); |
395 handler_->CloseSyncSetup(); | 395 handler_->CloseSyncSetup(); |
396 EXPECT_EQ(NULL, | 396 EXPECT_EQ(NULL, |
397 LoginUIServiceFactory::GetForProfile( | 397 LoginUIServiceFactory::GetForProfile( |
398 profile_.get())->current_login_ui()); | 398 profile_.get())->current_login_ui()); |
399 } | 399 } |
400 | 400 |
401 TEST_F(SyncSetupHandlerTest, DisplayForceLogin) { | 401 TEST_F(SyncSetupHandlerTest, DisplayForceLogin) { |
402 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 402 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) |
403 .WillRepeatedly(Return(false)); | 403 .WillRepeatedly(Return(false)); |
404 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 404 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
405 .WillRepeatedly(Return(true)); | 405 .WillRepeatedly(Return(true)); |
406 // This should display the login UI even though sync setup has already | 406 // This should display the login UI even though sync setup has already |
407 // completed. | 407 // completed. |
408 handler_->OpenSyncSetup(true); | 408 handler_->OpenSyncSetup(true); |
409 EXPECT_EQ(&web_ui_, | 409 EXPECT_EQ(handler_.get(), |
410 LoginUIServiceFactory::GetForProfile( | 410 LoginUIServiceFactory::GetForProfile( |
411 profile_.get())->current_login_ui()); | 411 profile_.get())->current_login_ui()); |
412 ASSERT_EQ(1U, web_ui_.call_data().size()); | 412 ASSERT_EQ(1U, web_ui_.call_data().size()); |
413 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 413 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
414 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 414 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
415 std::string page; | 415 std::string page; |
416 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 416 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
417 EXPECT_EQ(page, "login"); | 417 EXPECT_EQ(page, "login"); |
418 // Now make sure that the appropriate params are being passed. | 418 // Now make sure that the appropriate params are being passed. |
419 DictionaryValue* dictionary; | 419 DictionaryValue* dictionary; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 mock_signin_->SetAuthenticatedUsername(kTestUser); | 796 mock_signin_->SetAuthenticatedUsername(kTestUser); |
797 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 797 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) |
798 .WillRepeatedly(Return(true)); | 798 .WillRepeatedly(Return(true)); |
799 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 799 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
800 .WillRepeatedly(Return(false)); | 800 .WillRepeatedly(Return(false)); |
801 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 801 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
802 .WillRepeatedly(Return(false)); | 802 .WillRepeatedly(Return(false)); |
803 // This should display the login dialog (not login). | 803 // This should display the login dialog (not login). |
804 handler_->OpenSyncSetup(false); | 804 handler_->OpenSyncSetup(false); |
805 | 805 |
806 EXPECT_EQ(&web_ui_, | 806 EXPECT_EQ(handler_.get(), |
807 LoginUIServiceFactory::GetForProfile( | 807 LoginUIServiceFactory::GetForProfile( |
808 profile_.get())->current_login_ui()); | 808 profile_.get())->current_login_ui()); |
809 ASSERT_EQ(1U, web_ui_.call_data().size()); | 809 ASSERT_EQ(1U, web_ui_.call_data().size()); |
810 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 810 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
811 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 811 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
812 std::string page; | 812 std::string page; |
813 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 813 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
814 EXPECT_EQ(page, "login"); | 814 EXPECT_EQ(page, "login"); |
815 DictionaryValue* dictionary; | 815 DictionaryValue* dictionary; |
816 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 816 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 types.Put(kUserSelectableTypes[i]); | 890 types.Put(kUserSelectableTypes[i]); |
891 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). | 891 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()). |
892 WillRepeatedly(Return(types)); | 892 WillRepeatedly(Return(types)); |
893 | 893 |
894 // This should display the sync setup dialog (not login). | 894 // This should display the sync setup dialog (not login). |
895 handler_->OpenSyncSetup(false); | 895 handler_->OpenSyncSetup(false); |
896 | 896 |
897 ExpectConfig(); | 897 ExpectConfig(); |
898 // Close the config overlay. | 898 // Close the config overlay. |
899 LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed( | 899 LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed( |
900 &web_ui_); | 900 handler_.get()); |
901 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 901 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
902 DictionaryValue* dictionary; | 902 DictionaryValue* dictionary; |
903 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 903 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
904 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); | 904 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); |
905 Mock::VerifyAndClearExpectations(mock_pss_); | 905 Mock::VerifyAndClearExpectations(mock_pss_); |
906 // Clean up so we can loop back to display the dialog again. | 906 // Clean up so we can loop back to display the dialog again. |
907 web_ui_.ClearTrackedCalls(); | 907 web_ui_.ClearTrackedCalls(); |
908 } | 908 } |
909 } | 909 } |
910 | 910 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 | 960 |
961 // This should display the sync setup dialog (not login). | 961 // This should display the sync setup dialog (not login). |
962 handler_->OpenSyncSetup(false); | 962 handler_->OpenSyncSetup(false); |
963 | 963 |
964 ExpectConfig(); | 964 ExpectConfig(); |
965 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 965 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
966 DictionaryValue* dictionary; | 966 DictionaryValue* dictionary; |
967 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 967 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
968 CheckBool(dictionary, "encryptAllData", true); | 968 CheckBool(dictionary, "encryptAllData", true); |
969 } | 969 } |
OLD | NEW |