diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-21 21:48:16 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-21 21:48:16 +0000 |
commit | 62828b10e4a87405159a7516be36c826bf397e36 (patch) | |
tree | 6a8e16482d5b4b2388222d5aa88a57627cb76dee /chrome/browser/sync/sync_setup_wizard_unittest.cc | |
parent | c11f6dd8dd485e3d441c22469839b703c9948bed (diff) | |
download | chromium_src-62828b10e4a87405159a7516be36c826bf397e36.zip chromium_src-62828b10e4a87405159a7516be36c826bf397e36.tar.gz chromium_src-62828b10e4a87405159a7516be36c826bf397e36.tar.bz2 |
sync: listen for missing notifications
This adds a 'Could not connect' error if the server is unreachable instead of infinite spin. Trying to sign in again won't work though, because there's no path to re-attempt backend initialization. I'm going to add a way for SBH to callback on failure as well as success in an upcoming patch, but it's separable from this change.
BUG=87871,85022,88109
TEST=SyncSetupWizardTest, ProfileSyncServiceStartupTest
Review URL: http://codereview.chromium.org/7464005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/sync_setup_wizard_unittest.cc')
-rw-r--r-- | chrome/browser/sync/sync_setup_wizard_unittest.cc | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/chrome/browser/sync/sync_setup_wizard_unittest.cc b/chrome/browser/sync/sync_setup_wizard_unittest.cc index d53def0..0be7867 100644 --- a/chrome/browser/sync/sync_setup_wizard_unittest.cc +++ b/chrome/browser/sync/sync_setup_wizard_unittest.cc @@ -12,6 +12,7 @@ #include "chrome/browser/sync/engine/syncapi.h" #include "chrome/browser/sync/profile_sync_factory_mock.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/signin_manager.h" #include "chrome/browser/sync/sync_setup_flow.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" @@ -36,7 +37,9 @@ class MockSyncSetupHandler : public SyncSetupHandler { // SyncSetupFlowHandler implementation. virtual void ShowGaiaLogin(const DictionaryValue& args) {} - virtual void ShowGaiaSuccessAndClose() {} + virtual void ShowGaiaSuccessAndClose() { + flow()->OnDialogClosed(""); + } virtual void ShowGaiaSuccessAndSettingUp() {} virtual void ShowConfigure(const DictionaryValue& args) {} virtual void ShowPassphraseEntry(const DictionaryValue& args) {} @@ -57,7 +60,7 @@ class MockSyncSetupHandler : public SyncSetupHandler { class ProfileSyncServiceForWizardTest : public ProfileSyncService { public: ProfileSyncServiceForWizardTest(ProfileSyncFactory* factory, Profile* profile) - : ProfileSyncService(factory, profile, ""), + : ProfileSyncService(factory, profile, new SigninManager(), ""), user_cancelled_dialog_(false), is_using_secondary_passphrase_(false) { RegisterPreferences(); @@ -133,6 +136,11 @@ class ProfileSyncServiceForWizardTest : public ProfileSyncService { chosen_data_types_.clear(); } + // Use this to have the service act as if it were running under CrOS. + void set_cros_mode() { + cros_user_ = kTestUser; + } + std::string username_; std::string password_; std::string captcha_; @@ -483,7 +491,33 @@ TEST_F(SyncSetupWizardTest, DiscreteRunGaiaLogin) { service_->set_auth_state(kTestUser, AuthError::None()); wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); - CloseSetupUI(); +} + +// Tests a scenario where sync is disabled on chrome os on startup due to +// an auth error (application specific password is needed). +TEST_F(SyncSetupWizardTest, CrosAuthSetup) { + SKIP_TEST_ON_MACOSX(); + service_->set_cros_mode(); + + wizard_->Step(SyncSetupWizard::GAIA_LOGIN); + + AttachSyncSetupHandler(); + EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, flow_->end_state_); + + DictionaryValue dialog_args; + SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); + EXPECT_EQ(4U, dialog_args.size()); + std::string actual_user; + dialog_args.GetString("user", &actual_user); + EXPECT_EQ(kTestUser, actual_user); + int error = -1; + dialog_args.GetInteger("error", &error); + EXPECT_EQ(0, error); + bool editable = true; + dialog_args.GetBoolean("editable_user", &editable); + EXPECT_FALSE(editable); + wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); + EXPECT_TRUE(service_->user_cancelled_dialog_); } TEST_F(SyncSetupWizardTest, NonFatalError) { |