From eae4077d2f3445872406ab48e3bd1436cc022068 Mon Sep 17 00:00:00 2001 From: Terry Mancey Date: Thu, 5 Oct 2023 12:33:00 -0500 Subject: [PATCH] Rename Brave Ads Set*Pref unit test helpers to Set*PrefValue --- ...rmation_user_data_builder_unittest_util.cc | 3 +- .../statement/statement_util_unittest.cc | 2 +- .../diagnostic_id_user_data_unittest.cc | 10 +++-- .../redeem_payment_tokens_unittest.cc | 10 ++--- .../common/unittest/unittest_pref_util.cc | 20 +++++----- .../common/unittest/unittest_pref_util.h | 24 +++++------ ...y_client_migration_issue_23794_unittest.cc | 2 +- .../legacy_client_migration_unittest.cc | 2 +- .../legacy_client_migration_util_unittest.cc | 4 +- .../legacy_confirmation_migration_unittest.cc | 2 +- ...cy_confirmation_migration_util_unittest.cc | 4 +- ..._rewards_migration_issue_25384_unittest.cc | 2 +- ...ision_targeting_exclusion_rule_unittest.cc | 40 +++++++++---------- .../internal/settings/settings_unittest.cc | 2 +- .../settings/settings_unittest_util.cc | 20 +++++----- .../subdivision_targeting_unittest.cc | 24 ++++++----- ...uld_serve_at_regular_intervals_unittest.cc | 2 +- 17 files changed, 89 insertions(+), 84 deletions(-) diff --git a/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_unittest_util.cc b/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_unittest_util.cc index eda2d1d2267..16494977ba9 100644 --- a/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_unittest_util.cc +++ b/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_unittest_util.cc @@ -16,7 +16,8 @@ namespace brave_ads { namespace { void MockDiagnosticId() { - SetStringPref(prefs::kDiagnosticId, "c1298fde-7fdb-401f-a3ce-0b58fe86e6e2"); + SetStringPrefValue(prefs::kDiagnosticId, + "c1298fde-7fdb-401f-a3ce-0b58fe86e6e2"); } } // namespace diff --git a/components/brave_ads/core/internal/account/statement/statement_util_unittest.cc b/components/brave_ads/core/internal/account/statement/statement_util_unittest.cc index 660dd5784ca..470068f8dcf 100644 --- a/components/brave_ads/core/internal/account/statement/statement_util_unittest.cc +++ b/components/brave_ads/core/internal/account/statement/statement_util_unittest.cc @@ -24,7 +24,7 @@ TEST_F(BraveAdsStatementUtilTest, GetNextPaymentDate) { const base::Time next_token_redemption_at = TimeFromString("5 February 2020", /*is_local*/ false); - SetTimePref(prefs::kNextTokenRedemptionAt, next_token_redemption_at); + SetTimePrefValue(prefs::kNextTokenRedemptionAt, next_token_redemption_at); const TransactionList transactions; diff --git a/components/brave_ads/core/internal/account/user_data/dynamic/diagnostic_id_user_data_unittest.cc b/components/brave_ads/core/internal/account/user_data/dynamic/diagnostic_id_user_data_unittest.cc index 10ec3b771f2..5f513ee0b12 100644 --- a/components/brave_ads/core/internal/account/user_data/dynamic/diagnostic_id_user_data_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/dynamic/diagnostic_id_user_data_unittest.cc @@ -20,7 +20,8 @@ class BraveAdsDiagnosticIdUserDataTest : public UnitTestBase {}; TEST_F(BraveAdsDiagnosticIdUserDataTest, BuildDiagnosticIdUserDataForRewardsUser) { // Arrange - SetStringPref(prefs::kDiagnosticId, "c1298fde-7fdb-401f-a3ce-0b58fe86e6e2"); + SetStringPrefValue(prefs::kDiagnosticId, + "c1298fde-7fdb-401f-a3ce-0b58fe86e6e2"); // Act @@ -38,7 +39,8 @@ TEST_F(BraveAdsDiagnosticIdUserDataTest, // Arrange DisableBraveRewardsForTesting(); - SetStringPref(prefs::kDiagnosticId, "c1298fde-7fdb-401f-a3ce-0b58fe86e6e2"); + SetStringPrefValue(prefs::kDiagnosticId, + "c1298fde-7fdb-401f-a3ce-0b58fe86e6e2"); // Act @@ -49,7 +51,7 @@ TEST_F(BraveAdsDiagnosticIdUserDataTest, TEST_F(BraveAdsDiagnosticIdUserDataTest, DoNotBuildDiagnosticUserDataIfDiagnosticIdIsInvalid) { // Arrange - SetStringPref(prefs::kDiagnosticId, "INVALID"); + SetStringPrefValue(prefs::kDiagnosticId, "INVALID"); // Act @@ -60,7 +62,7 @@ TEST_F(BraveAdsDiagnosticIdUserDataTest, TEST_F(BraveAdsDiagnosticIdUserDataTest, DoNotBuildDiagnosticIdUserDataIfDiagnosticIdIsEmpty) { // Arrange - SetStringPref(prefs::kDiagnosticId, ""); + SetStringPrefValue(prefs::kDiagnosticId, ""); // Act diff --git a/components/brave_ads/core/internal/account/utility/redeem_payment_tokens/redeem_payment_tokens_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_payment_tokens/redeem_payment_tokens_unittest.cc index baa19aa1ce4..2c815a3544d 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_payment_tokens/redeem_payment_tokens_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_payment_tokens/redeem_payment_tokens_unittest.cc @@ -46,7 +46,7 @@ TEST_F(BraveAdsRedeemPaymentTokensTest, RedeemPaymentTokens) { {{net::HTTP_OK, BuildRedeemPaymentTokensUrlResponseBodyForTesting()}}}}; MockUrlResponses(ads_client_mock_, url_responses); - SetTimePref(prefs::kNextTokenRedemptionAt, Now()); + SetTimePrefValue(prefs::kNextTokenRedemptionAt, Now()); SetPaymentTokensForTesting(/*count*/ 1); @@ -79,7 +79,7 @@ TEST_F(BraveAdsRedeemPaymentTokensTest, RedeemPaymentTokensMultipleTimes) { {net::HTTP_OK, BuildRedeemPaymentTokensUrlResponseBodyForTesting()}}}}; MockUrlResponses(ads_client_mock_, url_responses); - SetTimePref(prefs::kNextTokenRedemptionAt, Now()); + SetTimePrefValue(prefs::kNextTokenRedemptionAt, Now()); const PaymentTokenList payment_tokens = SetPaymentTokensForTesting(/*count*/ 1); @@ -116,7 +116,7 @@ TEST_F(BraveAdsRedeemPaymentTokensTest, ScheduleNextTokenRedemption) { {{net::HTTP_OK, BuildRedeemPaymentTokensUrlResponseBodyForTesting()}}}}; MockUrlResponses(ads_client_mock_, url_responses); - SetTimePref(prefs::kNextTokenRedemptionAt, Now()); + SetTimePrefValue(prefs::kNextTokenRedemptionAt, Now()); SetPaymentTokensForTesting(/*count*/ 1); @@ -142,7 +142,7 @@ TEST_F(BraveAdsRedeemPaymentTokensTest, ScheduleNextTokenRedemption) { TEST_F(BraveAdsRedeemPaymentTokensTest, NoPaymentTokens) { // Arrange - SetTimePref(prefs::kNextTokenRedemptionAt, Now()); + SetTimePrefValue(prefs::kNextTokenRedemptionAt, Now()); // Act EXPECT_CALL(ads_client_mock_, UrlRequest).Times(0); @@ -176,7 +176,7 @@ TEST_F(BraveAdsRedeemPaymentTokensTest, Retry) { {net::HTTP_OK, BuildRedeemPaymentTokensUrlResponseBodyForTesting()}}}}; MockUrlResponses(ads_client_mock_, url_responses); - SetTimePref(prefs::kNextTokenRedemptionAt, Now()); + SetTimePrefValue(prefs::kNextTokenRedemptionAt, Now()); SetPaymentTokensForTesting(/*count*/ 1); diff --git a/components/brave_ads/core/internal/common/unittest/unittest_pref_util.cc b/components/brave_ads/core/internal/common/unittest/unittest_pref_util.cc index 00461b2ec7d..540a21e3917 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_pref_util.cc +++ b/components/brave_ads/core/internal/common/unittest/unittest_pref_util.cc @@ -12,48 +12,48 @@ namespace brave_ads { -void SetBooleanPref(const std::string& path, const bool value) { +void SetBooleanPrefValue(const std::string& path, const bool value) { SetPrefValue(path, base::NumberToString(static_cast(value))); } -void SetIntegerPref(const std::string& path, const int value) { +void SetIntegerPrefValue(const std::string& path, const int value) { SetPrefValue(path, base::NumberToString(static_cast(value))); } -void SetDoublePref(const std::string& path, const double value) { +void SetDoublePrefValue(const std::string& path, const double value) { SetPrefValue(path, base::NumberToString(static_cast(value))); } -void SetStringPref(const std::string& path, const std::string& value) { +void SetStringPrefValue(const std::string& path, const std::string& value) { SetPrefValue(path, value); } -void SetInt64Pref(const std::string& path, const int64_t value) { +void SetInt64PrefValue(const std::string& path, const int64_t value) { SetPrefValue(path, base::NumberToString(static_cast(value))); } -void SetUint64Pref(const std::string& path, const uint64_t value) { +void SetUint64PrefValue(const std::string& path, const uint64_t value) { SetPrefValue(path, base::NumberToString(static_cast(value))); } -void SetDictPref(const std::string& path, base::Value::Dict value) { +void SetDictPrefValue(const std::string& path, base::Value::Dict value) { std::string json; CHECK(base::JSONWriter::Write(value, &json)); SetPrefValue(path, json); } -void SetListPref(const std::string& path, base::Value::List value) { +void SetListPrefValue(const std::string& path, base::Value::List value) { std::string json; CHECK(base::JSONWriter::Write(value, &json)); SetPrefValue(path, json); } -void SetTimePref(const std::string& path, const base::Time value) { +void SetTimePrefValue(const std::string& path, const base::Time value) { SetPrefValue(path, base::NumberToString( value.ToDeltaSinceWindowsEpoch().InMicroseconds())); } -void SetLocalStatePref(const std::string& path, const std::string& value) { +void SetLocalStatePrefValue(const std::string& path, const std::string& value) { SetPrefValue(path, value); } diff --git a/components/brave_ads/core/internal/common/unittest/unittest_pref_util.h b/components/brave_ads/core/internal/common/unittest/unittest_pref_util.h index 5dce5416cde..bcb070fabf9 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_pref_util.h +++ b/components/brave_ads/core/internal/common/unittest/unittest_pref_util.h @@ -17,18 +17,18 @@ class Time; namespace brave_ads { -// Unlike |ads_client_mock_->Set*Pref| in |UnitTestBase|, |Set*Pref| will not -// notify observers. -void SetBooleanPref(const std::string& path, bool value); -void SetIntegerPref(const std::string& path, int value); -void SetDoublePref(const std::string& path, double value); -void SetStringPref(const std::string& path, const std::string& value); -void SetInt64Pref(const std::string& path, int64_t value); -void SetUint64Pref(const std::string& path, uint64_t value); -void SetDictPref(const std::string& path, base::Value::Dict value = {}); -void SetListPref(const std::string& path, base::Value::List value = {}); -void SetTimePref(const std::string& path, base::Time value); -void SetLocalStatePref(const std::string& path, const std::string& value); +// Unlike |ads_client_mock_->Set*Pref| in |UnitTestBase|, |Set*PrefValue| will +// not notify observers. +void SetBooleanPrefValue(const std::string& path, bool value); +void SetIntegerPrefValue(const std::string& path, int value); +void SetDoublePrefValue(const std::string& path, double value); +void SetStringPrefValue(const std::string& path, const std::string& value); +void SetInt64PrefValue(const std::string& path, int64_t value); +void SetUint64PrefValue(const std::string& path, uint64_t value); +void SetDictPrefValue(const std::string& path, base::Value::Dict value = {}); +void SetListPrefValue(const std::string& path, base::Value::List value = {}); +void SetTimePrefValue(const std::string& path, base::Time value); +void SetLocalStatePrefValue(const std::string& path, const std::string& value); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_issue_23794_unittest.cc b/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_issue_23794_unittest.cc index 610abd45eee..a3a2e032023 100644 --- a/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_issue_23794_unittest.cc +++ b/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_issue_23794_unittest.cc @@ -23,7 +23,7 @@ constexpr char kClientIssue23794Filename[] = "client_issue_23794.json"; class BraveAdsLegacyClientMigrationIssue23794Test : public UnitTestBase { protected: void SetUpMocks() override { - SetBooleanPref(prefs::kHasMigratedClientState, false); + SetBooleanPrefValue(prefs::kHasMigratedClientState, false); } }; diff --git a/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_unittest.cc b/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_unittest.cc index 6d556647ae5..d41afe0859c 100644 --- a/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_unittest.cc +++ b/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_unittest.cc @@ -23,7 +23,7 @@ constexpr char kInvalidJsonFilename[] = "invalid.json"; class BraveAdsLegacyClientMigrationTest : public UnitTestBase { protected: void SetUpMocks() override { - SetBooleanPref(prefs::kHasMigratedClientState, false); + SetBooleanPrefValue(prefs::kHasMigratedClientState, false); } }; diff --git a/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_util_unittest.cc b/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_util_unittest.cc index 595b3632cb5..cd5aba4a483 100644 --- a/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_util_unittest.cc +++ b/components/brave_ads/core/internal/legacy_migration/client/legacy_client_migration_util_unittest.cc @@ -17,7 +17,7 @@ class BraveAdsLegacyClientMigrationUtilTest : public UnitTestBase {}; TEST_F(BraveAdsLegacyClientMigrationUtilTest, HasMigrated) { // Arrange - SetBooleanPref(prefs::kHasMigratedClientState, true); + SetBooleanPrefValue(prefs::kHasMigratedClientState, true); // Act @@ -27,7 +27,7 @@ TEST_F(BraveAdsLegacyClientMigrationUtilTest, HasMigrated) { TEST_F(BraveAdsLegacyClientMigrationUtilTest, HasNotMigrated) { // Arrange - SetBooleanPref(prefs::kHasMigratedClientState, false); + SetBooleanPrefValue(prefs::kHasMigratedClientState, false); // Act diff --git a/components/brave_ads/core/internal/legacy_migration/confirmations/legacy_confirmation_migration_unittest.cc b/components/brave_ads/core/internal/legacy_migration/confirmations/legacy_confirmation_migration_unittest.cc index 954600d292d..a0b13fb1bda 100644 --- a/components/brave_ads/core/internal/legacy_migration/confirmations/legacy_confirmation_migration_unittest.cc +++ b/components/brave_ads/core/internal/legacy_migration/confirmations/legacy_confirmation_migration_unittest.cc @@ -24,7 +24,7 @@ constexpr char kInvalidJsonFilename[] = "invalid.json"; class BraveAdsLegacyConfirmationMigrationTest : public UnitTestBase { protected: void SetUpMocks() override { - SetBooleanPref(prefs::kHasMigratedConfirmationState, false); + SetBooleanPrefValue(prefs::kHasMigratedConfirmationState, false); } }; diff --git a/components/brave_ads/core/internal/legacy_migration/confirmations/legacy_confirmation_migration_util_unittest.cc b/components/brave_ads/core/internal/legacy_migration/confirmations/legacy_confirmation_migration_util_unittest.cc index 082d3e4b0b7..a7a633116fe 100644 --- a/components/brave_ads/core/internal/legacy_migration/confirmations/legacy_confirmation_migration_util_unittest.cc +++ b/components/brave_ads/core/internal/legacy_migration/confirmations/legacy_confirmation_migration_util_unittest.cc @@ -17,7 +17,7 @@ class BraveAdsLegacyConfirmationMigrationUtilTest : public UnitTestBase {}; TEST_F(BraveAdsLegacyConfirmationMigrationUtilTest, HasMigrated) { // Arrange - SetBooleanPref(prefs::kHasMigratedConfirmationState, true); + SetBooleanPrefValue(prefs::kHasMigratedConfirmationState, true); // Act @@ -27,7 +27,7 @@ TEST_F(BraveAdsLegacyConfirmationMigrationUtilTest, HasMigrated) { TEST_F(BraveAdsLegacyConfirmationMigrationUtilTest, HasNotMigrated) { // Arrange - SetBooleanPref(prefs::kHasMigratedConfirmationState, false); + SetBooleanPrefValue(prefs::kHasMigratedConfirmationState, false); // Act diff --git a/components/brave_ads/core/internal/legacy_migration/rewards/legacy_rewards_migration_issue_25384_unittest.cc b/components/brave_ads/core/internal/legacy_migration/rewards/legacy_rewards_migration_issue_25384_unittest.cc index f507c542d8d..4e1a3adb68d 100644 --- a/components/brave_ads/core/internal/legacy_migration/rewards/legacy_rewards_migration_issue_25384_unittest.cc +++ b/components/brave_ads/core/internal/legacy_migration/rewards/legacy_rewards_migration_issue_25384_unittest.cc @@ -31,7 +31,7 @@ class BraveAdsLegacyRewardsMigrationIssue25384Test : public UnitTestBase { TEST_F(BraveAdsLegacyRewardsMigrationIssue25384Test, Migrate) { // Arrange - SetBooleanPref(prefs::kHasMigratedRewardsState, false); + SetBooleanPrefValue(prefs::kHasMigratedRewardsState, false); base::MockCallback callback; EXPECT_CALL(callback, Run(/*success*/ true)); diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule_unittest.cc index adb06161d1c..e4cfd01edb6 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule_unittest.cc @@ -139,7 +139,7 @@ TEST_P( BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldIncludeIfSubdivisionTargetingIsNotAllowedForGeoTargetWithNoRegion) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, false); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, false); CreativeAdInfo creative_ad; creative_ad.creative_set_id = kCreativeSetId; @@ -154,7 +154,7 @@ TEST_P( TEST_P(BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldIncludeIfSubdivisionTargetingIsSupportedAndAutoDetected) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); MockUrlResponseForTestParam(); @@ -174,7 +174,7 @@ TEST_P( BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldIncludeIfSubdivisionTargetingIsSupportedAndAutoDetectedForMultipleGeoTargets) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); MockUrlResponseForTestParam(); @@ -195,7 +195,7 @@ TEST_P( BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldIncludeIfSubdivisionTargetingIsSupportedAndAutoDetectedForGeoTargetWithNoRegion) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); MockUrlResponseForTestParam(); @@ -215,10 +215,10 @@ TEST_P( BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldIncludeIfSubdivisionTargetingIsSupportedAndSubdivisionWasManuallySelected) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); - SetStringPref(prefs::kSubdivisionTargetingSubdivision, - BuildSubdivisionForTestParam()); + SetStringPrefValue(prefs::kSubdivisionTargetingSubdivision, + BuildSubdivisionForTestParam()); MockUrlResponseForTestParam(); @@ -238,10 +238,10 @@ TEST_P( BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldIncludeIfSubdivisionTargetingIsSupportedAndSubdivisionWasManuallySelectedForMultipleGeoTargets) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); - SetStringPref(prefs::kSubdivisionTargetingSubdivision, - BuildSubdivisionForTestParam()); + SetStringPrefValue(prefs::kSubdivisionTargetingSubdivision, + BuildSubdivisionForTestParam()); MockUrlResponseForTestParam(); @@ -262,10 +262,10 @@ TEST_P( BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldIncludeIfSubdivisionTargetingIsSupportedAndManuallySelectedForGeoTargetWithNoRegion) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); - SetStringPref(prefs::kSubdivisionTargetingSubdivision, - BuildSubdivisionForTestParam()); + SetStringPrefValue(prefs::kSubdivisionTargetingSubdivision, + BuildSubdivisionForTestParam()); MockUrlResponseForTestParam(); @@ -284,7 +284,7 @@ TEST_P( TEST_P(BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldExcludeIfSubdivisionTargetingIsSupportedForUnsupportedGeoTarget) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); MockUrlResponseForTestParam(); @@ -303,7 +303,7 @@ TEST_P( BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldExcludeIfSubdivisionTargetingIsNotSupportedForSubdivisionGeoTarget) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); MockUrlResponseForTestParam(); @@ -324,7 +324,7 @@ TEST_P( BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldIncludeIfSubdivisionTargetingIsNotSupportedForNonSubdivisionGeoTarget) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); const URLResponseMap url_responses = { {BuildSubdivisionUrlPath(), @@ -348,9 +348,9 @@ TEST_P( TEST_P(BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldExcludeIfSubdivisionTargetingIsDisabledForSubdivisionGeoTarget) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); - SetStringPref(prefs::kSubdivisionTargetingSubdivision, "DISABLED"); + SetStringPrefValue(prefs::kSubdivisionTargetingSubdivision, "DISABLED"); MockUrlResponseForTestParam(); @@ -370,9 +370,9 @@ TEST_P( BraveAdsSubdivisionTargetingExclusionRuleTest, ShouldIncludeIfSubdivisionTargetingIsDisabledForNonSubdivisionGeoTarget) { // Arrange - SetBooleanPref(prefs::kShouldAllowSubdivisionTargeting, true); + SetBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, true); - SetStringPref(prefs::kSubdivisionTargetingSubdivision, "DISABLED"); + SetStringPrefValue(prefs::kSubdivisionTargetingSubdivision, "DISABLED"); MockUrlResponseForTestParam(); diff --git a/components/brave_ads/core/internal/settings/settings_unittest.cc b/components/brave_ads/core/internal/settings/settings_unittest.cc index 0258ead6b55..eeb6bc7b72b 100644 --- a/components/brave_ads/core/internal/settings/settings_unittest.cc +++ b/components/brave_ads/core/internal/settings/settings_unittest.cc @@ -100,7 +100,7 @@ TEST_F(BraveAdsSettingsTest, MaximumNotificationAdsPerHour) { scoped_feature_list.InitAndEnableFeatureWithParameters( kNotificationAdFeature, {{"default_ads_per_hour", "2"}}); - SetInt64Pref(prefs::kMaximumNotificationAdsPerHour, 3); + SetInt64PrefValue(prefs::kMaximumNotificationAdsPerHour, 3); // Act diff --git a/components/brave_ads/core/internal/settings/settings_unittest_util.cc b/components/brave_ads/core/internal/settings/settings_unittest_util.cc index e627428fd37..12f9c36ca30 100644 --- a/components/brave_ads/core/internal/settings/settings_unittest_util.cc +++ b/components/brave_ads/core/internal/settings/settings_unittest_util.cc @@ -14,28 +14,28 @@ namespace brave_ads { void DisableBraveRewardsForTesting() { - SetBooleanPref(brave_rewards::prefs::kEnabled, false); + SetBooleanPrefValue(brave_rewards::prefs::kEnabled, false); } void OptOutOfBraveNewsAdsForTesting() { - SetBooleanPref(brave_news::prefs::kBraveNewsOptedIn, false); - SetBooleanPref(brave_news::prefs::kNewTabPageShowToday, false); + SetBooleanPrefValue(brave_news::prefs::kBraveNewsOptedIn, false); + SetBooleanPrefValue(brave_news::prefs::kNewTabPageShowToday, false); } void OptOutOfNewTabPageAdsForTesting() { - SetBooleanPref(ntp_background_images::prefs::kNewTabPageShowBackgroundImage, - false); - SetBooleanPref(ntp_background_images::prefs:: - kNewTabPageShowSponsoredImagesBackgroundImage, - false); + SetBooleanPrefValue( + ntp_background_images::prefs::kNewTabPageShowBackgroundImage, false); + SetBooleanPrefValue(ntp_background_images::prefs:: + kNewTabPageShowSponsoredImagesBackgroundImage, + false); } void OptOutOfNotificationAdsForTesting() { - SetBooleanPref(prefs::kOptedInToNotificationAds, false); + SetBooleanPrefValue(prefs::kOptedInToNotificationAds, false); } void SetMaximumNotificationAdsPerHourForTesting(const int max_ads_per_hour) { - SetInt64Pref(prefs::kMaximumNotificationAdsPerHour, max_ads_per_hour); + SetInt64PrefValue(prefs::kMaximumNotificationAdsPerHour, max_ads_per_hour); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/targeting/geographical/subdivision/subdivision_targeting_unittest.cc b/components/brave_ads/core/internal/targeting/geographical/subdivision/subdivision_targeting_unittest.cc index e838c21cb2b..d5d1589b33c 100644 --- a/components/brave_ads/core/internal/targeting/geographical/subdivision/subdivision_targeting_unittest.cc +++ b/components/brave_ads/core/internal/targeting/geographical/subdivision/subdivision_targeting_unittest.cc @@ -174,8 +174,8 @@ TEST_F(BraveAdsSubdivisionTargetingTest, TEST_F(BraveAdsSubdivisionTargetingTest, ShouldAllowIfDisabledAndCountryIsSupported) { // Arrange - SetStringPref(prefs::kSubdivisionTargetingSubdivision, - kSubdivisionTargetingDisabled); + SetStringPrefValue(prefs::kSubdivisionTargetingSubdivision, + kSubdivisionTargetingDisabled); MockHttpOkUrlResponse(/*country_code*/ "US", /*subdivision_code*/ "CA"); // Act @@ -190,8 +190,8 @@ TEST_F(BraveAdsSubdivisionTargetingTest, TEST_F(BraveAdsSubdivisionTargetingTest, ShouldAllowIfDisabledAndCountryIsUnsupported) { // Arrange - SetStringPref(prefs::kSubdivisionTargetingSubdivision, - kSubdivisionTargetingDisabled); + SetStringPrefValue(prefs::kSubdivisionTargetingSubdivision, + kSubdivisionTargetingDisabled); MockHttpOkUrlResponse(/*country_code*/ "XX", /*subdivision_code*/ "XX"); // Act @@ -206,7 +206,8 @@ TEST_F(BraveAdsSubdivisionTargetingTest, TEST_F(BraveAdsSubdivisionTargetingTest, ShouldAllowAndAutoDetectIfCountryIsSupported) { // Arrange - SetStringPref(prefs::kSubdivisionTargetingAutoDetectedSubdivision, "US-CA"); + SetStringPrefValue(prefs::kSubdivisionTargetingAutoDetectedSubdivision, + "US-CA"); // Act NotifyDidInitializeAds(); @@ -222,7 +223,8 @@ TEST_F(BraveAdsSubdivisionTargetingTest, TEST_F(BraveAdsSubdivisionTargetingTest, ShouldAllowAndAutoDetectIfSubdivisionCodeIsUnsupported) { // Arrange - SetStringPref(prefs::kSubdivisionTargetingAutoDetectedSubdivision, "XX-XX"); + SetStringPrefValue(prefs::kSubdivisionTargetingAutoDetectedSubdivision, + "XX-XX"); // Act NotifyDidInitializeAds(); @@ -251,8 +253,8 @@ TEST_F(BraveAdsSubdivisionTargetingTest, TEST_F(BraveAdsSubdivisionTargetingTest, ShouldAllowIfSubdivisionCodeNotValid) { // Arrange - SetStringPref(prefs::kSubdivisionTargetingAutoDetectedSubdivision, - "CA-NO REGION"); + SetStringPrefValue(prefs::kSubdivisionTargetingAutoDetectedSubdivision, + "CA-NO REGION"); // Act NotifyDidInitializeAds(); @@ -304,7 +306,7 @@ TEST_F(BraveAdsSubdivisionTargetingTest, TEST_F(BraveAdsSubdivisionTargetingTest, ShouldAllowWhenUserSelectSubdivisionWithSameCountry) { // Arrange - SetStringPref(prefs::kSubdivisionTargetingSubdivision, "US-FL"); + SetStringPrefValue(prefs::kSubdivisionTargetingSubdivision, "US-FL"); MockHttpOkUrlResponse(/*country_code*/ "US", /*subdivision_code*/ "CA"); // Act @@ -324,7 +326,7 @@ TEST_F(BraveAdsSubdivisionTargetingTest, TEST_F(BraveAdsSubdivisionTargetingTest, ShouldAllowWhenUserSelectSubdivisionAndAutodetectedCountryIsSupported) { // Arrange - SetStringPref(prefs::kSubdivisionTargetingSubdivision, "US-FL"); + SetStringPrefValue(prefs::kSubdivisionTargetingSubdivision, "US-FL"); MockHttpOkUrlResponse(/*country_code*/ "CA", /*subdivision_code*/ "AL"); // Act @@ -342,7 +344,7 @@ TEST_F( BraveAdsSubdivisionTargetingTest, ShouldNotAllowWhenUserSelectSubdivisionAndAutodetectedCountryIsUnsupported) { // Arrange - SetStringPref(prefs::kSubdivisionTargetingSubdivision, "US-FL"); + SetStringPrefValue(prefs::kSubdivisionTargetingSubdivision, "US-FL"); MockHttpOkUrlResponse(/*country_code*/ "XX", /*subdivision_code*/ "XX"); // Act diff --git a/components/brave_ads/core/internal/units/notification_ad/notification_ad_handler_util_should_serve_at_regular_intervals_unittest.cc b/components/brave_ads/core/internal/units/notification_ad/notification_ad_handler_util_should_serve_at_regular_intervals_unittest.cc index d70d758c64e..c9c800be39b 100644 --- a/components/brave_ads/core/internal/units/notification_ad/notification_ad_handler_util_should_serve_at_regular_intervals_unittest.cc +++ b/components/brave_ads/core/internal/units/notification_ad/notification_ad_handler_util_should_serve_at_regular_intervals_unittest.cc @@ -58,7 +58,7 @@ class BraveAdsNotificationAdHandlerUtilShouldServeAtRegularIntervalsTest void SetUpMocks() override { const ParamInfo param = GetParam(); - SetBooleanPref(prefs::kOptedInToNotificationAds, param.should_opt_in); + SetBooleanPrefValue(prefs::kOptedInToNotificationAds, param.should_opt_in); MockCanShowNotificationAdsWhileBrowserIsBackgrounded( ads_client_mock_, param.can_show_while_browser_is_backgrounded);