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

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

Issue 6902101: Refactor sync passphrase setup flow and fix passphrase tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: de Morgan's law simplification. Created 9 years, 7 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/profile_sync_factory_mock.h" 15 #include "chrome/browser/sync/profile_sync_factory_mock.h"
15 #include "chrome/browser/sync/profile_sync_service.h" 16 #include "chrome/browser/sync/profile_sync_service.h"
16 #include "chrome/browser/sync/sync_setup_flow.h" 17 #include "chrome/browser/sync/sync_setup_flow.h"
17 #include "chrome/browser/sync/sync_setup_flow_handler.h" 18 #include "chrome/browser/sync/sync_setup_flow_handler.h"
18 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_list.h" 20 #include "chrome/browser/ui/browser_list.h"
20 #include "chrome/common/net/gaia/google_service_auth_error.h" 21 #include "chrome/common/net/gaia/google_service_auth_error.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "chrome/test/browser_with_test_window_test.h" 23 #include "chrome/test/browser_with_test_window_test.h"
23 #include "chrome/test/test_browser_window.h" 24 #include "chrome/test/test_browser_window.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 virtual string16 GetAuthenticatedUsername() const { 72 virtual string16 GetAuthenticatedUsername() const {
72 return UTF8ToUTF16(username_); 73 return UTF8ToUTF16(username_);
73 } 74 }
74 75
75 void set_auth_state(const std::string& last_email, 76 void set_auth_state(const std::string& last_email,
76 const AuthError& error) { 77 const AuthError& error) {
77 last_attempted_user_email_ = last_email; 78 last_attempted_user_email_ = last_email;
78 last_auth_error_ = error; 79 last_auth_error_ = error;
79 } 80 }
80 81
81 void set_passphrase_required(bool required) { 82 void SetPassphraseRequiredReason(sync_api::PassphraseRequiredReason reason) {
82 observed_passphrase_required_ = required; 83 passphrase_required_reason_ = reason;
83 } 84 }
84 85
85 void ResetTestStats() { 86 void ResetTestStats() {
86 username_.clear(); 87 username_.clear();
87 password_.clear(); 88 password_.clear();
88 captcha_.clear(); 89 captcha_.clear();
89 user_cancelled_dialog_ = false; 90 user_cancelled_dialog_ = false;
90 user_chose_data_types_ = false; 91 user_chose_data_types_ = false;
91 keep_everything_synced_ = false; 92 keep_everything_synced_ = false;
92 chosen_data_types_.clear(); 93 chosen_data_types_.clear();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 #endif 331 #endif
331 test_window_->CloseDialog(); 332 test_window_->CloseDialog();
332 } 333 }
333 334
334 TEST_F(SyncSetupWizardTest, DISABLED_EnterPassphraseRequired) { 335 TEST_F(SyncSetupWizardTest, DISABLED_EnterPassphraseRequired) {
335 SKIP_TEST_ON_MACOSX(); 336 SKIP_TEST_ON_MACOSX();
336 wizard_->Step(SyncSetupWizard::GAIA_LOGIN); 337 wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
337 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 338 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
338 wizard_->Step(SyncSetupWizard::CONFIGURE); 339 wizard_->Step(SyncSetupWizard::CONFIGURE);
339 wizard_->Step(SyncSetupWizard::SETTING_UP); 340 wizard_->Step(SyncSetupWizard::SETTING_UP);
340 service_->set_passphrase_required(true); 341 service_->SetPassphraseRequiredReason(sync_api::REASON_ENCRYPTION);
341 wizard_->Step(SyncSetupWizard::ENTER_PASSPHRASE); 342 wizard_->Step(SyncSetupWizard::ENTER_PASSPHRASE);
342 EXPECT_EQ(SyncSetupWizard::ENTER_PASSPHRASE, 343 EXPECT_EQ(SyncSetupWizard::ENTER_PASSPHRASE,
343 test_window_->flow()->current_state_); 344 test_window_->flow()->current_state_);
344 #if 0 345 #if 0
345 ListValue value; 346 ListValue value;
346 value.Append(new StringValue("{\"passphrase\":\"myPassphrase\"," 347 value.Append(new StringValue("{\"passphrase\":\"myPassphrase\","
347 "\"mode\":\"gaia\"}")); 348 "\"mode\":\"gaia\"}"));
348 test_window_->flow()->flow_handler_->HandlePassphraseEntry(&value); 349 test_window_->flow()->flow_handler_->HandlePassphraseEntry(&value);
349 EXPECT_EQ("myPassphrase", service_->passphrase_); 350 EXPECT_EQ("myPassphrase", service_->passphrase_);
350 #endif 351 #endif
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 int error = -1; 528 int error = -1;
528 dialog_args.GetInteger("error", &error); 529 dialog_args.GetInteger("error", &error);
529 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error); 530 EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error);
530 service_->set_auth_state(kTestUser, AuthError::None()); 531 service_->set_auth_state(kTestUser, AuthError::None());
531 532
532 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS); 533 wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
533 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled()); 534 EXPECT_TRUE(test_window_->TestAndResetWasShowHTMLDialogCalled());
534 } 535 }
535 536
536 #undef SKIP_TEST_ON_MACOSX 537 #undef SKIP_TEST_ON_MACOSX
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698