| 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 CheckString(dictionary, "user", user, false); | 279 CheckString(dictionary, "user", user, false); |
| 280 CheckString(dictionary, "captchaUrl", captcha_url, false); | 280 CheckString(dictionary, "captchaUrl", captcha_url, false); |
| 281 CheckInt(dictionary, "error", error); | 281 CheckInt(dictionary, "error", error); |
| 282 CheckBool(dictionary, "fatalError", fatal_error, true); | 282 CheckBool(dictionary, "fatalError", fatal_error, true); |
| 283 CheckBool(dictionary, "editable_user", user_is_editable); | 283 CheckBool(dictionary, "editable_user", user_is_editable); |
| 284 } | 284 } |
| 285 | 285 |
| 286 TEST_F(SyncSetupHandlerTest, Basic) { | 286 TEST_F(SyncSetupHandlerTest, Basic) { |
| 287 } | 287 } |
| 288 | 288 |
| 289 #if !defined(OS_CHROMEOS) |
| 289 TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) { | 290 TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) { |
| 290 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 291 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) |
| 291 .WillRepeatedly(Return(false)); | 292 .WillRepeatedly(Return(false)); |
| 292 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 293 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 293 .WillRepeatedly(Return(false)); | 294 .WillRepeatedly(Return(false)); |
| 294 handler_->OpenSyncSetup(false); | 295 handler_->OpenSyncSetup(false); |
| 295 EXPECT_EQ(&web_ui_, | 296 EXPECT_EQ(&web_ui_, |
| 296 LoginUIServiceFactory::GetForProfile( | 297 LoginUIServiceFactory::GetForProfile( |
| 297 profile_.get())->current_login_ui()); | 298 profile_.get())->current_login_ui()); |
| 298 ASSERT_EQ(1U, web_ui_.call_data().size()); | 299 ASSERT_EQ(1U, web_ui_.call_data().size()); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 std::string page; | 393 std::string page; |
| 393 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 394 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
| 394 EXPECT_EQ(page, "login"); | 395 EXPECT_EQ(page, "login"); |
| 395 // Now make sure that the appropriate params are being passed. | 396 // Now make sure that the appropriate params are being passed. |
| 396 DictionaryValue* dictionary; | 397 DictionaryValue* dictionary; |
| 397 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 398 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 398 CheckShowSyncSetupArgs( | 399 CheckShowSyncSetupArgs( |
| 399 dictionary, "", false, GoogleServiceAuthError::CAPTCHA_REQUIRED, | 400 dictionary, "", false, GoogleServiceAuthError::CAPTCHA_REQUIRED, |
| 400 kTestUser, true, kTestCaptchaImageUrl); | 401 kTestUser, true, kTestCaptchaImageUrl); |
| 401 } | 402 } |
| 403 #endif // !OS_CHROMEOS |
| 402 | 404 |
| 403 TEST_F(SyncSetupHandlerTest, HandleFatalError) { | 405 TEST_F(SyncSetupHandlerTest, HandleFatalError) { |
| 404 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 406 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) |
| 405 .WillRepeatedly(Return(false)); | 407 .WillRepeatedly(Return(false)); |
| 406 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 408 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 407 .WillRepeatedly(Return(false)); | 409 .WillRepeatedly(Return(false)); |
| 408 handler_->ShowFatalError(); | 410 handler_->ShowFatalError(); |
| 409 ASSERT_EQ(1U, web_ui_.call_data().size()); | 411 ASSERT_EQ(1U, web_ui_.call_data().size()); |
| 410 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 412 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
| 411 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 413 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
| 412 std::string page; | 414 std::string page; |
| 413 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 415 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
| 414 EXPECT_EQ(page, "login"); | 416 EXPECT_EQ(page, "login"); |
| 415 // Now make sure that the appropriate params are being passed. | 417 // Now make sure that the appropriate params are being passed. |
| 416 DictionaryValue* dictionary; | 418 DictionaryValue* dictionary; |
| 417 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 419 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 418 CheckShowSyncSetupArgs( | 420 CheckShowSyncSetupArgs( |
| 419 dictionary, "", true, GoogleServiceAuthError::NONE, "", true, ""); | 421 dictionary, "", true, GoogleServiceAuthError::NONE, "", true, ""); |
| 420 } | 422 } |
| 421 | 423 |
| 424 #if !defined(OS_CHROMEOS) |
| 422 TEST_F(SyncSetupHandlerTest, UnrecoverableErrorInitializingSync) { | 425 TEST_F(SyncSetupHandlerTest, UnrecoverableErrorInitializingSync) { |
| 423 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) | 426 EXPECT_CALL(*mock_pss_, AreCredentialsAvailable()) |
| 424 .WillRepeatedly(Return(false)); | 427 .WillRepeatedly(Return(false)); |
| 425 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 428 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
| 426 .WillRepeatedly(Return(false)); | 429 .WillRepeatedly(Return(false)); |
| 427 // Open the web UI. | 430 // Open the web UI. |
| 428 handler_->OpenSyncSetup(false); | 431 handler_->OpenSyncSetup(false); |
| 429 ASSERT_EQ(1U, web_ui_.call_data().size()); | 432 ASSERT_EQ(1U, web_ui_.call_data().size()); |
| 430 // Fake a successful GAIA request (gaia credentials valid, but signin not | 433 // Fake a successful GAIA request (gaia credentials valid, but signin not |
| 431 // complete yet). | 434 // complete yet). |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 std::string page; | 489 std::string page; |
| 487 ASSERT_TRUE(data.arg1->GetAsString(&page)); | 490 ASSERT_TRUE(data.arg1->GetAsString(&page)); |
| 488 EXPECT_EQ(page, "login"); | 491 EXPECT_EQ(page, "login"); |
| 489 // Now make sure that the appropriate params are being passed. | 492 // Now make sure that the appropriate params are being passed. |
| 490 DictionaryValue* dictionary; | 493 DictionaryValue* dictionary; |
| 491 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 494 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 492 CheckShowSyncSetupArgs( | 495 CheckShowSyncSetupArgs( |
| 493 dictionary, "", false, GoogleServiceAuthError::SERVICE_UNAVAILABLE, | 496 dictionary, "", false, GoogleServiceAuthError::SERVICE_UNAVAILABLE, |
| 494 kTestUser, true, ""); | 497 kTestUser, true, ""); |
| 495 } | 498 } |
| 499 #endif // !OS_CHROMEOS |
| 496 | 500 |
| 497 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { | 501 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { |
| 498 std::string args = | 502 std::string args = |
| 499 "{\"syncAllDataTypes\":true," | 503 "{\"syncAllDataTypes\":true," |
| 500 "\"sync_apps\":true," | 504 "\"sync_apps\":true," |
| 501 "\"sync_autofill\":true," | 505 "\"sync_autofill\":true," |
| 502 "\"sync_bookmarks\":true," | 506 "\"sync_bookmarks\":true," |
| 503 "\"sync_extensions\":true," | 507 "\"sync_extensions\":true," |
| 504 "\"sync_passwords\":true," | 508 "\"sync_passwords\":true," |
| 505 "\"sync_preferences\":true," | 509 "\"sync_preferences\":true," |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 | 920 |
| 917 // This should display the sync setup dialog (not login). | 921 // This should display the sync setup dialog (not login). |
| 918 handler_->OpenSyncSetup(false); | 922 handler_->OpenSyncSetup(false); |
| 919 | 923 |
| 920 ExpectConfig(); | 924 ExpectConfig(); |
| 921 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 925 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
| 922 DictionaryValue* dictionary; | 926 DictionaryValue* dictionary; |
| 923 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 927 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 924 CheckBool(dictionary, "encryptAllData", true); | 928 CheckBool(dictionary, "encryptAllData", true); |
| 925 } | 929 } |
| OLD | NEW |