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

Side by Side Diff: chrome/browser/ui/webui/settings/sync_handler_unittest.cc

Issue 1503333003: Settings People Rewrite: Make Sync/Sign-in naming consistent to People. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/settings/sync_handler.h"
6
7 #include <vector>
8
9 #include "base/command_line.h"
10 #include "base/json/json_writer.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/prefs/pref_service.h"
13 #include "base/stl_util.h"
14 #include "base/values.h"
15 #include "chrome/browser/signin/fake_signin_manager_builder.h"
16 #include "chrome/browser/signin/signin_error_controller_factory.h"
17 #include "chrome/browser/signin/signin_manager_factory.h"
18 #include "chrome/browser/sync/profile_sync_service_factory.h"
19 #include "chrome/browser/sync/profile_sync_service_mock.h"
20 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
21 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h"
24 #include "chrome/test/base/scoped_testing_local_state.h"
25 #include "chrome/test/base/testing_browser_process.h"
26 #include "chrome/test/base/testing_profile.h"
27 #include "components/signin/core/browser/fake_auth_status_provider.h"
28 #include "components/signin/core/browser/signin_manager.h"
29 #include "components/sync_driver/sync_prefs.h"
30 #include "content/public/browser/web_ui.h"
31 #include "content/public/test/test_browser_thread.h"
32 #include "content/public/test/test_browser_thread_bundle.h"
33 #include "content/public/test/test_web_ui.h"
34 #include "testing/gtest/include/gtest/gtest.h"
35 #include "ui/base/layout.h"
36
37 using ::testing::_;
38 using ::testing::Mock;
39 using ::testing::Return;
40 using ::testing::ReturnRef;
41 using ::testing::Values;
42
43 typedef GoogleServiceAuthError AuthError;
44
45 namespace {
46
47 MATCHER_P(ModelTypeSetMatches, value, "") { return arg.Equals(value); }
48
49 const char kTestUser[] = "chrome.p13n.test@gmail.com";
50
51 // Returns a ModelTypeSet with all user selectable types set.
52 syncer::ModelTypeSet GetAllTypes() {
53 return syncer::UserSelectableTypes();
54 }
55
56 enum SyncAllDataConfig {
57 SYNC_ALL_DATA,
58 CHOOSE_WHAT_TO_SYNC,
59 SYNC_NOTHING
60 };
61
62 enum EncryptAllConfig {
63 ENCRYPT_ALL_DATA,
64 ENCRYPT_PASSWORDS
65 };
66
67 // Create a json-format string with the key/value pairs appropriate for a call
68 // to HandleConfigure(). If |extra_values| is non-null, then the values from
69 // the passed dictionary are added to the json.
70 std::string GetConfiguration(const base::DictionaryValue* extra_values,
71 SyncAllDataConfig sync_all,
72 syncer::ModelTypeSet types,
73 const std::string& passphrase,
74 EncryptAllConfig encrypt_all) {
75 base::DictionaryValue result;
76 if (extra_values)
77 result.MergeDictionary(extra_values);
78 result.SetBoolean("syncAllDataTypes", sync_all == SYNC_ALL_DATA);
79 result.SetBoolean("syncNothing", sync_all == SYNC_NOTHING);
80 result.SetBoolean("encryptAllData", encrypt_all == ENCRYPT_ALL_DATA);
81 result.SetBoolean("usePassphrase", !passphrase.empty());
82 if (!passphrase.empty())
83 result.SetString("passphrase", passphrase);
84 // Add all of our data types.
85 result.SetBoolean("appsSynced", types.Has(syncer::APPS));
86 result.SetBoolean("autofillSynced", types.Has(syncer::AUTOFILL));
87 result.SetBoolean("bookmarksSynced", types.Has(syncer::BOOKMARKS));
88 result.SetBoolean("extensionsSynced", types.Has(syncer::EXTENSIONS));
89 result.SetBoolean("passwordsSynced", types.Has(syncer::PASSWORDS));
90 result.SetBoolean("preferencesSynced", types.Has(syncer::PREFERENCES));
91 result.SetBoolean("tabsSynced", types.Has(syncer::PROXY_TABS));
92 result.SetBoolean("themesSynced", types.Has(syncer::THEMES));
93 result.SetBoolean("typedUrlsSynced", types.Has(syncer::TYPED_URLS));
94 result.SetBoolean("wifiCredentialsSynced",
95 types.Has(syncer::WIFI_CREDENTIALS));
96 std::string args;
97 base::JSONWriter::Write(result, &args);
98 return args;
99 }
100
101 // Checks whether the passed |dictionary| contains a |key| with the given
102 // |expected_value|. If |omit_if_false| is true, then the value should only
103 // be present if |expected_value| is true.
104 void CheckBool(const base::DictionaryValue* dictionary,
105 const std::string& key,
106 bool expected_value,
107 bool omit_if_false) {
108 if (omit_if_false && !expected_value) {
109 EXPECT_FALSE(dictionary->HasKey(key)) <<
110 "Did not expect to find value for " << key;
111 } else {
112 bool actual_value;
113 EXPECT_TRUE(dictionary->GetBoolean(key, &actual_value)) <<
114 "No value found for " << key;
115 EXPECT_EQ(expected_value, actual_value) <<
116 "Mismatch found for " << key;
117 }
118 }
119
120 void CheckBool(const base::DictionaryValue* dictionary,
121 const std::string& key,
122 bool expected_value) {
123 return CheckBool(dictionary, key, expected_value, false);
124 }
125
126 // Checks to make sure that the values stored in |dictionary| match the values
127 // expected by the showSyncSetupPage() JS function for a given set of data
128 // types.
129 void CheckConfigDataTypeArguments(const base::DictionaryValue* dictionary,
130 SyncAllDataConfig config,
131 syncer::ModelTypeSet types) {
132 CheckBool(dictionary, "syncAllDataTypes", config == SYNC_ALL_DATA);
133 CheckBool(dictionary, "syncNothing", config == SYNC_NOTHING);
134 CheckBool(dictionary, "appsSynced", types.Has(syncer::APPS));
135 CheckBool(dictionary, "autofillSynced", types.Has(syncer::AUTOFILL));
136 CheckBool(dictionary, "bookmarksSynced", types.Has(syncer::BOOKMARKS));
137 CheckBool(dictionary, "extensionsSynced", types.Has(syncer::EXTENSIONS));
138 CheckBool(dictionary, "passwordsSynced", types.Has(syncer::PASSWORDS));
139 CheckBool(dictionary, "preferencesSynced", types.Has(syncer::PREFERENCES));
140 CheckBool(dictionary, "tabsSynced", types.Has(syncer::PROXY_TABS));
141 CheckBool(dictionary, "themesSynced", types.Has(syncer::THEMES));
142 CheckBool(dictionary, "typedUrlsSynced", types.Has(syncer::TYPED_URLS));
143 CheckBool(dictionary, "wifiCredentialsSynced",
144 types.Has(syncer::WIFI_CREDENTIALS));
145 }
146
147 } // namespace
148
149 namespace settings {
150
151 class TestingSyncHandler : public SyncHandler {
152 public:
153 TestingSyncHandler(content::WebUI* web_ui, Profile* profile)
154 : SyncHandler(profile) {
155 set_web_ui(web_ui);
156 }
157 ~TestingSyncHandler() override {
158 // TODO(tommycli): SyncHandler needs this call to destruct properly in the
159 // unit testing context. See the destructor to SyncHandler. This is hacky.
160 set_web_ui(nullptr);
161 }
162
163 void FocusUI() override {}
164
165 using SyncHandler::is_configuring_sync;
166
167 private:
168 #if !defined(OS_CHROMEOS)
169 void DisplayGaiaLoginInNewTabOrWindow(
170 signin_metrics::AccessPoint access_point) override {}
171 #endif
172
173 DISALLOW_COPY_AND_ASSIGN(TestingSyncHandler);
174 };
175
176 // The boolean parameter indicates whether the test is run with ClientOAuth
177 // or not. The test parameter is a bool: whether or not to test with/
178 // /ClientLogin enabled or not.
179 class SyncHandlerTest : public testing::Test {
180 public:
181 SyncHandlerTest() : error_(GoogleServiceAuthError::NONE) {}
182 void SetUp() override {
183 error_ = GoogleServiceAuthError::AuthErrorNone();
184
185 TestingProfile::Builder builder;
186 builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
187 BuildFakeSigninManagerBase);
188 profile_ = builder.Build();
189
190 // Sign in the user.
191 mock_signin_ = static_cast<SigninManagerBase*>(
192 SigninManagerFactory::GetForProfile(profile_.get()));
193 std::string username = GetTestUser();
194 if (!username.empty())
195 mock_signin_->SetAuthenticatedAccountInfo(username, username);
196
197 mock_pss_ = static_cast<ProfileSyncServiceMock*>(
198 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
199 profile_.get(),
200 ProfileSyncServiceMock::BuildMockProfileSyncService));
201 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
202 ON_CALL(*mock_pss_, GetPassphraseType()).WillByDefault(
203 Return(syncer::IMPLICIT_PASSPHRASE));
204 ON_CALL(*mock_pss_, GetPassphraseTime()).WillByDefault(
205 Return(base::Time()));
206 ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault(
207 Return(base::Time()));
208 ON_CALL(*mock_pss_, GetRegisteredDataTypes())
209 .WillByDefault(Return(syncer::ModelTypeSet()));
210
211 mock_pss_->Initialize();
212
213 handler_.reset(new TestingSyncHandler(&web_ui_, profile_.get()));
214 }
215
216 // Setup the expectations for calls made when displaying the config page.
217 void SetDefaultExpectationsForConfigPage() {
218 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
219 EXPECT_CALL(*mock_pss_, GetRegisteredDataTypes())
220 .WillRepeatedly(Return(GetAllTypes()));
221 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes())
222 .WillRepeatedly(Return(GetAllTypes()));
223 EXPECT_CALL(*mock_pss_, GetActiveDataTypes())
224 .WillRepeatedly(Return(GetAllTypes()));
225 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
226 .WillRepeatedly(Return(true));
227 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled())
228 .WillRepeatedly(Return(false));
229 }
230
231 void SetupInitializedProfileSyncService() {
232 // An initialized ProfileSyncService will have already completed sync setup
233 // and will have an initialized sync backend.
234 ASSERT_TRUE(mock_signin_->IsInitialized());
235 EXPECT_CALL(*mock_pss_, IsBackendInitialized())
236 .WillRepeatedly(Return(true));
237 }
238
239 void ExpectConfig() {
240 ASSERT_EQ(1U, web_ui_.call_data().size());
241 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
242 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage",
243 data.function_name());
244 std::string page;
245 ASSERT_TRUE(data.arg1()->GetAsString(&page));
246 EXPECT_EQ(page, "configure");
247 }
248
249 void ExpectDone() {
250 ASSERT_EQ(1U, web_ui_.call_data().size());
251 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
252 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage",
253 data.function_name());
254 std::string page;
255 ASSERT_TRUE(data.arg1()->GetAsString(&page));
256 EXPECT_EQ(page, "done");
257 }
258
259 void ExpectSpinnerAndClose() {
260 // We expect a call to settings.SyncPrivateApi.showSyncSetupPage.
261 EXPECT_EQ(1U, web_ui_.call_data().size());
262 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
263 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage",
264 data.function_name());
265
266 std::string page;
267 ASSERT_TRUE(data.arg1()->GetAsString(&page));
268 EXPECT_EQ(page, "spinner");
269 // Cancelling the spinner dialog will cause CloseSyncSetup().
270 handler_->CloseSyncSetup();
271 EXPECT_EQ(NULL,
272 LoginUIServiceFactory::GetForProfile(
273 profile_.get())->current_login_ui());
274 }
275
276 // It's difficult to notify sync listeners when using a ProfileSyncServiceMock
277 // so this helper routine dispatches an OnStateChanged() notification to the
278 // SyncStartupTracker.
279 void NotifySyncListeners() {
280 if (handler_->sync_startup_tracker_)
281 handler_->sync_startup_tracker_->OnStateChanged();
282 }
283
284 virtual std::string GetTestUser() {
285 return std::string(kTestUser);
286 }
287
288 content::TestBrowserThreadBundle thread_bundle_;
289 scoped_ptr<Profile> profile_;
290 ProfileSyncServiceMock* mock_pss_;
291 GoogleServiceAuthError error_;
292 SigninManagerBase* mock_signin_;
293 content::TestWebUI web_ui_;
294 scoped_ptr<TestingSyncHandler> handler_;
295 };
296
297 class SyncHandlerFirstSigninTest : public SyncHandlerTest {
298 std::string GetTestUser() override { return std::string(); }
299 };
300
301 TEST_F(SyncHandlerTest, Basic) {
302 }
303
304 #if !defined(OS_CHROMEOS)
305 TEST_F(SyncHandlerFirstSigninTest, DisplayBasicLogin) {
306 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
307 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
308 .WillRepeatedly(Return(false));
309 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
310 .WillRepeatedly(Return(false));
311 // Ensure that the user is not signed in before calling |HandleStartSignin()|.
312 SigninManager* manager = static_cast<SigninManager*>(mock_signin_);
313 manager->SignOut(signin_metrics::SIGNOUT_TEST);
314 handler_->HandleStartSignin(NULL);
315
316 // Sync setup hands off control to the gaia login tab.
317 EXPECT_EQ(NULL,
318 LoginUIServiceFactory::GetForProfile(
319 profile_.get())->current_login_ui());
320
321 ASSERT_FALSE(handler_->is_configuring_sync());
322
323 handler_->CloseSyncSetup();
324 EXPECT_EQ(NULL,
325 LoginUIServiceFactory::GetForProfile(
326 profile_.get())->current_login_ui());
327 }
328
329 TEST_F(SyncHandlerTest, ShowSyncSetupWhenNotSignedIn) {
330 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
331 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
332 .WillRepeatedly(Return(false));
333 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
334 .WillRepeatedly(Return(false));
335 handler_->HandleShowSetupUI(NULL);
336
337 // We expect a call to settings.SyncPrivateApi.showSyncSetupPage.
338 ASSERT_EQ(1U, web_ui_.call_data().size());
339 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
340 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name());
341
342 ASSERT_FALSE(handler_->is_configuring_sync());
343 EXPECT_EQ(NULL,
344 LoginUIServiceFactory::GetForProfile(
345 profile_.get())->current_login_ui());
346 }
347 #endif // !defined(OS_CHROMEOS)
348
349 // Verifies that the sync setup is terminated correctly when the
350 // sync is disabled.
351 TEST_F(SyncHandlerTest, HandleSetupUIWhenSyncDisabled) {
352 EXPECT_CALL(*mock_pss_, IsManaged()).WillRepeatedly(Return(true));
353 handler_->HandleShowSetupUI(NULL);
354
355 // Sync setup is closed when sync is disabled.
356 EXPECT_EQ(NULL,
357 LoginUIServiceFactory::GetForProfile(
358 profile_.get())->current_login_ui());
359 ASSERT_FALSE(handler_->is_configuring_sync());
360 }
361
362 // Verifies that the handler correctly handles a cancellation when
363 // it is displaying the spinner to the user.
364 TEST_F(SyncHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) {
365 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
366 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
367 .WillRepeatedly(Return(true));
368 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
369 .WillRepeatedly(Return(false));
370 error_ = GoogleServiceAuthError::AuthErrorNone();
371 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
372
373 // We're simulating a user setting up sync, which would cause the backend to
374 // kick off initialization, but not download user data types. The sync
375 // backend will try to download control data types (e.g encryption info), but
376 // that won't finish for this test as we're simulating cancelling while the
377 // spinner is showing.
378 handler_->HandleShowSetupUI(NULL);
379
380 EXPECT_EQ(handler_.get(),
381 LoginUIServiceFactory::GetForProfile(
382 profile_.get())->current_login_ui());
383
384 ExpectSpinnerAndClose();
385 }
386
387 // Verifies that the handler correctly transitions from showing the spinner
388 // to showing a configuration page when sync setup completes successfully.
389 TEST_F(SyncHandlerTest,
390 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) {
391 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
392 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
393 .WillRepeatedly(Return(true));
394 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
395 .WillRepeatedly(Return(false));
396 error_ = GoogleServiceAuthError::AuthErrorNone();
397 // Sync backend is stopped initially, and will start up.
398 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
399 SetDefaultExpectationsForConfigPage();
400
401 handler_->OpenSyncSetup(nullptr);
402
403 // We expect a call to settings.SyncPrivateApi.showSyncSetupPage.
404 EXPECT_EQ(1U, web_ui_.call_data().size());
405
406 const content::TestWebUI::CallData& data0 = *web_ui_.call_data()[0];
407 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data0.function_name());
408 std::string page;
409 ASSERT_TRUE(data0.arg1()->GetAsString(&page));
410 EXPECT_EQ(page, "spinner");
411
412 Mock::VerifyAndClearExpectations(mock_pss_);
413 // Now, act as if the ProfileSyncService has started up.
414 SetDefaultExpectationsForConfigPage();
415 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(true));
416 error_ = GoogleServiceAuthError::AuthErrorNone();
417 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
418 NotifySyncListeners();
419
420 // We expect a second call to settings.SyncPrivateApi.showSyncSetupPage.
421 EXPECT_EQ(2U, web_ui_.call_data().size());
422 const content::TestWebUI::CallData& data1 = *web_ui_.call_data().back();
423 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data1.function_name());
424 ASSERT_TRUE(data1.arg1()->GetAsString(&page));
425 EXPECT_EQ(page, "configure");
426 const base::DictionaryValue* dictionary = nullptr;
427 ASSERT_TRUE(data1.arg2()->GetAsDictionary(&dictionary));
428 CheckBool(dictionary, "passphraseFailed", false);
429 CheckBool(dictionary, "syncAllDataTypes", true);
430 CheckBool(dictionary, "encryptAllDataAllowed", true);
431 CheckBool(dictionary, "encryptAllData", false);
432 CheckBool(dictionary, "usePassphrase", false);
433 }
434
435 // Verifies the case where the user cancels after the sync backend has
436 // initialized (meaning it already transitioned from the spinner to a proper
437 // configuration page, tested by
438 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user
439 // before the user has continued on.
440 TEST_F(SyncHandlerTest,
441 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) {
442 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
443 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
444 .WillRepeatedly(Return(true));
445 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
446 .WillRepeatedly(Return(false));
447 error_ = GoogleServiceAuthError::AuthErrorNone();
448 EXPECT_CALL(*mock_pss_, IsBackendInitialized())
449 .WillOnce(Return(false))
450 .WillRepeatedly(Return(true));
451 SetDefaultExpectationsForConfigPage();
452 handler_->OpenSyncSetup(nullptr);
453
454 // It's important to tell sync the user cancelled the setup flow before we
455 // tell it we're through with the setup progress.
456 testing::InSequence seq;
457 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA));
458 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false));
459
460 handler_->CloseSyncSetup();
461 EXPECT_EQ(NULL,
462 LoginUIServiceFactory::GetForProfile(
463 profile_.get())->current_login_ui());
464 }
465
466 TEST_F(SyncHandlerTest,
467 DisplayConfigureWithBackendDisabledAndSigninFailed) {
468 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
469 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
470 .WillRepeatedly(Return(true));
471 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
472 .WillRepeatedly(Return(false));
473 error_ = GoogleServiceAuthError::AuthErrorNone();
474 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
475
476 handler_->OpenSyncSetup(nullptr);
477 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
478 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name());
479 std::string page;
480 ASSERT_TRUE(data.arg1()->GetAsString(&page));
481 EXPECT_EQ(page, "spinner");
482 Mock::VerifyAndClearExpectations(mock_pss_);
483 error_ = GoogleServiceAuthError(
484 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
485 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
486 NotifySyncListeners();
487
488 // On failure, the dialog will be closed.
489 EXPECT_EQ(NULL,
490 LoginUIServiceFactory::GetForProfile(
491 profile_.get())->current_login_ui());
492 }
493
494 #if !defined(OS_CHROMEOS)
495
496 class SyncHandlerNonCrosTest : public SyncHandlerTest {
497 public:
498 SyncHandlerNonCrosTest() {}
499 };
500
501 TEST_F(SyncHandlerNonCrosTest, HandleGaiaAuthFailure) {
502 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
503 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
504 .WillRepeatedly(Return(false));
505 EXPECT_CALL(*mock_pss_, HasUnrecoverableError())
506 .WillRepeatedly(Return(false));
507 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
508 .WillRepeatedly(Return(false));
509 // Open the web UI.
510 handler_->OpenSyncSetup(nullptr);
511
512 ASSERT_FALSE(handler_->is_configuring_sync());
513 }
514
515 // TODO(kochi): We need equivalent tests for ChromeOS.
516 TEST_F(SyncHandlerNonCrosTest, UnrecoverableErrorInitializingSync) {
517 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
518 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
519 .WillRepeatedly(Return(false));
520 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
521 .WillRepeatedly(Return(false));
522 // Open the web UI.
523 handler_->OpenSyncSetup(nullptr);
524
525 ASSERT_FALSE(handler_->is_configuring_sync());
526 }
527
528 TEST_F(SyncHandlerNonCrosTest, GaiaErrorInitializingSync) {
529 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false));
530 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
531 .WillRepeatedly(Return(false));
532 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
533 .WillRepeatedly(Return(false));
534 // Open the web UI.
535 handler_->OpenSyncSetup(nullptr);
536
537 ASSERT_FALSE(handler_->is_configuring_sync());
538 }
539
540 #endif // #if !defined(OS_CHROMEOS)
541
542 TEST_F(SyncHandlerTest, TestSyncEverything) {
543 std::string args = GetConfiguration(
544 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS);
545 base::ListValue list_args;
546 list_args.Append(new base::StringValue(args));
547 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
548 .WillRepeatedly(Return(false));
549 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
550 .WillRepeatedly(Return(false));
551 SetupInitializedProfileSyncService();
552 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
553 handler_->HandleConfigure(&list_args);
554
555 // Ensure that we navigated to the "done" state since we don't need a
556 // passphrase.
557 ExpectDone();
558 }
559
560 TEST_F(SyncHandlerTest, TestSyncNothing) {
561 std::string args = GetConfiguration(
562 NULL, SYNC_NOTHING, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS);
563 base::ListValue list_args;
564 list_args.Append(new base::StringValue(args));
565 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA));
566 SetupInitializedProfileSyncService();
567 handler_->HandleConfigure(&list_args);
568
569 // We expect a call to settings.SyncPrivateApi.showSyncSetupPage.
570 ASSERT_EQ(1U, web_ui_.call_data().size());
571 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
572 EXPECT_EQ("settings.SyncPrivateApi.showSyncSetupPage", data.function_name());
573 }
574
575 TEST_F(SyncHandlerTest, TurnOnEncryptAll) {
576 std::string args = GetConfiguration(
577 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA);
578 base::ListValue list_args;
579 list_args.Append(new base::StringValue(args));
580 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
581 .WillRepeatedly(Return(false));
582 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
583 .WillRepeatedly(Return(false));
584 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
585 .WillRepeatedly(Return(true));
586 SetupInitializedProfileSyncService();
587 EXPECT_CALL(*mock_pss_, EnableEncryptEverything());
588 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
589 handler_->HandleConfigure(&list_args);
590
591 // Ensure that we navigated to the "done" state since we don't need a
592 // passphrase.
593 ExpectDone();
594 }
595
596 TEST_F(SyncHandlerTest, TestPassphraseStillRequired) {
597 std::string args = GetConfiguration(
598 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS);
599 base::ListValue list_args;
600 list_args.Append(new base::StringValue(args));
601 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
602 .WillRepeatedly(Return(true));
603 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
604 .WillRepeatedly(Return(true));
605 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
606 .WillRepeatedly(Return(false));
607 SetupInitializedProfileSyncService();
608 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
609 SetDefaultExpectationsForConfigPage();
610
611 // We should navigate back to the configure page since we need a passphrase.
612 handler_->HandleConfigure(&list_args);
613
614 ExpectConfig();
615 }
616
617 TEST_F(SyncHandlerTest, SuccessfullySetPassphrase) {
618 base::DictionaryValue dict;
619 dict.SetBoolean("isGooglePassphrase", true);
620 std::string args = GetConfiguration(&dict,
621 SYNC_ALL_DATA,
622 GetAllTypes(),
623 "gaiaPassphrase",
624 ENCRYPT_PASSWORDS);
625 base::ListValue list_args;
626 list_args.Append(new base::StringValue(args));
627 // Act as if an encryption passphrase is required the first time, then never
628 // again after that.
629 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true));
630 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
631 .WillRepeatedly(Return(false));
632 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
633 .WillRepeatedly(Return(false));
634 SetupInitializedProfileSyncService();
635 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
636 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")).
637 WillOnce(Return(true));
638
639 handler_->HandleConfigure(&list_args);
640 // We should navigate to "done" page since we finished configuring.
641 ExpectDone();
642 }
643
644 TEST_F(SyncHandlerTest, SelectCustomEncryption) {
645 base::DictionaryValue dict;
646 dict.SetBoolean("isGooglePassphrase", false);
647 std::string args = GetConfiguration(&dict,
648 SYNC_ALL_DATA,
649 GetAllTypes(),
650 "custom_passphrase",
651 ENCRYPT_PASSWORDS);
652 base::ListValue list_args;
653 list_args.Append(new base::StringValue(args));
654 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
655 .WillRepeatedly(Return(false));
656 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
657 .WillRepeatedly(Return(false));
658 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
659 .WillRepeatedly(Return(false));
660 SetupInitializedProfileSyncService();
661 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
662 EXPECT_CALL(*mock_pss_,
663 SetEncryptionPassphrase("custom_passphrase",
664 ProfileSyncService::EXPLICIT));
665
666 handler_->HandleConfigure(&list_args);
667 // We should navigate to "done" page since we finished configuring.
668 ExpectDone();
669 }
670
671 TEST_F(SyncHandlerTest, UnsuccessfullySetPassphrase) {
672 base::DictionaryValue dict;
673 dict.SetBoolean("isGooglePassphrase", true);
674 std::string args = GetConfiguration(&dict,
675 SYNC_ALL_DATA,
676 GetAllTypes(),
677 "invalid_passphrase",
678 ENCRYPT_PASSWORDS);
679 base::ListValue list_args;
680 list_args.Append(new base::StringValue(args));
681 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
682 .WillRepeatedly(Return(true));
683 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
684 .WillRepeatedly(Return(true));
685 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
686 .WillRepeatedly(Return(false));
687 SetupInitializedProfileSyncService();
688 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _));
689 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("invalid_passphrase")).
690 WillOnce(Return(false));
691
692 SetDefaultExpectationsForConfigPage();
693 // We should navigate back to the configure page since we need a passphrase.
694 handler_->HandleConfigure(&list_args);
695
696 ExpectConfig();
697
698 // Make sure we display an error message to the user due to the failed
699 // passphrase.
700 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
701 const base::DictionaryValue* dictionary = nullptr;
702 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
703 CheckBool(dictionary, "passphraseFailed", true);
704 }
705
706 // Walks through each user selectable type, and tries to sync just that single
707 // data type.
708 TEST_F(SyncHandlerTest, TestSyncIndividualTypes) {
709 syncer::ModelTypeSet user_selectable_types = GetAllTypes();
710 syncer::ModelTypeSet::Iterator it;
711 for (it = user_selectable_types.First(); it.Good(); it.Inc()) {
712 syncer::ModelTypeSet type_to_set;
713 type_to_set.Put(it.Get());
714 std::string args = GetConfiguration(NULL,
715 CHOOSE_WHAT_TO_SYNC,
716 type_to_set,
717 std::string(),
718 ENCRYPT_PASSWORDS);
719 base::ListValue list_args;
720 list_args.Append(new base::StringValue(args));
721 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
722 .WillRepeatedly(Return(false));
723 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
724 .WillRepeatedly(Return(false));
725 SetupInitializedProfileSyncService();
726 EXPECT_CALL(*mock_pss_,
727 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set)));
728 handler_->HandleConfigure(&list_args);
729
730 ExpectDone();
731 Mock::VerifyAndClearExpectations(mock_pss_);
732 web_ui_.ClearTrackedCalls();
733 }
734 }
735
736 TEST_F(SyncHandlerTest, TestSyncAllManually) {
737 std::string args = GetConfiguration(NULL,
738 CHOOSE_WHAT_TO_SYNC,
739 GetAllTypes(),
740 std::string(),
741 ENCRYPT_PASSWORDS);
742 base::ListValue list_args;
743 list_args.Append(new base::StringValue(args));
744 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
745 .WillRepeatedly(Return(false));
746 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
747 .WillRepeatedly(Return(false));
748 SetupInitializedProfileSyncService();
749 EXPECT_CALL(*mock_pss_,
750 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes())));
751 handler_->HandleConfigure(&list_args);
752
753 ExpectDone();
754 }
755
756 TEST_F(SyncHandlerTest, ShowSyncSetup) {
757 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
758 .WillRepeatedly(Return(false));
759 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
760 .WillRepeatedly(Return(false));
761 SetupInitializedProfileSyncService();
762 // This should display the sync setup dialog (not login).
763 SetDefaultExpectationsForConfigPage();
764 handler_->OpenSyncSetup(nullptr);
765
766 ExpectConfig();
767 }
768
769 // We do not display signin on chromeos in the case of auth error.
770 TEST_F(SyncHandlerTest, ShowSigninOnAuthError) {
771 // Initialize the system to a signed in state, but with an auth error.
772 error_ = GoogleServiceAuthError(
773 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
774
775 SetupInitializedProfileSyncService();
776 mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser);
777 FakeAuthStatusProvider provider(
778 SigninErrorControllerFactory::GetForProfile(profile_.get()));
779 provider.SetAuthError(kTestUser, error_);
780 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
781 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
782 .WillRepeatedly(Return(true));
783 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
784 .WillRepeatedly(Return(false));
785 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
786 .WillRepeatedly(Return(false));
787 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
788
789 #if defined(OS_CHROMEOS)
790 // On ChromeOS, auth errors are ignored - instead we just try to start the
791 // sync backend (which will fail due to the auth error). This should only
792 // happen if the user manually navigates to chrome://settings/syncSetup -
793 // clicking on the button in the UI will sign the user out rather than
794 // displaying a spinner. Should be no visible UI on ChromeOS in this case.
795 EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(
796 profile_.get())->current_login_ui());
797 #else
798
799 // On ChromeOS, this should display the spinner while we try to startup the
800 // sync backend, and on desktop this displays the login dialog.
801 handler_->OpenSyncSetup(nullptr);
802
803 // Sync setup is closed when re-auth is in progress.
804 EXPECT_EQ(NULL,
805 LoginUIServiceFactory::GetForProfile(
806 profile_.get())->current_login_ui());
807
808 ASSERT_FALSE(handler_->is_configuring_sync());
809 #endif
810 }
811
812 TEST_F(SyncHandlerTest, ShowSetupSyncEverything) {
813 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
814 .WillRepeatedly(Return(false));
815 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
816 .WillRepeatedly(Return(false));
817 SetupInitializedProfileSyncService();
818 SetDefaultExpectationsForConfigPage();
819 // This should display the sync setup dialog (not login).
820 handler_->OpenSyncSetup(nullptr);
821
822 ExpectConfig();
823 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
824 const base::DictionaryValue* dictionary = nullptr;
825 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
826 CheckBool(dictionary, "syncAllDataTypes", true);
827 CheckBool(dictionary, "appsRegistered", true);
828 CheckBool(dictionary, "autofillRegistered", true);
829 CheckBool(dictionary, "bookmarksRegistered", true);
830 CheckBool(dictionary, "extensionsRegistered", true);
831 CheckBool(dictionary, "passwordsRegistered", true);
832 CheckBool(dictionary, "preferencesRegistered", true);
833 CheckBool(dictionary, "wifiCredentialsRegistered", true);
834 CheckBool(dictionary, "tabsRegistered", true);
835 CheckBool(dictionary, "themesRegistered", true);
836 CheckBool(dictionary, "typedUrlsRegistered", true);
837 CheckBool(dictionary, "showPassphrase", false);
838 CheckBool(dictionary, "usePassphrase", false);
839 CheckBool(dictionary, "passphraseFailed", false);
840 CheckBool(dictionary, "encryptAllData", false);
841 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes());
842 }
843
844 TEST_F(SyncHandlerTest, ShowSetupManuallySyncAll) {
845 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
846 .WillRepeatedly(Return(false));
847 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
848 .WillRepeatedly(Return(false));
849 SetupInitializedProfileSyncService();
850 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs());
851 sync_prefs.SetKeepEverythingSynced(false);
852 SetDefaultExpectationsForConfigPage();
853 // This should display the sync setup dialog (not login).
854 handler_->OpenSyncSetup(nullptr);
855
856 ExpectConfig();
857 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
858 const base::DictionaryValue* dictionary = nullptr;
859 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
860 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes());
861 }
862
863 TEST_F(SyncHandlerTest, ShowSetupSyncForAllTypesIndividually) {
864 syncer::ModelTypeSet user_selectable_types = GetAllTypes();
865 syncer::ModelTypeSet::Iterator it;
866 for (it = user_selectable_types.First(); it.Good(); it.Inc()) {
867 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
868 .WillRepeatedly(Return(false));
869 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
870 .WillRepeatedly(Return(false));
871 SetupInitializedProfileSyncService();
872 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs());
873 sync_prefs.SetKeepEverythingSynced(false);
874 SetDefaultExpectationsForConfigPage();
875 syncer::ModelTypeSet types;
876 types.Put(it.Get());
877 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()).
878 WillRepeatedly(Return(types));
879
880 // This should display the sync setup dialog (not login).
881 handler_->OpenSyncSetup(nullptr);
882
883 ExpectConfig();
884 // Close the config overlay.
885 LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed(
886 handler_.get());
887 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
888 const base::DictionaryValue* dictionary = nullptr;
889 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
890 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types);
891 Mock::VerifyAndClearExpectations(mock_pss_);
892 // Clean up so we can loop back to display the dialog again.
893 web_ui_.ClearTrackedCalls();
894 }
895 }
896
897 TEST_F(SyncHandlerTest, ShowSetupGaiaPassphraseRequired) {
898 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
899 .WillRepeatedly(Return(true));
900 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
901 .WillRepeatedly(Return(false));
902 SetupInitializedProfileSyncService();
903 SetDefaultExpectationsForConfigPage();
904
905 // This should display the sync setup dialog (not login).
906 handler_->OpenSyncSetup(nullptr);
907
908 ExpectConfig();
909 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
910 const base::DictionaryValue* dictionary = nullptr;
911 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
912 CheckBool(dictionary, "showPassphrase", true);
913 CheckBool(dictionary, "usePassphrase", false);
914 CheckBool(dictionary, "passphraseFailed", false);
915 }
916
917 TEST_F(SyncHandlerTest, ShowSetupCustomPassphraseRequired) {
918 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
919 .WillRepeatedly(Return(true));
920 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
921 .WillRepeatedly(Return(true));
922 EXPECT_CALL(*mock_pss_, GetPassphraseType())
923 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE));
924 SetupInitializedProfileSyncService();
925 SetDefaultExpectationsForConfigPage();
926
927 // This should display the sync setup dialog (not login).
928 handler_->OpenSyncSetup(nullptr);
929
930 ExpectConfig();
931 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
932 const base::DictionaryValue* dictionary = nullptr;
933 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
934 CheckBool(dictionary, "showPassphrase", true);
935 CheckBool(dictionary, "usePassphrase", true);
936 CheckBool(dictionary, "passphraseFailed", false);
937 }
938
939 TEST_F(SyncHandlerTest, ShowSetupEncryptAll) {
940 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
941 .WillRepeatedly(Return(false));
942 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
943 .WillRepeatedly(Return(false));
944 SetupInitializedProfileSyncService();
945 SetDefaultExpectationsForConfigPage();
946 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled())
947 .WillRepeatedly(Return(true));
948
949 // This should display the sync setup dialog (not login).
950 handler_->OpenSyncSetup(nullptr);
951
952 ExpectConfig();
953 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
954 const base::DictionaryValue* dictionary = nullptr;
955 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
956 CheckBool(dictionary, "encryptAllData", true);
957 }
958
959 TEST_F(SyncHandlerTest, ShowSetupEncryptAllDisallowed) {
960 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
961 .WillRepeatedly(Return(false));
962 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
963 .WillRepeatedly(Return(false));
964 SetupInitializedProfileSyncService();
965 SetDefaultExpectationsForConfigPage();
966 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
967 .WillRepeatedly(Return(false));
968
969 // This should display the sync setup dialog (not login).
970 handler_->OpenSyncSetup(nullptr);
971
972 ExpectConfig();
973 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
974 const base::DictionaryValue* dictionary = nullptr;
975 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary));
976 CheckBool(dictionary, "encryptAllData", false);
977 CheckBool(dictionary, "encryptAllDataAllowed", false);
978 }
979
980 TEST_F(SyncHandlerTest, TurnOnEncryptAllDisallowed) {
981 std::string args = GetConfiguration(
982 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA);
983 base::ListValue list_args;
984 list_args.Append(new base::StringValue(args));
985 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
986 .WillRepeatedly(Return(false));
987 EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
988 .WillRepeatedly(Return(false));
989 SetupInitializedProfileSyncService();
990 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed())
991 .WillRepeatedly(Return(false));
992 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
993 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
994 handler_->HandleConfigure(&list_args);
995
996 // Ensure that we navigated to the "done" state since we don't need a
997 // passphrase.
998 ExpectDone();
999 }
1000
1001 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698