OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/webui/options/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/settings/sync_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/signin/fake_signin_manager_builder.h" | 15 #include "chrome/browser/signin/fake_signin_manager_builder.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 CheckBool(dictionary, "extensionsSynced", types.Has(syncer::EXTENSIONS)); | 137 CheckBool(dictionary, "extensionsSynced", types.Has(syncer::EXTENSIONS)); |
138 CheckBool(dictionary, "passwordsSynced", types.Has(syncer::PASSWORDS)); | 138 CheckBool(dictionary, "passwordsSynced", types.Has(syncer::PASSWORDS)); |
139 CheckBool(dictionary, "preferencesSynced", types.Has(syncer::PREFERENCES)); | 139 CheckBool(dictionary, "preferencesSynced", types.Has(syncer::PREFERENCES)); |
140 CheckBool(dictionary, "tabsSynced", types.Has(syncer::PROXY_TABS)); | 140 CheckBool(dictionary, "tabsSynced", types.Has(syncer::PROXY_TABS)); |
141 CheckBool(dictionary, "themesSynced", types.Has(syncer::THEMES)); | 141 CheckBool(dictionary, "themesSynced", types.Has(syncer::THEMES)); |
142 CheckBool(dictionary, "typedUrlsSynced", types.Has(syncer::TYPED_URLS)); | 142 CheckBool(dictionary, "typedUrlsSynced", types.Has(syncer::TYPED_URLS)); |
143 CheckBool(dictionary, "wifiCredentialsSynced", | 143 CheckBool(dictionary, "wifiCredentialsSynced", |
144 types.Has(syncer::WIFI_CREDENTIALS)); | 144 types.Has(syncer::WIFI_CREDENTIALS)); |
145 } | 145 } |
146 | 146 |
147 | |
148 } // namespace | 147 } // namespace |
149 | 148 |
150 class TestingSyncSetupHandler : public SyncSetupHandler { | 149 namespace settings { |
| 150 |
| 151 class TestingSyncHandler : public SyncHandler { |
151 public: | 152 public: |
152 TestingSyncSetupHandler(content::WebUI* web_ui, Profile* profile) | 153 TestingSyncHandler(content::WebUI* web_ui, Profile* profile) |
153 : profile_(profile) { | 154 : profile_(profile) { |
154 set_web_ui(web_ui); | 155 set_web_ui(web_ui); |
155 } | 156 } |
156 ~TestingSyncSetupHandler() override { set_web_ui(NULL); } | 157 ~TestingSyncHandler() override { set_web_ui(nullptr); } |
157 | 158 |
158 void FocusUI() override {} | 159 void FocusUI() override {} |
159 | 160 |
160 Profile* GetProfile() const override { return profile_; } | 161 Profile* GetProfile() const override { return profile_; } |
161 | 162 |
162 using SyncSetupHandler::is_configuring_sync; | 163 using SyncHandler::is_configuring_sync; |
163 | 164 |
164 private: | 165 private: |
165 #if !defined(OS_CHROMEOS) | 166 #if !defined(OS_CHROMEOS) |
166 void DisplayGaiaLoginInNewTabOrWindow() override {} | 167 void DisplayGaiaLoginInNewTabOrWindow() override {} |
167 #endif | 168 #endif |
168 | 169 |
169 // Weak pointer to parent profile. | 170 // Weak pointer to parent profile. |
170 Profile* profile_; | 171 Profile* profile_; |
171 DISALLOW_COPY_AND_ASSIGN(TestingSyncSetupHandler); | 172 DISALLOW_COPY_AND_ASSIGN(TestingSyncHandler); |
172 }; | 173 }; |
173 | 174 |
174 // The boolean parameter indicates whether the test is run with ClientOAuth | 175 // The boolean parameter indicates whether the test is run with ClientOAuth |
175 // or not. The test parameter is a bool: whether or not to test with/ | 176 // or not. The test parameter is a bool: whether or not to test with/ |
176 // /ClientLogin enabled or not. | 177 // /ClientLogin enabled or not. |
177 class SyncSetupHandlerTest : public testing::Test { | 178 class SyncHandlerTest : public testing::Test { |
178 public: | 179 public: |
179 SyncSetupHandlerTest() : error_(GoogleServiceAuthError::NONE) {} | 180 SyncHandlerTest() : error_(GoogleServiceAuthError::NONE) {} |
180 void SetUp() override { | 181 void SetUp() override { |
181 error_ = GoogleServiceAuthError::AuthErrorNone(); | 182 error_ = GoogleServiceAuthError::AuthErrorNone(); |
182 | 183 |
183 TestingProfile::Builder builder; | 184 TestingProfile::Builder builder; |
184 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 185 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
185 BuildFakeSigninManagerBase); | 186 BuildFakeSigninManagerBase); |
186 profile_ = builder.Build(); | 187 profile_ = builder.Build(); |
187 | 188 |
188 // Sign in the user. | 189 // Sign in the user. |
189 mock_signin_ = static_cast<SigninManagerBase*>( | 190 mock_signin_ = static_cast<SigninManagerBase*>( |
(...skipping 11 matching lines...) Expand all Loading... |
201 Return(syncer::IMPLICIT_PASSPHRASE)); | 202 Return(syncer::IMPLICIT_PASSPHRASE)); |
202 ON_CALL(*mock_pss_, GetPassphraseTime()).WillByDefault( | 203 ON_CALL(*mock_pss_, GetPassphraseTime()).WillByDefault( |
203 Return(base::Time())); | 204 Return(base::Time())); |
204 ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault( | 205 ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault( |
205 Return(base::Time())); | 206 Return(base::Time())); |
206 ON_CALL(*mock_pss_, GetRegisteredDataTypes()) | 207 ON_CALL(*mock_pss_, GetRegisteredDataTypes()) |
207 .WillByDefault(Return(syncer::ModelTypeSet())); | 208 .WillByDefault(Return(syncer::ModelTypeSet())); |
208 | 209 |
209 mock_pss_->Initialize(); | 210 mock_pss_->Initialize(); |
210 | 211 |
211 handler_.reset(new TestingSyncSetupHandler(&web_ui_, profile_.get())); | 212 handler_.reset(new TestingSyncHandler(&web_ui_, profile_.get())); |
212 } | 213 } |
213 | 214 |
214 // Setup the expectations for calls made when displaying the config page. | 215 // Setup the expectations for calls made when displaying the config page. |
215 void SetDefaultExpectationsForConfigPage() { | 216 void SetDefaultExpectationsForConfigPage() { |
216 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 217 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
217 EXPECT_CALL(*mock_pss_, GetRegisteredDataTypes()) | 218 EXPECT_CALL(*mock_pss_, GetRegisteredDataTypes()) |
218 .WillRepeatedly(Return(GetAllTypes())); | 219 .WillRepeatedly(Return(GetAllTypes())); |
219 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()) | 220 EXPECT_CALL(*mock_pss_, GetPreferredDataTypes()) |
220 .WillRepeatedly(Return(GetAllTypes())); | 221 .WillRepeatedly(Return(GetAllTypes())); |
221 EXPECT_CALL(*mock_pss_, GetActiveDataTypes()) | 222 EXPECT_CALL(*mock_pss_, GetActiveDataTypes()) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 virtual std::string GetTestUser() { | 280 virtual std::string GetTestUser() { |
280 return std::string(kTestUser); | 281 return std::string(kTestUser); |
281 } | 282 } |
282 | 283 |
283 content::TestBrowserThreadBundle thread_bundle_; | 284 content::TestBrowserThreadBundle thread_bundle_; |
284 scoped_ptr<Profile> profile_; | 285 scoped_ptr<Profile> profile_; |
285 ProfileSyncServiceMock* mock_pss_; | 286 ProfileSyncServiceMock* mock_pss_; |
286 GoogleServiceAuthError error_; | 287 GoogleServiceAuthError error_; |
287 SigninManagerBase* mock_signin_; | 288 SigninManagerBase* mock_signin_; |
288 content::TestWebUI web_ui_; | 289 content::TestWebUI web_ui_; |
289 scoped_ptr<TestingSyncSetupHandler> handler_; | 290 scoped_ptr<TestingSyncHandler> handler_; |
290 }; | 291 }; |
291 | 292 |
292 class SyncSetupHandlerFirstSigninTest : public SyncSetupHandlerTest { | 293 class SyncHandlerFirstSigninTest : public SyncHandlerTest { |
293 std::string GetTestUser() override { return std::string(); } | 294 std::string GetTestUser() override { return std::string(); } |
294 }; | 295 }; |
295 | 296 |
296 TEST_F(SyncSetupHandlerTest, Basic) { | 297 TEST_F(SyncHandlerTest, Basic) { |
297 } | 298 } |
298 | 299 |
299 #if !defined(OS_CHROMEOS) | 300 #if !defined(OS_CHROMEOS) |
300 TEST_F(SyncSetupHandlerFirstSigninTest, DisplayBasicLogin) { | 301 TEST_F(SyncHandlerFirstSigninTest, DisplayBasicLogin) { |
301 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 302 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
302 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 303 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
303 .WillRepeatedly(Return(false)); | 304 .WillRepeatedly(Return(false)); |
304 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 305 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
305 .WillRepeatedly(Return(false)); | 306 .WillRepeatedly(Return(false)); |
306 // Ensure that the user is not signed in before calling |HandleStartSignin()|. | 307 // Ensure that the user is not signed in before calling |HandleStartSignin()|. |
307 SigninManager* manager = static_cast<SigninManager*>(mock_signin_); | 308 SigninManager* manager = static_cast<SigninManager*>(mock_signin_); |
308 manager->SignOut(signin_metrics::SIGNOUT_TEST); | 309 manager->SignOut(signin_metrics::SIGNOUT_TEST); |
309 handler_->HandleStartSignin(NULL); | 310 handler_->HandleStartSignin(NULL); |
310 | 311 |
311 // Sync setup hands off control to the gaia login tab. | 312 // Sync setup hands off control to the gaia login tab. |
312 EXPECT_EQ(NULL, | 313 EXPECT_EQ(NULL, |
313 LoginUIServiceFactory::GetForProfile( | 314 LoginUIServiceFactory::GetForProfile( |
314 profile_.get())->current_login_ui()); | 315 profile_.get())->current_login_ui()); |
315 | 316 |
316 ASSERT_FALSE(handler_->is_configuring_sync()); | 317 ASSERT_FALSE(handler_->is_configuring_sync()); |
317 | 318 |
318 handler_->CloseSyncSetup(); | 319 handler_->CloseSyncSetup(); |
319 EXPECT_EQ(NULL, | 320 EXPECT_EQ(NULL, |
320 LoginUIServiceFactory::GetForProfile( | 321 LoginUIServiceFactory::GetForProfile( |
321 profile_.get())->current_login_ui()); | 322 profile_.get())->current_login_ui()); |
322 } | 323 } |
323 | 324 |
324 TEST_F(SyncSetupHandlerTest, ShowSyncSetupWhenNotSignedIn) { | 325 TEST_F(SyncHandlerTest, ShowSyncSetupWhenNotSignedIn) { |
325 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 326 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
326 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 327 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
327 .WillRepeatedly(Return(false)); | 328 .WillRepeatedly(Return(false)); |
328 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 329 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
329 .WillRepeatedly(Return(false)); | 330 .WillRepeatedly(Return(false)); |
330 handler_->HandleShowSetupUI(NULL); | 331 handler_->HandleShowSetupUI(NULL); |
331 | 332 |
332 // We expect a call to SyncSetupOverlay.showSyncSetupPage. | 333 // We expect a call to SyncSetupOverlay.showSyncSetupPage. |
333 ASSERT_EQ(1U, web_ui_.call_data().size()); | 334 ASSERT_EQ(1U, web_ui_.call_data().size()); |
334 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 335 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
335 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); | 336 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); |
336 | 337 |
337 ASSERT_FALSE(handler_->is_configuring_sync()); | 338 ASSERT_FALSE(handler_->is_configuring_sync()); |
338 EXPECT_EQ(NULL, | 339 EXPECT_EQ(NULL, |
339 LoginUIServiceFactory::GetForProfile( | 340 LoginUIServiceFactory::GetForProfile( |
340 profile_.get())->current_login_ui()); | 341 profile_.get())->current_login_ui()); |
341 } | 342 } |
342 #endif // !defined(OS_CHROMEOS) | 343 #endif // !defined(OS_CHROMEOS) |
343 | 344 |
344 // Verifies that the sync setup is terminated correctly when the | 345 // Verifies that the sync setup is terminated correctly when the |
345 // sync is disabled. | 346 // sync is disabled. |
346 TEST_F(SyncSetupHandlerTest, HandleSetupUIWhenSyncDisabled) { | 347 TEST_F(SyncHandlerTest, HandleSetupUIWhenSyncDisabled) { |
347 EXPECT_CALL(*mock_pss_, IsManaged()).WillRepeatedly(Return(true)); | 348 EXPECT_CALL(*mock_pss_, IsManaged()).WillRepeatedly(Return(true)); |
348 handler_->HandleShowSetupUI(NULL); | 349 handler_->HandleShowSetupUI(NULL); |
349 | 350 |
350 // Sync setup is closed when sync is disabled. | 351 // Sync setup is closed when sync is disabled. |
351 EXPECT_EQ(NULL, | 352 EXPECT_EQ(NULL, |
352 LoginUIServiceFactory::GetForProfile( | 353 LoginUIServiceFactory::GetForProfile( |
353 profile_.get())->current_login_ui()); | 354 profile_.get())->current_login_ui()); |
354 ASSERT_FALSE(handler_->is_configuring_sync()); | 355 ASSERT_FALSE(handler_->is_configuring_sync()); |
355 } | 356 } |
356 | 357 |
357 // Verifies that the handler correctly handles a cancellation when | 358 // Verifies that the handler correctly handles a cancellation when |
358 // it is displaying the spinner to the user. | 359 // it is displaying the spinner to the user. |
359 TEST_F(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { | 360 TEST_F(SyncHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { |
360 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 361 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
361 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 362 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
362 .WillRepeatedly(Return(true)); | 363 .WillRepeatedly(Return(true)); |
363 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 364 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
364 .WillRepeatedly(Return(false)); | 365 .WillRepeatedly(Return(false)); |
365 error_ = GoogleServiceAuthError::AuthErrorNone(); | 366 error_ = GoogleServiceAuthError::AuthErrorNone(); |
366 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); | 367 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
367 | 368 |
368 // We're simulating a user setting up sync, which would cause the backend to | 369 // We're simulating a user setting up sync, which would cause the backend to |
369 // kick off initialization, but not download user data types. The sync | 370 // kick off initialization, but not download user data types. The sync |
370 // backend will try to download control data types (e.g encryption info), but | 371 // backend will try to download control data types (e.g encryption info), but |
371 // that won't finish for this test as we're simulating cancelling while the | 372 // that won't finish for this test as we're simulating cancelling while the |
372 // spinner is showing. | 373 // spinner is showing. |
373 handler_->HandleShowSetupUI(NULL); | 374 handler_->HandleShowSetupUI(NULL); |
374 | 375 |
375 EXPECT_EQ(handler_.get(), | 376 EXPECT_EQ(handler_.get(), |
376 LoginUIServiceFactory::GetForProfile( | 377 LoginUIServiceFactory::GetForProfile( |
377 profile_.get())->current_login_ui()); | 378 profile_.get())->current_login_ui()); |
378 | 379 |
379 ExpectSpinnerAndClose(); | 380 ExpectSpinnerAndClose(); |
380 } | 381 } |
381 | 382 |
382 // Verifies that the handler correctly transitions from showing the spinner | 383 // Verifies that the handler correctly transitions from showing the spinner |
383 // to showing a configuration page when sync setup completes successfully. | 384 // to showing a configuration page when sync setup completes successfully. |
384 TEST_F(SyncSetupHandlerTest, | 385 TEST_F(SyncHandlerTest, |
385 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) { | 386 DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) { |
386 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 387 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
387 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 388 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
388 .WillRepeatedly(Return(true)); | 389 .WillRepeatedly(Return(true)); |
389 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 390 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
390 .WillRepeatedly(Return(false)); | 391 .WillRepeatedly(Return(false)); |
391 error_ = GoogleServiceAuthError::AuthErrorNone(); | 392 error_ = GoogleServiceAuthError::AuthErrorNone(); |
392 // Sync backend is stopped initially, and will start up. | 393 // Sync backend is stopped initially, and will start up. |
393 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); | 394 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
394 SetDefaultExpectationsForConfigPage(); | 395 SetDefaultExpectationsForConfigPage(); |
(...skipping 30 matching lines...) Expand all Loading... |
425 CheckBool(dictionary, "encryptAllDataAllowed", true); | 426 CheckBool(dictionary, "encryptAllDataAllowed", true); |
426 CheckBool(dictionary, "encryptAllData", false); | 427 CheckBool(dictionary, "encryptAllData", false); |
427 CheckBool(dictionary, "usePassphrase", false); | 428 CheckBool(dictionary, "usePassphrase", false); |
428 } | 429 } |
429 | 430 |
430 // Verifies the case where the user cancels after the sync backend has | 431 // Verifies the case where the user cancels after the sync backend has |
431 // initialized (meaning it already transitioned from the spinner to a proper | 432 // initialized (meaning it already transitioned from the spinner to a proper |
432 // configuration page, tested by | 433 // configuration page, tested by |
433 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user | 434 // DisplayConfigureWithBackendDisabledAndSigninSuccess), but before the user |
434 // before the user has continued on. | 435 // before the user has continued on. |
435 TEST_F(SyncSetupHandlerTest, | 436 TEST_F(SyncHandlerTest, |
436 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { | 437 DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) { |
437 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 438 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
438 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 439 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
439 .WillRepeatedly(Return(true)); | 440 .WillRepeatedly(Return(true)); |
440 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 441 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
441 .WillRepeatedly(Return(false)); | 442 .WillRepeatedly(Return(false)); |
442 error_ = GoogleServiceAuthError::AuthErrorNone(); | 443 error_ = GoogleServiceAuthError::AuthErrorNone(); |
443 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) | 444 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) |
444 .WillOnce(Return(false)) | 445 .WillOnce(Return(false)) |
445 .WillRepeatedly(Return(true)); | 446 .WillRepeatedly(Return(true)); |
446 SetDefaultExpectationsForConfigPage(); | 447 SetDefaultExpectationsForConfigPage(); |
447 handler_->OpenSyncSetup(); | 448 handler_->OpenSyncSetup(); |
448 | 449 |
449 // It's important to tell sync the user cancelled the setup flow before we | 450 // It's important to tell sync the user cancelled the setup flow before we |
450 // tell it we're through with the setup progress. | 451 // tell it we're through with the setup progress. |
451 testing::InSequence seq; | 452 testing::InSequence seq; |
452 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); | 453 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); |
453 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); | 454 EXPECT_CALL(*mock_pss_, SetSetupInProgress(false)); |
454 | 455 |
455 handler_->CloseSyncSetup(); | 456 handler_->CloseSyncSetup(); |
456 EXPECT_EQ(NULL, | 457 EXPECT_EQ(NULL, |
457 LoginUIServiceFactory::GetForProfile( | 458 LoginUIServiceFactory::GetForProfile( |
458 profile_.get())->current_login_ui()); | 459 profile_.get())->current_login_ui()); |
459 } | 460 } |
460 | 461 |
461 TEST_F(SyncSetupHandlerTest, | 462 TEST_F(SyncHandlerTest, |
462 DisplayConfigureWithBackendDisabledAndSigninFailed) { | 463 DisplayConfigureWithBackendDisabledAndSigninFailed) { |
463 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 464 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
464 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 465 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
465 .WillRepeatedly(Return(true)); | 466 .WillRepeatedly(Return(true)); |
466 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 467 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
467 .WillRepeatedly(Return(false)); | 468 .WillRepeatedly(Return(false)); |
468 error_ = GoogleServiceAuthError::AuthErrorNone(); | 469 error_ = GoogleServiceAuthError::AuthErrorNone(); |
469 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); | 470 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); |
470 | 471 |
471 handler_->OpenSyncSetup(); | 472 handler_->OpenSyncSetup(); |
472 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 473 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
473 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); | 474 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); |
474 std::string page; | 475 std::string page; |
475 ASSERT_TRUE(data.arg1()->GetAsString(&page)); | 476 ASSERT_TRUE(data.arg1()->GetAsString(&page)); |
476 EXPECT_EQ(page, "spinner"); | 477 EXPECT_EQ(page, "spinner"); |
477 Mock::VerifyAndClearExpectations(mock_pss_); | 478 Mock::VerifyAndClearExpectations(mock_pss_); |
478 error_ = GoogleServiceAuthError( | 479 error_ = GoogleServiceAuthError( |
479 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 480 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
480 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 481 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
481 NotifySyncListeners(); | 482 NotifySyncListeners(); |
482 | 483 |
483 // On failure, the dialog will be closed. | 484 // On failure, the dialog will be closed. |
484 EXPECT_EQ(NULL, | 485 EXPECT_EQ(NULL, |
485 LoginUIServiceFactory::GetForProfile( | 486 LoginUIServiceFactory::GetForProfile( |
486 profile_.get())->current_login_ui()); | 487 profile_.get())->current_login_ui()); |
487 } | 488 } |
488 | 489 |
489 #if !defined(OS_CHROMEOS) | 490 #if !defined(OS_CHROMEOS) |
490 | 491 |
491 class SyncSetupHandlerNonCrosTest : public SyncSetupHandlerTest { | 492 class SyncHandlerNonCrosTest : public SyncHandlerTest { |
492 public: | 493 public: |
493 SyncSetupHandlerNonCrosTest() {} | 494 SyncHandlerNonCrosTest() {} |
494 }; | 495 }; |
495 | 496 |
496 TEST_F(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) { | 497 TEST_F(SyncHandlerNonCrosTest, HandleGaiaAuthFailure) { |
497 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 498 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
498 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 499 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
499 .WillRepeatedly(Return(false)); | 500 .WillRepeatedly(Return(false)); |
500 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) | 501 EXPECT_CALL(*mock_pss_, HasUnrecoverableError()) |
501 .WillRepeatedly(Return(false)); | 502 .WillRepeatedly(Return(false)); |
502 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 503 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
503 .WillRepeatedly(Return(false)); | 504 .WillRepeatedly(Return(false)); |
504 // Open the web UI. | 505 // Open the web UI. |
505 handler_->OpenSyncSetup(); | 506 handler_->OpenSyncSetup(); |
506 | 507 |
507 ASSERT_FALSE(handler_->is_configuring_sync()); | 508 ASSERT_FALSE(handler_->is_configuring_sync()); |
508 } | 509 } |
509 | 510 |
510 // TODO(kochi): We need equivalent tests for ChromeOS. | 511 // TODO(kochi): We need equivalent tests for ChromeOS. |
511 TEST_F(SyncSetupHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { | 512 TEST_F(SyncHandlerNonCrosTest, UnrecoverableErrorInitializingSync) { |
512 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 513 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
513 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 514 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
514 .WillRepeatedly(Return(false)); | 515 .WillRepeatedly(Return(false)); |
515 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 516 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
516 .WillRepeatedly(Return(false)); | 517 .WillRepeatedly(Return(false)); |
517 // Open the web UI. | 518 // Open the web UI. |
518 handler_->OpenSyncSetup(); | 519 handler_->OpenSyncSetup(); |
519 | 520 |
520 ASSERT_FALSE(handler_->is_configuring_sync()); | 521 ASSERT_FALSE(handler_->is_configuring_sync()); |
521 } | 522 } |
522 | 523 |
523 TEST_F(SyncSetupHandlerNonCrosTest, GaiaErrorInitializingSync) { | 524 TEST_F(SyncHandlerNonCrosTest, GaiaErrorInitializingSync) { |
524 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); | 525 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(false)); |
525 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) | 526 EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) |
526 .WillRepeatedly(Return(false)); | 527 .WillRepeatedly(Return(false)); |
527 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) | 528 EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) |
528 .WillRepeatedly(Return(false)); | 529 .WillRepeatedly(Return(false)); |
529 // Open the web UI. | 530 // Open the web UI. |
530 handler_->OpenSyncSetup(); | 531 handler_->OpenSyncSetup(); |
531 | 532 |
532 ASSERT_FALSE(handler_->is_configuring_sync()); | 533 ASSERT_FALSE(handler_->is_configuring_sync()); |
533 } | 534 } |
534 | 535 |
535 #endif // #if !defined(OS_CHROMEOS) | 536 #endif // #if !defined(OS_CHROMEOS) |
536 | 537 |
537 TEST_F(SyncSetupHandlerTest, TestSyncEverything) { | 538 TEST_F(SyncHandlerTest, TestSyncEverything) { |
538 std::string args = GetConfiguration( | 539 std::string args = GetConfiguration( |
539 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); | 540 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); |
540 base::ListValue list_args; | 541 base::ListValue list_args; |
541 list_args.Append(new base::StringValue(args)); | 542 list_args.Append(new base::StringValue(args)); |
542 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 543 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
543 .WillRepeatedly(Return(false)); | 544 .WillRepeatedly(Return(false)); |
544 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 545 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
545 .WillRepeatedly(Return(false)); | 546 .WillRepeatedly(Return(false)); |
546 SetupInitializedProfileSyncService(); | 547 SetupInitializedProfileSyncService(); |
547 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 548 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
548 handler_->HandleConfigure(&list_args); | 549 handler_->HandleConfigure(&list_args); |
549 | 550 |
550 // Ensure that we navigated to the "done" state since we don't need a | 551 // Ensure that we navigated to the "done" state since we don't need a |
551 // passphrase. | 552 // passphrase. |
552 ExpectDone(); | 553 ExpectDone(); |
553 } | 554 } |
554 | 555 |
555 TEST_F(SyncSetupHandlerTest, TestSyncNothing) { | 556 TEST_F(SyncHandlerTest, TestSyncNothing) { |
556 std::string args = GetConfiguration( | 557 std::string args = GetConfiguration( |
557 NULL, SYNC_NOTHING, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); | 558 NULL, SYNC_NOTHING, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); |
558 base::ListValue list_args; | 559 base::ListValue list_args; |
559 list_args.Append(new base::StringValue(args)); | 560 list_args.Append(new base::StringValue(args)); |
560 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); | 561 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); |
561 SetupInitializedProfileSyncService(); | 562 SetupInitializedProfileSyncService(); |
562 handler_->HandleConfigure(&list_args); | 563 handler_->HandleConfigure(&list_args); |
563 | 564 |
564 // We expect a call to SyncSetupOverlay.showSyncSetupPage. | 565 // We expect a call to SyncSetupOverlay.showSyncSetupPage. |
565 ASSERT_EQ(1U, web_ui_.call_data().size()); | 566 ASSERT_EQ(1U, web_ui_.call_data().size()); |
566 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 567 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
567 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); | 568 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name()); |
568 } | 569 } |
569 | 570 |
570 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAll) { | 571 TEST_F(SyncHandlerTest, TurnOnEncryptAll) { |
571 std::string args = GetConfiguration( | 572 std::string args = GetConfiguration( |
572 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); | 573 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); |
573 base::ListValue list_args; | 574 base::ListValue list_args; |
574 list_args.Append(new base::StringValue(args)); | 575 list_args.Append(new base::StringValue(args)); |
575 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 576 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
576 .WillRepeatedly(Return(false)); | 577 .WillRepeatedly(Return(false)); |
577 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 578 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
578 .WillRepeatedly(Return(false)); | 579 .WillRepeatedly(Return(false)); |
579 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 580 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
580 .WillRepeatedly(Return(true)); | 581 .WillRepeatedly(Return(true)); |
581 SetupInitializedProfileSyncService(); | 582 SetupInitializedProfileSyncService(); |
582 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()); | 583 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()); |
583 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 584 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
584 handler_->HandleConfigure(&list_args); | 585 handler_->HandleConfigure(&list_args); |
585 | 586 |
586 // Ensure that we navigated to the "done" state since we don't need a | 587 // Ensure that we navigated to the "done" state since we don't need a |
587 // passphrase. | 588 // passphrase. |
588 ExpectDone(); | 589 ExpectDone(); |
589 } | 590 } |
590 | 591 |
591 TEST_F(SyncSetupHandlerTest, TestPassphraseStillRequired) { | 592 TEST_F(SyncHandlerTest, TestPassphraseStillRequired) { |
592 std::string args = GetConfiguration( | 593 std::string args = GetConfiguration( |
593 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); | 594 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_PASSWORDS); |
594 base::ListValue list_args; | 595 base::ListValue list_args; |
595 list_args.Append(new base::StringValue(args)); | 596 list_args.Append(new base::StringValue(args)); |
596 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 597 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
597 .WillRepeatedly(Return(true)); | 598 .WillRepeatedly(Return(true)); |
598 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 599 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
599 .WillRepeatedly(Return(true)); | 600 .WillRepeatedly(Return(true)); |
600 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 601 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
601 .WillRepeatedly(Return(false)); | 602 .WillRepeatedly(Return(false)); |
602 SetupInitializedProfileSyncService(); | 603 SetupInitializedProfileSyncService(); |
603 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); | 604 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
604 SetDefaultExpectationsForConfigPage(); | 605 SetDefaultExpectationsForConfigPage(); |
605 | 606 |
606 // We should navigate back to the configure page since we need a passphrase. | 607 // We should navigate back to the configure page since we need a passphrase. |
607 handler_->HandleConfigure(&list_args); | 608 handler_->HandleConfigure(&list_args); |
608 | 609 |
609 ExpectConfig(); | 610 ExpectConfig(); |
610 } | 611 } |
611 | 612 |
612 TEST_F(SyncSetupHandlerTest, SuccessfullySetPassphrase) { | 613 TEST_F(SyncHandlerTest, SuccessfullySetPassphrase) { |
613 base::DictionaryValue dict; | 614 base::DictionaryValue dict; |
614 dict.SetBoolean("isGooglePassphrase", true); | 615 dict.SetBoolean("isGooglePassphrase", true); |
615 std::string args = GetConfiguration(&dict, | 616 std::string args = GetConfiguration(&dict, |
616 SYNC_ALL_DATA, | 617 SYNC_ALL_DATA, |
617 GetAllTypes(), | 618 GetAllTypes(), |
618 "gaiaPassphrase", | 619 "gaiaPassphrase", |
619 ENCRYPT_PASSWORDS); | 620 ENCRYPT_PASSWORDS); |
620 base::ListValue list_args; | 621 base::ListValue list_args; |
621 list_args.Append(new base::StringValue(args)); | 622 list_args.Append(new base::StringValue(args)); |
622 // Act as if an encryption passphrase is required the first time, then never | 623 // Act as if an encryption passphrase is required the first time, then never |
623 // again after that. | 624 // again after that. |
624 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true)); | 625 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()).WillOnce(Return(true)); |
625 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 626 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
626 .WillRepeatedly(Return(false)); | 627 .WillRepeatedly(Return(false)); |
627 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 628 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
628 .WillRepeatedly(Return(false)); | 629 .WillRepeatedly(Return(false)); |
629 SetupInitializedProfileSyncService(); | 630 SetupInitializedProfileSyncService(); |
630 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); | 631 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
631 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")). | 632 EXPECT_CALL(*mock_pss_, SetDecryptionPassphrase("gaiaPassphrase")). |
632 WillOnce(Return(true)); | 633 WillOnce(Return(true)); |
633 | 634 |
634 handler_->HandleConfigure(&list_args); | 635 handler_->HandleConfigure(&list_args); |
635 // We should navigate to "done" page since we finished configuring. | 636 // We should navigate to "done" page since we finished configuring. |
636 ExpectDone(); | 637 ExpectDone(); |
637 } | 638 } |
638 | 639 |
639 TEST_F(SyncSetupHandlerTest, SelectCustomEncryption) { | 640 TEST_F(SyncHandlerTest, SelectCustomEncryption) { |
640 base::DictionaryValue dict; | 641 base::DictionaryValue dict; |
641 dict.SetBoolean("isGooglePassphrase", false); | 642 dict.SetBoolean("isGooglePassphrase", false); |
642 std::string args = GetConfiguration(&dict, | 643 std::string args = GetConfiguration(&dict, |
643 SYNC_ALL_DATA, | 644 SYNC_ALL_DATA, |
644 GetAllTypes(), | 645 GetAllTypes(), |
645 "custom_passphrase", | 646 "custom_passphrase", |
646 ENCRYPT_PASSWORDS); | 647 ENCRYPT_PASSWORDS); |
647 base::ListValue list_args; | 648 base::ListValue list_args; |
648 list_args.Append(new base::StringValue(args)); | 649 list_args.Append(new base::StringValue(args)); |
649 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 650 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
650 .WillRepeatedly(Return(false)); | 651 .WillRepeatedly(Return(false)); |
651 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 652 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
652 .WillRepeatedly(Return(false)); | 653 .WillRepeatedly(Return(false)); |
653 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 654 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
654 .WillRepeatedly(Return(false)); | 655 .WillRepeatedly(Return(false)); |
655 SetupInitializedProfileSyncService(); | 656 SetupInitializedProfileSyncService(); |
656 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); | 657 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(_, _)); |
657 EXPECT_CALL(*mock_pss_, | 658 EXPECT_CALL(*mock_pss_, |
658 SetEncryptionPassphrase("custom_passphrase", | 659 SetEncryptionPassphrase("custom_passphrase", |
659 ProfileSyncService::EXPLICIT)); | 660 ProfileSyncService::EXPLICIT)); |
660 | 661 |
661 handler_->HandleConfigure(&list_args); | 662 handler_->HandleConfigure(&list_args); |
662 // We should navigate to "done" page since we finished configuring. | 663 // We should navigate to "done" page since we finished configuring. |
663 ExpectDone(); | 664 ExpectDone(); |
664 } | 665 } |
665 | 666 |
666 TEST_F(SyncSetupHandlerTest, UnsuccessfullySetPassphrase) { | 667 TEST_F(SyncHandlerTest, UnsuccessfullySetPassphrase) { |
667 base::DictionaryValue dict; | 668 base::DictionaryValue dict; |
668 dict.SetBoolean("isGooglePassphrase", true); | 669 dict.SetBoolean("isGooglePassphrase", true); |
669 std::string args = GetConfiguration(&dict, | 670 std::string args = GetConfiguration(&dict, |
670 SYNC_ALL_DATA, | 671 SYNC_ALL_DATA, |
671 GetAllTypes(), | 672 GetAllTypes(), |
672 "invalid_passphrase", | 673 "invalid_passphrase", |
673 ENCRYPT_PASSWORDS); | 674 ENCRYPT_PASSWORDS); |
674 base::ListValue list_args; | 675 base::ListValue list_args; |
675 list_args.Append(new base::StringValue(args)); | 676 list_args.Append(new base::StringValue(args)); |
676 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 677 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
(...skipping 16 matching lines...) Expand all Loading... |
693 // Make sure we display an error message to the user due to the failed | 694 // Make sure we display an error message to the user due to the failed |
694 // passphrase. | 695 // passphrase. |
695 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 696 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
696 const base::DictionaryValue* dictionary = nullptr; | 697 const base::DictionaryValue* dictionary = nullptr; |
697 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 698 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
698 CheckBool(dictionary, "passphraseFailed", true); | 699 CheckBool(dictionary, "passphraseFailed", true); |
699 } | 700 } |
700 | 701 |
701 // Walks through each user selectable type, and tries to sync just that single | 702 // Walks through each user selectable type, and tries to sync just that single |
702 // data type. | 703 // data type. |
703 TEST_F(SyncSetupHandlerTest, TestSyncIndividualTypes) { | 704 TEST_F(SyncHandlerTest, TestSyncIndividualTypes) { |
704 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); | 705 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); |
705 syncer::ModelTypeSet::Iterator it; | 706 syncer::ModelTypeSet::Iterator it; |
706 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { | 707 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { |
707 syncer::ModelTypeSet type_to_set; | 708 syncer::ModelTypeSet type_to_set; |
708 type_to_set.Put(it.Get()); | 709 type_to_set.Put(it.Get()); |
709 std::string args = GetConfiguration(NULL, | 710 std::string args = GetConfiguration(NULL, |
710 CHOOSE_WHAT_TO_SYNC, | 711 CHOOSE_WHAT_TO_SYNC, |
711 type_to_set, | 712 type_to_set, |
712 std::string(), | 713 std::string(), |
713 ENCRYPT_PASSWORDS); | 714 ENCRYPT_PASSWORDS); |
714 base::ListValue list_args; | 715 base::ListValue list_args; |
715 list_args.Append(new base::StringValue(args)); | 716 list_args.Append(new base::StringValue(args)); |
716 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 717 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
717 .WillRepeatedly(Return(false)); | 718 .WillRepeatedly(Return(false)); |
718 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 719 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
719 .WillRepeatedly(Return(false)); | 720 .WillRepeatedly(Return(false)); |
720 SetupInitializedProfileSyncService(); | 721 SetupInitializedProfileSyncService(); |
721 EXPECT_CALL(*mock_pss_, | 722 EXPECT_CALL(*mock_pss_, |
722 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set))); | 723 OnUserChoseDatatypes(false, ModelTypeSetMatches(type_to_set))); |
723 handler_->HandleConfigure(&list_args); | 724 handler_->HandleConfigure(&list_args); |
724 | 725 |
725 ExpectDone(); | 726 ExpectDone(); |
726 Mock::VerifyAndClearExpectations(mock_pss_); | 727 Mock::VerifyAndClearExpectations(mock_pss_); |
727 web_ui_.ClearTrackedCalls(); | 728 web_ui_.ClearTrackedCalls(); |
728 } | 729 } |
729 } | 730 } |
730 | 731 |
731 TEST_F(SyncSetupHandlerTest, TestSyncAllManually) { | 732 TEST_F(SyncHandlerTest, TestSyncAllManually) { |
732 std::string args = GetConfiguration(NULL, | 733 std::string args = GetConfiguration(NULL, |
733 CHOOSE_WHAT_TO_SYNC, | 734 CHOOSE_WHAT_TO_SYNC, |
734 GetAllTypes(), | 735 GetAllTypes(), |
735 std::string(), | 736 std::string(), |
736 ENCRYPT_PASSWORDS); | 737 ENCRYPT_PASSWORDS); |
737 base::ListValue list_args; | 738 base::ListValue list_args; |
738 list_args.Append(new base::StringValue(args)); | 739 list_args.Append(new base::StringValue(args)); |
739 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 740 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
740 .WillRepeatedly(Return(false)); | 741 .WillRepeatedly(Return(false)); |
741 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 742 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
742 .WillRepeatedly(Return(false)); | 743 .WillRepeatedly(Return(false)); |
743 SetupInitializedProfileSyncService(); | 744 SetupInitializedProfileSyncService(); |
744 EXPECT_CALL(*mock_pss_, | 745 EXPECT_CALL(*mock_pss_, |
745 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes()))); | 746 OnUserChoseDatatypes(false, ModelTypeSetMatches(GetAllTypes()))); |
746 handler_->HandleConfigure(&list_args); | 747 handler_->HandleConfigure(&list_args); |
747 | 748 |
748 ExpectDone(); | 749 ExpectDone(); |
749 } | 750 } |
750 | 751 |
751 TEST_F(SyncSetupHandlerTest, ShowSyncSetup) { | 752 TEST_F(SyncHandlerTest, ShowSyncSetup) { |
752 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 753 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
753 .WillRepeatedly(Return(false)); | 754 .WillRepeatedly(Return(false)); |
754 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 755 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
755 .WillRepeatedly(Return(false)); | 756 .WillRepeatedly(Return(false)); |
756 SetupInitializedProfileSyncService(); | 757 SetupInitializedProfileSyncService(); |
757 // This should display the sync setup dialog (not login). | 758 // This should display the sync setup dialog (not login). |
758 SetDefaultExpectationsForConfigPage(); | 759 SetDefaultExpectationsForConfigPage(); |
759 handler_->OpenSyncSetup(); | 760 handler_->OpenSyncSetup(); |
760 | 761 |
761 ExpectConfig(); | 762 ExpectConfig(); |
762 } | 763 } |
763 | 764 |
764 // We do not display signin on chromeos in the case of auth error. | 765 // We do not display signin on chromeos in the case of auth error. |
765 TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) { | 766 TEST_F(SyncHandlerTest, ShowSigninOnAuthError) { |
766 // Initialize the system to a signed in state, but with an auth error. | 767 // Initialize the system to a signed in state, but with an auth error. |
767 error_ = GoogleServiceAuthError( | 768 error_ = GoogleServiceAuthError( |
768 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 769 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
769 | 770 |
770 SetupInitializedProfileSyncService(); | 771 SetupInitializedProfileSyncService(); |
771 mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser); | 772 mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser); |
772 FakeAuthStatusProvider provider( | 773 FakeAuthStatusProvider provider( |
773 SigninErrorControllerFactory::GetForProfile(profile_.get())); | 774 SigninErrorControllerFactory::GetForProfile(profile_.get())); |
774 provider.SetAuthError(kTestUser, error_); | 775 provider.SetAuthError(kTestUser, error_); |
775 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); | 776 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); |
(...skipping 21 matching lines...) Expand all Loading... |
797 | 798 |
798 // Sync setup is closed when re-auth is in progress. | 799 // Sync setup is closed when re-auth is in progress. |
799 EXPECT_EQ(NULL, | 800 EXPECT_EQ(NULL, |
800 LoginUIServiceFactory::GetForProfile( | 801 LoginUIServiceFactory::GetForProfile( |
801 profile_.get())->current_login_ui()); | 802 profile_.get())->current_login_ui()); |
802 | 803 |
803 ASSERT_FALSE(handler_->is_configuring_sync()); | 804 ASSERT_FALSE(handler_->is_configuring_sync()); |
804 #endif | 805 #endif |
805 } | 806 } |
806 | 807 |
807 TEST_F(SyncSetupHandlerTest, ShowSetupSyncEverything) { | 808 TEST_F(SyncHandlerTest, ShowSetupSyncEverything) { |
808 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 809 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
809 .WillRepeatedly(Return(false)); | 810 .WillRepeatedly(Return(false)); |
810 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 811 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
811 .WillRepeatedly(Return(false)); | 812 .WillRepeatedly(Return(false)); |
812 SetupInitializedProfileSyncService(); | 813 SetupInitializedProfileSyncService(); |
813 SetDefaultExpectationsForConfigPage(); | 814 SetDefaultExpectationsForConfigPage(); |
814 // This should display the sync setup dialog (not login). | 815 // This should display the sync setup dialog (not login). |
815 handler_->OpenSyncSetup(); | 816 handler_->OpenSyncSetup(); |
816 | 817 |
817 ExpectConfig(); | 818 ExpectConfig(); |
(...skipping 11 matching lines...) Expand all Loading... |
829 CheckBool(dictionary, "tabsRegistered", true); | 830 CheckBool(dictionary, "tabsRegistered", true); |
830 CheckBool(dictionary, "themesRegistered", true); | 831 CheckBool(dictionary, "themesRegistered", true); |
831 CheckBool(dictionary, "typedUrlsRegistered", true); | 832 CheckBool(dictionary, "typedUrlsRegistered", true); |
832 CheckBool(dictionary, "showPassphrase", false); | 833 CheckBool(dictionary, "showPassphrase", false); |
833 CheckBool(dictionary, "usePassphrase", false); | 834 CheckBool(dictionary, "usePassphrase", false); |
834 CheckBool(dictionary, "passphraseFailed", false); | 835 CheckBool(dictionary, "passphraseFailed", false); |
835 CheckBool(dictionary, "encryptAllData", false); | 836 CheckBool(dictionary, "encryptAllData", false); |
836 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); | 837 CheckConfigDataTypeArguments(dictionary, SYNC_ALL_DATA, GetAllTypes()); |
837 } | 838 } |
838 | 839 |
839 TEST_F(SyncSetupHandlerTest, ShowSetupManuallySyncAll) { | 840 TEST_F(SyncHandlerTest, ShowSetupManuallySyncAll) { |
840 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 841 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
841 .WillRepeatedly(Return(false)); | 842 .WillRepeatedly(Return(false)); |
842 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 843 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
843 .WillRepeatedly(Return(false)); | 844 .WillRepeatedly(Return(false)); |
844 SetupInitializedProfileSyncService(); | 845 SetupInitializedProfileSyncService(); |
845 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 846 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
846 sync_prefs.SetKeepEverythingSynced(false); | 847 sync_prefs.SetKeepEverythingSynced(false); |
847 SetDefaultExpectationsForConfigPage(); | 848 SetDefaultExpectationsForConfigPage(); |
848 // This should display the sync setup dialog (not login). | 849 // This should display the sync setup dialog (not login). |
849 handler_->OpenSyncSetup(); | 850 handler_->OpenSyncSetup(); |
850 | 851 |
851 ExpectConfig(); | 852 ExpectConfig(); |
852 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 853 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
853 const base::DictionaryValue* dictionary = nullptr; | 854 const base::DictionaryValue* dictionary = nullptr; |
854 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 855 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
855 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); | 856 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, GetAllTypes()); |
856 } | 857 } |
857 | 858 |
858 TEST_F(SyncSetupHandlerTest, ShowSetupSyncForAllTypesIndividually) { | 859 TEST_F(SyncHandlerTest, ShowSetupSyncForAllTypesIndividually) { |
859 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); | 860 syncer::ModelTypeSet user_selectable_types = GetAllTypes(); |
860 syncer::ModelTypeSet::Iterator it; | 861 syncer::ModelTypeSet::Iterator it; |
861 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { | 862 for (it = user_selectable_types.First(); it.Good(); it.Inc()) { |
862 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 863 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
863 .WillRepeatedly(Return(false)); | 864 .WillRepeatedly(Return(false)); |
864 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 865 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
865 .WillRepeatedly(Return(false)); | 866 .WillRepeatedly(Return(false)); |
866 SetupInitializedProfileSyncService(); | 867 SetupInitializedProfileSyncService(); |
867 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 868 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
868 sync_prefs.SetKeepEverythingSynced(false); | 869 sync_prefs.SetKeepEverythingSynced(false); |
(...skipping 13 matching lines...) Expand all Loading... |
882 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 883 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
883 const base::DictionaryValue* dictionary = nullptr; | 884 const base::DictionaryValue* dictionary = nullptr; |
884 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 885 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
885 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); | 886 CheckConfigDataTypeArguments(dictionary, CHOOSE_WHAT_TO_SYNC, types); |
886 Mock::VerifyAndClearExpectations(mock_pss_); | 887 Mock::VerifyAndClearExpectations(mock_pss_); |
887 // Clean up so we can loop back to display the dialog again. | 888 // Clean up so we can loop back to display the dialog again. |
888 web_ui_.ClearTrackedCalls(); | 889 web_ui_.ClearTrackedCalls(); |
889 } | 890 } |
890 } | 891 } |
891 | 892 |
892 TEST_F(SyncSetupHandlerTest, ShowSetupGaiaPassphraseRequired) { | 893 TEST_F(SyncHandlerTest, ShowSetupGaiaPassphraseRequired) { |
893 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 894 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
894 .WillRepeatedly(Return(true)); | 895 .WillRepeatedly(Return(true)); |
895 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 896 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
896 .WillRepeatedly(Return(false)); | 897 .WillRepeatedly(Return(false)); |
897 SetupInitializedProfileSyncService(); | 898 SetupInitializedProfileSyncService(); |
898 SetDefaultExpectationsForConfigPage(); | 899 SetDefaultExpectationsForConfigPage(); |
899 | 900 |
900 // This should display the sync setup dialog (not login). | 901 // This should display the sync setup dialog (not login). |
901 handler_->OpenSyncSetup(); | 902 handler_->OpenSyncSetup(); |
902 | 903 |
903 ExpectConfig(); | 904 ExpectConfig(); |
904 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 905 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
905 const base::DictionaryValue* dictionary = nullptr; | 906 const base::DictionaryValue* dictionary = nullptr; |
906 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 907 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
907 CheckBool(dictionary, "showPassphrase", true); | 908 CheckBool(dictionary, "showPassphrase", true); |
908 CheckBool(dictionary, "usePassphrase", false); | 909 CheckBool(dictionary, "usePassphrase", false); |
909 CheckBool(dictionary, "passphraseFailed", false); | 910 CheckBool(dictionary, "passphraseFailed", false); |
910 } | 911 } |
911 | 912 |
912 TEST_F(SyncSetupHandlerTest, ShowSetupCustomPassphraseRequired) { | 913 TEST_F(SyncHandlerTest, ShowSetupCustomPassphraseRequired) { |
913 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 914 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
914 .WillRepeatedly(Return(true)); | 915 .WillRepeatedly(Return(true)); |
915 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 916 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
916 .WillRepeatedly(Return(true)); | 917 .WillRepeatedly(Return(true)); |
917 EXPECT_CALL(*mock_pss_, GetPassphraseType()) | 918 EXPECT_CALL(*mock_pss_, GetPassphraseType()) |
918 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); | 919 .WillRepeatedly(Return(syncer::CUSTOM_PASSPHRASE)); |
919 SetupInitializedProfileSyncService(); | 920 SetupInitializedProfileSyncService(); |
920 SetDefaultExpectationsForConfigPage(); | 921 SetDefaultExpectationsForConfigPage(); |
921 | 922 |
922 // This should display the sync setup dialog (not login). | 923 // This should display the sync setup dialog (not login). |
923 handler_->OpenSyncSetup(); | 924 handler_->OpenSyncSetup(); |
924 | 925 |
925 ExpectConfig(); | 926 ExpectConfig(); |
926 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 927 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
927 const base::DictionaryValue* dictionary = nullptr; | 928 const base::DictionaryValue* dictionary = nullptr; |
928 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 929 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
929 CheckBool(dictionary, "showPassphrase", true); | 930 CheckBool(dictionary, "showPassphrase", true); |
930 CheckBool(dictionary, "usePassphrase", true); | 931 CheckBool(dictionary, "usePassphrase", true); |
931 CheckBool(dictionary, "passphraseFailed", false); | 932 CheckBool(dictionary, "passphraseFailed", false); |
932 } | 933 } |
933 | 934 |
934 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAll) { | 935 TEST_F(SyncHandlerTest, ShowSetupEncryptAll) { |
935 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 936 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
936 .WillRepeatedly(Return(false)); | 937 .WillRepeatedly(Return(false)); |
937 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 938 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
938 .WillRepeatedly(Return(false)); | 939 .WillRepeatedly(Return(false)); |
939 SetupInitializedProfileSyncService(); | 940 SetupInitializedProfileSyncService(); |
940 SetDefaultExpectationsForConfigPage(); | 941 SetDefaultExpectationsForConfigPage(); |
941 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) | 942 EXPECT_CALL(*mock_pss_, IsEncryptEverythingEnabled()) |
942 .WillRepeatedly(Return(true)); | 943 .WillRepeatedly(Return(true)); |
943 | 944 |
944 // This should display the sync setup dialog (not login). | 945 // This should display the sync setup dialog (not login). |
945 handler_->OpenSyncSetup(); | 946 handler_->OpenSyncSetup(); |
946 | 947 |
947 ExpectConfig(); | 948 ExpectConfig(); |
948 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 949 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
949 const base::DictionaryValue* dictionary = nullptr; | 950 const base::DictionaryValue* dictionary = nullptr; |
950 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 951 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
951 CheckBool(dictionary, "encryptAllData", true); | 952 CheckBool(dictionary, "encryptAllData", true); |
952 } | 953 } |
953 | 954 |
954 TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) { | 955 TEST_F(SyncHandlerTest, ShowSetupEncryptAllDisallowed) { |
955 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 956 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
956 .WillRepeatedly(Return(false)); | 957 .WillRepeatedly(Return(false)); |
957 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 958 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
958 .WillRepeatedly(Return(false)); | 959 .WillRepeatedly(Return(false)); |
959 SetupInitializedProfileSyncService(); | 960 SetupInitializedProfileSyncService(); |
960 SetDefaultExpectationsForConfigPage(); | 961 SetDefaultExpectationsForConfigPage(); |
961 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 962 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
962 .WillRepeatedly(Return(false)); | 963 .WillRepeatedly(Return(false)); |
963 | 964 |
964 // This should display the sync setup dialog (not login). | 965 // This should display the sync setup dialog (not login). |
965 handler_->OpenSyncSetup(); | 966 handler_->OpenSyncSetup(); |
966 | 967 |
967 ExpectConfig(); | 968 ExpectConfig(); |
968 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; | 969 const content::TestWebUI::CallData& data = *web_ui_.call_data()[0]; |
969 const base::DictionaryValue* dictionary = nullptr; | 970 const base::DictionaryValue* dictionary = nullptr; |
970 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); | 971 ASSERT_TRUE(data.arg2()->GetAsDictionary(&dictionary)); |
971 CheckBool(dictionary, "encryptAllData", false); | 972 CheckBool(dictionary, "encryptAllData", false); |
972 CheckBool(dictionary, "encryptAllDataAllowed", false); | 973 CheckBool(dictionary, "encryptAllDataAllowed", false); |
973 } | 974 } |
974 | 975 |
975 TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) { | 976 TEST_F(SyncHandlerTest, TurnOnEncryptAllDisallowed) { |
976 std::string args = GetConfiguration( | 977 std::string args = GetConfiguration( |
977 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); | 978 NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA); |
978 base::ListValue list_args; | 979 base::ListValue list_args; |
979 list_args.Append(new base::StringValue(args)); | 980 list_args.Append(new base::StringValue(args)); |
980 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 981 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
981 .WillRepeatedly(Return(false)); | 982 .WillRepeatedly(Return(false)); |
982 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 983 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
983 .WillRepeatedly(Return(false)); | 984 .WillRepeatedly(Return(false)); |
984 SetupInitializedProfileSyncService(); | 985 SetupInitializedProfileSyncService(); |
985 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 986 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
986 .WillRepeatedly(Return(false)); | 987 .WillRepeatedly(Return(false)); |
987 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); | 988 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); |
988 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); | 989 EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _)); |
989 handler_->HandleConfigure(&list_args); | 990 handler_->HandleConfigure(&list_args); |
990 | 991 |
991 // Ensure that we navigated to the "done" state since we don't need a | 992 // Ensure that we navigated to the "done" state since we don't need a |
992 // passphrase. | 993 // passphrase. |
993 ExpectDone(); | 994 ExpectDone(); |
994 } | 995 } |
995 | 996 |
| 997 } // namespace settings |
OLD | NEW |