Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: chrome/browser/sync/sync_setup_wizard_unittest.cc

Issue 7093004: Sync: Refactor the ProfileSyncService and sync setup flow to remove use of WebUI from PSS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests, fixes. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // TODO(jhawkins): Rewrite these tests to handle the new inlined sync UI. 5 // TODO(jhawkins): Rewrite these tests to handle the new inlined sync UI.
6 6
7 #include "chrome/browser/sync/sync_setup_wizard.h" 7 #include "chrome/browser/sync/sync_setup_wizard.h"
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"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/sync/engine/syncapi.h" 14 #include "chrome/browser/sync/engine/syncapi.h"
15 #include "chrome/browser/sync/profile_sync_factory_mock.h" 15 #include "chrome/browser/sync/profile_sync_factory_mock.h"
16 #include "chrome/browser/sync/profile_sync_service.h" 16 #include "chrome/browser/sync/profile_sync_service.h"
17 #include "chrome/browser/sync/sync_setup_flow.h" 17 #include "chrome/browser/sync/sync_setup_flow.h"
18 #include "chrome/browser/sync/sync_setup_flow_handler.h"
19 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_list.h" 19 #include "chrome/browser/ui/browser_list.h"
20 #include "chrome/browser/ui/webui/options/sync_setup_handler.h"
21 #include "chrome/common/net/gaia/google_service_auth_error.h" 21 #include "chrome/common/net/gaia/google_service_auth_error.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "chrome/test/browser_with_test_window_test.h" 23 #include "chrome/test/browser_with_test_window_test.h"
24 #include "chrome/test/test_browser_window.h" 24 #include "chrome/test/test_browser_window.h"
25 #include "chrome/test/testing_profile.h" 25 #include "chrome/test/testing_profile.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 27
28 static const char kTestUser[] = "chrome.p13n.test@gmail.com"; 28 static const char kTestUser[] = "chrome.p13n.test@gmail.com";
29 static const char kTestPassword[] = "passwd"; 29 static const char kTestPassword[] = "passwd";
30 static const char kTestCaptcha[] = "pizzamyheart"; 30 static const char kTestCaptcha[] = "pizzamyheart";
31 static const char kTestCaptchaUrl[] = "http://pizzamyheart/"; 31 static const char kTestCaptchaUrl[] = "http://pizzamyheart/";
32 32
33 typedef GoogleServiceAuthError AuthError; 33 typedef GoogleServiceAuthError AuthError;
34 34
35 class MockSyncSetupHandler : public SyncSetupHandler {
36 public:
37 MockSyncSetupHandler() {}
38
39 // SyncSetupFlowHandler implementation.
40 virtual void ShowGaiaLogin(const DictionaryValue& args) {}
41 virtual void ShowGaiaSuccessAndClose() {}
42 virtual void ShowGaiaSuccessAndSettingUp() {}
43 virtual void ShowConfigure(const DictionaryValue& args) {}
44 virtual void ShowPassphraseEntry(const DictionaryValue& args) {}
45 virtual void ShowSettingUp() {}
46 virtual void ShowSetupDone(const std::wstring& user) {
47 flow()->OnDialogClosed("");
48 }
49
50 void CloseSetupUI() {
51 ShowSetupDone(std::wstring());
52 }
53
54 private:
55 DISALLOW_COPY_AND_ASSIGN(MockSyncSetupHandler);
56 };
57
35 // A PSS subtype to inject. 58 // A PSS subtype to inject.
36 class ProfileSyncServiceForWizardTest : public ProfileSyncService { 59 class ProfileSyncServiceForWizardTest : public ProfileSyncService {
37 public: 60 public:
38 ProfileSyncServiceForWizardTest(ProfileSyncFactory* factory, Profile* profile) 61 ProfileSyncServiceForWizardTest(ProfileSyncFactory* factory, Profile* profile)
39 : ProfileSyncService(factory, profile, ""), 62 : ProfileSyncService(factory, profile, ""),
40 user_cancelled_dialog_(false) { 63 user_cancelled_dialog_(false),
64 is_using_secondary_passphrase_(false) {
41 RegisterPreferences(); 65 RegisterPreferences();
42 ResetTestStats(); 66 ResetTestStats();
43 } 67 }
44 68
45 virtual ~ProfileSyncServiceForWizardTest() { } 69 virtual ~ProfileSyncServiceForWizardTest() {}
46 70
47 virtual void OnUserSubmittedAuth(const std::string& username, 71 virtual void OnUserSubmittedAuth(const std::string& username,
48 const std::string& password, 72 const std::string& password,
49 const std::string& captcha, 73 const std::string& captcha,
50 const std::string& access_code) { 74 const std::string& access_code) {
51 username_ = username; 75 username_ = username;
52 password_ = password; 76 password_ = password;
53 captcha_ = captcha; 77 captcha_ = captcha;
54 } 78 }
55 79
(...skipping 10 matching lines...) Expand all
66 virtual void SetPassphrase(const std::string& passphrase, 90 virtual void SetPassphrase(const std::string& passphrase,
67 bool is_explicit, 91 bool is_explicit,
68 bool is_creation) { 92 bool is_creation) {
69 passphrase_ = passphrase; 93 passphrase_ = passphrase;
70 } 94 }
71 95
72 virtual string16 GetAuthenticatedUsername() const { 96 virtual string16 GetAuthenticatedUsername() const {
73 return UTF8ToUTF16(username_); 97 return UTF8ToUTF16(username_);
74 } 98 }
75 99
100 virtual bool IsUsingSecondaryPassphrase() const {
101 // The only value of |is_using_secondary_passphrase_| we current care about
102 // is when it's true.
103 if (!is_using_secondary_passphrase_)
104 return ProfileSyncService::IsUsingSecondaryPassphrase();
105 else
106 return is_using_secondary_passphrase_;
107 }
108
76 void set_auth_state(const std::string& last_email, 109 void set_auth_state(const std::string& last_email,
77 const AuthError& error) { 110 const AuthError& error) {
78 last_attempted_user_email_ = last_email; 111 last_attempted_user_email_ = last_email;
79 last_auth_error_ = error; 112 last_auth_error_ = error;
80 } 113 }
81 114
82 void SetPassphraseRequiredReason(sync_api::PassphraseRequiredReason reason) { 115 void set_last_auth_error(const AuthError& error) {
116 last_auth_error_ = error;
117 }
118
119 void set_is_using_secondary_passphrase(bool secondary) {
120 is_using_secondary_passphrase_ = secondary;
121 }
122
123 void set_passphrase_required_reason(
124 sync_api::PassphraseRequiredReason reason) {
83 passphrase_required_reason_ = reason; 125 passphrase_required_reason_ = reason;
84 } 126 }
85 127
86 void ResetTestStats() { 128 void ResetTestStats() {
87 username_.clear(); 129 username_.clear();
88 password_.clear(); 130 password_.clear();
89 captcha_.clear(); 131 captcha_.clear();
90 user_cancelled_dialog_ = false; 132 user_cancelled_dialog_ = false;
91 user_chose_data_types_ = false; 133 user_chose_data_types_ = false;
92 keep_everything_synced_ = false; 134 keep_everything_synced_ = false;
93 chosen_data_types_.clear(); 135 chosen_data_types_.clear();
94 } 136 }
95 137
96 std::string username_; 138 std::string username_;
97 std::string password_; 139 std::string password_;
98 std::string captcha_; 140 std::string captcha_;
99 bool user_cancelled_dialog_; 141 bool user_cancelled_dialog_;
100 bool user_chose_data_types_; 142 bool user_chose_data_types_;
101 bool keep_everything_synced_; 143 bool keep_everything_synced_;
144 bool is_using_secondary_passphrase_;
102 syncable::ModelTypeSet chosen_data_types_; 145 syncable::ModelTypeSet chosen_data_types_;
103 146
104 std::string passphrase_; 147 std::string passphrase_;
105 148
106 private: 149 private:
107 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceForWizardTest); 150 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceForWizardTest);
108 }; 151 };
109 152
110 class TestingProfileWithSyncService : public TestingProfile { 153 class TestingProfileWithSyncService : public TestingProfile {
111 public: 154 public:
112 TestingProfileWithSyncService() { 155 TestingProfileWithSyncService() {
113 sync_service_.reset(new ProfileSyncServiceForWizardTest(&factory_, this)); 156 sync_service_.reset(new ProfileSyncServiceForWizardTest(&factory_, this));
114 } 157 }
115 158
116 virtual ProfileSyncService* GetProfileSyncService() { 159 virtual ProfileSyncService* GetProfileSyncService() {
117 return sync_service_.get(); 160 return sync_service_.get();
118 } 161 }
119 private: 162 private:
120 ProfileSyncFactoryMock factory_; 163 ProfileSyncFactoryMock factory_;
121 scoped_ptr<ProfileSyncService> sync_service_; 164 scoped_ptr<ProfileSyncService> sync_service_;
122 }; 165 };
123 166
124 class TestBrowserWindowForWizardTest : public TestBrowserWindow { 167 // TODO(jhawkins): Subclass Browser (specifically, ShowOptionsTab) and inject it
125 public: 168 // here to test the visibility of the Sync UI.
126 explicit TestBrowserWindowForWizardTest(Browser* browser)
127 : TestBrowserWindow(browser), flow_(NULL),
128 was_show_html_dialog_called_(false) {
129 }
130
131 virtual ~TestBrowserWindowForWizardTest() {
132 if (flow_.get()) {
133 // The handler contract is that they are valid for the lifetime of the
134 // sync login overlay, but are cleaned up after the dialog is closed
135 // and/or deleted.
136 flow_.reset();
137 }
138 }
139
140 bool TestAndResetWasShowHTMLDialogCalled() {
141 bool ret = was_show_html_dialog_called_;
142 was_show_html_dialog_called_ = false;
143 return ret;
144 }
145
146 // Simulates the user (or browser view hierarchy) closing the html dialog.
147 // Handles cleaning up the delegate and associated handlers.
148 void CloseDialog() {
149 if (flow_.get()) {
150 // The flow deletes itself here. Don't use reset().
151 flow_.release()->OnDialogClosed("");
152 }
153 }
154
155 SyncSetupFlow* flow() { return flow_.get(); }
156
157 private:
158 // In real life, this is owned by the view that is opened by the browser. We
159 // mock all that out, so we need to take ownership so the flow doesn't leak.
160 scoped_ptr<SyncSetupFlow> flow_;
161
162 bool was_show_html_dialog_called_;
163 };
164
165 class SyncSetupWizardTest : public BrowserWithTestWindowTest { 169 class SyncSetupWizardTest : public BrowserWithTestWindowTest {
166 public: 170 public:
167 SyncSetupWizardTest() 171 SyncSetupWizardTest()
168 : test_window_(NULL), 172 : test_window_(NULL),
169 wizard_(NULL) { } 173 wizard_(NULL),
170 virtual ~SyncSetupWizardTest() { } 174 service_(NULL),
175 flow_(NULL) {}
176 virtual ~SyncSetupWizardTest() {}
171 virtual void SetUp() { 177 virtual void SetUp() {
172 set_profile(new TestingProfileWithSyncService()); 178 set_profile(new TestingProfileWithSyncService());
173 profile()->CreateBookmarkModel(false); 179 profile()->CreateBookmarkModel(false);
174 // Wait for the bookmarks model to load. 180 // Wait for the bookmarks model to load.
175 profile()->BlockUntilBookmarkModelLoaded(); 181 profile()->BlockUntilBookmarkModelLoaded();
176 set_browser(new Browser(Browser::TYPE_TABBED, profile())); 182 set_browser(new Browser(Browser::TYPE_TABBED, profile()));
177 test_window_ = new TestBrowserWindowForWizardTest(browser()); 183 test_window_ = new TestBrowserWindow(browser());
178 set_window(test_window_); 184 //set_window(test_window_);
csilv 2011/06/13 22:20:57 If this line isn't commented out as part of the TO
binji 2011/06/13 22:32:52 remove commented code
James Hawkins 2011/06/13 23:14:52 Done.
James Hawkins 2011/06/13 23:14:52 Done.
179 browser()->set_window(window()); 185 browser()->set_window(window());
180 BrowserList::SetLastActive(browser()); 186 BrowserList::SetLastActive(browser());
181 service_ = static_cast<ProfileSyncServiceForWizardTest*>( 187 service_ = static_cast<ProfileSyncServiceForWizardTest*>(
182 profile()->GetProfileSyncService()); 188 profile()->GetProfileSyncService());
183 wizard_.reset(new SyncSetupWizard(service_)); 189 wizard_.reset(new SyncSetupWizard(service_));
184 } 190 }
185 191
186 virtual void TearDown() { 192 virtual void TearDown() {
187 test_window_ = NULL; 193 test_window_ = NULL;
194 wizard_.reset();
188 service_ = NULL; 195 service_ = NULL;
189 wizard_.reset(); 196 flow_ = NULL;
190 } 197 }
191 198
192 TestBrowserWindowForWizardTest* test_window_; 199 protected:
200 void AttachSyncSetupHandler() {
201 flow_ = wizard_->AttachSyncSetupHandler(&handler_);
202 }
203
204 void CompleteSetup() {
205 // For a discrete run, we need to have ran through setup once.
206 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
207 AttachSyncSetupHandler();
208 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
209 wizard_->Step(SyncSetupWizard::SYNC_EVERYTHING);
210 wizard_->Step(SyncSetupWizard::SETTING_UP);
211 wizard_->Step(SyncSetupWizard::DONE);
212 }
213
214 void CloseSetupUI() {
215 handler_.CloseSetupUI();
216 }
217
218 TestBrowserWindow* test_window_;
193 scoped_ptr<SyncSetupWizard> wizard_; 219 scoped_ptr<SyncSetupWizard> wizard_;
194 ProfileSyncServiceForWizardTest* service_; 220 ProfileSyncServiceForWizardTest* service_;
221 SyncSetupFlow* flow_;
222 MockSyncSetupHandler handler_;
195 }; 223 };
196 224
197 // See http://code.google.com/p/chromium/issues/detail?id=40715 for 225 // See http://code.google.com/p/chromium/issues/detail?id=40715 for
198 // why we skip the below tests on OS X. We don't use DISABLED_ as we 226 // why we skip the below tests on OS X. We don't use DISABLED_ as we
199 // would have to change the corresponding FRIEND_TEST() declarations. 227 // would have to change the corresponding FRIEND_TEST() declarations.
200 228
201 #if defined(OS_MACOSX) 229 #if defined(OS_MACOSX)
csilv 2011/06/13 22:20:57 We may not need to skip these tests anymore. The
James Hawkins 2011/06/13 23:14:52 I'll do that in a followup CL.
202 #define SKIP_TEST_ON_MACOSX() \ 230 #define SKIP_TEST_ON_MACOSX() \
203 do { LOG(WARNING) << "Test skipped on OS X"; return; } while (0) 231 do { LOG(WARNING) << "Test skipped on OS X"; return; } while (0)
204 #else 232 #else
205 #define SKIP_TEST_ON_MACOSX() do {} while (0) 233 #define SKIP_TEST_ON_MACOSX() do {} while (0)
206 #endif 234 #endif
207 235
208 TEST_F(SyncSetupWizardTest, DISABLED_InitialStepLogin) { 236 TEST_F(SyncSetupWizardTest, InitialStepLogin) {
209 SKIP_TEST_ON_MACOSX(); 237 SKIP_TEST_ON_MACOSX();
210 DictionaryValue dialog_args; 238 DictionaryValue dialog_args;
211 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); 239 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
212 std::string json_start_args; 240 std::string json_start_args;
213 base::JSONWriter::Write(&dialog_args, false, &json_start_args); 241 base::JSONWriter::Write(&dialog_args, false, &json_start_args);
214 ListValue credentials; 242 ListValue credentials;
215 std::string auth = "{\"user\":\""; 243 std::string auth = "{\"user\":\"";
216 auth += std::string(kTestUser) + "\",\"pass\":\""; 244 auth += std::string(kTestUser) + "\",\"pass\":\"";
217 auth += std::string(kTestPassword) + "\",\"captcha\":\""; 245 auth += std::string(kTestPassword) + "\",\"captcha\":\"";
218 auth += std::string(kTestCaptcha) + "\",\"access_code\":\""; 246 auth += std::string(kTestCaptcha) + "\",\"access_code\":\"";
219 auth += std::string() + "\"}"; 247 auth += std::string() + "\"}";
220 credentials.Append(new StringValue(auth)); 248 credentials.Append(new StringValue(auth));
221 249
222 EXPECT_FALSE(wizard_->IsVisible()); 250 EXPECT_FALSE(wizard_->IsVisible());
223 EXPECT_FALSE(test_window_->flow()); 251 EXPECT_EQ(static_cast<SyncSetupFlow*>(NULL), flow_);
224 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 252 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
253 AttachSyncSetupHandler();
225 254
226 EXPECT_TRUE(wizard_->IsVisible()); 255 EXPECT_TRUE(wizard_->IsVisible());
227 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 256 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
228 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); 257 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
229 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->end_state_); 258 EXPECT_EQ(json_start_args, flow_->dialog_start_args_);
230 EXPECT_EQ(json_start_args, test_window_->flow()->dialog_start_args_);
231 259
232 #if 0
233 // Simulate the user submitting credentials. 260 // Simulate the user submitting credentials.
234 test_window_->flow()->flow_handler_->HandleSubmitAuth(&credentials); 261 handler_.HandleSubmitAuth(&credentials);
235 EXPECT_TRUE(wizard_->IsVisible()); 262 EXPECT_TRUE(wizard_->IsVisible());
236 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); 263 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
237 EXPECT_EQ(kTestUser, service_->username_); 264 EXPECT_EQ(kTestUser, service_->username_);
238 EXPECT_EQ(kTestPassword, service_->password_); 265 EXPECT_EQ(kTestPassword, service_->password_);
239 EXPECT_EQ(kTestCaptcha, service_->captcha_); 266 EXPECT_EQ(kTestCaptcha, service_->captcha_);
240 EXPECT_FALSE(service_->user_cancelled_dialog_); 267 EXPECT_FALSE(service_->user_cancelled_dialog_);
241 service_->ResetTestStats(); 268 service_->ResetTestStats();
242 #endif
243 269
244 // Simulate failed credentials. 270 // Simulate failed credentials.
245 AuthError invalid_gaia(AuthError::INVALID_GAIA_CREDENTIALS); 271 AuthError invalid_gaia(AuthError::INVALID_GAIA_CREDENTIALS);
246 service_->set_auth_state(kTestUser, invalid_gaia); 272 service_->set_auth_state(kTestUser, invalid_gaia);
247 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 273 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
274 AttachSyncSetupHandler();
248 EXPECT_TRUE(wizard_->IsVisible()); 275 EXPECT_TRUE(wizard_->IsVisible());
249 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 276 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
250 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_);
251 dialog_args.Clear(); 277 dialog_args.Clear();
252 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); 278 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
253 EXPECT_EQ(5U, dialog_args.size()); 279 EXPECT_EQ(4U, dialog_args.size());
254 std::string iframe_to_show;
255 dialog_args.GetString("iframeToShow", &iframe_to_show);
256 EXPECT_EQ("login", iframe_to_show);
257 std::string actual_user; 280 std::string actual_user;
258 dialog_args.GetString("user", &actual_user); 281 dialog_args.GetString("user", &actual_user);
259 EXPECT_EQ(kTestUser, actual_user); 282 EXPECT_EQ(kTestUser, actual_user);
260 int error = -1; 283 int error = -1;
261 dialog_args.GetInteger("error", &error); 284 dialog_args.GetInteger("error", &error);
262 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error); 285 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error);
263 service_->set_auth_state(kTestUser, AuthError::None()); 286 service_->set_auth_state(kTestUser, AuthError::None());
264 287
265 // Simulate captcha. 288 // Simulate captcha.
266 AuthError captcha_error(AuthError::FromCaptchaChallenge( 289 AuthError captcha_error(AuthError::FromCaptchaChallenge(
267 std::string(), GURL(kTestCaptchaUrl), GURL())); 290 std::string(), GURL(kTestCaptchaUrl), GURL()));
268 service_->set_auth_state(kTestUser, captcha_error); 291 service_->set_auth_state(kTestUser, captcha_error);
269 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 292 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
293 AttachSyncSetupHandler();
270 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); 294 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
271 EXPECT_EQ(5U, dialog_args.size()); 295 EXPECT_EQ(4U, dialog_args.size());
272 dialog_args.GetString("iframeToShow", &iframe_to_show);
273 EXPECT_EQ("login", iframe_to_show);
274 std::string captcha_url; 296 std::string captcha_url;
275 dialog_args.GetString("captchaUrl", &captcha_url); 297 dialog_args.GetString("captchaUrl", &captcha_url);
276 EXPECT_EQ(kTestCaptchaUrl, GURL(captcha_url).spec()); 298 EXPECT_EQ(kTestCaptchaUrl, GURL(captcha_url).spec());
277 error = -1; 299 error = -1;
278 dialog_args.GetInteger("error", &error); 300 dialog_args.GetInteger("error", &error);
279 EXPECT_EQ(static_cast<int>(AuthError::CAPTCHA_REQUIRED), error); 301 EXPECT_EQ(static_cast<int>(AuthError::CAPTCHA_REQUIRED), error);
280 service_->set_auth_state(kTestUser, AuthError::None()); 302 service_->set_auth_state(kTestUser, AuthError::None());
281 303
282 // Simulate success. 304 // Simulate success.
283 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 305 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
284 EXPECT_TRUE(wizard_->IsVisible()); 306 EXPECT_TRUE(wizard_->IsVisible());
285 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
286 // In a non-discrete run, GAIA_SUCCESS immediately transitions you to 307 // In a non-discrete run, GAIA_SUCCESS immediately transitions you to
287 // SYNC_EVERYTHING. 308 // SYNC_EVERYTHING.
288 EXPECT_EQ(SyncSetupWizard::SYNC_EVERYTHING, 309 EXPECT_EQ(SyncSetupWizard::SYNC_EVERYTHING, flow_->current_state_);
289 test_window_->flow()->current_state_);
290 310
291 // That's all we're testing here, just move on to DONE. We'll test the 311 // That's all we're testing here, just move on to DONE. We'll test the
292 // "choose data types" scenarios elsewhere. 312 // "choose data types" scenarios elsewhere.
293 wizard_->Step(SyncSetupWizard::SETTING_UP); // No merge and sync. 313 wizard_->Step(SyncSetupWizard::SETTING_UP); // No merge and sync.
294 wizard_->Step(SyncSetupWizard::DONE); // No merge and sync. 314 wizard_->Step(SyncSetupWizard::DONE); // No merge and sync.
295 EXPECT_TRUE(wizard_->IsVisible()); 315 EXPECT_FALSE(wizard_->IsVisible());
296 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
297 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->current_state_);
298 } 316 }
299 317
300 TEST_F(SyncSetupWizardTest, DISABLED_ChooseDataTypesSetsPrefs) { 318 TEST_F(SyncSetupWizardTest, ChooseDataTypesSetsPrefs) {
301 SKIP_TEST_ON_MACOSX(); 319 SKIP_TEST_ON_MACOSX();
302 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 320 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
321 AttachSyncSetupHandler();
303 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 322 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
304 wizard_->Step(SyncSetupWizard::CONFIGURE); 323 wizard_->Step(SyncSetupWizard::CONFIGURE);
305 324
306 ListValue data_type_choices_value; 325 ListValue data_type_choices_value;
307 std::string data_type_choices = "{\"keepEverythingSynced\":false,"; 326 std::string data_type_choices =
308 data_type_choices += "\"syncBookmarks\":true,\"syncPreferences\":true,"; 327 "{\"keepEverythingSynced\":false,\"syncBookmarks\":true,"
309 data_type_choices += "\"syncThemes\":false,\"syncPasswords\":false,"; 328 "\"syncPreferences\":true,\"syncThemes\":false,\"syncPasswords\":false,"
310 data_type_choices += "\"syncAutofill\":false,\"syncExtensions\":false,"; 329 "\"syncAutofill\":false,\"syncExtensions\":false,\"syncTypedUrls\":true,"
311 data_type_choices += "\"syncTypedUrls\":true,\"syncApps\":true,"; 330 "\"syncApps\":true,\"syncSessions\":false,\"usePassphrase\":false,"
312 data_type_choices += "\"syncSessions\":false,\"usePassphrase\":false}"; 331 "\"encryptAllData\":false}";
313 data_type_choices_value.Append(new StringValue(data_type_choices)); 332 data_type_choices_value.Append(new StringValue(data_type_choices));
314 333
315 #if 0 334 // Simulate the user choosing data types; bookmarks, prefs, typed URLS, and
316 // Simulate the user choosing data types; bookmarks, prefs, typed 335 // apps are on, the rest are off.
317 // URLS, and apps are on, the rest are off. 336 handler_.HandleConfigure(&data_type_choices_value);
318 test_window_->flow()->flow_handler_->HandleConfigure(
319 &data_type_choices_value);
320 EXPECT_TRUE(wizard_->IsVisible()); 337 EXPECT_TRUE(wizard_->IsVisible());
321 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
322 EXPECT_FALSE(service_->keep_everything_synced_); 338 EXPECT_FALSE(service_->keep_everything_synced_);
323 EXPECT_EQ(service_->chosen_data_types_.count(syncable::BOOKMARKS), 1U); 339 EXPECT_EQ(1U, service_->chosen_data_types_.count(syncable::BOOKMARKS));
324 EXPECT_EQ(service_->chosen_data_types_.count(syncable::PREFERENCES), 1U); 340 EXPECT_EQ(1U, service_->chosen_data_types_.count(syncable::PREFERENCES));
325 EXPECT_EQ(service_->chosen_data_types_.count(syncable::THEMES), 0U); 341 EXPECT_EQ(0U, service_->chosen_data_types_.count(syncable::THEMES));
326 EXPECT_EQ(service_->chosen_data_types_.count(syncable::PASSWORDS), 0U); 342 EXPECT_EQ(0U, service_->chosen_data_types_.count(syncable::PASSWORDS));
327 EXPECT_EQ(service_->chosen_data_types_.count(syncable::AUTOFILL), 0U); 343 EXPECT_EQ(0U, service_->chosen_data_types_.count(syncable::AUTOFILL));
328 EXPECT_EQ(service_->chosen_data_types_.count(syncable::EXTENSIONS), 0U); 344 EXPECT_EQ(0U, service_->chosen_data_types_.count(syncable::EXTENSIONS));
329 EXPECT_EQ(service_->chosen_data_types_.count(syncable::TYPED_URLS), 1U); 345 EXPECT_EQ(1U, service_->chosen_data_types_.count(syncable::TYPED_URLS));
330 EXPECT_EQ(service_->chosen_data_types_.count(syncable::APPS), 1U); 346 EXPECT_EQ(1U, service_->chosen_data_types_.count(syncable::APPS));
331 #endif 347
332 test_window_->CloseDialog(); 348 CloseSetupUI();
333 } 349 }
334 350
335 TEST_F(SyncSetupWizardTest, DISABLED_EnterPassphraseRequired) { 351 TEST_F(SyncSetupWizardTest, EnterPassphraseRequired) {
336 SKIP_TEST_ON_MACOSX(); 352 SKIP_TEST_ON_MACOSX();
337 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 353 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
354 AttachSyncSetupHandler();
338 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 355 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
339 wizard_->Step(SyncSetupWizard::CONFIGURE); 356 wizard_->Step(SyncSetupWizard::CONFIGURE);
340 wizard_->Step(SyncSetupWizard::SETTING_UP); 357 wizard_->Step(SyncSetupWizard::SETTING_UP);
341 service_->SetPassphraseRequiredReason(sync_api::REASON_ENCRYPTION); 358 service_->set_passphrase_required_reason(sync_api::REASON_ENCRYPTION);
342 wizard_->Step(SyncSetupWizard::ENTER_PASSPHRASE); 359 wizard_->Step(SyncSetupWizard::ENTER_PASSPHRASE);
343 EXPECT_EQ(SyncSetupWizard::ENTER_PASSPHRASE, 360 EXPECT_EQ(SyncSetupWizard::ENTER_PASSPHRASE, flow_->current_state_);
344 test_window_->flow()->current_state_); 361
345 #if 0
346 ListValue value; 362 ListValue value;
347 value.Append(new StringValue("{\"passphrase\":\"myPassphrase\"," 363 value.Append(new StringValue("{\"passphrase\":\"myPassphrase\","
348 "\"mode\":\"gaia\"}")); 364 "\"mode\":\"gaia\"}"));
349 test_window_->flow()->flow_handler_->HandlePassphraseEntry(&value); 365 handler_.HandlePassphraseEntry(&value);
350 EXPECT_EQ("myPassphrase", service_->passphrase_); 366 EXPECT_EQ("myPassphrase", service_->passphrase_);
351 #endif
352 } 367 }
353 368
354 TEST_F(SyncSetupWizardTest, DISABLED_DialogCancelled) { 369 TEST_F(SyncSetupWizardTest, DialogCancelled) {
355 SKIP_TEST_ON_MACOSX(); 370 SKIP_TEST_ON_MACOSX();
356 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 371 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
372 AttachSyncSetupHandler();
357 // Simulate the user closing the dialog. 373 // Simulate the user closing the dialog.
358 test_window_->CloseDialog(); 374 CloseSetupUI();
359 EXPECT_FALSE(wizard_->IsVisible()); 375 EXPECT_FALSE(wizard_->IsVisible());
360 EXPECT_TRUE(service_->user_cancelled_dialog_); 376 EXPECT_TRUE(service_->user_cancelled_dialog_);
361 EXPECT_EQ(std::string(), service_->username_); 377 EXPECT_EQ(std::string(), service_->username_);
362 EXPECT_EQ(std::string(), service_->password_); 378 EXPECT_EQ(std::string(), service_->password_);
363 379
364 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 380 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
381 AttachSyncSetupHandler();
365 EXPECT_TRUE(wizard_->IsVisible()); 382 EXPECT_TRUE(wizard_->IsVisible());
366 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
367 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 383 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
368 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
369 384
370 test_window_->CloseDialog(); 385 CloseSetupUI();
371 EXPECT_FALSE(wizard_->IsVisible()); 386 EXPECT_FALSE(wizard_->IsVisible());
372 EXPECT_TRUE(service_->user_cancelled_dialog_); 387 EXPECT_TRUE(service_->user_cancelled_dialog_);
373 EXPECT_EQ(std::string(), service_->username_); 388 EXPECT_EQ(std::string(), service_->username_);
374 EXPECT_EQ(std::string(), service_->password_); 389 EXPECT_EQ(std::string(), service_->password_);
375 } 390 }
376 391
377 TEST_F(SyncSetupWizardTest, DISABLED_InvalidTransitions) { 392 TEST_F(SyncSetupWizardTest, InvalidTransitions) {
378 SKIP_TEST_ON_MACOSX(); 393 SKIP_TEST_ON_MACOSX();
379 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 394 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
380 EXPECT_FALSE(wizard_->IsVisible()); 395 EXPECT_FALSE(wizard_->IsVisible());
381 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
382 396
383 wizard_->Step(SyncSetupWizard::DONE); 397 wizard_->Step(SyncSetupWizard::DONE);
384 EXPECT_FALSE(wizard_->IsVisible()); 398 EXPECT_FALSE(wizard_->IsVisible());
385 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
386 399
387 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 400 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
401 AttachSyncSetupHandler();
388 402
389 wizard_->Step(SyncSetupWizard::DONE); 403 wizard_->Step(SyncSetupWizard::DONE);
390 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); 404 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
391 405
392 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR); 406 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR);
393 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, 407 AttachSyncSetupHandler();
394 test_window_->flow()->current_state_); 408 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
395 409
396 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 410 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
397 EXPECT_EQ(SyncSetupWizard::SYNC_EVERYTHING, 411 EXPECT_EQ(SyncSetupWizard::SYNC_EVERYTHING, flow_->current_state_);
398 test_window_->flow()->current_state_);
399 412
400 wizard_->Step(SyncSetupWizard::FATAL_ERROR); 413 wizard_->Step(SyncSetupWizard::FATAL_ERROR);
401 EXPECT_EQ(SyncSetupWizard::FATAL_ERROR, test_window_->flow()->current_state_); 414 EXPECT_EQ(SyncSetupWizard::FATAL_ERROR, flow_->current_state_);
402 } 415 }
403 416
404 TEST_F(SyncSetupWizardTest, DISABLED_FullSuccessfulRunSetsPref) { 417 TEST_F(SyncSetupWizardTest, FullSuccessfulRunSetsPref) {
405 SKIP_TEST_ON_MACOSX(); 418 SKIP_TEST_ON_MACOSX();
406 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 419 CompleteSetup();
407 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
408 wizard_->Step(SyncSetupWizard::SETTING_UP);
409 wizard_->Step(SyncSetupWizard::DONE);
410 test_window_->CloseDialog();
411 EXPECT_FALSE(wizard_->IsVisible()); 420 EXPECT_FALSE(wizard_->IsVisible());
412 EXPECT_TRUE(service_->profile()->GetPrefs()->GetBoolean( 421 EXPECT_TRUE(service_->profile()->GetPrefs()->GetBoolean(
413 prefs::kSyncHasSetupCompleted)); 422 prefs::kSyncHasSetupCompleted));
414 } 423 }
415 424
416 TEST_F(SyncSetupWizardTest, DISABLED_AbortedByPendingClear) { 425 TEST_F(SyncSetupWizardTest, AbortedByPendingClear) {
417 SKIP_TEST_ON_MACOSX(); 426 SKIP_TEST_ON_MACOSX();
418 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 427 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
428 AttachSyncSetupHandler();
419 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 429 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
420 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR); 430 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR);
421 EXPECT_EQ(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR, 431 EXPECT_EQ(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR,
422 test_window_->flow()->current_state_); 432 flow_->current_state_);
423 test_window_->CloseDialog(); 433 CloseSetupUI();
424 EXPECT_FALSE(wizard_->IsVisible()); 434 EXPECT_FALSE(wizard_->IsVisible());
425 } 435 }
426 436
427 TEST_F(SyncSetupWizardTest, DISABLED_DiscreteRunChooseDataTypes) { 437 TEST_F(SyncSetupWizardTest, DiscreteRunChooseDataTypes) {
428 SKIP_TEST_ON_MACOSX(); 438 SKIP_TEST_ON_MACOSX();
429 // For a discrete run, we need to have ran through setup once. 439
430 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 440 CompleteSetup();
431 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
432 wizard_->Step(SyncSetupWizard::DONE);
433 test_window_->CloseDialog();
434 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
435 441
436 wizard_->Step(SyncSetupWizard::CONFIGURE); 442 wizard_->Step(SyncSetupWizard::CONFIGURE);
437 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 443 AttachSyncSetupHandler();
438 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->end_state_); 444 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
439 445
446 wizard_->Step(SyncSetupWizard::SETTING_UP);
440 wizard_->Step(SyncSetupWizard::DONE); 447 wizard_->Step(SyncSetupWizard::DONE);
441 test_window_->CloseDialog();
442 EXPECT_FALSE(wizard_->IsVisible()); 448 EXPECT_FALSE(wizard_->IsVisible());
443 } 449 }
444 450
445 TEST_F(SyncSetupWizardTest, 451 TEST_F(SyncSetupWizardTest, DiscreteRunChooseDataTypesAbortedByPendingClear) {
446 DISABLED_DiscreteRunChooseDataTypesAbortedByPendingClear) {
447 SKIP_TEST_ON_MACOSX(); 452 SKIP_TEST_ON_MACOSX();
448 // For a discrete run, we need to have ran through setup once. 453
449 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 454 CompleteSetup();
450 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
451 wizard_->Step(SyncSetupWizard::DONE);
452 test_window_->CloseDialog();
453 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
454 455
455 wizard_->Step(SyncSetupWizard::CONFIGURE); 456 wizard_->Step(SyncSetupWizard::CONFIGURE);
456 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 457 AttachSyncSetupHandler();
457 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->end_state_); 458 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
458 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR); 459 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR);
459 EXPECT_EQ(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR, 460 EXPECT_EQ(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR,
460 test_window_->flow()->current_state_); 461 flow_->current_state_);
461 462
462 test_window_->CloseDialog(); 463 CloseSetupUI();
463 EXPECT_FALSE(wizard_->IsVisible()); 464 EXPECT_FALSE(wizard_->IsVisible());
464 } 465 }
465 466
466 TEST_F(SyncSetupWizardTest, DISABLED_DiscreteRunGaiaLogin) { 467 TEST_F(SyncSetupWizardTest, DiscreteRunGaiaLogin) {
467 SKIP_TEST_ON_MACOSX(); 468 SKIP_TEST_ON_MACOSX();
468 DictionaryValue dialog_args; 469
469 // For a discrete run, we need to have ran through setup once. 470 CompleteSetup();
470 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
471 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
472 wizard_->Step(SyncSetupWizard::SETTING_UP);
473 wizard_->Step(SyncSetupWizard::DONE);
474 test_window_->CloseDialog();
475 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
476 471
477 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 472 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
478 EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, test_window_->flow()->end_state_); 473 AttachSyncSetupHandler();
474 EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, flow_->end_state_);
479 475
480 AuthError invalid_gaia(AuthError::INVALID_GAIA_CREDENTIALS); 476 AuthError invalid_gaia(AuthError::INVALID_GAIA_CREDENTIALS);
481 service_->set_auth_state(kTestUser, invalid_gaia); 477 service_->set_auth_state(kTestUser, invalid_gaia);
482 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 478 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
483 EXPECT_TRUE(wizard_->IsVisible()); 479 EXPECT_TRUE(wizard_->IsVisible());
480
481 DictionaryValue dialog_args;
484 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); 482 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
485 EXPECT_EQ(5U, dialog_args.size()); 483 EXPECT_EQ(4U, dialog_args.size());
486 std::string iframe_to_show;
487 dialog_args.GetString("iframeToShow", &iframe_to_show);
488 EXPECT_EQ("login", iframe_to_show);
489 std::string actual_user; 484 std::string actual_user;
490 dialog_args.GetString("user", &actual_user); 485 dialog_args.GetString("user", &actual_user);
491 EXPECT_EQ(kTestUser, actual_user); 486 EXPECT_EQ(kTestUser, actual_user);
492 int error = -1; 487 int error = -1;
493 dialog_args.GetInteger("error", &error); 488 dialog_args.GetInteger("error", &error);
494 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error); 489 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error);
495 service_->set_auth_state(kTestUser, AuthError::None()); 490 service_->set_auth_state(kTestUser, AuthError::None());
496 491
497 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 492 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
498 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 493 }
494
495 TEST_F(SyncSetupWizardTest, NonFatalError) {
496 SKIP_TEST_ON_MACOSX();
497
498 CompleteSetup();
499
500 // Set up the ENTER_PASSPHRASE case.
501 service_->set_passphrase_required_reason(sync_api::REASON_ENCRYPTION);
502 service_->set_is_using_secondary_passphrase(true);
503 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
504 AttachSyncSetupHandler();
505 EXPECT_EQ(SyncSetupWizard::ENTER_PASSPHRASE, flow_->current_state_);
506 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
507 CloseSetupUI();
508 EXPECT_FALSE(wizard_->IsVisible());
509
510 // Reset.
511 service_->set_passphrase_required_reason(
512 sync_api::REASON_PASSPHRASE_NOT_REQUIRED);
513 service_->set_is_using_secondary_passphrase(false);
514
515 // Test the various auth error states that lead to GAIA_LOGIN.
516
517 service_->set_last_auth_error(
518 AuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
519 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
520 AttachSyncSetupHandler();
521 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
522 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
523 CloseSetupUI();
524 EXPECT_FALSE(wizard_->IsVisible());
525
526 service_->set_last_auth_error(
527 AuthError(GoogleServiceAuthError::CAPTCHA_REQUIRED));
528 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
529 AttachSyncSetupHandler();
530 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
531 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
532 CloseSetupUI();
533 EXPECT_FALSE(wizard_->IsVisible());
534
535 service_->set_last_auth_error(
536 AuthError(GoogleServiceAuthError::ACCOUNT_DELETED));
537 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
538 AttachSyncSetupHandler();
539 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
540 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
541 CloseSetupUI();
542 EXPECT_FALSE(wizard_->IsVisible());
543
544 service_->set_last_auth_error(
545 AuthError(GoogleServiceAuthError::ACCOUNT_DISABLED));
546 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
547 AttachSyncSetupHandler();
548 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
549 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
550 CloseSetupUI();
551 EXPECT_FALSE(wizard_->IsVisible());
552
553 service_->set_last_auth_error(
554 AuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
555 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
556 AttachSyncSetupHandler();
557 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
558 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
559 CloseSetupUI();
560 EXPECT_FALSE(wizard_->IsVisible());
499 } 561 }
500 562
501 #undef SKIP_TEST_ON_MACOSX 563 #undef SKIP_TEST_ON_MACOSX
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698