| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sync/sync_setup_wizard.h" | 5 #include "chrome/browser/sync/sync_setup_wizard.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 virtual void OnUserChoseDatatypes(bool sync_everything, | 52 virtual void OnUserChoseDatatypes(bool sync_everything, |
| 53 const syncable::ModelTypeSet& chosen_types) { | 53 const syncable::ModelTypeSet& chosen_types) { |
| 54 user_chose_data_types_ = true; | 54 user_chose_data_types_ = true; |
| 55 chosen_data_types_ = chosen_types; | 55 chosen_data_types_ = chosen_types; |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual void OnUserCancelledDialog() { | 58 virtual void OnUserCancelledDialog() { |
| 59 user_cancelled_dialog_ = true; | 59 user_cancelled_dialog_ = true; |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual void SetSecondaryPassphrase(const std::string& passphrase) { |
| 63 passphrase_ = passphrase; |
| 64 } |
| 65 |
| 62 virtual string16 GetAuthenticatedUsername() const { | 66 virtual string16 GetAuthenticatedUsername() const { |
| 63 return UTF8ToUTF16(username_); | 67 return UTF8ToUTF16(username_); |
| 64 } | 68 } |
| 65 | 69 |
| 66 void set_auth_state(const std::string& last_email, | 70 void set_auth_state(const std::string& last_email, |
| 67 const AuthError& error) { | 71 const AuthError& error) { |
| 68 last_attempted_user_email_ = last_email; | 72 last_attempted_user_email_ = last_email; |
| 69 last_auth_error_ = error; | 73 last_auth_error_ = error; |
| 70 } | 74 } |
| 71 | 75 |
| 76 void set_passphrase_required(bool required) { |
| 77 observed_passphrase_required_ = required; |
| 78 } |
| 79 |
| 72 void ResetTestStats() { | 80 void ResetTestStats() { |
| 73 username_.clear(); | 81 username_.clear(); |
| 74 password_.clear(); | 82 password_.clear(); |
| 75 captcha_.clear(); | 83 captcha_.clear(); |
| 76 user_cancelled_dialog_ = false; | 84 user_cancelled_dialog_ = false; |
| 77 user_chose_data_types_ = false; | 85 user_chose_data_types_ = false; |
| 78 keep_everything_synced_ = false; | 86 keep_everything_synced_ = false; |
| 79 chosen_data_types_.clear(); | 87 chosen_data_types_.clear(); |
| 80 } | 88 } |
| 81 | 89 |
| 82 std::string username_; | 90 std::string username_; |
| 83 std::string password_; | 91 std::string password_; |
| 84 std::string captcha_; | 92 std::string captcha_; |
| 85 bool user_cancelled_dialog_; | 93 bool user_cancelled_dialog_; |
| 86 bool user_chose_data_types_; | 94 bool user_chose_data_types_; |
| 87 bool keep_everything_synced_; | 95 bool keep_everything_synced_; |
| 88 syncable::ModelTypeSet chosen_data_types_; | 96 syncable::ModelTypeSet chosen_data_types_; |
| 89 | 97 |
| 98 std::string passphrase_; |
| 99 |
| 90 private: | 100 private: |
| 91 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceForWizardTest); | 101 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceForWizardTest); |
| 92 }; | 102 }; |
| 93 | 103 |
| 94 class TestingProfileWithSyncService : public TestingProfile { | 104 class TestingProfileWithSyncService : public TestingProfile { |
| 95 public: | 105 public: |
| 96 TestingProfileWithSyncService() { | 106 TestingProfileWithSyncService() { |
| 97 sync_service_.reset(new ProfileSyncServiceForWizardTest(&factory_, this)); | 107 sync_service_.reset(new ProfileSyncServiceForWizardTest(&factory_, this)); |
| 98 } | 108 } |
| 99 | 109 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 EXPECT_EQ(service_->chosen_data_types_.count(syncable::THEMES), 0U); | 334 EXPECT_EQ(service_->chosen_data_types_.count(syncable::THEMES), 0U); |
| 325 EXPECT_EQ(service_->chosen_data_types_.count(syncable::PASSWORDS), 0U); | 335 EXPECT_EQ(service_->chosen_data_types_.count(syncable::PASSWORDS), 0U); |
| 326 EXPECT_EQ(service_->chosen_data_types_.count(syncable::AUTOFILL), 0U); | 336 EXPECT_EQ(service_->chosen_data_types_.count(syncable::AUTOFILL), 0U); |
| 327 EXPECT_EQ(service_->chosen_data_types_.count(syncable::EXTENSIONS), 0U); | 337 EXPECT_EQ(service_->chosen_data_types_.count(syncable::EXTENSIONS), 0U); |
| 328 EXPECT_EQ(service_->chosen_data_types_.count(syncable::TYPED_URLS), 1U); | 338 EXPECT_EQ(service_->chosen_data_types_.count(syncable::TYPED_URLS), 1U); |
| 329 EXPECT_EQ(service_->chosen_data_types_.count(syncable::APPS), 1U); | 339 EXPECT_EQ(service_->chosen_data_types_.count(syncable::APPS), 1U); |
| 330 | 340 |
| 331 test_window_->CloseDialog(); | 341 test_window_->CloseDialog(); |
| 332 } | 342 } |
| 333 | 343 |
| 344 TEST_F(SyncSetupWizardTest, EnterPassphraseRequired) { |
| 345 SKIP_TEST_ON_MACOSX(); |
| 346 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 347 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
| 348 wizard_->Step(SyncSetupWizard::CONFIGURE); |
| 349 wizard_->Step(SyncSetupWizard::SETTING_UP); |
| 350 service_->set_passphrase_required(true); |
| 351 wizard_->Step(SyncSetupWizard::ENTER_PASSPHRASE); |
| 352 EXPECT_EQ(SyncSetupWizard::ENTER_PASSPHRASE, |
| 353 test_window_->flow()->current_state_); |
| 354 ListValue value; |
| 355 value.Append(new StringValue("{\"passphrase\":\"myPassphrase\"}")); |
| 356 test_window_->flow()->flow_handler_->HandlePassphraseEntry(&value); |
| 357 EXPECT_EQ("myPassphrase", service_->passphrase_); |
| 358 } |
| 359 |
| 334 TEST_F(SyncSetupWizardTest, DialogCancelled) { | 360 TEST_F(SyncSetupWizardTest, DialogCancelled) { |
| 335 SKIP_TEST_ON_MACOSX(); | 361 SKIP_TEST_ON_MACOSX(); |
| 336 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); | 362 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); |
| 337 // Simulate the user closing the dialog. | 363 // Simulate the user closing the dialog. |
| 338 test_window_->CloseDialog(); | 364 test_window_->CloseDialog(); |
| 339 EXPECT_FALSE(wizard_->IsVisible()); | 365 EXPECT_FALSE(wizard_->IsVisible()); |
| 340 EXPECT_TRUE(service_->user_cancelled_dialog_); | 366 EXPECT_TRUE(service_->user_cancelled_dialog_); |
| 341 EXPECT_EQ(std::string(), service_->username_); | 367 EXPECT_EQ(std::string(), service_->username_); |
| 342 EXPECT_EQ(std::string(), service_->password_); | 368 EXPECT_EQ(std::string(), service_->password_); |
| 343 | 369 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 int error = -1; | 515 int error = -1; |
| 490 dialog_args.GetInteger("error", &error); | 516 dialog_args.GetInteger("error", &error); |
| 491 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error); | 517 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error); |
| 492 service_->set_auth_state(kTestUser, AuthError::None()); | 518 service_->set_auth_state(kTestUser, AuthError::None()); |
| 493 | 519 |
| 494 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); | 520 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); |
| 495 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); | 521 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); |
| 496 } | 522 } |
| 497 | 523 |
| 498 #undef SKIP_TEST_ON_MACOSX | 524 #undef SKIP_TEST_ON_MACOSX |
| OLD | NEW |