OLD | NEW |
---|---|
1 // Copyright 2015 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/settings/people_handler.h" | 5 #include "chrome/browser/ui/webui/settings/people_handler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 "Person 1", nullptr, base::UTF8ToUTF16("Person 1"), 0, std::string(), | 194 "Person 1", nullptr, base::UTF8ToUTF16("Person 1"), 0, std::string(), |
195 testing_factories); | 195 testing_factories); |
196 | 196 |
197 // Sign in the user. | 197 // Sign in the user. |
198 mock_signin_ = static_cast<SigninManagerBase*>( | 198 mock_signin_ = static_cast<SigninManagerBase*>( |
199 SigninManagerFactory::GetForProfile(profile_)); | 199 SigninManagerFactory::GetForProfile(profile_)); |
200 std::string username = GetTestUser(); | 200 std::string username = GetTestUser(); |
201 if (!username.empty()) | 201 if (!username.empty()) |
202 mock_signin_->SetAuthenticatedAccountInfo(username, username); | 202 mock_signin_->SetAuthenticatedAccountInfo(username, username); |
203 | 203 |
204 mock_pss_ = static_cast<ProfileSyncServiceMock*>( | 204 mock_pss_ = static_cast<browser_sync::ProfileSyncServiceMock*>( |
skym
2016/09/22 17:25:59
Again, unittest, using?
maxbogue
2016/09/22 19:41:15
Done.
| |
205 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 205 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
206 profile_, BuildMockProfileSyncService)); | 206 profile_, BuildMockProfileSyncService)); |
207 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); | 207 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); |
208 ON_CALL(*mock_pss_, GetPassphraseType()) | 208 ON_CALL(*mock_pss_, GetPassphraseType()) |
209 .WillByDefault(Return(syncer::PassphraseType::IMPLICIT_PASSPHRASE)); | 209 .WillByDefault(Return(syncer::PassphraseType::IMPLICIT_PASSPHRASE)); |
210 ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault( | 210 ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault( |
211 Return(base::Time())); | 211 Return(base::Time())); |
212 ON_CALL(*mock_pss_, GetRegisteredDataTypes()) | 212 ON_CALL(*mock_pss_, GetRegisteredDataTypes()) |
213 .WillByDefault(Return(syncer::ModelTypeSet())); | 213 .WillByDefault(Return(syncer::ModelTypeSet())); |
214 | 214 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 handler_->sync_startup_tracker_->OnStateChanged(); | 297 handler_->sync_startup_tracker_->OnStateChanged(); |
298 } | 298 } |
299 | 299 |
300 virtual std::string GetTestUser() { | 300 virtual std::string GetTestUser() { |
301 return std::string(kTestUser); | 301 return std::string(kTestUser); |
302 } | 302 } |
303 | 303 |
304 content::TestBrowserThreadBundle thread_bundle_; | 304 content::TestBrowserThreadBundle thread_bundle_; |
305 std::unique_ptr<TestingProfileManager> profile_manager_; | 305 std::unique_ptr<TestingProfileManager> profile_manager_; |
306 Profile* profile_; | 306 Profile* profile_; |
307 ProfileSyncServiceMock* mock_pss_; | 307 browser_sync::ProfileSyncServiceMock* mock_pss_; |
308 GoogleServiceAuthError error_; | 308 GoogleServiceAuthError error_; |
309 SigninManagerBase* mock_signin_; | 309 SigninManagerBase* mock_signin_; |
310 content::TestWebUI web_ui_; | 310 content::TestWebUI web_ui_; |
311 std::unique_ptr<TestingPeopleHandler> handler_; | 311 std::unique_ptr<TestingPeopleHandler> handler_; |
312 }; | 312 }; |
313 | 313 |
314 class PeopleHandlerFirstSigninTest : public PeopleHandlerTest { | 314 class PeopleHandlerFirstSigninTest : public PeopleHandlerTest { |
315 std::string GetTestUser() override { return std::string(); } | 315 std::string GetTestUser() override { return std::string(); } |
316 }; | 316 }; |
317 | 317 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 error_ = GoogleServiceAuthError::AuthErrorNone(); | 436 error_ = GoogleServiceAuthError::AuthErrorNone(); |
437 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) | 437 EXPECT_CALL(*mock_pss_, IsBackendInitialized()) |
438 .WillOnce(Return(false)) | 438 .WillOnce(Return(false)) |
439 .WillRepeatedly(Return(true)); | 439 .WillRepeatedly(Return(true)); |
440 SetDefaultExpectationsForConfigPage(); | 440 SetDefaultExpectationsForConfigPage(); |
441 handler_->OpenSyncSetup(false /* creating_supervised_user */); | 441 handler_->OpenSyncSetup(false /* creating_supervised_user */); |
442 | 442 |
443 // It's important to tell sync the user cancelled the setup flow before we | 443 // It's important to tell sync the user cancelled the setup flow before we |
444 // tell it we're through with the setup progress. | 444 // tell it we're through with the setup progress. |
445 testing::InSequence seq; | 445 testing::InSequence seq; |
446 EXPECT_CALL(*mock_pss_, RequestStop(ProfileSyncService::CLEAR_DATA)); | 446 EXPECT_CALL(*mock_pss_, |
447 RequestStop(browser_sync::ProfileSyncService::CLEAR_DATA)); | |
447 EXPECT_CALL(*mock_pss_, OnSetupInProgressHandleDestroyed()); | 448 EXPECT_CALL(*mock_pss_, OnSetupInProgressHandleDestroyed()); |
448 | 449 |
449 handler_->CloseSyncSetup(); | 450 handler_->CloseSyncSetup(); |
450 EXPECT_EQ(NULL, | 451 EXPECT_EQ(NULL, |
451 LoginUIServiceFactory::GetForProfile( | 452 LoginUIServiceFactory::GetForProfile( |
452 profile_)->current_login_ui()); | 453 profile_)->current_login_ui()); |
453 } | 454 } |
454 | 455 |
455 TEST_F(PeopleHandlerTest, | 456 TEST_F(PeopleHandlerTest, |
456 DisplayConfigureWithBackendDisabledAndSigninFailed) { | 457 DisplayConfigureWithBackendDisabledAndSigninFailed) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 base::ListValue list_args; | 581 base::ListValue list_args; |
581 list_args.AppendString(kTestCallbackId); | 582 list_args.AppendString(kTestCallbackId); |
582 list_args.AppendString(args); | 583 list_args.AppendString(args); |
583 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) | 584 EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption()) |
584 .WillRepeatedly(Return(false)); | 585 .WillRepeatedly(Return(false)); |
585 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) | 586 EXPECT_CALL(*mock_pss_, IsPassphraseRequired()) |
586 .WillRepeatedly(Return(false)); | 587 .WillRepeatedly(Return(false)); |
587 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) | 588 EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) |
588 .WillRepeatedly(Return(false)); | 589 .WillRepeatedly(Return(false)); |
589 SetupInitializedProfileSyncService(); | 590 SetupInitializedProfileSyncService(); |
590 EXPECT_CALL(*mock_pss_, | 591 EXPECT_CALL(*mock_pss_, SetEncryptionPassphrase( |
591 SetEncryptionPassphrase("custom_passphrase", | 592 "custom_passphrase", |
592 ProfileSyncService::EXPLICIT)); | 593 browser_sync::ProfileSyncService::EXPLICIT)); |
593 | 594 |
594 handler_->HandleSetEncryption(&list_args); | 595 handler_->HandleSetEncryption(&list_args); |
595 ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus); | 596 ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus); |
596 } | 597 } |
597 | 598 |
598 TEST_F(PeopleHandlerTest, EnterWrongExistingPassphrase) { | 599 TEST_F(PeopleHandlerTest, EnterWrongExistingPassphrase) { |
599 base::DictionaryValue dict; | 600 base::DictionaryValue dict; |
600 dict.SetBoolean("setNewPassphrase", false); | 601 dict.SetBoolean("setNewPassphrase", false); |
601 std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), | 602 std::string args = GetConfiguration(&dict, SYNC_ALL_DATA, GetAllTypes(), |
602 "invalid_passphrase", ENCRYPT_ALL_DATA); | 603 "invalid_passphrase", ENCRYPT_ALL_DATA); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
908 SetupInitializedProfileSyncService(); | 909 SetupInitializedProfileSyncService(); |
909 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) | 910 EXPECT_CALL(*mock_pss_, IsEncryptEverythingAllowed()) |
910 .WillRepeatedly(Return(false)); | 911 .WillRepeatedly(Return(false)); |
911 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); | 912 EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0); |
912 handler_->HandleSetEncryption(&list_args); | 913 handler_->HandleSetEncryption(&list_args); |
913 | 914 |
914 ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus); | 915 ExpectPageStatusResponse(PeopleHandler::kConfigurePageStatus); |
915 } | 916 } |
916 | 917 |
917 } // namespace settings | 918 } // namespace settings |
OLD | NEW |