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

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

Issue 270081: Facelifts to sync UI (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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/views/sync/sync_setup_wizard.cc ('k') | chrome/browser/views/toolbar_view.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 // Use of this source code is governed by a BSD-style license that can be 1 // Use of this source code is governed by a BSD-style license that can be
2 // found in the LICENSE file. 2 // found in the LICENSE file.
3 3
4 #ifdef CHROME_PERSONALIZATION 4 #ifdef CHROME_PERSONALIZATION
5 5
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 #include "base/json_writer.h" 8 #include "base/json_writer.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 test_window_->flow()->flow_handler_->HandleSubmitMergeAndSync(NULL); 248 test_window_->flow()->flow_handler_->HandleSubmitMergeAndSync(NULL);
249 EXPECT_TRUE(wizard_->IsVisible()); 249 EXPECT_TRUE(wizard_->IsVisible());
250 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, 250 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC,
251 test_window_->flow()->current_state_); 251 test_window_->flow()->current_state_);
252 EXPECT_EQ(std::string(), service_->username_); 252 EXPECT_EQ(std::string(), service_->username_);
253 EXPECT_EQ(std::string(), service_->password_); 253 EXPECT_EQ(std::string(), service_->password_);
254 EXPECT_TRUE(service_->user_accepted_merge_and_sync_); 254 EXPECT_TRUE(service_->user_accepted_merge_and_sync_);
255 EXPECT_FALSE(service_->user_cancelled_dialog_); 255 EXPECT_FALSE(service_->user_cancelled_dialog_);
256 service_->ResetTestStats(); 256 service_->ResetTestStats();
257 wizard_->Step(SyncSetupWizard::DONE); // No merge and sync. 257 wizard_->Step(SyncSetupWizard::DONE_FIRST_TIME); // No merge and sync.
258 EXPECT_TRUE(wizard_->IsVisible()); 258 EXPECT_TRUE(wizard_->IsVisible());
259 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 259 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
260 EXPECT_EQ(SyncSetupWizard::DONE, test_window_->flow()->current_state_); 260 EXPECT_EQ(SyncSetupWizard::DONE_FIRST_TIME,
261 test_window_->flow()->current_state_);
261 } 262 }
262 263
263 TEST_F(SyncSetupWizardTest, DialogCancelled) { 264 TEST_F(SyncSetupWizardTest, DialogCancelled) {
264 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 265 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
265 // Simulate the user closing the dialog. 266 // Simulate the user closing the dialog.
266 test_window_->CloseDialog(); 267 test_window_->CloseDialog();
267 EXPECT_FALSE(wizard_->IsVisible()); 268 EXPECT_FALSE(wizard_->IsVisible());
268 EXPECT_TRUE(service_->user_cancelled_dialog_); 269 EXPECT_TRUE(service_->user_cancelled_dialog_);
269 EXPECT_EQ(std::string(), service_->username_); 270 EXPECT_EQ(std::string(), service_->username_);
270 EXPECT_EQ(std::string(), service_->password_); 271 EXPECT_EQ(std::string(), service_->password_);
(...skipping 16 matching lines...) Expand all
287 288
288 TEST_F(SyncSetupWizardTest, InvalidTransitions) { 289 TEST_F(SyncSetupWizardTest, InvalidTransitions) {
289 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 290 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
290 EXPECT_FALSE(wizard_->IsVisible()); 291 EXPECT_FALSE(wizard_->IsVisible());
291 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 292 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
292 293
293 wizard_->Step(SyncSetupWizard::DONE); 294 wizard_->Step(SyncSetupWizard::DONE);
294 EXPECT_FALSE(wizard_->IsVisible()); 295 EXPECT_FALSE(wizard_->IsVisible());
295 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 296 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
296 297
298 wizard_->Step(SyncSetupWizard::DONE_FIRST_TIME);
299 EXPECT_FALSE(wizard_->IsVisible());
300 EXPECT_FALSE(test_window_->TestAndResetWasShowHTMLDialogCalled());
301
297 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 302 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
298 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); 303 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
299 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); 304 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_);
300 305
301 wizard_->Step(SyncSetupWizard::DONE); 306 wizard_->Step(SyncSetupWizard::DONE);
302 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_); 307 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_);
308 wizard_->Step(SyncSetupWizard::DONE_FIRST_TIME);
309 EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, test_window_->flow()->current_state_);
303 310
304 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 311 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
305 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); 312 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
306 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, 313 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC,
307 test_window_->flow()->current_state_); 314 test_window_->flow()->current_state_);
308 315
309 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 316 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
310 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC, 317 EXPECT_EQ(SyncSetupWizard::MERGE_AND_SYNC,
311 test_window_->flow()->current_state_); 318 test_window_->flow()->current_state_);
312 319
313 wizard_->Step(SyncSetupWizard::FATAL_ERROR); 320 wizard_->Step(SyncSetupWizard::FATAL_ERROR);
314 EXPECT_EQ(SyncSetupWizard::FATAL_ERROR, test_window_->flow()->current_state_); 321 EXPECT_EQ(SyncSetupWizard::FATAL_ERROR, test_window_->flow()->current_state_);
315 } 322 }
316 323
317 TEST_F(SyncSetupWizardTest, FullSuccessfulRunSetsPref) { 324 TEST_F(SyncSetupWizardTest, FullSuccessfulRunSetsPref) {
318 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 325 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
319 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 326 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
320 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); 327 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
321 wizard_->Step(SyncSetupWizard::DONE); 328 wizard_->Step(SyncSetupWizard::DONE);
322 test_window_->CloseDialog(); 329 test_window_->CloseDialog();
323 EXPECT_FALSE(wizard_->IsVisible()); 330 EXPECT_FALSE(wizard_->IsVisible());
324 EXPECT_TRUE(service_->profile()->GetPrefs()->GetBoolean( 331 EXPECT_TRUE(service_->profile()->GetPrefs()->GetBoolean(
325 prefs::kSyncHasSetupCompleted)); 332 prefs::kSyncHasSetupCompleted));
326 } 333 }
327 334
335 TEST_F(SyncSetupWizardTest, FirstFullSuccessfulRunSetsPref) {
336 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
337 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
338 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
339 wizard_->Step(SyncSetupWizard::DONE_FIRST_TIME);
340 test_window_->CloseDialog();
341 EXPECT_FALSE(wizard_->IsVisible());
342 EXPECT_TRUE(service_->profile()->GetPrefs()->GetBoolean(
343 prefs::kSyncHasSetupCompleted));
344 }
345
328 TEST_F(SyncSetupWizardTest, DiscreteRun) { 346 TEST_F(SyncSetupWizardTest, DiscreteRun) {
329 DictionaryValue dialog_args; 347 DictionaryValue dialog_args;
330 // For a discrete run, we need to have ran through setup once. 348 // For a discrete run, we need to have ran through setup once.
331 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 349 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
332 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 350 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
333 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC); 351 wizard_->Step(SyncSetupWizard::MERGE_AND_SYNC);
334 wizard_->Step(SyncSetupWizard::DONE); 352 wizard_->Step(SyncSetupWizard::DONE);
335 test_window_->CloseDialog(); 353 test_window_->CloseDialog();
336 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 354 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
337 355
(...skipping 11 matching lines...) Expand all
349 int error = -1; 367 int error = -1;
350 dialog_args.GetInteger(L"error", &error); 368 dialog_args.GetInteger(L"error", &error);
351 EXPECT_EQ(static_cast<int>(AUTH_ERROR_INVALID_GAIA_CREDENTIALS), error); 369 EXPECT_EQ(static_cast<int>(AUTH_ERROR_INVALID_GAIA_CREDENTIALS), error);
352 service_->set_auth_state(kTestUser, AUTH_ERROR_NONE); 370 service_->set_auth_state(kTestUser, AUTH_ERROR_NONE);
353 371
354 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 372 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
355 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 373 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
356 } 374 }
357 375
358 #endif // CHROME_PERSONALIZATION 376 #endif // CHROME_PERSONALIZATION
OLDNEW
« no previous file with comments | « chrome/browser/views/sync/sync_setup_wizard.cc ('k') | chrome/browser/views/toolbar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698