diff options
Diffstat (limited to 'chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc')
-rw-r--r-- | chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc index b3d39140ff4..c1b13af01e6 100644 --- a/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc +++ b/chromium/chrome/browser/ui/webui/signin/dice_turn_sync_on_helper_unittest.cc @@ -46,8 +46,6 @@ using ::testing::AtLeast; using ::testing::Return; -using namespace unified_consent; - class DiceTurnSyncOnHelperTestBase; namespace { @@ -103,10 +101,11 @@ class UnittestProfileManager : public ProfileManagerWithoutInit { : ProfileManagerWithoutInit(user_data_dir) {} protected: - Profile* CreateProfileHelper(const base::FilePath& file_path) override { - if (!base::PathExists(file_path) && !base::CreateDirectory(file_path)) + std::unique_ptr<Profile> CreateProfileHelper( + const base::FilePath& path) override { + if (!base::PathExists(path) && !base::CreateDirectory(path)) return nullptr; - return BuildTestingProfile(file_path, /*delegate=*/nullptr).release(); + return BuildTestingProfile(path, /*delegate=*/nullptr); } std::unique_ptr<Profile> CreateProfileAsyncHelper( @@ -140,7 +139,7 @@ class FakeUserPolicySigninService : public policy::UserPolicySigninService { void set_dm_token(const std::string& dm_token) { dm_token_ = dm_token; } void set_client_id(const std::string& client_id) { client_id_ = client_id; } - void set_account(const std::string& account_id, const std::string& email) { + void set_account(const CoreAccountId& account_id, const std::string& email) { account_id_ = account_id; email_ = email; } @@ -148,7 +147,7 @@ class FakeUserPolicySigninService : public policy::UserPolicySigninService { // policy::UserPolicySigninService: void RegisterForPolicyWithAccountId( const std::string& username, - const std::string& account_id, + const CoreAccountId& account_id, const PolicyRegistrationCallback& callback) override { EXPECT_EQ(email_, username); EXPECT_EQ(account_id_, account_id); @@ -168,7 +167,7 @@ class FakeUserPolicySigninService : public policy::UserPolicySigninService { private: std::string dm_token_; std::string client_id_; - std::string account_id_; + CoreAccountId account_id_; std::string email_; }; @@ -237,7 +236,7 @@ class DiceTurnSyncOnHelperTestBase : public testing::Test { signin::IdentityManager* identity_manager() { return identity_test_env()->identity_manager(); } - const std::string& account_id() { return account_id_; } + const CoreAccountId& account_id() { return account_id_; } FakeUserPolicySigninService* user_policy_signin_service() { return user_policy_signin_service_; } @@ -272,7 +271,7 @@ class DiceTurnSyncOnHelperTestBase : public testing::Test { user_policy_signin_service_->set_account(account_id_, kEnterpriseEmail); } - void UseInvalidAccount() { account_id_ = "invalid_account"; } + void UseInvalidAccount() { account_id_ = CoreAccountId("invalid_account"); } void SetExpectationsForSyncStartupCompleted() { syncer::MockSyncService* mock_sync_service = GetMockSyncService(); @@ -408,7 +407,7 @@ class DiceTurnSyncOnHelperTestBase : public testing::Test { content::BrowserTaskEnvironment task_environment_; base::ScopedTempDir temp_dir_; ScopedTestingLocalState local_state_; - std::string account_id_; + CoreAccountId account_id_; std::unique_ptr<TestingProfile> profile_; std::unique_ptr<IdentityTestEnvironmentProfileAdaptor> identity_test_env_profile_adaptor_; @@ -442,12 +441,13 @@ class DiceTurnSyncOnHelperTestWithUnifiedConsent : public DiceTurnSyncOnHelperTestBase { public: DiceTurnSyncOnHelperTestWithUnifiedConsent() - : scoped_unified_consent_(UnifiedConsentFeatureState::kEnabled) {} + : scoped_unified_consent_( + unified_consent::UnifiedConsentFeatureState::kEnabled) {} ~DiceTurnSyncOnHelperTestWithUnifiedConsent() override {} private: ScopedAccountConsistencyDice scoped_dice_; - ScopedUnifiedConsent scoped_unified_consent_; + unified_consent::ScopedUnifiedConsent scoped_unified_consent_; }; // TestDiceTurnSyncOnHelperDelegate implementation. @@ -654,8 +654,9 @@ TEST_F(DiceTurnSyncOnHelperTest, UndoSync) { // Set expectations. expected_sync_confirmation_shown_ = true; SetExpectationsForSyncStartupCompleted(); - EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(), - SetFirstSetupComplete()) + EXPECT_CALL( + *GetMockSyncService()->GetMockUserSettings(), + SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW)) .Times(0); // Signin flow. @@ -674,8 +675,9 @@ TEST_F(DiceTurnSyncOnHelperTest, ConfigureSync) { expected_sync_confirmation_shown_ = true; expected_sync_settings_shown_ = true; SetExpectationsForSyncStartupCompleted(); - EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(), - SetFirstSetupComplete()) + EXPECT_CALL( + *GetMockSyncService()->GetMockUserSettings(), + SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW)) .Times(0); // Configure the test. @@ -696,8 +698,9 @@ TEST_F(DiceTurnSyncOnHelperTest, StartSync) { // Set expectations. expected_sync_confirmation_shown_ = true; SetExpectationsForSyncStartupCompleted(); - EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(), - SetFirstSetupComplete()) + EXPECT_CALL( + *GetMockSyncService()->GetMockUserSettings(), + SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW)) .Times(1); // Configure the test. sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult:: @@ -720,8 +723,9 @@ TEST_F(DiceTurnSyncOnHelperTest, ShowSyncDialogForEndConsumerAccount) { sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult:: SYNC_WITH_DEFAULT_SETTINGS; SetExpectationsForSyncStartupCompleted(); - EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(), - SetFirstSetupComplete()) + EXPECT_CALL( + *GetMockSyncService()->GetMockUserSettings(), + SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW)) .Times(1); // Signin flow. @@ -738,21 +742,23 @@ TEST_F(DiceTurnSyncOnHelperTest, ShowSyncDialogForEndConsumerAccount) { // Tests that the user enabled unified consent, TEST_F(DiceTurnSyncOnHelperTestWithUnifiedConsent, ShowSyncDialogForEndConsumerAccount_UnifiedConsentEnabled) { - ASSERT_TRUE(IsUnifiedConsentFeatureEnabled()); + ASSERT_TRUE(unified_consent::IsUnifiedConsentFeatureEnabled()); // Set expectations. expected_sync_confirmation_shown_ = true; sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult:: SYNC_WITH_DEFAULT_SETTINGS; SetExpectationsForSyncStartupCompleted(); - EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(), - SetFirstSetupComplete()) + EXPECT_CALL( + *GetMockSyncService()->GetMockUserSettings(), + SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW)) .Times(1); PrefService* pref_service = profile()->GetPrefs(); - std::unique_ptr<UrlKeyedDataCollectionConsentHelper> - url_keyed_collection_helper = UrlKeyedDataCollectionConsentHelper:: - NewAnonymizedDataCollectionConsentHelper( - pref_service, - ProfileSyncServiceFactory::GetForProfile(profile())); + std::unique_ptr<unified_consent::UrlKeyedDataCollectionConsentHelper> + url_keyed_collection_helper = + unified_consent::UrlKeyedDataCollectionConsentHelper:: + NewAnonymizedDataCollectionConsentHelper( + pref_service, + ProfileSyncServiceFactory::GetForProfile(profile())); EXPECT_FALSE(url_keyed_collection_helper->IsEnabled()); // Signin flow. @@ -792,8 +798,9 @@ TEST_F(DiceTurnSyncOnHelperTest, // Simulate that sync startup has completed. expected_sync_confirmation_shown_ = true; - EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(), - SetFirstSetupComplete()) + EXPECT_CALL( + *GetMockSyncService()->GetMockUserSettings(), + SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW)) .Times(1); sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult:: SYNC_WITH_DEFAULT_SETTINGS; @@ -826,8 +833,9 @@ TEST_F(DiceTurnSyncOnHelperTest, // Simulate that sync startup has failed. expected_sync_confirmation_shown_ = true; - EXPECT_CALL(*GetMockSyncService()->GetMockUserSettings(), - SetFirstSetupComplete()) + EXPECT_CALL( + *GetMockSyncService()->GetMockUserSettings(), + SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource::BASIC_FLOW)) .Times(1); sync_confirmation_result_ = LoginUIService::SyncConfirmationUIClosedResult:: SYNC_WITH_DEFAULT_SETTINGS; |