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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 435 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
436 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); | 436 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); |
437 | 437 |
438 ASSERT_FALSE(handler_->is_configuring_sync()); | 438 ASSERT_FALSE(handler_->is_configuring_sync()); |
439 EXPECT_EQ(NULL, | 439 EXPECT_EQ(NULL, |
440 LoginUIServiceFactory::GetForProfile( | 440 LoginUIServiceFactory::GetForProfile( |
441 profile_.get())->current_login_ui()); | 441 profile_.get())->current_login_ui()); |
442 } | 442 } |
443 #endif // !defined(OS_CHROMEOS) | 443 #endif // !defined(OS_CHROMEOS) |
444 | 444 |
| 445 // Verifies that the sync setup is terminated correctly when the |
| 446 // sync is disabled. |
| 447 TEST_F(SyncSetupHandlerTest, HandleSetupUIWhenSyncDisabled) { |
| 448 EXPECT_CALL(*mock_pss_, IsManaged()).WillRepeatedly(Return(true)); |
| 449 handler_->HandleShowSetupUI(NULL); |
| 450 |
| 451 // Sync setup is closed when sync is disabled. |
| 452 EXPECT_EQ(NULL, |
| 453 LoginUIServiceFactory::GetForProfile( |
| 454 profile_.get())->current_login_ui()); |
| 455 ASSERT_FALSE(handler_->is_configuring_sync()); |
| 456 } |
| 457 |
445 // Verifies that the handler correctly handles a cancellation when | 458 // Verifies that the handler correctly handles a cancellation when |
446 // it is displaying the spinner to the user. | 459 // it is displaying the spinner to the user. |
447 TEST_F(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { | 460 TEST_F(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { |
448 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) | 461 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) |
449 .WillRepeatedly(Return(true)); | 462 .WillRepeatedly(Return(true)); |
450 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 463 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
451 .WillRepeatedly(Return(true)); | 464 .WillRepeatedly(Return(true)); |
452 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 465 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
453 .WillRepeatedly(Return(false)); | 466 .WillRepeatedly(Return(false)); |
454 error_ = GoogleServiceAuthError::AuthErrorNone(); | 467 error_ = GoogleServiceAuthError::AuthErrorNone(); |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 | 1053 |
1041 // This should display the sync setup dialog (not login). | 1054 // This should display the sync setup dialog (not login). |
1042 handler_->OpenSyncSetup(); | 1055 handler_->OpenSyncSetup(); |
1043 | 1056 |
1044 ExpectConfig(); | 1057 ExpectConfig(); |
1045 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 1058 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
1046 base::DictionaryValue* dictionary; | 1059 base::DictionaryValue* dictionary; |
1047 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1060 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
1048 CheckBool(dictionary, "encryptAllData", true); | 1061 CheckBool(dictionary, "encryptAllData", true); |
1049 } | 1062 } |
OLD | NEW |