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

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: Review fixes and cleanups. 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
« no previous file with comments | « chrome/browser/sync/sync_setup_wizard.cc ('k') | chrome/browser/sync/sync_ui_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 : wizard_(NULL),
169 wizard_(NULL) { } 173 service_(NULL),
170 virtual ~SyncSetupWizardTest() { } 174 flow_(NULL) {}
175 virtual ~SyncSetupWizardTest() {}
171 virtual void SetUp() { 176 virtual void SetUp() {
172 set_profile(new TestingProfileWithSyncService()); 177 set_profile(new TestingProfileWithSyncService());
173 profile()->CreateBookmarkModel(false); 178 profile()->CreateBookmarkModel(false);
174 // Wait for the bookmarks model to load. 179 // Wait for the bookmarks model to load.
175 profile()->BlockUntilBookmarkModelLoaded(); 180 profile()->BlockUntilBookmarkModelLoaded();
176 set_browser(new Browser(Browser::TYPE_TABBED, profile())); 181 set_browser(new Browser(Browser::TYPE_TABBED, profile()));
177 test_window_ = new TestBrowserWindowForWizardTest(browser());
178 set_window(test_window_);
179 browser()->set_window(window()); 182 browser()->set_window(window());
180 BrowserList::SetLastActive(browser()); 183 BrowserList::SetLastActive(browser());
181 service_ = static_cast<ProfileSyncServiceForWizardTest*>( 184 service_ = static_cast<ProfileSyncServiceForWizardTest*>(
182 profile()->GetProfileSyncService()); 185 profile()->GetProfileSyncService());
183 wizard_.reset(new SyncSetupWizard(service_)); 186 wizard_.reset(new SyncSetupWizard(service_));
184 } 187 }
185 188
186 virtual void TearDown() { 189 virtual void TearDown() {
187 test_window_ = NULL; 190 wizard_.reset();
188 service_ = NULL; 191 service_ = NULL;
189 wizard_.reset(); 192 flow_ = NULL;
190 } 193 }
191 194
192 TestBrowserWindowForWizardTest* test_window_; 195 protected:
196 void AttachSyncSetupHandler() {
197 flow_ = wizard_->AttachSyncSetupHandler(&handler_);
198 }
199
200 void CompleteSetup() {
201 // For a discrete run, we need to have ran through setup once.
202 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
203 AttachSyncSetupHandler();
204 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
205 wizard_->Step(SyncSetupWizard::SYNC_EVERYTHING);
206 wizard_->Step(SyncSetupWizard::SETTING_UP);
207 wizard_->Step(SyncSetupWizard::DONE);
208 }
209
210 void CloseSetupUI() {
211 handler_.CloseSetupUI();
212 }
213
193 scoped_ptr<SyncSetupWizard> wizard_; 214 scoped_ptr<SyncSetupWizard> wizard_;
194 ProfileSyncServiceForWizardTest* service_; 215 ProfileSyncServiceForWizardTest* service_;
216 SyncSetupFlow* flow_;
217 MockSyncSetupHandler handler_;
195 }; 218 };
196 219
197 // See http://code.google.com/p/chromium/issues/detail?id=40715 for 220 // 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 221 // 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. 222 // would have to change the corresponding FRIEND_TEST() declarations.
200 223
201 #if defined(OS_MACOSX) 224 #if defined(OS_MACOSX)
202 #define SKIP_TEST_ON_MACOSX() \ 225 #define SKIP_TEST_ON_MACOSX() \
203 do { LOG(WARNING) << "Test skipped on OS X"; return; } while (0) 226 do { LOG(WARNING) << "Test skipped on OS X"; return; } while (0)
204 #else 227 #else
205 #define SKIP_TEST_ON_MACOSX() do {} while (0) 228 #define SKIP_TEST_ON_MACOSX() do {} while (0)
206 #endif 229 #endif
207 230
208 TEST_F(SyncSetupWizardTest, DISABLED_InitialStepLogin) { 231 TEST_F(SyncSetupWizardTest, InitialStepLogin) {
209 SKIP_TEST_ON_MACOSX(); 232 SKIP_TEST_ON_MACOSX();
210 DictionaryValue dialog_args; 233 DictionaryValue dialog_args;
211 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); 234 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
212 std::string json_start_args; 235 std::string json_start_args;
213 base::JSONWriter::Write(&dialog_args, false, &json_start_args); 236 base::JSONWriter::Write(&dialog_args, false, &json_start_args);
214 ListValue credentials; 237 ListValue credentials;
215 std::string auth = "{\"user\":\""; 238 std::string auth = "{\"user\":\"";
216 auth += std::string(kTestUser) + "\",\"pass\":\""; 239 auth += std::string(kTestUser) + "\",\"pass\":\"";
217 auth += std::string(kTestPassword) + "\",\"captcha\":\""; 240 auth += std::string(kTestPassword) + "\",\"captcha\":\"";
218 auth += std::string(kTestCaptcha) + "\",\"access_code\":\""; 241 auth += std::string(kTestCaptcha) + "\",\"access_code\":\"";
219 auth += std::string() + "\"}"; 242 auth += std::string() + "\"}";
220 credentials.Append(new StringValue(auth)); 243 credentials.Append(new StringValue(auth));
221 244
222 EXPECT_FALSE(wizard_->IsVisible()); 245 EXPECT_FALSE(wizard_->IsVisible());
223 EXPECT_FALSE(test_window_->flow()); 246 EXPECT_EQ(static_cast<SyncSetupFlow*>(NULL), flow_);
224 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 247 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
248 AttachSyncSetupHandler();
225 249
226 EXPECT_TRUE(wizard_->IsVisible()); 250 EXPECT_TRUE(wizard_->IsVisible());
227 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 251 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
228 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); 252 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
229 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->end_state_); 253 EXPECT_EQ(json_start_args, flow_->dialog_start_args_);
230 EXPECT_EQ(json_start_args, test_window_->flow()->dialog_start_args_);
231 254
232 #if 0
233 // Simulate the user submitting credentials. 255 // Simulate the user submitting credentials.
234 test_window_->flow()->flow_handler_->HandleSubmitAuth(&credentials); 256 handler_.HandleSubmitAuth(&credentials);
235 EXPECT_TRUE(wizard_->IsVisible()); 257 EXPECT_TRUE(wizard_->IsVisible());
236 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); 258 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
237 EXPECT_EQ(kTestUser, service_->username_); 259 EXPECT_EQ(kTestUser, service_->username_);
238 EXPECT_EQ(kTestPassword, service_->password_); 260 EXPECT_EQ(kTestPassword, service_->password_);
239 EXPECT_EQ(kTestCaptcha, service_->captcha_); 261 EXPECT_EQ(kTestCaptcha, service_->captcha_);
240 EXPECT_FALSE(service_->user_cancelled_dialog_); 262 EXPECT_FALSE(service_->user_cancelled_dialog_);
241 service_->ResetTestStats(); 263 service_->ResetTestStats();
242 #endif
243 264
244 // Simulate failed credentials. 265 // Simulate failed credentials.
245 AuthError invalid_gaia(AuthError::INVALID_GAIA_CREDENTIALS); 266 AuthError invalid_gaia(AuthError::INVALID_GAIA_CREDENTIALS);
246 service_->set_auth_state(kTestUser, invalid_gaia); 267 service_->set_auth_state(kTestUser, invalid_gaia);
247 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 268 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
269 AttachSyncSetupHandler();
248 EXPECT_TRUE(wizard_->IsVisible()); 270 EXPECT_TRUE(wizard_->IsVisible());
249 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 271 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
250 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_);
251 dialog_args.Clear(); 272 dialog_args.Clear();
252 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); 273 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
253 EXPECT_EQ(5U, dialog_args.size()); 274 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; 275 std::string actual_user;
258 dialog_args.GetString("user", &actual_user); 276 dialog_args.GetString("user", &actual_user);
259 EXPECT_EQ(kTestUser, actual_user); 277 EXPECT_EQ(kTestUser, actual_user);
260 int error = -1; 278 int error = -1;
261 dialog_args.GetInteger("error", &error); 279 dialog_args.GetInteger("error", &error);
262 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error); 280 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error);
263 service_->set_auth_state(kTestUser, AuthError::None()); 281 service_->set_auth_state(kTestUser, AuthError::None());
264 282
265 // Simulate captcha. 283 // Simulate captcha.
266 AuthError captcha_error(AuthError::FromCaptchaChallenge( 284 AuthError captcha_error(AuthError::FromCaptchaChallenge(
267 std::string(), GURL(kTestCaptchaUrl), GURL())); 285 std::string(), GURL(kTestCaptchaUrl), GURL()));
268 service_->set_auth_state(kTestUser, captcha_error); 286 service_->set_auth_state(kTestUser, captcha_error);
269 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 287 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
288 AttachSyncSetupHandler();
270 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); 289 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
271 EXPECT_EQ(5U, dialog_args.size()); 290 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; 291 std::string captcha_url;
275 dialog_args.GetString("captchaUrl", &captcha_url); 292 dialog_args.GetString("captchaUrl", &captcha_url);
276 EXPECT_EQ(kTestCaptchaUrl, GURL(captcha_url).spec()); 293 EXPECT_EQ(kTestCaptchaUrl, GURL(captcha_url).spec());
277 error = -1; 294 error = -1;
278 dialog_args.GetInteger("error", &error); 295 dialog_args.GetInteger("error", &error);
279 EXPECT_EQ(static_cast<int>(AuthError::CAPTCHA_REQUIRED), error); 296 EXPECT_EQ(static_cast<int>(AuthError::CAPTCHA_REQUIRED), error);
280 service_->set_auth_state(kTestUser, AuthError::None()); 297 service_->set_auth_state(kTestUser, AuthError::None());
281 298
282 // Simulate success. 299 // Simulate success.
283 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 300 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
284 EXPECT_TRUE(wizard_->IsVisible()); 301 EXPECT_TRUE(wizard_->IsVisible());
285 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
286 // In a non-discrete run, GAIA_SUCCESS immediately transitions you to 302 // In a non-discrete run, GAIA_SUCCESS immediately transitions you to
287 // SYNC_EVERYTHING. 303 // SYNC_EVERYTHING.
288 EXPECT_EQ(SyncSetupWizard::SYNC_EVERYTHING, 304 EXPECT_EQ(SyncSetupWizard::SYNC_EVERYTHING, flow_->current_state_);
289 test_window_->flow()->current_state_);
290 305
291 // That's all we're testing here, just move on to DONE. We'll test the 306 // That's all we're testing here, just move on to DONE. We'll test the
292 // "choose data types" scenarios elsewhere. 307 // "choose data types" scenarios elsewhere.
293 wizard_->Step(SyncSetupWizard::SETTING_UP); // No merge and sync. 308 wizard_->Step(SyncSetupWizard::SETTING_UP); // No merge and sync.
294 wizard_->Step(SyncSetupWizard::DONE); // No merge and sync. 309 wizard_->Step(SyncSetupWizard::DONE); // No merge and sync.
295 EXPECT_TRUE(wizard_->IsVisible()); 310 EXPECT_FALSE(wizard_->IsVisible());
296 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
297 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->current_state_);
298 } 311 }
299 312
300 TEST_F(SyncSetupWizardTest, DISABLED_ChooseDataTypesSetsPrefs) { 313 TEST_F(SyncSetupWizardTest, ChooseDataTypesSetsPrefs) {
301 SKIP_TEST_ON_MACOSX(); 314 SKIP_TEST_ON_MACOSX();
302 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 315 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
316 AttachSyncSetupHandler();
303 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 317 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
304 wizard_->Step(SyncSetupWizard::CONFIGURE); 318 wizard_->Step(SyncSetupWizard::CONFIGURE);
305 319
306 ListValue data_type_choices_value; 320 ListValue data_type_choices_value;
307 std::string data_type_choices = "{\"keepEverythingSynced\":false,"; 321 std::string data_type_choices =
308 data_type_choices += "\"syncBookmarks\":true,\"syncPreferences\":true,"; 322 "{\"keepEverythingSynced\":false,\"syncBookmarks\":true,"
309 data_type_choices += "\"syncThemes\":false,\"syncPasswords\":false,"; 323 "\"syncPreferences\":true,\"syncThemes\":false,\"syncPasswords\":false,"
310 data_type_choices += "\"syncAutofill\":false,\"syncExtensions\":false,"; 324 "\"syncAutofill\":false,\"syncExtensions\":false,\"syncTypedUrls\":true,"
311 data_type_choices += "\"syncTypedUrls\":true,\"syncApps\":true,"; 325 "\"syncApps\":true,\"syncSessions\":false,\"usePassphrase\":false,"
312 data_type_choices += "\"syncSessions\":false,\"usePassphrase\":false}"; 326 "\"encryptAllData\":false}";
313 data_type_choices_value.Append(new StringValue(data_type_choices)); 327 data_type_choices_value.Append(new StringValue(data_type_choices));
314 328
315 #if 0 329 // Simulate the user choosing data types; bookmarks, prefs, typed URLS, and
316 // Simulate the user choosing data types; bookmarks, prefs, typed 330 // apps are on, the rest are off.
317 // URLS, and apps are on, the rest are off. 331 handler_.HandleConfigure(&data_type_choices_value);
318 test_window_->flow()->flow_handler_->HandleConfigure(
319 &data_type_choices_value);
320 EXPECT_TRUE(wizard_->IsVisible()); 332 EXPECT_TRUE(wizard_->IsVisible());
321 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
322 EXPECT_FALSE(service_->keep_everything_synced_); 333 EXPECT_FALSE(service_->keep_everything_synced_);
323 EXPECT_EQ(service_->chosen_data_types_.count(syncable::BOOKMARKS), 1U); 334 EXPECT_EQ(1U, service_->chosen_data_types_.count(syncable::BOOKMARKS));
324 EXPECT_EQ(service_->chosen_data_types_.count(syncable::PREFERENCES), 1U); 335 EXPECT_EQ(1U, service_->chosen_data_types_.count(syncable::PREFERENCES));
325 EXPECT_EQ(service_->chosen_data_types_.count(syncable::THEMES), 0U); 336 EXPECT_EQ(0U, service_->chosen_data_types_.count(syncable::THEMES));
326 EXPECT_EQ(service_->chosen_data_types_.count(syncable::PASSWORDS), 0U); 337 EXPECT_EQ(0U, service_->chosen_data_types_.count(syncable::PASSWORDS));
327 EXPECT_EQ(service_->chosen_data_types_.count(syncable::AUTOFILL), 0U); 338 EXPECT_EQ(0U, service_->chosen_data_types_.count(syncable::AUTOFILL));
328 EXPECT_EQ(service_->chosen_data_types_.count(syncable::EXTENSIONS), 0U); 339 EXPECT_EQ(0U, service_->chosen_data_types_.count(syncable::EXTENSIONS));
329 EXPECT_EQ(service_->chosen_data_types_.count(syncable::TYPED_URLS), 1U); 340 EXPECT_EQ(1U, service_->chosen_data_types_.count(syncable::TYPED_URLS));
330 EXPECT_EQ(service_->chosen_data_types_.count(syncable::APPS), 1U); 341 EXPECT_EQ(1U, service_->chosen_data_types_.count(syncable::APPS));
331 #endif 342
332 test_window_->CloseDialog(); 343 CloseSetupUI();
333 } 344 }
334 345
335 TEST_F(SyncSetupWizardTest, DISABLED_EnterPassphraseRequired) { 346 TEST_F(SyncSetupWizardTest, EnterPassphraseRequired) {
336 SKIP_TEST_ON_MACOSX(); 347 SKIP_TEST_ON_MACOSX();
337 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 348 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
349 AttachSyncSetupHandler();
338 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 350 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
339 wizard_->Step(SyncSetupWizard::CONFIGURE); 351 wizard_->Step(SyncSetupWizard::CONFIGURE);
340 wizard_->Step(SyncSetupWizard::SETTING_UP); 352 wizard_->Step(SyncSetupWizard::SETTING_UP);
341 service_->SetPassphraseRequiredReason(sync_api::REASON_ENCRYPTION); 353 service_->set_passphrase_required_reason(sync_api::REASON_ENCRYPTION);
342 wizard_->Step(SyncSetupWizard::ENTER_PASSPHRASE); 354 wizard_->Step(SyncSetupWizard::ENTER_PASSPHRASE);
343 EXPECT_EQ(SyncSetupWizard::ENTER_PASSPHRASE, 355 EXPECT_EQ(SyncSetupWizard::ENTER_PASSPHRASE, flow_->current_state_);
344 test_window_->flow()->current_state_); 356
345 #if 0
346 ListValue value; 357 ListValue value;
347 value.Append(new StringValue("{\"passphrase\":\"myPassphrase\"," 358 value.Append(new StringValue("{\"passphrase\":\"myPassphrase\","
348 "\"mode\":\"gaia\"}")); 359 "\"mode\":\"gaia\"}"));
349 test_window_->flow()->flow_handler_->HandlePassphraseEntry(&value); 360 handler_.HandlePassphraseEntry(&value);
350 EXPECT_EQ("myPassphrase", service_->passphrase_); 361 EXPECT_EQ("myPassphrase", service_->passphrase_);
351 #endif
352 } 362 }
353 363
354 TEST_F(SyncSetupWizardTest, DISABLED_DialogCancelled) { 364 TEST_F(SyncSetupWizardTest, DialogCancelled) {
355 SKIP_TEST_ON_MACOSX(); 365 SKIP_TEST_ON_MACOSX();
356 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 366 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
367 AttachSyncSetupHandler();
357 // Simulate the user closing the dialog. 368 // Simulate the user closing the dialog.
358 test_window_->CloseDialog(); 369 CloseSetupUI();
359 EXPECT_FALSE(wizard_->IsVisible()); 370 EXPECT_FALSE(wizard_->IsVisible());
360 EXPECT_TRUE(service_->user_cancelled_dialog_); 371 EXPECT_TRUE(service_->user_cancelled_dialog_);
361 EXPECT_EQ(std::string(), service_->username_); 372 EXPECT_EQ(std::string(), service_->username_);
362 EXPECT_EQ(std::string(), service_->password_); 373 EXPECT_EQ(std::string(), service_->password_);
363 374
364 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 375 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
376 AttachSyncSetupHandler();
365 EXPECT_TRUE(wizard_->IsVisible()); 377 EXPECT_TRUE(wizard_->IsVisible());
366 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
367 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 378 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
368 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
369 379
370 test_window_->CloseDialog(); 380 CloseSetupUI();
371 EXPECT_FALSE(wizard_->IsVisible()); 381 EXPECT_FALSE(wizard_->IsVisible());
372 EXPECT_TRUE(service_->user_cancelled_dialog_); 382 EXPECT_TRUE(service_->user_cancelled_dialog_);
373 EXPECT_EQ(std::string(), service_->username_); 383 EXPECT_EQ(std::string(), service_->username_);
374 EXPECT_EQ(std::string(), service_->password_); 384 EXPECT_EQ(std::string(), service_->password_);
375 } 385 }
376 386
377 TEST_F(SyncSetupWizardTest, DISABLED_InvalidTransitions) { 387 TEST_F(SyncSetupWizardTest, InvalidTransitions) {
378 SKIP_TEST_ON_MACOSX(); 388 SKIP_TEST_ON_MACOSX();
379 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 389 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
380 EXPECT_FALSE(wizard_->IsVisible()); 390 EXPECT_FALSE(wizard_->IsVisible());
381 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
382 391
383 wizard_->Step(SyncSetupWizard::DONE); 392 wizard_->Step(SyncSetupWizard::DONE);
384 EXPECT_FALSE(wizard_->IsVisible()); 393 EXPECT_FALSE(wizard_->IsVisible());
385 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
386 394
387 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 395 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
396 AttachSyncSetupHandler();
388 397
389 wizard_->Step(SyncSetupWizard::DONE); 398 wizard_->Step(SyncSetupWizard::DONE);
390 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); 399 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
391 400
392 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR); 401 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR);
393 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, 402 AttachSyncSetupHandler();
394 test_window_->flow()->current_state_); 403 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
395 404
396 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 405 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
397 EXPECT_EQ(SyncSetupWizard::SYNC_EVERYTHING, 406 EXPECT_EQ(SyncSetupWizard::SYNC_EVERYTHING, flow_->current_state_);
398 test_window_->flow()->current_state_);
399 407
400 wizard_->Step(SyncSetupWizard::FATAL_ERROR); 408 wizard_->Step(SyncSetupWizard::FATAL_ERROR);
401 EXPECT_EQ(SyncSetupWizard::FATAL_ERROR, test_window_->flow()->current_state_); 409 EXPECT_EQ(SyncSetupWizard::FATAL_ERROR, flow_->current_state_);
402 } 410 }
403 411
404 TEST_F(SyncSetupWizardTest, DISABLED_FullSuccessfulRunSetsPref) { 412 TEST_F(SyncSetupWizardTest, FullSuccessfulRunSetsPref) {
405 SKIP_TEST_ON_MACOSX(); 413 SKIP_TEST_ON_MACOSX();
406 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 414 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()); 415 EXPECT_FALSE(wizard_->IsVisible());
412 EXPECT_TRUE(service_->profile()->GetPrefs()->GetBoolean( 416 EXPECT_TRUE(service_->profile()->GetPrefs()->GetBoolean(
413 prefs::kSyncHasSetupCompleted)); 417 prefs::kSyncHasSetupCompleted));
414 } 418 }
415 419
416 TEST_F(SyncSetupWizardTest, DISABLED_AbortedByPendingClear) { 420 TEST_F(SyncSetupWizardTest, AbortedByPendingClear) {
417 SKIP_TEST_ON_MACOSX(); 421 SKIP_TEST_ON_MACOSX();
418 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 422 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
423 AttachSyncSetupHandler();
419 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 424 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
420 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR); 425 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR);
421 EXPECT_EQ(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR, 426 EXPECT_EQ(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR,
422 test_window_->flow()->current_state_); 427 flow_->current_state_);
423 test_window_->CloseDialog(); 428 CloseSetupUI();
424 EXPECT_FALSE(wizard_->IsVisible()); 429 EXPECT_FALSE(wizard_->IsVisible());
425 } 430 }
426 431
427 TEST_F(SyncSetupWizardTest, DISABLED_DiscreteRunChooseDataTypes) { 432 TEST_F(SyncSetupWizardTest, DiscreteRunChooseDataTypes) {
428 SKIP_TEST_ON_MACOSX(); 433 SKIP_TEST_ON_MACOSX();
429 // For a discrete run, we need to have ran through setup once. 434
430 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 435 CompleteSetup();
431 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
432 wizard_->Step(SyncSetupWizard::DONE);
433 test_window_->CloseDialog();
434 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
435 436
436 wizard_->Step(SyncSetupWizard::CONFIGURE); 437 wizard_->Step(SyncSetupWizard::CONFIGURE);
437 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 438 AttachSyncSetupHandler();
438 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->end_state_); 439 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
439 440
441 wizard_->Step(SyncSetupWizard::SETTING_UP);
440 wizard_->Step(SyncSetupWizard::DONE); 442 wizard_->Step(SyncSetupWizard::DONE);
441 test_window_->CloseDialog();
442 EXPECT_FALSE(wizard_->IsVisible()); 443 EXPECT_FALSE(wizard_->IsVisible());
443 } 444 }
444 445
445 TEST_F(SyncSetupWizardTest, 446 TEST_F(SyncSetupWizardTest, DiscreteRunChooseDataTypesAbortedByPendingClear) {
446 DISABLED_DiscreteRunChooseDataTypesAbortedByPendingClear) {
447 SKIP_TEST_ON_MACOSX(); 447 SKIP_TEST_ON_MACOSX();
448 // For a discrete run, we need to have ran through setup once. 448
449 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 449 CompleteSetup();
450 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
451 wizard_->Step(SyncSetupWizard::DONE);
452 test_window_->CloseDialog();
453 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
454 450
455 wizard_->Step(SyncSetupWizard::CONFIGURE); 451 wizard_->Step(SyncSetupWizard::CONFIGURE);
456 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 452 AttachSyncSetupHandler();
457 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->end_state_); 453 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
458 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR); 454 wizard_->Step(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR);
459 EXPECT_EQ(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR, 455 EXPECT_EQ(SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR,
460 test_window_->flow()->current_state_); 456 flow_->current_state_);
461 457
462 test_window_->CloseDialog(); 458 CloseSetupUI();
463 EXPECT_FALSE(wizard_->IsVisible()); 459 EXPECT_FALSE(wizard_->IsVisible());
464 } 460 }
465 461
466 TEST_F(SyncSetupWizardTest, DISABLED_DiscreteRunGaiaLogin) { 462 TEST_F(SyncSetupWizardTest, DiscreteRunGaiaLogin) {
467 SKIP_TEST_ON_MACOSX(); 463 SKIP_TEST_ON_MACOSX();
468 DictionaryValue dialog_args; 464
469 // For a discrete run, we need to have ran through setup once. 465 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 466
477 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 467 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
478 EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, test_window_->flow()->end_state_); 468 AttachSyncSetupHandler();
469 EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, flow_->end_state_);
479 470
480 AuthError invalid_gaia(AuthError::INVALID_GAIA_CREDENTIALS); 471 AuthError invalid_gaia(AuthError::INVALID_GAIA_CREDENTIALS);
481 service_->set_auth_state(kTestUser, invalid_gaia); 472 service_->set_auth_state(kTestUser, invalid_gaia);
482 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 473 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
483 EXPECT_TRUE(wizard_->IsVisible()); 474 EXPECT_TRUE(wizard_->IsVisible());
475
476 DictionaryValue dialog_args;
484 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args); 477 SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
485 EXPECT_EQ(5U, dialog_args.size()); 478 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; 479 std::string actual_user;
490 dialog_args.GetString("user", &actual_user); 480 dialog_args.GetString("user", &actual_user);
491 EXPECT_EQ(kTestUser, actual_user); 481 EXPECT_EQ(kTestUser, actual_user);
492 int error = -1; 482 int error = -1;
493 dialog_args.GetInteger("error", &error); 483 dialog_args.GetInteger("error", &error);
494 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error); 484 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error);
495 service_->set_auth_state(kTestUser, AuthError::None()); 485 service_->set_auth_state(kTestUser, AuthError::None());
496 486
497 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 487 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
498 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 488 }
489
490 TEST_F(SyncSetupWizardTest, NonFatalError) {
491 SKIP_TEST_ON_MACOSX();
492
493 CompleteSetup();
494
495 // Set up the ENTER_PASSPHRASE case.
496 service_->set_passphrase_required_reason(sync_api::REASON_ENCRYPTION);
497 service_->set_is_using_secondary_passphrase(true);
498 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
499 AttachSyncSetupHandler();
500 EXPECT_EQ(SyncSetupWizard::ENTER_PASSPHRASE, flow_->current_state_);
501 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
502 CloseSetupUI();
503 EXPECT_FALSE(wizard_->IsVisible());
504
505 // Reset.
506 service_->set_passphrase_required_reason(
507 sync_api::REASON_PASSPHRASE_NOT_REQUIRED);
508 service_->set_is_using_secondary_passphrase(false);
509
510 // Test the various auth error states that lead to GAIA_LOGIN.
511
512 service_->set_last_auth_error(
513 AuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
514 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
515 AttachSyncSetupHandler();
516 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
517 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
518 CloseSetupUI();
519 EXPECT_FALSE(wizard_->IsVisible());
520
521 service_->set_last_auth_error(
522 AuthError(GoogleServiceAuthError::CAPTCHA_REQUIRED));
523 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
524 AttachSyncSetupHandler();
525 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
526 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
527 CloseSetupUI();
528 EXPECT_FALSE(wizard_->IsVisible());
529
530 service_->set_last_auth_error(
531 AuthError(GoogleServiceAuthError::ACCOUNT_DELETED));
532 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
533 AttachSyncSetupHandler();
534 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
535 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
536 CloseSetupUI();
537 EXPECT_FALSE(wizard_->IsVisible());
538
539 service_->set_last_auth_error(
540 AuthError(GoogleServiceAuthError::ACCOUNT_DISABLED));
541 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
542 AttachSyncSetupHandler();
543 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
544 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
545 CloseSetupUI();
546 EXPECT_FALSE(wizard_->IsVisible());
547
548 service_->set_last_auth_error(
549 AuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
550 wizard_->Step(SyncSetupWizard::NONFATAL_ERROR);
551 AttachSyncSetupHandler();
552 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
553 EXPECT_EQ(SyncSetupWizard::DONE, flow_->end_state_);
554 CloseSetupUI();
555 EXPECT_FALSE(wizard_->IsVisible());
499 } 556 }
500 557
501 #undef SKIP_TEST_ON_MACOSX 558 #undef SKIP_TEST_ON_MACOSX
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_setup_wizard.cc ('k') | chrome/browser/sync/sync_ui_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698