diff --git a/components/brave_ads/core/internal/account/account.cc b/components/brave_ads/core/internal/account/account.cc index a2f72383772c..04c5ad96bc59 100644 --- a/components/brave_ads/core/internal/account/account.cc +++ b/components/brave_ads/core/internal/account/account.cc @@ -56,8 +56,9 @@ void Account::RemoveObserver(AccountObserver* const observer) { } void Account::SetWallet(const std::string& payment_id, - const std::string& recovery_seed) { - const std::optional wallet = ToWallet(payment_id, recovery_seed); + const std::string& recovery_seed_base64) { + const std::optional wallet = + ToWallet(payment_id, recovery_seed_base64); if (!wallet) { // TODO(https://github.com/brave/brave-browser/issues/32066): // Detect potential defects using `DumpWithoutCrashing`. diff --git a/components/brave_ads/core/internal/account/account.h b/components/brave_ads/core/internal/account/account.h index ba24ce03b5a1..d310ea49f477 100644 --- a/components/brave_ads/core/internal/account/account.h +++ b/components/brave_ads/core/internal/account/account.h @@ -50,7 +50,7 @@ class Account final : public AdsClientNotifierObserver, bool IsUserRewardsSupported() const { return !!user_rewards_; } void SetWallet(const std::string& payment_id, - const std::string& recovery_seed); + const std::string& recovery_seed_base64); static void GetStatement(GetStatementOfAccountsCallback callback); diff --git a/components/brave_ads/core/internal/account/account_unittest.cc b/components/brave_ads/core/internal/account/account_unittest.cc index 25d480670528..412d1641e9df 100644 --- a/components/brave_ads/core/internal/account/account_unittest.cc +++ b/components/brave_ads/core/internal/account/account_unittest.cc @@ -44,7 +44,7 @@ class BraveAdsAccountTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - ads_observer_mock_ = AddAdsObserverMock(); + ads_observer_mock_ = test::AddAdsObserverMock(); account_ = std::make_unique(&token_generator_mock_); account_->AddObserver(&account_observer_mock_); @@ -66,7 +66,7 @@ class BraveAdsAccountTest : public UnitTestBase { TEST_F(BraveAdsAccountTest, SupportUserRewardsForRewardsUser) { // Arrange - account_->SetWallet(kWalletPaymentId, kWalletRecoverySeed); + account_->SetWallet(test::kWalletPaymentId, test::kWalletRecoverySeedBase64); NotifyDidInitializeAds(); @@ -88,28 +88,28 @@ TEST_F(BraveAdsAccountTest, SetWallet) { // Act & Assert EXPECT_CALL(account_observer_mock_, OnDidInitializeWallet); EXPECT_CALL(account_observer_mock_, OnFailedToInitializeWallet).Times(0); - account_->SetWallet(kWalletPaymentId, kWalletRecoverySeed); + account_->SetWallet(test::kWalletPaymentId, test::kWalletRecoverySeedBase64); } TEST_F(BraveAdsAccountTest, DoNotSetWalletWithEmptyPaymentId) { // Act & Assert EXPECT_CALL(account_observer_mock_, OnDidInitializeWallet).Times(0); EXPECT_CALL(account_observer_mock_, OnFailedToInitializeWallet); - account_->SetWallet(/*payment_id=*/{}, kWalletRecoverySeed); + account_->SetWallet(/*payment_id=*/"", test::kWalletRecoverySeedBase64); } TEST_F(BraveAdsAccountTest, DoNotSetWalletWithInvalidRecoverySeed) { // Act & Assert EXPECT_CALL(account_observer_mock_, OnDidInitializeWallet).Times(0); EXPECT_CALL(account_observer_mock_, OnFailedToInitializeWallet); - account_->SetWallet(kWalletPaymentId, kInvalidWalletRecoverySeed); + account_->SetWallet(test::kWalletPaymentId, test::kInvalidWalletRecoverySeed); } TEST_F(BraveAdsAccountTest, DoNotSetWalletWithEmptyRecoverySeed) { // Act & Assert EXPECT_CALL(account_observer_mock_, OnDidInitializeWallet).Times(0); EXPECT_CALL(account_observer_mock_, OnFailedToInitializeWallet); - account_->SetWallet(kWalletPaymentId, /*recovery_seed=*/""); + account_->SetWallet(test::kWalletPaymentId, /*recovery_seed_base64=*/""); } TEST_F(BraveAdsAccountTest, GetStatementForRewardsUser) { @@ -204,11 +204,11 @@ TEST_F(BraveAdsAccountTest, DepositForCash) { test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, test::BuildFetchPaymentTokenUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -220,7 +220,8 @@ TEST_F(BraveAdsAccountTest, DepositForCash) { EXPECT_CALL(account_observer_mock_, OnDidProcessDeposit); EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0); EXPECT_CALL(*ads_observer_mock_, OnAdRewardsDidChange); - account_->Deposit(kCreativeInstanceId, kSegment, AdType::kNotificationAd, + account_->Deposit(test::kCreativeInstanceId, test::kSegment, + AdType::kNotificationAd, ConfirmationType::kViewedImpression); } @@ -233,11 +234,11 @@ TEST_F(BraveAdsAccountTest, DepositForCashWithUserData) { test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, test::BuildFetchPaymentTokenUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -249,7 +250,7 @@ TEST_F(BraveAdsAccountTest, DepositForCashWithUserData) { EXPECT_CALL(account_observer_mock_, OnDidProcessDeposit); EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0); EXPECT_CALL(*ads_observer_mock_, OnAdRewardsDidChange); - account_->DepositWithUserData(kCreativeInstanceId, kSegment, + account_->DepositWithUserData(test::kCreativeInstanceId, test::kSegment, AdType::kNotificationAd, ConfirmationType::kViewedImpression, /*user_data=*/{}); @@ -265,8 +266,8 @@ TEST_F(BraveAdsAccountTest, DepositForNonCash) { EXPECT_CALL(account_observer_mock_, OnDidProcessDeposit); EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0); EXPECT_CALL(*ads_observer_mock_, OnAdRewardsDidChange); - account_->Deposit(kCreativeInstanceId, kSegment, AdType::kNotificationAd, - ConfirmationType::kClicked); + account_->Deposit(test::kCreativeInstanceId, test::kSegment, + AdType::kNotificationAd, ConfirmationType::kClicked); } TEST_F(BraveAdsAccountTest, DepositForNonCashWithUserData) { @@ -279,7 +280,7 @@ TEST_F(BraveAdsAccountTest, DepositForNonCashWithUserData) { EXPECT_CALL(account_observer_mock_, OnDidProcessDeposit); EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0); EXPECT_CALL(*ads_observer_mock_, OnAdRewardsDidChange); - account_->DepositWithUserData(kCreativeInstanceId, kSegment, + account_->DepositWithUserData(test::kCreativeInstanceId, test::kSegment, AdType::kNotificationAd, ConfirmationType::kClicked, /*user_data=*/{}); } @@ -296,7 +297,7 @@ TEST_F(BraveAdsAccountTest, DoNotDepositCashIfCreativeInstanceIdDoesNotExist) { EXPECT_CALL(account_observer_mock_, OnDidProcessDeposit).Times(0); EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit); EXPECT_CALL(*ads_observer_mock_, OnAdRewardsDidChange).Times(0); - account_->Deposit(kMissingCreativeInstanceId, kSegment, + account_->Deposit(test::kMissingCreativeInstanceId, test::kSegment, AdType::kNotificationAd, ConfirmationType::kViewedImpression); } @@ -314,7 +315,8 @@ TEST_F(BraveAdsAccountTest, AddTransactionWhenDepositingCashForRewardsUser) { EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0); EXPECT_CALL(*ads_observer_mock_, OnAdRewardsDidChange); - account_->Deposit(kCreativeInstanceId, kSegment, AdType::kNotificationAd, + account_->Deposit(test::kCreativeInstanceId, test::kSegment, + AdType::kNotificationAd, ConfirmationType::kViewedImpression); // Assert @@ -339,8 +341,8 @@ TEST_F(BraveAdsAccountTest, AddTransactionWhenDepositingNonCashForRewardsUser) { EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0); EXPECT_CALL(*ads_observer_mock_, OnAdRewardsDidChange); - account_->Deposit(kCreativeInstanceId, kSegment, AdType::kNotificationAd, - ConfirmationType::kClicked); + account_->Deposit(test::kCreativeInstanceId, test::kSegment, + AdType::kNotificationAd, ConfirmationType::kClicked); // Assert base::MockCallback callback; @@ -365,7 +367,8 @@ TEST_F(BraveAdsAccountTest, EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0); EXPECT_CALL(*ads_observer_mock_, OnAdRewardsDidChange); - account_->Deposit(kCreativeInstanceId, kSegment, AdType::kNotificationAd, + account_->Deposit(test::kCreativeInstanceId, test::kSegment, + AdType::kNotificationAd, ConfirmationType::kViewedImpression); // Assert @@ -391,8 +394,8 @@ TEST_F(BraveAdsAccountTest, EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0); EXPECT_CALL(*ads_observer_mock_, OnAdRewardsDidChange); - account_->Deposit(kCreativeInstanceId, kSegment, AdType::kNotificationAd, - ConfirmationType::kClicked); + account_->Deposit(test::kCreativeInstanceId, test::kSegment, + AdType::kNotificationAd, ConfirmationType::kClicked); // Assert base::MockCallback callback; diff --git a/components/brave_ads/core/internal/account/confirmations/non_reward/non_reward_confirmation_test_util.cc b/components/brave_ads/core/internal/account/confirmations/non_reward/non_reward_confirmation_test_util.cc index c7319778149b..c09948dd9b21 100644 --- a/components/brave_ads/core/internal/account/confirmations/non_reward/non_reward_confirmation_test_util.cc +++ b/components/brave_ads/core/internal/account/confirmations/non_reward/non_reward_confirmation_test_util.cc @@ -16,7 +16,7 @@ std::optional BuildNonRewardConfirmation( const bool should_generate_random_uuids) { CHECK(!UserHasJoinedBraveRewards()); - const TransactionInfo transaction = test::BuildUnreconciledTransaction( + const TransactionInfo transaction = BuildUnreconciledTransaction( /*value=*/0.01, AdType::kNotificationAd, ConfirmationType::kViewedImpression, should_generate_random_uuids); return BuildNonRewardConfirmation(transaction, /*user_data=*/{}); diff --git a/components/brave_ads/core/internal/account/confirmations/non_reward/non_reward_confirmation_util_unittest.cc b/components/brave_ads/core/internal/account/confirmations/non_reward/non_reward_confirmation_util_unittest.cc index 74652115d9d7..0de254392543 100644 --- a/components/brave_ads/core/internal/account/confirmations/non_reward/non_reward_confirmation_util_unittest.cc +++ b/components/brave_ads/core/internal/account/confirmations/non_reward/non_reward_confirmation_util_unittest.cc @@ -26,7 +26,7 @@ class BraveAdsNonRewardConfirmationUtilTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - MockConfirmationUserData(); + test::MockConfirmationUserData(); } }; @@ -46,11 +46,11 @@ TEST_F(BraveAdsNonRewardConfirmationUtilTest, BuildNonRewardConfirmation) { // Assert EXPECT_THAT(*confirmation, - ::testing::FieldsAre(kTransactionId, kCreativeInstanceId, - ConfirmationType::kViewedImpression, - AdType::kNotificationAd, - /*created_at*/ Now(), - /*reward*/ std::nullopt, UserDataInfo{})); + ::testing::FieldsAre( + test::kTransactionId, test::kCreativeInstanceId, + ConfirmationType::kViewedImpression, AdType::kNotificationAd, + /*created_at*/ Now(), + /*reward*/ std::nullopt, UserDataInfo{})); } TEST_F(BraveAdsNonRewardConfirmationUtilTest, diff --git a/components/brave_ads/core/internal/account/confirmations/payload/confirmation_payload_json_writer_unittest.cc b/components/brave_ads/core/internal/account/confirmations/payload/confirmation_payload_json_writer_unittest.cc index 0d9e30e085c5..fb0dffb23b37 100644 --- a/components/brave_ads/core/internal/account/confirmations/payload/confirmation_payload_json_writer_unittest.cc +++ b/components/brave_ads/core/internal/account/confirmations/payload/confirmation_payload_json_writer_unittest.cc @@ -30,7 +30,7 @@ class BraveAdsConfirmationPayloadJsonWriterTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - MockConfirmationUserData(); + test::MockConfirmationUserData(); AdvanceClockTo(TimeFromUTCString("Mon, 8 Jul 1996 09:25")); } diff --git a/components/brave_ads/core/internal/account/confirmations/queue/confirmation_queue_database_table_unittest.cc b/components/brave_ads/core/internal/account/confirmations/queue/confirmation_queue_database_table_unittest.cc index 06a68becca6e..ab3fd0e294b4 100644 --- a/components/brave_ads/core/internal/account/confirmations/queue/confirmation_queue_database_table_unittest.cc +++ b/components/brave_ads/core/internal/account/confirmations/queue/confirmation_queue_database_table_unittest.cc @@ -33,7 +33,7 @@ class BraveAdsConfirmationQueueDatabaseTableTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - MockConfirmationUserData(); + test::MockConfirmationUserData(); AdvanceClockTo(TimeFromUTCString("Mon, 8 Jul 1996 09:25")); } diff --git a/components/brave_ads/core/internal/account/confirmations/queue/confirmation_queue_unittest.cc b/components/brave_ads/core/internal/account/confirmations/queue/confirmation_queue_unittest.cc index 11f32ae5aedb..1b5f5f7c9cea 100644 --- a/components/brave_ads/core/internal/account/confirmations/queue/confirmation_queue_unittest.cc +++ b/components/brave_ads/core/internal/account/confirmations/queue/confirmation_queue_unittest.cc @@ -95,11 +95,11 @@ TEST_F(BraveAdsConfirmationQueueTest, ProcessConfirmation) { test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, test::BuildFetchPaymentTokenUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); diff --git a/components/brave_ads/core/internal/account/confirmations/reward/reward_confirmation_test_util.cc b/components/brave_ads/core/internal/account/confirmations/reward/reward_confirmation_test_util.cc index 3d0413dbe3fc..bc25fd6a4cd6 100644 --- a/components/brave_ads/core/internal/account/confirmations/reward/reward_confirmation_test_util.cc +++ b/components/brave_ads/core/internal/account/confirmations/reward/reward_confirmation_test_util.cc @@ -23,7 +23,7 @@ std::optional BuildRewardConfirmation( CHECK(token_generator); CHECK(UserHasJoinedBraveRewards()); - const TransactionInfo transaction = test::BuildUnreconciledTransaction( + const TransactionInfo transaction = BuildUnreconciledTransaction( /*value=*/0.01, AdType::kNotificationAd, ConfirmationType::kViewedImpression, should_generate_random_uuids); return BuildRewardConfirmation(token_generator, transaction, diff --git a/components/brave_ads/core/internal/account/confirmations/reward/reward_confirmation_util_unittest.cc b/components/brave_ads/core/internal/account/confirmations/reward/reward_confirmation_util_unittest.cc index 995fa250efa5..242049c1aa43 100644 --- a/components/brave_ads/core/internal/account/confirmations/reward/reward_confirmation_util_unittest.cc +++ b/components/brave_ads/core/internal/account/confirmations/reward/reward_confirmation_util_unittest.cc @@ -33,7 +33,7 @@ class BraveAdsRewardConfirmationUtilTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - MockConfirmationUserData(); + test::MockConfirmationUserData(); AdvanceClockTo(TimeFromUTCString("Mon, 8 Jul 1996 09:25")); } @@ -110,7 +110,7 @@ TEST_F(BraveAdsRewardConfirmationUtilTest, BuildRewardConfirmation) { EXPECT_THAT(*confirmation, ::testing::FieldsAre( - kTransactionId, kCreativeInstanceId, + test::kTransactionId, test::kCreativeInstanceId, ConfirmationType::kViewedImpression, AdType::kNotificationAd, /*created_at*/ Now(), expected_reward, expected_user_data)); } diff --git a/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_test_util.cc b/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_test_util.cc index ae3e52433680..b044d3eec0bd 100644 --- a/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_test_util.cc +++ b/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_test_util.cc @@ -11,7 +11,7 @@ #include "brave/components/brave_ads/core/internal/common/unittest/unittest_profile_pref_value.h" #include "brave/components/brave_ads/core/public/prefs/pref_names.h" -namespace brave_ads { +namespace brave_ads::test { namespace { @@ -30,4 +30,4 @@ void MockConfirmationUserData() { SetCatalogId(kCatalogId); } -} // namespace brave_ads +} // namespace brave_ads::test diff --git a/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_test_util.h b/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_test_util.h index 788bc0bd9489..375937940367 100644 --- a/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_test_util.h +++ b/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_test_util.h @@ -6,10 +6,10 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_CONFIRMATIONS_USER_DATA_BUILDER_CONFIRMATION_USER_DATA_BUILDER_TEST_UTIL_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_CONFIRMATIONS_USER_DATA_BUILDER_CONFIRMATION_USER_DATA_BUILDER_TEST_UTIL_H_ -namespace brave_ads { +namespace brave_ads::test { void MockConfirmationUserData(); -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_CONFIRMATIONS_USER_DATA_BUILDER_CONFIRMATION_USER_DATA_BUILDER_TEST_UTIL_H_ diff --git a/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_unittest.cc b/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_unittest.cc index 0feb4de7e2b5..d0c26f8fe999 100644 --- a/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_unittest.cc +++ b/components/brave_ads/core/internal/account/confirmations/user_data_builder/confirmation_user_data_builder_unittest.cc @@ -28,7 +28,7 @@ class BraveAdsConfirmationUserDataBuilderTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - MockConfirmationUserData(); + test::MockConfirmationUserData(); AdvanceClockTo(TimeFromUTCString("November 18 2020 12:34:56.789")); } diff --git a/components/brave_ads/core/internal/account/confirmations/user_data_builder/dynamic/confirmation_dynamic_user_data_builder_unittest.cc b/components/brave_ads/core/internal/account/confirmations/user_data_builder/dynamic/confirmation_dynamic_user_data_builder_unittest.cc index 862936340cf1..a89924c40f87 100644 --- a/components/brave_ads/core/internal/account/confirmations/user_data_builder/dynamic/confirmation_dynamic_user_data_builder_unittest.cc +++ b/components/brave_ads/core/internal/account/confirmations/user_data_builder/dynamic/confirmation_dynamic_user_data_builder_unittest.cc @@ -20,7 +20,7 @@ class BraveAdsConfirmationDynamicUserDataBuilderTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - MockConfirmationUserData(); + test::MockConfirmationUserData(); AdvanceClockTo(TimeFromUTCString("November 18 2020 12:34:56.789")); } diff --git a/components/brave_ads/core/internal/account/confirmations/user_data_builder/fixed/confirmation_fixed_user_data_builder_unittest.cc b/components/brave_ads/core/internal/account/confirmations/user_data_builder/fixed/confirmation_fixed_user_data_builder_unittest.cc index e62c10355ff9..c96b220d55be 100644 --- a/components/brave_ads/core/internal/account/confirmations/user_data_builder/fixed/confirmation_fixed_user_data_builder_unittest.cc +++ b/components/brave_ads/core/internal/account/confirmations/user_data_builder/fixed/confirmation_fixed_user_data_builder_unittest.cc @@ -23,7 +23,7 @@ class BraveAdsFixedUserDataBuilderTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - MockConfirmationUserData(); + test::MockConfirmationUserData(); AdvanceClockTo(TimeFromUTCString("November 18 2020 12:34:56.789")); } diff --git a/components/brave_ads/core/internal/account/deposits/cash_deposit_test.cc b/components/brave_ads/core/internal/account/deposits/cash_deposit_test.cc index 528a235cf684..5f87d0d5d838 100644 --- a/components/brave_ads/core/internal/account/deposits/cash_deposit_test.cc +++ b/components/brave_ads/core/internal/account/deposits/cash_deposit_test.cc @@ -36,7 +36,7 @@ TEST_F(BraveAdsCashDepositIntegrationTest, GetValue) { // Act & Assert base::MockCallback callback; EXPECT_CALL(callback, Run(/*success=*/true, /*value=*/1.0)); - deposit.GetValue(kCreativeInstanceId, callback.Get()); + deposit.GetValue(test::kCreativeInstanceId, callback.Get()); } TEST_F(BraveAdsCashDepositIntegrationTest, @@ -47,7 +47,7 @@ TEST_F(BraveAdsCashDepositIntegrationTest, // Act & Assert base::MockCallback callback; EXPECT_CALL(callback, Run(/*success=*/false, /*value=*/0.0)); - deposit.GetValue(kMissingCreativeInstanceId, callback.Get()); + deposit.GetValue(test::kMissingCreativeInstanceId, callback.Get()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/deposits/non_cash_deposit_unittest.cc b/components/brave_ads/core/internal/account/deposits/non_cash_deposit_unittest.cc index 7a0e2b9253a8..4c59632a0e14 100644 --- a/components/brave_ads/core/internal/account/deposits/non_cash_deposit_unittest.cc +++ b/components/brave_ads/core/internal/account/deposits/non_cash_deposit_unittest.cc @@ -22,7 +22,7 @@ TEST_F(BraveAdsNonCashDepositTest, GetValue) { // Act & Assert base::MockCallback callback; EXPECT_CALL(callback, Run(/*success=*/true, /*value=*/0.0)); - deposit.GetValue(kCreativeInstanceId, callback.Get()); + deposit.GetValue(test::kCreativeInstanceId, callback.Get()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/issuers/public_key_util_unittest.cc b/components/brave_ads/core/internal/account/issuers/public_key_util_unittest.cc index e1eaf22a7fed..e6807a2fb53a 100644 --- a/components/brave_ads/core/internal/account/issuers/public_key_util_unittest.cc +++ b/components/brave_ads/core/internal/account/issuers/public_key_util_unittest.cc @@ -15,8 +15,9 @@ namespace brave_ads { namespace { -constexpr char kPublicKey[] = "bCKwI6tx5LWrZKxWbW5CxaVIGe2N0qGYLfFE+38urCg="; -constexpr char kMissingPublicKey[] = +constexpr char kPublicKeyBase64[] = + "bCKwI6tx5LWrZKxWbW5CxaVIGe2N0qGYLfFE+38urCg="; +constexpr char kMissingPublicKeyBase64[] = "QnShwT9vRebch3WDu28nqlTaNCU5MaOF1n4VV4Q3K1g=="; } // namespace @@ -26,24 +27,26 @@ class BraveAdsPublicKeyUtilTest : public UnitTestBase {}; TEST_F(BraveAdsPublicKeyUtilTest, PublicKeyExists) { // Arrange IssuerInfo issuer; - issuer.public_keys.insert({kPublicKey, /*associated_value=*/0.1}); + issuer.public_keys.insert({kPublicKeyBase64, /*associated_value=*/0.1}); // Act & Assert - EXPECT_TRUE(PublicKeyExists(issuer, cbr::PublicKey(kPublicKey))); + EXPECT_TRUE(PublicKeyExists(issuer, cbr::PublicKey(kPublicKeyBase64))); } TEST_F(BraveAdsPublicKeyUtilTest, PublicKeyDoesNotExist) { // Arrange IssuerInfo issuer; - issuer.public_keys.insert({kPublicKey, /*associated_value=*/0.1}); + issuer.public_keys.insert({kPublicKeyBase64, /*associated_value=*/0.1}); // Act & Assert - EXPECT_FALSE(PublicKeyExists(issuer, cbr::PublicKey(kMissingPublicKey))); + EXPECT_FALSE( + PublicKeyExists(issuer, cbr::PublicKey(kMissingPublicKeyBase64))); } TEST_F(BraveAdsPublicKeyUtilTest, NoPublicKeys) { // Act & Assert - EXPECT_FALSE(PublicKeyExists(/*issuer*/ {}, cbr::PublicKey(kPublicKey))); + EXPECT_FALSE( + PublicKeyExists(/*issuer*/ {}, cbr::PublicKey(kPublicKeyBase64))); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/transactions/transaction_test_constants.h b/components/brave_ads/core/internal/account/transactions/transaction_test_constants.h index a1f4f27a4f38..31742ca07590 100644 --- a/components/brave_ads/core/internal/account/transactions/transaction_test_constants.h +++ b/components/brave_ads/core/internal/account/transactions/transaction_test_constants.h @@ -6,10 +6,10 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_TRANSACTIONS_TRANSACTION_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_TRANSACTIONS_TRANSACTION_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { inline constexpr char kTransactionId[] = "8b742869-6e4a-490c-ac31-31b49130098a"; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_TRANSACTIONS_TRANSACTION_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/account/transactions/transactions_unittest.cc b/components/brave_ads/core/internal/account/transactions/transactions_unittest.cc index 1dbff94de58a..e5d519c3811e 100644 --- a/components/brave_ads/core/internal/account/transactions/transactions_unittest.cc +++ b/components/brave_ads/core/internal/account/transactions/transactions_unittest.cc @@ -28,8 +28,9 @@ TEST_F(BraveAdsTransactionsTest, Add) { // Act const TransactionInfo transaction = AddTransaction( - kCreativeInstanceId, kSegment, /*value=*/0.01, AdType::kNotificationAd, - ConfirmationType::kViewedImpression, add_transaction_callback.Get()); + test::kCreativeInstanceId, test::kSegment, /*value=*/0.01, + AdType::kNotificationAd, ConfirmationType::kViewedImpression, + add_transaction_callback.Get()); // Assert base::MockCallback callback; diff --git a/components/brave_ads/core/internal/account/user_data/fixed/catalog_user_data_unittest.cc b/components/brave_ads/core/internal/account/user_data/fixed/catalog_user_data_unittest.cc index 7c9ee3ff61f2..584dd8c8e75d 100644 --- a/components/brave_ads/core/internal/account/user_data/fixed/catalog_user_data_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/fixed/catalog_user_data_unittest.cc @@ -20,7 +20,7 @@ class BraveAdsCatalogUserDataTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - SetCatalogId(kCatalogId); + SetCatalogId(test::kCatalogId); } }; diff --git a/components/brave_ads/core/internal/account/user_data/fixed/conversion_user_data_unittest.cc b/components/brave_ads/core/internal/account/user_data/fixed/conversion_user_data_unittest.cc index 0b29834137de..88f7d14f0fc7 100644 --- a/components/brave_ads/core/internal/account/user_data/fixed/conversion_user_data_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/fixed/conversion_user_data_unittest.cc @@ -58,9 +58,9 @@ TEST_F(BraveAdsConversionUserDataBuilderTest, const AdEventInfo ad_event = BuildAdEvent(ad, ConfirmationType::kClicked, /*created_at=*/Now()); const ConversionInfo conversion = BuildConversion( - ad_event, - VerifiableConversionInfo{kVerifiableConversionId, - kVerifiableConversionAdvertiserPublicKey}); + ad_event, VerifiableConversionInfo{ + test::kVerifiableConversionId, + test::kVerifiableConversionAdvertiserPublicKeyBase64}); // Act const base::Value::Dict user_data = BuildConversionUserData(conversion); @@ -113,9 +113,9 @@ TEST_F(BraveAdsConversionUserDataBuilderTest, const AdEventInfo ad_event = BuildAdEvent(ad, ConfirmationType::kClicked, /*created_at=*/Now()); const ConversionInfo conversion = BuildConversion( - ad_event, - VerifiableConversionInfo{kVerifiableConversionId, - kVerifiableConversionAdvertiserPublicKey}); + ad_event, VerifiableConversionInfo{ + test::kVerifiableConversionId, + test::kVerifiableConversionAdvertiserPublicKeyBase64}); // Act const base::Value::Dict user_data = BuildConversionUserData(conversion); diff --git a/components/brave_ads/core/internal/account/user_data/fixed/conversion_user_data_util_unittest.cc b/components/brave_ads/core/internal/account/user_data/fixed/conversion_user_data_util_unittest.cc index d4ef5deb6278..28756814d7e9 100644 --- a/components/brave_ads/core/internal/account/user_data/fixed/conversion_user_data_util_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/fixed/conversion_user_data_util_unittest.cc @@ -33,9 +33,9 @@ TEST_F(BraveAdsConversionUserDataUtilTest, BuildVerifiableConversionUserData) { const AdEventInfo ad_event = BuildAdEvent( ad, ConfirmationType::kViewedImpression, /*created_at=*/Now()); const ConversionInfo conversion = BuildConversion( - ad_event, - VerifiableConversionInfo{kVerifiableConversionId, - kVerifiableConversionAdvertiserPublicKey}); + ad_event, VerifiableConversionInfo{ + test::kVerifiableConversionId, + test::kVerifiableConversionAdvertiserPublicKeyBase64}); // Act const std::optional verifiable_conversion_user_data = diff --git a/components/brave_ads/core/internal/account/user_data/fixed/top_segment_user_data_unittest.cc b/components/brave_ads/core/internal/account/user_data/fixed/top_segment_user_data_unittest.cc index 69460be2b319..9ff20f309c6e 100644 --- a/components/brave_ads/core/internal/account/user_data/fixed/top_segment_user_data_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/fixed/top_segment_user_data_unittest.cc @@ -26,8 +26,8 @@ class BraveAdsTopSegmentUserDataTest : public UnitTestBase { targeting_helper_ = std::make_unique(task_environment_); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); } std::unique_ptr targeting_helper_; diff --git a/components/brave_ads/core/internal/account/user_rewards/user_rewards_unittest.cc b/components/brave_ads/core/internal/account/user_rewards/user_rewards_unittest.cc index 51fc9a2cdd34..b6b7454bec15 100644 --- a/components/brave_ads/core/internal/account/user_rewards/user_rewards_unittest.cc +++ b/components/brave_ads/core/internal/account/user_rewards/user_rewards_unittest.cc @@ -189,9 +189,10 @@ TEST_F(BraveAdsUserRewardsTest, RefillConfirmationTokens) { test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, test::BuildGetSignedTokensUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -205,7 +206,7 @@ TEST_F(BraveAdsUserRewardsTest, RefillConfirmationTokens) { TEST_F(BraveAdsUserRewardsTest, RedeemPaymentTokens) { // Arrange const URLResponseMap url_responses = { - {BuildRedeemPaymentTokensUrlPath(/*payment_id=*/kWalletPaymentId), + {BuildRedeemPaymentTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_OK, test::BuildRedeemPaymentTokensUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -269,9 +270,10 @@ TEST_F(BraveAdsUserRewardsTest, test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_UNAUTHORIZED, /*response_body=*/R"( { "captcha_id": "daf85dc8-164e-4eb9-a4d4-1836055004b3" @@ -281,7 +283,7 @@ TEST_F(BraveAdsUserRewardsTest, EXPECT_CALL(ads_client_mock_, ShowScheduledCaptcha( - kWalletPaymentId, + test::kWalletPaymentId, /*captcha_id=*/"daf85dc8-164e-4eb9-a4d4-1836055004b3")); // Act & Assert @@ -296,9 +298,10 @@ TEST_F(BraveAdsUserRewardsTest, test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_UNAUTHORIZED, /*response_body=*/R"( { "captcha_id": "" @@ -320,9 +323,10 @@ TEST_F(BraveAdsUserRewardsTest, test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, test::BuildGetSignedTokensUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/non_reward/redeem_non_reward_confirmation_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_confirmation/non_reward/redeem_non_reward_confirmation_unittest.cc index d52fafdd3e5e..b05c5fabcd24 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/non_reward/redeem_non_reward_confirmation_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/non_reward/redeem_non_reward_confirmation_unittest.cc @@ -41,7 +41,7 @@ class BraveAdsRedeemNonRewardConfirmationTest : public UnitTestBase { TEST_F(BraveAdsRedeemNonRewardConfirmationTest, Redeem) { // Arrange const URLResponseMap url_responses = { - {BuildCreateNonRewardConfirmationUrlPath(kTransactionId), + {BuildCreateNonRewardConfirmationUrlPath(test::kTransactionId), {{net::kHttpImATeapot, test::BuildCreateNonRewardConfirmationUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -63,7 +63,7 @@ TEST_F(BraveAdsRedeemNonRewardConfirmationTest, DoNotRetryRedeemingForHttpBadRequestResponse) { // Arrange const URLResponseMap url_responses = { - {BuildCreateNonRewardConfirmationUrlPath(kTransactionId), + {BuildCreateNonRewardConfirmationUrlPath(test::kTransactionId), {{net::HTTP_BAD_REQUEST, /*response_body=*/net::GetHttpReasonPhrase(net::HTTP_BAD_REQUEST)}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -86,7 +86,7 @@ TEST_F(BraveAdsRedeemNonRewardConfirmationTest, DoNotRetryRedeemingForHttpConflictResponse) { // Arrange const URLResponseMap url_responses = { - {BuildCreateNonRewardConfirmationUrlPath(kTransactionId), + {BuildCreateNonRewardConfirmationUrlPath(test::kTransactionId), {{net::HTTP_CONFLICT, /*response_body=*/net::GetHttpReasonPhrase(net::HTTP_CONFLICT)}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -109,7 +109,7 @@ TEST_F(BraveAdsRedeemNonRewardConfirmationTest, DoNotRetryReemingForHttpCreatedResponse) { // Arrange const URLResponseMap url_responses = { - {BuildCreateNonRewardConfirmationUrlPath(kTransactionId), + {BuildCreateNonRewardConfirmationUrlPath(test::kTransactionId), {{net::HTTP_CREATED, /*response_body=*/net::GetHttpReasonPhrase(net::HTTP_CREATED)}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -131,7 +131,7 @@ TEST_F(BraveAdsRedeemNonRewardConfirmationTest, TEST_F(BraveAdsRedeemNonRewardConfirmationTest, RetryRedeeming) { // Arrange const URLResponseMap url_responses = { - {BuildCreateNonRewardConfirmationUrlPath(kTransactionId), + {BuildCreateNonRewardConfirmationUrlPath(test::kTransactionId), {{net::HTTP_INTERNAL_SERVER_ERROR, /*response_body=*/net::GetHttpReasonPhrase( net::HTTP_INTERNAL_SERVER_ERROR)}}}}; diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/non_reward/url_request_builders/create_non_reward_confirmation_url_request_builder_util_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_confirmation/non_reward/url_request_builders/create_non_reward_confirmation_url_request_builder_util_unittest.cc index d9e069043f06..c298ce2886ec 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/non_reward/url_request_builders/create_non_reward_confirmation_url_request_builder_util_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/non_reward/url_request_builders/create_non_reward_confirmation_url_request_builder_util_unittest.cc @@ -15,7 +15,7 @@ namespace brave_ads { TEST(BraveAdsCreateNonRewardConfirmationUrlRequestBuilderUtilTest, GetPath) { // Act & Assert EXPECT_EQ("/v3/confirmation/8b742869-6e4a-490c-ac31-31b49130098a", - BuildCreateNonRewardConfirmationUrlPath(kTransactionId)); + BuildCreateNonRewardConfirmationUrlPath(test::kTransactionId)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/redeem_reward_confirmation_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/redeem_reward_confirmation_unittest.cc index ad205ef80630..08a88f5fb9fc 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/redeem_reward_confirmation_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/redeem_reward_confirmation_unittest.cc @@ -48,11 +48,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, Redeem) { test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, test::BuildFetchPaymentTokenUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -106,7 +106,7 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, test::BuildFetchPaymentTokenUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -136,11 +136,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_NOT_FOUND, net::GetHttpReasonPhrase(net::HTTP_NOT_FOUND)}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -172,11 +172,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_BAD_REQUEST, net::GetHttpReasonPhrase(net::HTTP_BAD_REQUEST)}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -209,11 +209,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_ACCEPTED, test::BuildFetchPaymentTokenUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -245,11 +245,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_INTERNAL_SERVER_ERROR, net::GetHttpReasonPhrase(net::HTTP_INTERNAL_SERVER_ERROR)}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -282,11 +282,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/"{INVALID}"}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -318,11 +318,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "createdAt" : "2020-04-20T10:27:11.717Z", @@ -367,11 +367,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "id" : "393abadc-e9ae-4aac-a321-3307e0d527c6", @@ -417,11 +417,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "id" : "8b742869-6e4a-490c-ac31-31b49130098a", @@ -460,11 +460,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "id" : "8b742869-6e4a-490c-ac31-31b49130098a", @@ -509,11 +509,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "id" : "8b742869-6e4a-490c-ac31-31b49130098a", @@ -559,11 +559,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "id" : "8b742869-6e4a-490c-ac31-31b49130098a", @@ -608,11 +608,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "id" : "8b742869-6e4a-490c-ac31-31b49130098a", @@ -657,11 +657,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "id" : "8b742869-6e4a-490c-ac31-31b49130098a", @@ -707,11 +707,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "id" : "8b742869-6e4a-490c-ac31-31b49130098a", @@ -754,11 +754,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "id" : "8b742869-6e4a-490c-ac31-31b49130098a", @@ -801,11 +801,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, /*response_body=*/R"( { "id" : "8b742869-6e4a-490c-ac31-31b49130098a", @@ -850,11 +850,11 @@ TEST_F(BraveAdsRedeemRewardConfirmationTest, FetchPaymentTokenAfter) { test::RefillConfirmationTokens(/*count=*/1); const URLResponseMap url_responses = { - {BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential), + {BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url), {{net::HTTP_CREATED, test::BuildCreateRewardConfirmationUrlResponseBody()}}}, - {BuildFetchPaymentTokenUrlPath(kTransactionId), + {BuildFetchPaymentTokenUrlPath(test::kTransactionId), {{net::HTTP_OK, test::BuildFetchPaymentTokenUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_test_constants.h b/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_test_constants.h index 1f6121ecba02..f04d87715765 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_test_constants.h +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_test_constants.h @@ -6,11 +6,11 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_UTILITY_REDEEM_CONFIRMATION_REWARD_URL_REQUEST_BUILDERS_CREATE_REWARD_CONFIRMATION_URL_REQUEST_BUILDER_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_UTILITY_REDEEM_CONFIRMATION_REWARD_URL_REQUEST_BUILDERS_CREATE_REWARD_CONFIRMATION_URL_REQUEST_BUILDER_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { -inline constexpr char kCreateRewardConfirmationCredential[] = +inline constexpr char kCredentialBase64Url[] = R"(eyJwYXlsb2FkIjoie1wiYmxpbmRlZFBheW1lbnRUb2tlbnNcIjpbXCJOSktBRFZNTlphZkEyVUFDTlkyVGxSZWFDSG43cW5mWndLZEdrd3dtSzBFPVwiXSxcImJ1aWxkQ2hhbm5lbFwiOlwicmVsZWFzZVwiLFwiY291bnRyeUNvZGVcIjpcIlVTXCIsXCJjcmVhdGl2ZUluc3RhbmNlSWRcIjpcIjQ4OWIxZGNjLWQ5MzgtNDFjZi05MmE4LWJhY2VhMGFiYjQ5MFwiLFwicGF5bG9hZFwiOnt9LFwicGxhdGZvcm1cIjpcIndpbmRvd3NcIixcInB1YmxpY0tleVwiOlwiTEFxSnhmeVhnV241MlhRQXFxRVhPMFAvVjQ2dVpjU0kvb1hMZFp3ekFnRT1cIixcInN0dWRpZXNcIjpbe1wiZ3JvdXBcIjpcIkV4Y2x1ZGVBZElmV2l0aGluVGltZVdpbmRvdz0waFwiLFwibmFtZVwiOlwiQnJhdmVBZHMuRnJlcXVlbmN5Q2FwcGluZ1N0dWR5XCJ9LHtcImdyb3VwXCI6XCJUcmlnZ2Vycz1FTVBUWS9UaHJlc2hvbGQ9MC4wL0lkbGVUaW1lVGhyZXNob2xkPTVcIixcIm5hbWVcIjpcIkJyYXZlQWRzLlVzZXJBY3Rpdml0eVN0dWR5XCJ9XSxcInR5cGVcIjpcImRpc21pc3NcIn0iLCJzaWduYXR1cmUiOiJlU3RqbkMzamVUWVBsSXJmb2JSdnBiL05oVCtZQmc1YlllVHlLN3NUcHd3em1pc0FOY0FUU2NSMXRYQkwzOTdFY1NXdVJ5ZHhwQk9ReFF5a0VHQUwrQT09IiwidCI6IlN4UllQVTJVamFNVjhhanV4QmVQRGlCWStsQXM3VHdIc2pubzVHYUJhc2hlZ1BZMmkyUGtTbSswWUIzT0toQ2hlTmVSNWNrYmMvRmREbnFqVktxMW1BPT0ifQ==)"; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_UTILITY_REDEEM_CONFIRMATION_REWARD_URL_REQUEST_BUILDERS_CREATE_REWARD_CONFIRMATION_URL_REQUEST_BUILDER_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_unittest.cc index 2ecb9b78f2d2..d99b14f68a52 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_unittest.cc @@ -30,7 +30,7 @@ class BraveAdsCreateRewardConfirmationUrlRequestBuilderTest void SetUp() override { UnitTestBase::SetUp(); - MockConfirmationUserData(); + test::MockConfirmationUserData(); AdvanceClockTo(TimeFromUTCString("Mon, 8 Jul 1996 09:25")); } diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_util_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_util_unittest.cc index c09addf5bb56..6ce56058828c 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_util_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/create_reward_confirmation_url_request_builder_util_unittest.cc @@ -17,8 +17,8 @@ TEST(BraveAdsCreateRewardConfirmationUrlRequestBuilderUtilTest, GetPath) { // Act & Assert EXPECT_EQ( R"(/v3/confirmation/8b742869-6e4a-490c-ac31-31b49130098a/eyJwYXlsb2FkIjoie1wiYmxpbmRlZFBheW1lbnRUb2tlbnNcIjpbXCJOSktBRFZNTlphZkEyVUFDTlkyVGxSZWFDSG43cW5mWndLZEdrd3dtSzBFPVwiXSxcImJ1aWxkQ2hhbm5lbFwiOlwicmVsZWFzZVwiLFwiY291bnRyeUNvZGVcIjpcIlVTXCIsXCJjcmVhdGl2ZUluc3RhbmNlSWRcIjpcIjQ4OWIxZGNjLWQ5MzgtNDFjZi05MmE4LWJhY2VhMGFiYjQ5MFwiLFwicGF5bG9hZFwiOnt9LFwicGxhdGZvcm1cIjpcIndpbmRvd3NcIixcInB1YmxpY0tleVwiOlwiTEFxSnhmeVhnV241MlhRQXFxRVhPMFAvVjQ2dVpjU0kvb1hMZFp3ekFnRT1cIixcInN0dWRpZXNcIjpbe1wiZ3JvdXBcIjpcIkV4Y2x1ZGVBZElmV2l0aGluVGltZVdpbmRvdz0waFwiLFwibmFtZVwiOlwiQnJhdmVBZHMuRnJlcXVlbmN5Q2FwcGluZ1N0dWR5XCJ9LHtcImdyb3VwXCI6XCJUcmlnZ2Vycz1FTVBUWS9UaHJlc2hvbGQ9MC4wL0lkbGVUaW1lVGhyZXNob2xkPTVcIixcIm5hbWVcIjpcIkJyYXZlQWRzLlVzZXJBY3Rpdml0eVN0dWR5XCJ9XSxcInR5cGVcIjpcImRpc21pc3NcIn0iLCJzaWduYXR1cmUiOiJlU3RqbkMzamVUWVBsSXJmb2JSdnBiL05oVCtZQmc1YlllVHlLN3NUcHd3em1pc0FOY0FUU2NSMXRYQkwzOTdFY1NXdVJ5ZHhwQk9ReFF5a0VHQUwrQT09IiwidCI6IlN4UllQVTJVamFNVjhhanV4QmVQRGlCWStsQXM3VHdIc2pubzVHYUJhc2hlZ1BZMmkyUGtTbSswWUIzT0toQ2hlTmVSNWNrYmMvRmREbnFqVktxMW1BPT0ifQ==)", - BuildCreateRewardConfirmationUrlPath( - kTransactionId, kCreateRewardConfirmationCredential)); + BuildCreateRewardConfirmationUrlPath(test::kTransactionId, + test::kCredentialBase64Url)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/fetch_payment_token_url_request_builder_util_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/fetch_payment_token_url_request_builder_util_unittest.cc index db5f47879650..78945ee1609b 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/fetch_payment_token_url_request_builder_util_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/reward/url_request_builders/fetch_payment_token_url_request_builder_util_unittest.cc @@ -16,7 +16,7 @@ TEST(BraveAdsFetchPaymentTokenUrlRequestBuilderUtilTest, GetPath) { // Act & Assert EXPECT_EQ( "/v3/confirmation/8b742869-6e4a-490c-ac31-31b49130098a/paymentToken", - BuildFetchPaymentTokenUrlPath(kTransactionId)); + BuildFetchPaymentTokenUrlPath(test::kTransactionId)); } } // namespace brave_ads 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 c679f0c6581b..abc2b3d281b3 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 @@ -41,7 +41,7 @@ class BraveAdsRedeemPaymentTokensTest : public UnitTestBase { TEST_F(BraveAdsRedeemPaymentTokensTest, RedeemPaymentTokens) { // Arrange const URLResponseMap url_responses = { - {BuildRedeemPaymentTokensUrlPath(/*payment_id=*/kWalletPaymentId), + {BuildRedeemPaymentTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_OK, test::BuildRedeemPaymentTokensUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -70,7 +70,7 @@ TEST_F(BraveAdsRedeemPaymentTokensTest, RedeemPaymentTokens) { TEST_F(BraveAdsRedeemPaymentTokensTest, RedeemPaymentTokensMultipleTimes) { // Arrange const URLResponseMap url_responses = { - {BuildRedeemPaymentTokensUrlPath(/*payment_id=*/kWalletPaymentId), + {BuildRedeemPaymentTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_OK, test::BuildRedeemPaymentTokensUrlResponseBody()}, {net::HTTP_OK, test::BuildRedeemPaymentTokensUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -101,7 +101,7 @@ TEST_F(BraveAdsRedeemPaymentTokensTest, RedeemPaymentTokensMultipleTimes) { TEST_F(BraveAdsRedeemPaymentTokensTest, ScheduleNextTokenRedemption) { // Arrange const URLResponseMap url_responses = { - {BuildRedeemPaymentTokensUrlPath(/*payment_id=*/kWalletPaymentId), + {BuildRedeemPaymentTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_OK, test::BuildRedeemPaymentTokensUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -143,7 +143,7 @@ TEST_F(BraveAdsRedeemPaymentTokensTest, NoPaymentTokens) { TEST_F(BraveAdsRedeemPaymentTokensTest, Retry) { // Arrange const URLResponseMap url_responses = { - {BuildRedeemPaymentTokensUrlPath(/*payment_id=*/kWalletPaymentId), + {BuildRedeemPaymentTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_NOT_FOUND, /*response_body=*/net::GetHttpReasonPhrase(net::HTTP_NOT_FOUND)}, {net::HTTP_OK, test::BuildRedeemPaymentTokensUrlResponseBody()}}}}; diff --git a/components/brave_ads/core/internal/account/utility/redeem_payment_tokens/url_request_builders/redeem_payment_tokens_url_request_builder_util_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_payment_tokens/url_request_builders/redeem_payment_tokens_url_request_builder_util_unittest.cc index d81c04d03c5e..2affebabb98b 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_payment_tokens/url_request_builders/redeem_payment_tokens_url_request_builder_util_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_payment_tokens/url_request_builders/redeem_payment_tokens_url_request_builder_util_unittest.cc @@ -15,7 +15,7 @@ namespace brave_ads { TEST(BraveAdsRedeemPaymentTokensUrlRequestBuilderUtilTest, GetPath) { // Act & Assert EXPECT_EQ("/v3/confirmation/payment/27a39b2f-9b2e-4eb0-bbb2-2f84447496e7", - BuildRedeemPaymentTokensUrlPath(kWalletPaymentId)); + BuildRedeemPaymentTokensUrlPath(test::kWalletPaymentId)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/refill_confirmation_tokens_unittest.cc b/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/refill_confirmation_tokens_unittest.cc index 0bef3eaa09d9..6c06e765efb7 100644 --- a/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/refill_confirmation_tokens_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/refill_confirmation_tokens_unittest.cc @@ -53,9 +53,10 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, RefillConfirmationTokens) { test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, test::BuildGetSignedTokensUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -79,9 +80,10 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_UNAUTHORIZED, /*response_body=*/R"( { "captcha_id": "daf85dc8-164e-4eb9-a4d4-1836055004b3" @@ -109,9 +111,10 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, IssuersPublicKeyMismatch) { test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, test::BuildGetSignedTokensUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -144,12 +147,13 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_INTERNAL_SERVER_ERROR, /*response_body=*/net::GetHttpReasonPhrase( net::HTTP_INTERNAL_SERVER_ERROR)}, {net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, test::BuildGetSignedTokensUrlResponseBody()}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -174,7 +178,7 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, RequestSignedTokensMissingNonce) { test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, /*response_body=*/"{}"}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -198,10 +202,11 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}, {net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_INTERNAL_SERVER_ERROR, /*response_body=*/net::GetHttpReasonPhrase( net::HTTP_INTERNAL_SERVER_ERROR)}, @@ -229,9 +234,10 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, GetSignedTokensInvalidResponse) { test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, /*response_body=*/"{INVALID}"}}}}; MockUrlResponses(ads_client_mock_, url_responses); @@ -254,9 +260,10 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, GetSignedTokensMissingPublicKey) { test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, /*response_body=*/R"( { "batchProof": "nZBm4sojuuKV91w9/Hcevh3r0SSmx7Cu26oeUko7hwIXYQJXjuFabmJ40nNToVm7UAkiaQvoKDFViqfpHcwxAA==", @@ -335,9 +342,10 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, /*response_body=*/R"( { "signedTokens": [ @@ -415,9 +423,10 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, /*response_body=*/R"( { "batchProof": "emZH1a/Y+Q/ub1n7FuWZdkS/989iw4wNl2AnSNMmCQgy4f4ocjDJbHsWMnXWJUAIDPMHilVNJ1SXVctZ8TleBw==", @@ -444,9 +453,10 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, GetInvalidSignedTokens) { test::MockTokenGenerator(token_generator_mock_, /*count=*/50); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, /*response_body=*/R"( { { @@ -547,9 +557,10 @@ TEST_F(BraveAdsRefillConfirmationTokensTest, RefillIfBelowTheMinimumThreshold) { test::RefillConfirmationTokens(/*count=*/19); const URLResponseMap url_responses = { - {BuildRequestSignedTokensUrlPath(kWalletPaymentId), + {BuildRequestSignedTokensUrlPath(test::kWalletPaymentId), {{net::HTTP_CREATED, test::BuildRequestSignedTokensUrlResponseBody()}}}, - {BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce), + {BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce), {{net::HTTP_OK, /*response_body=*/R"( { "batchProof": "gCF+6wrxT9bRFX+yjbdwPeWNZ8/wuDg6uZPy0Ea0yA2cfq5yEMpMfYMoH4BHW6EBbWR5QaOo1mVg+O9syYD3CA==", diff --git a/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/get_signed_tokens/get_signed_tokens_url_request_builder_test_constants.h b/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/get_signed_tokens/get_signed_tokens_url_request_builder_test_constants.h index 27723f73790d..45032b8d9e25 100644 --- a/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/get_signed_tokens/get_signed_tokens_url_request_builder_test_constants.h +++ b/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/get_signed_tokens/get_signed_tokens_url_request_builder_test_constants.h @@ -6,11 +6,11 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_UTILITY_REFILL_CONFIRMATION_TOKENS_URL_REQUESTS_GET_SIGNED_TOKENS_GET_SIGNED_TOKENS_URL_REQUEST_BUILDER_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_UTILITY_REFILL_CONFIRMATION_TOKENS_URL_REQUESTS_GET_SIGNED_TOKENS_GET_SIGNED_TOKENS_URL_REQUEST_BUILDER_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { -inline constexpr char kGetSignedTokensNonce[] = +inline constexpr char kRequestSignedTokensNonce[] = "2f0e2891-e7a5-4262-835b-550b13e58e5c"; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_UTILITY_REFILL_CONFIRMATION_TOKENS_URL_REQUESTS_GET_SIGNED_TOKENS_GET_SIGNED_TOKENS_URL_REQUEST_BUILDER_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/get_signed_tokens/get_signed_tokens_url_request_builder_util_unittest.cc b/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/get_signed_tokens/get_signed_tokens_url_request_builder_util_unittest.cc index b2503d3641ff..660fcbb7aed7 100644 --- a/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/get_signed_tokens/get_signed_tokens_url_request_builder_util_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/get_signed_tokens/get_signed_tokens_url_request_builder_util_unittest.cc @@ -17,7 +17,8 @@ TEST(BraveAdsBuildGetSignedTokensUrlRequestBuilderUtilTest, GetPath) { // Act & Assert EXPECT_EQ( R"(/v3/confirmation/token/27a39b2f-9b2e-4eb0-bbb2-2f84447496e7?nonce=2f0e2891-e7a5-4262-835b-550b13e58e5c)", - BuildGetSignedTokensUrlPath(kWalletPaymentId, kGetSignedTokensNonce)); + BuildGetSignedTokensUrlPath(test::kWalletPaymentId, + test::kRequestSignedTokensNonce)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/request_signed_tokens/request_signed_tokens_url_request_builder_util_unittest.cc b/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/request_signed_tokens/request_signed_tokens_url_request_builder_util_unittest.cc index 71a636f2fbe8..aa47f401fdcc 100644 --- a/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/request_signed_tokens/request_signed_tokens_url_request_builder_util_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/request_signed_tokens/request_signed_tokens_url_request_builder_util_unittest.cc @@ -15,7 +15,7 @@ namespace brave_ads { TEST(BraveAdsRequestSignedTokensUrlRequestBuilderUtilTest, GetPath) { // Act & Assert EXPECT_EQ("/v3/confirmation/token/27a39b2f-9b2e-4eb0-bbb2-2f84447496e7", - BuildRequestSignedTokensUrlPath(kWalletPaymentId)); + BuildRequestSignedTokensUrlPath(test::kWalletPaymentId)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/request_signed_tokens/request_signed_tokens_url_request_util_unittest.cc b/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/request_signed_tokens/request_signed_tokens_url_request_util_unittest.cc index 0bc95b5a9cdb..d2be076b5b5d 100644 --- a/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/request_signed_tokens/request_signed_tokens_url_request_util_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/refill_confirmation_tokens/url_requests/request_signed_tokens/request_signed_tokens_url_request_util_unittest.cc @@ -18,7 +18,7 @@ class BraveAdsRequestSignedTokensUrlRequestUtilTest : public UnitTestBase {}; TEST_F(BraveAdsRequestSignedTokensUrlRequestUtilTest, ParseNonce) { // Act & Assert - EXPECT_EQ(kGetSignedTokensNonce, + EXPECT_EQ(test::kRequestSignedTokensNonce, ParseNonce(base::test::ParseJsonDict( test::BuildRequestSignedTokensUrlResponseBody()))); } diff --git a/components/brave_ads/core/internal/account/wallet/wallet_test_constants.h b/components/brave_ads/core/internal/account/wallet/wallet_test_constants.h index 978bc3fe3169..ce925427c015 100644 --- a/components/brave_ads/core/internal/account/wallet/wallet_test_constants.h +++ b/components/brave_ads/core/internal/account/wallet/wallet_test_constants.h @@ -6,12 +6,12 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_WALLET_WALLET_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_WALLET_WALLET_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { inline constexpr char kWalletPaymentId[] = "27a39b2f-9b2e-4eb0-bbb2-2f84447496e7"; -inline constexpr char kWalletRecoverySeed[] = +inline constexpr char kWalletRecoverySeedBase64[] = "x5uBvgI5MTTVY6sjGv65e9EHr8v7i+UxkFB9qVc5fP0="; inline constexpr char kInvalidWalletRecoverySeed[] = "y6vCwhJ6NUUWZ7tkHw76f0FIs9w8j-VylGC0rWd6gQ1="; @@ -22,6 +22,6 @@ inline constexpr char kWalletPublicKey[] = inline constexpr char kWalletSecretKey[] = R"(kwUjEEdzI6rkI6hLoyxosa47ZrcZUvbYppAm4zvYF5gGIb+Le180tJ44D1kXmuQ8IbKGRzsoJFtBLdtUYy8VDQ==)"; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_WALLET_WALLET_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/account/wallet/wallet_test_util.cc b/components/brave_ads/core/internal/account/wallet/wallet_test_util.cc index 6bab5a21423a..b36580287154 100644 --- a/components/brave_ads/core/internal/account/wallet/wallet_test_util.cc +++ b/components/brave_ads/core/internal/account/wallet/wallet_test_util.cc @@ -5,6 +5,7 @@ #include "brave/components/brave_ads/core/internal/account/wallet/wallet_test_util.h" +#include "base/check.h" #include "brave/components/brave_ads/core/internal/account/wallet/wallet_info.h" #include "brave/components/brave_ads/core/internal/account/wallet/wallet_test_constants.h" #include "brave/components/brave_ads/core/internal/account/wallet/wallet_util.h" @@ -13,13 +14,17 @@ namespace brave_ads::test { WalletInfo Wallet() { - return ToWallet(kWalletPaymentId, kWalletRecoverySeed).value_or(WalletInfo{}); + const std::optional wallet = + ToWallet(kWalletPaymentId, kWalletRecoverySeedBase64); + CHECK(wallet); + + return *wallet; } mojom::WalletInfoPtr WalletPtr() { mojom::WalletInfoPtr wallet = mojom::WalletInfo::New(); wallet->payment_id = kWalletPaymentId; - wallet->recovery_seed = kWalletRecoverySeed; + wallet->recovery_seed = kWalletRecoverySeedBase64; return wallet; } diff --git a/components/brave_ads/core/internal/account/wallet/wallet_util.cc b/components/brave_ads/core/internal/account/wallet/wallet_util.cc index 7e62f15aaa17..657b0d9a78c9 100644 --- a/components/brave_ads/core/internal/account/wallet/wallet_util.cc +++ b/components/brave_ads/core/internal/account/wallet/wallet_util.cc @@ -15,9 +15,9 @@ namespace brave_ads { std::optional ToWallet(const std::string& payment_id, - const std::string& recovery_seed) { + const std::string& recovery_seed_base64) { const std::optional> raw_recovery_seed = - base::Base64Decode(recovery_seed); + base::Base64Decode(recovery_seed_base64); if (!raw_recovery_seed) { return std::nullopt; } diff --git a/components/brave_ads/core/internal/account/wallet/wallet_util.h b/components/brave_ads/core/internal/account/wallet/wallet_util.h index ddf871708000..bd70d8929158 100644 --- a/components/brave_ads/core/internal/account/wallet/wallet_util.h +++ b/components/brave_ads/core/internal/account/wallet/wallet_util.h @@ -14,7 +14,7 @@ namespace brave_ads { struct WalletInfo; std::optional ToWallet(const std::string& payment_id, - const std::string& recovery_seed); + const std::string& recovery_seed_base64); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/wallet/wallet_util_unittest.cc b/components/brave_ads/core/internal/account/wallet/wallet_util_unittest.cc index 8dc0b99d11f3..50542fa2203a 100644 --- a/components/brave_ads/core/internal/account/wallet/wallet_util_unittest.cc +++ b/components/brave_ads/core/internal/account/wallet/wallet_util_unittest.cc @@ -17,17 +17,19 @@ namespace brave_ads { TEST(BraveAdsWalletUtilTest, ToWallet) { // Act const std::optional wallet = - ToWallet(kWalletPaymentId, kWalletRecoverySeed); + ToWallet(test::kWalletPaymentId, test::kWalletRecoverySeedBase64); ASSERT_TRUE(wallet); // Assert - EXPECT_THAT(*wallet, ::testing::FieldsAre(kWalletPaymentId, kWalletPublicKey, - kWalletSecretKey)); + EXPECT_THAT(*wallet, ::testing::FieldsAre(test::kWalletPaymentId, + test::kWalletPublicKey, + test::kWalletSecretKey)); } TEST(BraveAdsWalletUtilTest, ToInvalidWallet) { // Act & Assert - EXPECT_FALSE(ToWallet(kWalletPaymentId, kInvalidWalletRecoverySeed)); + EXPECT_FALSE( + ToWallet(test::kWalletPaymentId, test::kInvalidWalletRecoverySeed)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/ad_units/ad_test_constants.h b/components/brave_ads/core/internal/ad_units/ad_test_constants.h index c1c3d0f3324b..0b5ececfb6fa 100644 --- a/components/brave_ads/core/internal/ad_units/ad_test_constants.h +++ b/components/brave_ads/core/internal/ad_units/ad_test_constants.h @@ -6,7 +6,7 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_AD_UNITS_AD_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_AD_UNITS_AD_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { inline constexpr char kPlacementId[] = "9bac9ae4-693c-4569-9b3e-300e357780cf"; inline constexpr char kMissingPlacementId[] = @@ -38,6 +38,6 @@ inline constexpr char kSegment[] = "untargeted"; inline constexpr char kTargetUrl[] = "https://brave.com"; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_AD_UNITS_AD_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_test.cc b/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_test.cc index 7f1c75dd3157..a7b0d02176c0 100644 --- a/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_test.cc +++ b/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_test.cc @@ -161,7 +161,7 @@ TEST_F(BraveAdsInlineContentAdIntegrationTest, // Act & Assert TriggerInlineContentAdEventAndVerifiyExpectations( - ad->placement_id, kInvalidCreativeInstanceId, + ad->placement_id, test::kInvalidCreativeInstanceId, mojom::InlineContentAdEventType::kViewedImpression, /*should_fire_event=*/false); }); diff --git a/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_test_util.cc b/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_test_util.cc index ed3b633b644d..c25f17e1af7c 100644 --- a/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_test_util.cc +++ b/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_test_util.cc @@ -14,7 +14,7 @@ namespace brave_ads::test { InlineContentAdInfo BuildInlineContentAd( const bool should_generate_random_uuids) { const CreativeInlineContentAdInfo creative_ad = - test::BuildCreativeInlineContentAd(should_generate_random_uuids); + BuildCreativeInlineContentAd(should_generate_random_uuids); return BuildInlineContentAd(creative_ad); } diff --git a/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_value_util_unittest.cc b/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_value_util_unittest.cc index 09e346dfb1b0..f483b9aa23ad 100644 --- a/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_value_util_unittest.cc +++ b/components/brave_ads/core/internal/ad_units/inline_content_ad/inline_content_ad_value_util_unittest.cc @@ -51,7 +51,7 @@ TEST_F(BraveAdsInlineContentAdValueUtilTest, FromValue) { const CreativeInlineContentAdInfo creative_ad = test::BuildCreativeInlineContentAd( /*should_generate_random_uuids=*/false); - EXPECT_EQ(BuildInlineContentAd(creative_ad, kPlacementId), ad); + EXPECT_EQ(BuildInlineContentAd(creative_ad, test::kPlacementId), ad); } TEST_F(BraveAdsInlineContentAdValueUtilTest, ToValue) { @@ -60,7 +60,7 @@ TEST_F(BraveAdsInlineContentAdValueUtilTest, ToValue) { test::BuildCreativeInlineContentAd( /*should_generate_random_uuids=*/false); const InlineContentAdInfo ad = - BuildInlineContentAd(creative_ad, kPlacementId); + BuildInlineContentAd(creative_ad, test::kPlacementId); // Act const base::Value::Dict dict = InlineContentAdToValue(ad); diff --git a/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_test.cc b/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_test.cc index 138507ce7af1..f42ad493c9da 100644 --- a/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_test.cc +++ b/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_test.cc @@ -145,7 +145,7 @@ TEST_F(BraveAdsNewTabPageAdIntegrationTest, // Act & Assert TriggerNewTabPageAdEventAndVerifiyExpectations( - kPlacementId, kCreativeInstanceId, + test::kPlacementId, test::kCreativeInstanceId, mojom::NewTabPageAdEventType::kViewedImpression, /*should_fire_event=*/true); } @@ -158,7 +158,7 @@ TEST_F( // Act & Assert TriggerNewTabPageAdEventAndVerifiyExpectations( - kPlacementId, kCreativeInstanceId, + test::kPlacementId, test::kCreativeInstanceId, mojom::NewTabPageAdEventType::kViewedImpression, /*should_fire_event=*/false); } @@ -200,13 +200,14 @@ TEST_F(BraveAdsNewTabPageAdIntegrationTest, test::DisableBraveRewards(); TriggerNewTabPageAdEventAndVerifiyExpectations( - kPlacementId, kCreativeInstanceId, + test::kPlacementId, test::kCreativeInstanceId, mojom::NewTabPageAdEventType::kViewedImpression, /*should_fire_event=*/true); // Act & Assert TriggerNewTabPageAdEventAndVerifiyExpectations( - kPlacementId, kCreativeInstanceId, mojom::NewTabPageAdEventType::kClicked, + test::kPlacementId, test::kCreativeInstanceId, + mojom::NewTabPageAdEventType::kClicked, /*should_fire_event=*/true); } @@ -217,17 +218,18 @@ TEST_F( test::DisableBraveRewards(); TriggerNewTabPageAdEventAndVerifiyExpectations( - kPlacementId, kCreativeInstanceId, + test::kPlacementId, test::kCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression, /*should_fire_event=*/false); TriggerNewTabPageAdEventAndVerifiyExpectations( - kPlacementId, kCreativeInstanceId, + test::kPlacementId, test::kCreativeInstanceId, mojom::NewTabPageAdEventType::kViewedImpression, /*should_fire_event=*/false); // Act & Assert TriggerNewTabPageAdEventAndVerifiyExpectations( - kPlacementId, kCreativeInstanceId, mojom::NewTabPageAdEventType::kClicked, + test::kPlacementId, test::kCreativeInstanceId, + mojom::NewTabPageAdEventType::kClicked, /*should_fire_event=*/false); } @@ -247,7 +249,7 @@ TEST_F(BraveAdsNewTabPageAdIntegrationTest, // Act & Assert TriggerNewTabPageAdEventAndVerifiyExpectations( - ad->placement_id, kInvalidCreativeInstanceId, + ad->placement_id, test::kInvalidCreativeInstanceId, mojom::NewTabPageAdEventType::kViewedImpression, /*should_fire_event=*/false); }); diff --git a/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_test_util.cc b/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_test_util.cc index 6caef135c91b..05f02069b161 100644 --- a/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_test_util.cc +++ b/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_test_util.cc @@ -13,7 +13,7 @@ namespace brave_ads::test { NewTabPageAdInfo BuildNewTabPageAd(const bool should_generate_random_uuids) { const CreativeNewTabPageAdInfo creative_ad = - test::BuildCreativeNewTabPageAd(should_generate_random_uuids); + BuildCreativeNewTabPageAd(should_generate_random_uuids); return BuildNewTabPageAd(creative_ad); } diff --git a/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_value_util_unittest.cc b/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_value_util_unittest.cc index 5e0c17c05b81..905535bfb10c 100644 --- a/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_value_util_unittest.cc +++ b/components/brave_ads/core/internal/ad_units/new_tab_page_ad/new_tab_page_ad_value_util_unittest.cc @@ -58,14 +58,15 @@ TEST_F(BraveAdsNewTabPageAdValueUtilTest, FromValue) { // Assert const CreativeNewTabPageAdInfo creative_ad = test::BuildCreativeNewTabPageAd(/*should_generate_random_uuids=*/false); - EXPECT_EQ(BuildNewTabPageAd(creative_ad, kPlacementId), ad); + EXPECT_EQ(BuildNewTabPageAd(creative_ad, test::kPlacementId), ad); } TEST_F(BraveAdsNewTabPageAdValueUtilTest, ToValue) { // Arrange const CreativeNewTabPageAdInfo creative_ad = test::BuildCreativeNewTabPageAd(/*should_generate_random_uuids=*/false); - const NewTabPageAdInfo ad = BuildNewTabPageAd(creative_ad, kPlacementId); + const NewTabPageAdInfo ad = + BuildNewTabPageAd(creative_ad, test::kPlacementId); // Act const base::Value::Dict dict = NewTabPageAdToValue(ad); diff --git a/components/brave_ads/core/internal/ad_units/notification_ad/notification_ad_test_util.cc b/components/brave_ads/core/internal/ad_units/notification_ad/notification_ad_test_util.cc index fa1d47214f72..83652ad0e8a0 100644 --- a/components/brave_ads/core/internal/ad_units/notification_ad/notification_ad_test_util.cc +++ b/components/brave_ads/core/internal/ad_units/notification_ad/notification_ad_test_util.cc @@ -14,7 +14,7 @@ namespace brave_ads::test { NotificationAdInfo BuildNotificationAd( const bool should_generate_random_uuids) { const CreativeNotificationAdInfo creative_ad = - test::BuildCreativeNotificationAd(should_generate_random_uuids); + BuildCreativeNotificationAd(should_generate_random_uuids); return BuildNotificationAd(creative_ad); } diff --git a/components/brave_ads/core/internal/ad_units/notification_ad/notification_ad_value_util_unittest.cc b/components/brave_ads/core/internal/ad_units/notification_ad/notification_ad_value_util_unittest.cc index cf7368782ff1..34804d72fe01 100644 --- a/components/brave_ads/core/internal/ad_units/notification_ad/notification_ad_value_util_unittest.cc +++ b/components/brave_ads/core/internal/ad_units/notification_ad/notification_ad_value_util_unittest.cc @@ -73,7 +73,8 @@ TEST_F(BraveAdsNotificationAdValueUtilTest, ToValue) { // Arrange const CreativeNotificationAdInfo creative_ad = test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/false); - const NotificationAdInfo ad = BuildNotificationAd(creative_ad, kPlacementId); + const NotificationAdInfo ad = + BuildNotificationAd(creative_ad, test::kPlacementId); // Act const base::Value::Dict dict = NotificationAdToValue(ad); @@ -86,7 +87,8 @@ TEST_F(BraveAdsNotificationAdValueUtilTest, ToListValue) { // Arrange const CreativeNotificationAdInfo creative_ad = test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/false); - const NotificationAdInfo ad = BuildNotificationAd(creative_ad, kPlacementId); + const NotificationAdInfo ad = + BuildNotificationAd(creative_ad, test::kPlacementId); // Act const base::Value::List list = NotificationAdsToValue({ad, ad}); @@ -105,7 +107,7 @@ TEST_F(BraveAdsNotificationAdValueUtilTest, FromValue) { // Assert const CreativeNotificationAdInfo creative_ad = test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/false); - EXPECT_EQ(BuildNotificationAd(creative_ad, kPlacementId), ad); + EXPECT_EQ(BuildNotificationAd(creative_ad, test::kPlacementId), ad); } TEST_F(BraveAdsNotificationAdValueUtilTest, FromListValue) { @@ -119,7 +121,8 @@ TEST_F(BraveAdsNotificationAdValueUtilTest, FromListValue) { // Assert const CreativeNotificationAdInfo creative_ad = test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/false); - const NotificationAdInfo ad = BuildNotificationAd(creative_ad, kPlacementId); + const NotificationAdInfo ad = + BuildNotificationAd(creative_ad, test::kPlacementId); const base::circular_deque expected_ads = {ad, ad}; EXPECT_TRUE(base::ranges::equal(expected_ads, ads)); } diff --git a/components/brave_ads/core/internal/ad_units/promoted_content_ad/promoted_content_ad_test.cc b/components/brave_ads/core/internal/ad_units/promoted_content_ad/promoted_content_ad_test.cc index e94d86dd21d7..4854b819e6c5 100644 --- a/components/brave_ads/core/internal/ad_units/promoted_content_ad/promoted_content_ad_test.cc +++ b/components/brave_ads/core/internal/ad_units/promoted_content_ad/promoted_content_ad_test.cc @@ -50,7 +50,7 @@ class BraveAdsPromotedContentAdIntegrationTest : public UnitTestBase { TEST_F(BraveAdsPromotedContentAdIntegrationTest, TriggerViewedEvent) { // Act & Assert TriggerPromotedContentAdEventAndVerifiyExpectations( - kPlacementId, kCreativeInstanceId, + test::kPlacementId, test::kCreativeInstanceId, mojom::PromotedContentAdEventType::kViewedImpression, /*should_fire_event=*/true); } @@ -58,13 +58,13 @@ TEST_F(BraveAdsPromotedContentAdIntegrationTest, TriggerViewedEvent) { TEST_F(BraveAdsPromotedContentAdIntegrationTest, TriggerClickedEvent) { // Arrange TriggerPromotedContentAdEventAndVerifiyExpectations( - kPlacementId, kCreativeInstanceId, + test::kPlacementId, test::kCreativeInstanceId, mojom::PromotedContentAdEventType::kViewedImpression, /*should_fire_event=*/true); // Act & Assert TriggerPromotedContentAdEventAndVerifiyExpectations( - kPlacementId, kCreativeInstanceId, + test::kPlacementId, test::kCreativeInstanceId, mojom::PromotedContentAdEventType::kClicked, /*should_fire_event=*/true); } @@ -73,7 +73,7 @@ TEST_F(BraveAdsPromotedContentAdIntegrationTest, DoNotTriggerEventForInvalidCreativeInstanceId) { // Act & Assert TriggerPromotedContentAdEventAndVerifiyExpectations( - kPlacementId, kInvalidCreativeInstanceId, + test::kPlacementId, test::kInvalidCreativeInstanceId, mojom::PromotedContentAdEventType::kViewedImpression, /*should_fire_event=*/false); } @@ -85,7 +85,7 @@ TEST_F(BraveAdsPromotedContentAdIntegrationTest, // Act & Assert TriggerPromotedContentAdEventAndVerifiyExpectations( - kPlacementId, kInvalidCreativeInstanceId, + test::kPlacementId, test::kInvalidCreativeInstanceId, mojom::PromotedContentAdEventType::kViewedImpression, /*should_fire_event=*/false); } diff --git a/components/brave_ads/core/internal/ads_observer_test_util.cc b/components/brave_ads/core/internal/ads_observer_test_util.cc index a9c0233cd0f2..af73a59f98e6 100644 --- a/components/brave_ads/core/internal/ads_observer_test_util.cc +++ b/components/brave_ads/core/internal/ads_observer_test_util.cc @@ -10,7 +10,7 @@ #include "brave/components/brave_ads/core/internal/ads_observer_mock.h" #include "brave/components/brave_ads/core/internal/ads_observer_test_util.h" -namespace brave_ads { +namespace brave_ads::test { AdsObserverMock* AddAdsObserverMock() { std::unique_ptr ads_observer_mock = @@ -20,7 +20,8 @@ AdsObserverMock* AddAdsObserverMock() { // `AdsNotifierManager` takes ownership of `ads_observer_mock`. AdsNotifierManager::GetInstance().AddObserver(std::move(ads_observer_mock)); + return value; } -} // namespace brave_ads +} // namespace brave_ads::test diff --git a/components/brave_ads/core/internal/ads_observer_test_util.h b/components/brave_ads/core/internal/ads_observer_test_util.h index 4dba5d3d6796..3f1cfdd54949 100644 --- a/components/brave_ads/core/internal/ads_observer_test_util.h +++ b/components/brave_ads/core/internal/ads_observer_test_util.h @@ -10,8 +10,12 @@ namespace brave_ads { class AdsObserverMock; +namespace test { + AdsObserverMock* AddAdsObserverMock(); +} // namespace test + } // namespace brave_ads #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ADS_OBSERVER_TEST_UTIL_H_ diff --git a/components/brave_ads/core/internal/catalog/catalog_test_constants.h b/components/brave_ads/core/internal/catalog/catalog_test_constants.h index 4644cc638989..71619977a60e 100644 --- a/components/brave_ads/core/internal/catalog/catalog_test_constants.h +++ b/components/brave_ads/core/internal/catalog/catalog_test_constants.h @@ -6,7 +6,7 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CATALOG_CATALOG_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CATALOG_CATALOG_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { inline constexpr char kCatalogFilename[] = "catalog.json"; inline constexpr char kEmptyCatalogFilename[] = "empty_catalog.json"; @@ -19,6 +19,6 @@ inline constexpr char kInvalidCatalogJson[] = "INVALID_JSON"; inline constexpr char kCatalogId[] = "29e5c8bc0ba319069980bb390d8e8f9b58c05a20"; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CATALOG_CATALOG_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/catalog/catalog_url_request_json_reader_unittest.cc b/components/brave_ads/core/internal/catalog/catalog_url_request_json_reader_unittest.cc index a341035c066a..861d62c45eb9 100644 --- a/components/brave_ads/core/internal/catalog/catalog_url_request_json_reader_unittest.cc +++ b/components/brave_ads/core/internal/catalog/catalog_url_request_json_reader_unittest.cc @@ -432,7 +432,8 @@ TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest, ParseCatalogWithSingleCampaign) { // Arrange const std::optional contents = - MaybeReadFileToStringAndReplaceTags(kCatalogWithSingleCampaignFilename); + MaybeReadFileToStringAndReplaceTags( + test::kCatalogWithSingleCampaignFilename); ASSERT_TRUE(contents); // Act @@ -442,7 +443,7 @@ TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest, // Assert EXPECT_THAT(*catalog, ::testing::FieldsAre( - kCatalogId, /*version*/ 9, + test::kCatalogId, /*version*/ 9, /*ping*/ base::Milliseconds(7'200'000), CatalogCampaignList{BuildCatalogCampaign1()})); } @@ -452,7 +453,7 @@ TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest, // Arrange const std::optional contents = MaybeReadFileToStringAndReplaceTags( - kCatalogWithMultipleCampaignsFilename); + test::kCatalogWithMultipleCampaignsFilename); ASSERT_TRUE(contents); // Act @@ -462,7 +463,7 @@ TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest, // Assert EXPECT_THAT(*catalog, ::testing::FieldsAre( - kCatalogId, /*version*/ 9, + test::kCatalogId, /*version*/ 9, /*ping*/ base::Milliseconds(7'200'000), CatalogCampaignList{BuildCatalogCampaign1(), BuildCatalogCampaign2()})); @@ -471,7 +472,7 @@ TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest, TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest, ParseEmptyCatalog) { // Arrange const std::optional contents = - MaybeReadFileToStringAndReplaceTags(kEmptyCatalogFilename); + MaybeReadFileToStringAndReplaceTags(test::kEmptyCatalogFilename); ASSERT_TRUE(contents); // Act @@ -481,14 +482,14 @@ TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest, ParseEmptyCatalog) { // Assert EXPECT_THAT(*catalog, - ::testing::FieldsAre(/*id*/ kCatalogId, /*version*/ 9, + ::testing::FieldsAre(test::kCatalogId, /*version*/ 9, /*ping*/ base::Milliseconds(7'200'000), /*campaigns*/ ::testing::IsEmpty())); } TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest, InvalidCatalog) { // Act & Assert - EXPECT_FALSE(json::reader::ReadCatalog(kInvalidCatalogJson)); + EXPECT_FALSE(json::reader::ReadCatalog(test::kInvalidCatalogJson)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/catalog/catalog_util_unittest.cc b/components/brave_ads/core/internal/catalog/catalog_util_unittest.cc index db8fe478ac13..bd3cc20ce81a 100644 --- a/components/brave_ads/core/internal/catalog/catalog_util_unittest.cc +++ b/components/brave_ads/core/internal/catalog/catalog_util_unittest.cc @@ -19,7 +19,7 @@ class BraveAdsCatalogUtilTest : public UnitTestBase {}; TEST_F(BraveAdsCatalogUtilTest, ResetCatalog) { // Arrange - SetCatalogId(kCatalogId); + SetCatalogId(test::kCatalogId); SetCatalogVersion(1); SetCatalogPing(base::Hours(1)); SetCatalogLastUpdated(Now()); @@ -52,7 +52,7 @@ TEST_F(BraveAdsCatalogUtilTest, CatalogDoesNotExist) { TEST_F(BraveAdsCatalogUtilTest, CatalogHasChanged) { // Arrange - SetCatalogId(kCatalogId); + SetCatalogId(test::kCatalogId); // Act & Assert EXPECT_TRUE(HasCatalogChanged( @@ -61,10 +61,10 @@ TEST_F(BraveAdsCatalogUtilTest, CatalogHasChanged) { TEST_F(BraveAdsCatalogUtilTest, CatalogHasNotChanged) { // Arrange - SetCatalogId(kCatalogId); + SetCatalogId(test::kCatalogId); // Act & Assert - EXPECT_FALSE(HasCatalogChanged(kCatalogId)); + EXPECT_FALSE(HasCatalogChanged(test::kCatalogId)); } TEST_F(BraveAdsCatalogUtilTest, CatalogHasExpired) { diff --git a/components/brave_ads/core/internal/common/crypto/crypto_util.cc b/components/brave_ads/core/internal/common/crypto/crypto_util.cc index fcff20dfbacf..278f184e860a 100644 --- a/components/brave_ads/core/internal/common/crypto/crypto_util.cc +++ b/components/brave_ads/core/internal/common/crypto/crypto_util.cc @@ -125,10 +125,10 @@ std::optional Sign(const std::string& message, } bool Verify(const std::string& message, - const std::string& public_key, + const std::string& public_key_base64, const std::string& signature) { const std::optional> raw_public_key = - base::Base64Decode(public_key); + base::Base64Decode(public_key_base64); if (!raw_public_key) { return false; } diff --git a/components/brave_ads/core/internal/common/crypto/crypto_util.h b/components/brave_ads/core/internal/common/crypto/crypto_util.h index 69e9c41fd971..f00fe32ee531 100644 --- a/components/brave_ads/core/internal/common/crypto/crypto_util.h +++ b/components/brave_ads/core/internal/common/crypto/crypto_util.h @@ -27,7 +27,7 @@ std::vector GenerateRandomNonce(); std::optional Sign(const std::string& message, const std::string& secret_key); [[nodiscard]] bool Verify(const std::string& message, - const std::string& public_key, + const std::string& public_key_base64, const std::string& signature); std::vector Encrypt(const std::vector& plaintext, diff --git a/components/brave_ads/core/internal/common/crypto/crypto_util_unittest.cc b/components/brave_ads/core/internal/common/crypto/crypto_util_unittest.cc index 1495a3cf7f5f..d3d11f1db012 100644 --- a/components/brave_ads/core/internal/common/crypto/crypto_util_unittest.cc +++ b/components/brave_ads/core/internal/common/crypto/crypto_util_unittest.cc @@ -18,8 +18,9 @@ namespace brave_ads::crypto { namespace { constexpr char kMessage[] = "The quick brown fox jumps over the lazy dog"; -constexpr char kPublicKey[] = "5LmgyD6OG0qcVeRgTzk3IWbzSWjemE4KpjTRtRW4eRk="; -constexpr char kSecretKey[] = +constexpr char kPublicKeyBase64[] = + "5LmgyD6OG0qcVeRgTzk3IWbzSWjemE4KpjTRtRW4eRk="; +constexpr char kSecretKeyBase64[] = R"(oyd1rHNB5xHU6TzPSO/MUUfUJNHiol1ExFHMMKV/7dvkuaDIPo4bSpxV5GBPOTchZvNJaN6YTgqmNNG1Fbh5GQ==)"; } // namespace @@ -35,7 +36,7 @@ TEST(BraveAdsCryptoUtilTest, Sha256) { TEST(BraveAdsCryptoUtilTest, Sha256WithEmptyString) { // Act - const std::vector sha256 = Sha256(/*value=*/{}); + const std::vector sha256 = Sha256(/*value=*/""); // Assert EXPECT_EQ("47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", @@ -80,7 +81,7 @@ TEST(BraveAdsCryptoUtilTest, GenerateRandomNonce) { TEST(BraveAdsCryptoUtilTest, Sign) { // Act - const std::optional signature = Sign(kMessage, kSecretKey); + const std::optional signature = Sign(kMessage, kSecretKeyBase64); // Assert EXPECT_TRUE(signature); @@ -88,11 +89,11 @@ TEST(BraveAdsCryptoUtilTest, Sign) { TEST(BraveAdsCryptoUtilTest, Verify) { // Act - const std::optional signature = Sign(kMessage, kSecretKey); + const std::optional signature = Sign(kMessage, kSecretKeyBase64); ASSERT_TRUE(signature); // Assert - EXPECT_TRUE(Verify(kMessage, kPublicKey, *signature)); + EXPECT_TRUE(Verify(kMessage, kPublicKeyBase64, *signature)); } TEST(BraveAdsCryptoUtilTest, EncryptAndDecrypt) { diff --git a/components/brave_ads/core/internal/common/resources/country_components_test_constants.h b/components/brave_ads/core/internal/common/resources/country_components_test_constants.h index 5de1e129fb0f..539464cc0e66 100644 --- a/components/brave_ads/core/internal/common/resources/country_components_test_constants.h +++ b/components/brave_ads/core/internal/common/resources/country_components_test_constants.h @@ -6,7 +6,7 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_RESOURCES_COUNTRY_COMPONENTS_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_RESOURCES_COUNTRY_COMPONENTS_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { inline constexpr char kCountryComponentManifestVersion[] = "1.0.0"; inline constexpr char kCountryComponentManifestVersionUpdate[] = "9.9.9"; @@ -16,6 +16,6 @@ inline constexpr char kCountryComponentId[] = inline constexpr char kInvalidCountryComponentId[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_RESOURCES_COUNTRY_COMPONENTS_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/common/resources/language_components_test_constants.h b/components/brave_ads/core/internal/common/resources/language_components_test_constants.h index 1cb9d1dd1df0..26d540593b2f 100644 --- a/components/brave_ads/core/internal/common/resources/language_components_test_constants.h +++ b/components/brave_ads/core/internal/common/resources/language_components_test_constants.h @@ -6,7 +6,7 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_RESOURCES_LANGUAGE_COMPONENTS_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_RESOURCES_LANGUAGE_COMPONENTS_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { inline constexpr char kLanguageComponentManifestVersion[] = "1.0.0"; inline constexpr char kLanguageComponentManifestVersionUpdate[] = "9.9.9"; @@ -16,6 +16,6 @@ inline constexpr char kLanguageComponentId[] = inline constexpr char kInvalidLanguageComponentId[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_RESOURCES_LANGUAGE_COMPONENTS_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/common/resources/resource_test_constants.h b/components/brave_ads/core/internal/common/resources/resource_test_constants.h index fca96162d70f..126b5fc5b063 100644 --- a/components/brave_ads/core/internal/common/resources/resource_test_constants.h +++ b/components/brave_ads/core/internal/common/resources/resource_test_constants.h @@ -6,11 +6,11 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_RESOURCES_RESOURCE_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_RESOURCES_RESOURCE_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { inline constexpr char kMissingResourceId[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; inline constexpr char kMalformedResourceId[] = "resources/malformed_resource"; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_RESOURCES_RESOURCE_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_test_constants.cc b/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_test_constants.cc index 9cd24f9f1b18..23689501d236 100644 --- a/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_test_constants.cc +++ b/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_test_constants.cc @@ -8,7 +8,7 @@ #include "base/no_destructor.h" #include "url/gurl.h" -namespace brave_ads { +namespace brave_ads::test { const std::vector& GetSearchEngineResultsPageUrls() { // When adding new search engines you should perform a search for `foobar` and @@ -72,4 +72,4 @@ const std::vector& GetSearchEngineResultsPageUrls() { return *urls; } -} // namespace brave_ads +} // namespace brave_ads::test diff --git a/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_test_constants.h b/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_test_constants.h index f663375d3cf4..001ef4ad54f9 100644 --- a/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_test_constants.h +++ b/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_test_constants.h @@ -10,10 +10,10 @@ class GURL; -namespace brave_ads { +namespace brave_ads::test { const std::vector& GetSearchEngineResultsPageUrls(); -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_SEARCH_ENGINE_SEARCH_ENGINE_RESULTS_PAGE_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_util_unittest.cc b/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_util_unittest.cc index d827c55365d5..1362078e6f12 100644 --- a/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_util_unittest.cc +++ b/components/brave_ads/core/internal/common/search_engine/search_engine_results_page_util_unittest.cc @@ -15,7 +15,7 @@ namespace brave_ads { TEST(BraveAdsSearchEngineResultsPageUtilTest, IsSearchEngineResultsPage) { // Act & Assert - for (const auto& url : GetSearchEngineResultsPageUrls()) { + for (const auto& url : test::GetSearchEngineResultsPageUrls()) { EXPECT_TRUE(IsSearchEngineResultsPage(url)); } } @@ -33,7 +33,7 @@ TEST(BraveAdsSearchEngineResultsPageUtilTest, TEST(BraveAdsSearchEngineResultsPageUtilTest, ExtractSearchTermQueryValue) { // Act & Assert - for (const auto& url : GetSearchEngineResultsPageUrls()) { + for (const auto& url : test::GetSearchEngineResultsPageUrls()) { if (const std::optional search_term_query_value = ExtractSearchTermQueryValue(url)) { EXPECT_EQ("foobar", search_term_query_value); diff --git a/components/brave_ads/core/internal/common/unittest/unittest_base_util.cc b/components/brave_ads/core/internal/common/unittest/unittest_base_util.cc index 65ade9a981c0..2bd7df89455b 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_base_util.cc +++ b/components/brave_ads/core/internal/common/unittest/unittest_base_util.cc @@ -107,7 +107,7 @@ void MockCacheAdEventForInstanceId(const AdsClientMock& mock) { CHECK(!ad_type.empty()); CHECK(!confirmation_type.empty()); - const std::string uuid = GetUuidForCurrentTestAndValue(id); + const std::string uuid = test::GetUuidForCurrentTestAndValue(id); const std::string type_id = base::StrCat({ad_type, confirmation_type}); AdEventCache()[uuid][type_id].push_back(time); @@ -122,7 +122,8 @@ void MockGetCachedAdEvents(const AdsClientMock& mock) { CHECK(!ad_type.empty()); CHECK(!confirmation_type.empty()); - const std::string uuid_for_current_test = GetUuidForCurrentTest(); + const std::string uuid_for_current_test = + test::GetUuidForCurrentTest(); const std::string type_id = base::StrCat({ad_type, confirmation_type}); @@ -154,7 +155,7 @@ void MockResetAdEventCacheForInstanceId(const AdsClientMock& mock) { .WillByDefault(::testing::Invoke([](const std::string& id) { CHECK(!id.empty()); - const std::string uuid = GetUuidForCurrentTestAndValue(id); + const std::string uuid = test::GetUuidForCurrentTestAndValue(id); AdEventCache()[uuid].clear(); })); } diff --git a/components/brave_ads/core/internal/common/unittest/unittest_current_test_util.cc b/components/brave_ads/core/internal/common/unittest/unittest_current_test_util.cc index d89b29d55c89..246dcb02110a 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_current_test_util.cc +++ b/components/brave_ads/core/internal/common/unittest/unittest_current_test_util.cc @@ -9,7 +9,7 @@ #include "base/strings/string_util.h" #include "testing/gtest/include/gtest/gtest.h" -namespace brave_ads { +namespace brave_ads::test { std::string GetUuidForCurrentTest() { const ::testing::TestInfo* const test_info = @@ -25,4 +25,4 @@ std::string GetUuidForCurrentTestAndValue(const std::string& value) { "$1:$2", {value, GetUuidForCurrentTest()}, nullptr); } -} // namespace brave_ads +} // namespace brave_ads::test diff --git a/components/brave_ads/core/internal/common/unittest/unittest_current_test_util.h b/components/brave_ads/core/internal/common/unittest/unittest_current_test_util.h index 6642b9cce322..57661393a75c 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_current_test_util.h +++ b/components/brave_ads/core/internal/common/unittest/unittest_current_test_util.h @@ -8,11 +8,11 @@ #include -namespace brave_ads { +namespace brave_ads::test { std::string GetUuidForCurrentTest(); std::string GetUuidForCurrentTestAndValue(const std::string& value); -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_COMMON_UNITTEST_UNITTEST_CURRENT_TEST_UTIL_H_ diff --git a/components/brave_ads/core/internal/common/unittest/unittest_local_state_pref_storage.cc b/components/brave_ads/core/internal/common/unittest/unittest_local_state_pref_storage.cc index 2fc91f3372f4..dca5c1d03a5d 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_local_state_pref_storage.cc +++ b/components/brave_ads/core/internal/common/unittest/unittest_local_state_pref_storage.cc @@ -23,13 +23,13 @@ base::flat_map& LocalStatePrefStorage() { } // namespace PrefInfo& LocalStatePref(const std::string& path) { - const std::string uuid = GetUuidForCurrentTestAndValue(path); + const std::string uuid = test::GetUuidForCurrentTestAndValue(path); return LocalStatePrefStorage()[uuid]; } bool HasLocalStatePref(const std::string& path) { return base::Contains(LocalStatePrefStorage(), - GetUuidForCurrentTestAndValue(path)); + test::GetUuidForCurrentTestAndValue(path)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/common/unittest/unittest_profile_pref_storage.cc b/components/brave_ads/core/internal/common/unittest/unittest_profile_pref_storage.cc index d530507af577..f8c378df80c5 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_profile_pref_storage.cc +++ b/components/brave_ads/core/internal/common/unittest/unittest_profile_pref_storage.cc @@ -23,13 +23,13 @@ base::flat_map& ProfilePrefStorage() { } // namespace PrefInfo& ProfilePref(const std::string& path) { - const std::string uuid = GetUuidForCurrentTestAndValue(path); + const std::string uuid = test::GetUuidForCurrentTestAndValue(path); return ProfilePrefStorage()[uuid]; } bool HasProfilePref(const std::string& path) { return base::Contains(ProfilePrefStorage(), - GetUuidForCurrentTestAndValue(path)); + test::GetUuidForCurrentTestAndValue(path)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/common/unittest/unittest_url_response_util.cc b/components/brave_ads/core/internal/common/unittest/unittest_url_response_util.cc index 5af4b29561f9..97100ef8aba4 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_url_response_util.cc +++ b/components/brave_ads/core/internal/common/unittest/unittest_url_response_util.cc @@ -59,7 +59,7 @@ std::optional GetNextUrlResponseForUrl( size_t index = 0; - const std::string uuid = GetUuidForCurrentTestAndValue(request_path); + const std::string uuid = test::GetUuidForCurrentTestAndValue(request_path); const auto iter = UrlResponseIndexes().find(uuid); if (iter == UrlResponseIndexes().cend()) { diff --git a/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_builder_unittest.cc b/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_builder_unittest.cc index 4c94f890d819..9752dc5ec9b7 100644 --- a/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_builder_unittest.cc +++ b/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_builder_unittest.cc @@ -32,12 +32,13 @@ TEST_F(BraveAdsCreativeSetConversionBuilderTest, ASSERT_TRUE(creative_set_conversion); // Assert - EXPECT_THAT(*creative_set_conversion, - ::testing::FieldsAre(kCreativeSetId, - /*url_pattern*/ "https://brave.com/*", - kVerifiableConversionAdvertiserPublicKey, - /*observation_window*/ base::Days(3), - /*expire_at*/ Now() + base::Days(3))); + EXPECT_THAT( + *creative_set_conversion, + ::testing::FieldsAre(test::kCreativeSetId, + /*url_pattern*/ "https://brave.com/*", + test::kVerifiableConversionAdvertiserPublicKeyBase64, + /*observation_window*/ base::Days(3), + /*expire_at*/ Now() + base::Days(3))); } TEST_F(BraveAdsCreativeSetConversionBuilderTest, diff --git a/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_database_table_unittest.cc index e22b691f03a0..f15f254e3ee4 100644 --- a/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_database_table_unittest.cc @@ -40,9 +40,9 @@ TEST_F(BraveAdsCreativeSetConversionDatabaseTableTest, const CreativeSetConversionInfo creative_set_conversion_1 = test::BuildVerifiableCreativeSetConversion( - kCreativeSetId, /*url_pattern=*/"https://www.brave.com/*", + test::kCreativeSetId, /*url_pattern=*/"https://www.brave.com/*", /*observation_window=*/base::Days(3), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); creative_set_conversions.push_back(creative_set_conversion_1); const CreativeSetConversionInfo creative_set_conversion_2 = @@ -69,9 +69,9 @@ TEST_F(BraveAdsCreativeSetConversionDatabaseTableTest, const CreativeSetConversionInfo creative_set_conversion = test::BuildVerifiableCreativeSetConversion( - kCreativeSetId, /*url_pattern=*/"https://www.brave.com/*", + test::kCreativeSetId, /*url_pattern=*/"https://www.brave.com/*", /*observation_window=*/base::Days(3), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); creative_set_conversions.push_back(creative_set_conversion); database::SaveCreativeSetConversions(creative_set_conversions); @@ -93,7 +93,7 @@ TEST_F(BraveAdsCreativeSetConversionDatabaseTableTest, const CreativeSetConversionInfo creative_set_conversion_1 = test::BuildCreativeSetConversion( - kCreativeSetId, + test::kCreativeSetId, /*url_pattern=*/"https://www.brave.com/*", /*observation_window=*/base::Days(7)); creative_set_conversions.push_back(creative_set_conversion_1); @@ -127,10 +127,10 @@ TEST_F(BraveAdsCreativeSetConversionDatabaseTableTest, const CreativeSetConversionInfo creative_set_conversion_1 = test::BuildVerifiableCreativeSetConversion( - kCreativeSetId, + test::kCreativeSetId, /*url_pattern=*/"https://www.brave.com/1", /*observation_window=*/base::Days(3), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); creative_set_conversions_1.push_back(creative_set_conversion_1); database::SaveCreativeSetConversions(creative_set_conversions_1); @@ -139,10 +139,10 @@ TEST_F(BraveAdsCreativeSetConversionDatabaseTableTest, const CreativeSetConversionInfo creative_set_conversion_2 = test::BuildVerifiableCreativeSetConversion( - kCreativeSetId, + test::kCreativeSetId, /*url_pattern=*/"https://www.brave.com/2", /*observation_window=*/base::Days(30), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); creative_set_conversions_2.push_back(creative_set_conversion_2); // Act diff --git a/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_util_unittest.cc b/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_util_unittest.cc index 6360cff76d07..c770f744ec53 100644 --- a/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_util_unittest.cc +++ b/components/brave_ads/core/internal/creatives/conversions/creative_set_conversion_util_unittest.cc @@ -27,25 +27,25 @@ TEST_F(BraveAdsCreativeSetConversionUtilTest, CreativeSetConversionList creative_set_conversions; const CreativeSetConversionInfo creative_set_conversion_1 = - test::BuildCreativeSetConversion(kCreativeSetId, + test::BuildCreativeSetConversion(test::kCreativeSetId, /*url_pattern=*/"https://foo.com/*", /*observation_window=*/base::Days(3)); creative_set_conversions.push_back(creative_set_conversion_1); const CreativeSetConversionInfo creative_set_conversion_2 = - test::BuildCreativeSetConversion(kCreativeSetId, + test::BuildCreativeSetConversion(test::kCreativeSetId, /*url_pattern=*/"https://*.qux.com/fred", /*observation_window=*/base::Days(7)); creative_set_conversions.push_back(creative_set_conversion_2); const CreativeSetConversionInfo creative_set_conversion_3 = - test::BuildCreativeSetConversion(kCreativeSetId, + test::BuildCreativeSetConversion(test::kCreativeSetId, /*url_pattern=*/"https://bar.com/foo", /*observation_window=*/base::Days(30)); creative_set_conversions.push_back(creative_set_conversion_3); const CreativeSetConversionInfo creative_set_conversion_4 = - test::BuildCreativeSetConversion(kCreativeSetId, + test::BuildCreativeSetConversion(test::kCreativeSetId, /*url_pattern=*/"https://baz.com/", /*observation_window=*/base::Days(1)); creative_set_conversions.push_back(creative_set_conversion_4); @@ -112,7 +112,7 @@ TEST_F(BraveAdsCreativeSetConversionUtilTest, const CreativeSetConversionInfo creative_set_conversion_1 = test::BuildCreativeSetConversion( - kCreativeSetId, + test::kCreativeSetId, /*url_pattern=*/"https://foo.com/*", /*observation_window=*/base::Days(3)); // Bucket #1 creative_set_conversions.push_back(creative_set_conversion_1); @@ -126,7 +126,7 @@ TEST_F(BraveAdsCreativeSetConversionUtilTest, const CreativeSetConversionInfo creative_set_conversion_3 = test::BuildCreativeSetConversion( - kCreativeSetId, + test::kCreativeSetId, /*url_pattern=*/"https://baz.com/", /*observation_window=*/base::Days(30)); // Bucket #1 creative_set_conversions.push_back(creative_set_conversion_3); @@ -138,7 +138,8 @@ TEST_F(BraveAdsCreativeSetConversionUtilTest, // Assert CreativeSetConversionBucketMap expected_creative_set_conversion_buckets; expected_creative_set_conversion_buckets.insert( // Bucket #1 - {kCreativeSetId, {creative_set_conversion_1, creative_set_conversion_3}}); + {test::kCreativeSetId, + {creative_set_conversion_1, creative_set_conversion_3}}); expected_creative_set_conversion_buckets.insert( // Bucket #2 {creative_set_conversion_2.id, {creative_set_conversion_2}}); EXPECT_EQ(expected_creative_set_conversion_buckets, @@ -160,7 +161,7 @@ TEST_F(BraveAdsCreativeSetConversionUtilTest, const CreativeSetConversionInfo creative_set_conversion_1 = test::BuildCreativeSetConversion( - kCreativeSetId, + test::kCreativeSetId, /*url_pattern=*/"https://foo.com/*", /*observation_window=*/base::Days(3)); // Bucket #1 creative_set_conversions.push_back(creative_set_conversion_1); @@ -199,7 +200,7 @@ TEST_F(BraveAdsCreativeSetConversionUtilTest, const CreativeSetConversionInfo creative_set_conversion_1 = test::BuildCreativeSetConversion( - kCreativeSetId, + test::kCreativeSetId, /*url_pattern=*/"https://foo.com/*", /*observation_window=*/base::Days(3)); // Bucket #1 creative_set_conversions.push_back(creative_set_conversion_1); @@ -247,10 +248,10 @@ TEST_F(BraveAdsCreativeSetConversionUtilTest, const CreativeSetConversionInfo creative_set_conversion_1 = test::BuildVerifiableCreativeSetConversion( - kCreativeSetId, + test::kCreativeSetId, /*url_pattern=*/"https://foo.com/*", /*observation_window=*/base::Days(7), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); creative_set_conversions.push_back(creative_set_conversion_1); const CreativeSetConversionInfo creative_set_conversion_2 = diff --git a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_unittest.cc index 0181830ad491..d83311392e99 100644 --- a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_unittest.cc @@ -229,9 +229,9 @@ TEST_F(BraveAdsCreativeInlineContentAdsDatabaseTableTest, // Act & Assert base::MockCallback callback; - EXPECT_CALL(callback, Run(/*success=*/false, kMissingCreativeInstanceId, + EXPECT_CALL(callback, Run(/*success=*/false, test::kMissingCreativeInstanceId, CreativeInlineContentAdInfo{})); - database_table_.GetForCreativeInstanceId(kMissingCreativeInstanceId, + database_table_.GetForCreativeInstanceId(test::kMissingCreativeInstanceId, callback.Get()); } diff --git a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_unittest.cc index 019956f0a016..c511a4fa4546 100644 --- a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_unittest.cc @@ -210,9 +210,9 @@ TEST_F(BraveAdsCreativeNewTabPageAdsDatabaseTableTest, // Act & Assert base::MockCallback callback; - EXPECT_CALL(callback, Run(/*success=*/false, kMissingCreativeInstanceId, + EXPECT_CALL(callback, Run(/*success=*/false, test::kMissingCreativeInstanceId, CreativeNewTabPageAdInfo{})); - database_table_.GetForCreativeInstanceId(kMissingCreativeInstanceId, + database_table_.GetForCreativeInstanceId(test::kMissingCreativeInstanceId, callback.Get()); } diff --git a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_unittest.cc index 2587b75f78de..4a383c3e9138 100644 --- a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_unittest.cc @@ -224,9 +224,9 @@ TEST_F(BraveAdsCreativePromotedContentAdsDatabaseTableTest, // Act & Assert base::MockCallback callback; - EXPECT_CALL(callback, Run(/*success=*/false, kMissingCreativeInstanceId, + EXPECT_CALL(callback, Run(/*success=*/false, test::kMissingCreativeInstanceId, CreativePromotedContentAdInfo{})); - database_table_.GetForCreativeInstanceId(kMissingCreativeInstanceId, + database_table_.GetForCreativeInstanceId(test::kMissingCreativeInstanceId, callback.Get()); } diff --git a/components/brave_ads/core/internal/creatives/search_result_ads/creative_search_result_ad_test_util.cc b/components/brave_ads/core/internal/creatives/search_result_ads/creative_search_result_ad_test_util.cc index f6bf03cb9e62..c6cf699496d2 100644 --- a/components/brave_ads/core/internal/creatives/search_result_ads/creative_search_result_ad_test_util.cc +++ b/components/brave_ads/core/internal/creatives/search_result_ads/creative_search_result_ad_test_util.cc @@ -60,7 +60,7 @@ mojom::CreativeSearchResultAdInfoPtr BuildCreativeSearchResultAdWithConversion( kConversionUrlPattern; mojom_creative_ad->creative_set_conversion ->verifiable_advertiser_public_key_base64 = - kVerifiableConversionAdvertiserPublicKey; + kVerifiableConversionAdvertiserPublicKeyBase64; mojom_creative_ad->creative_set_conversion->observation_window = kConversionObservationWindow; diff --git a/components/brave_ads/core/internal/diagnostics/diagnostic_manager_unittest.cc b/components/brave_ads/core/internal/diagnostics/diagnostic_manager_unittest.cc index a807bcf7c6be..0e90dffad037 100644 --- a/components/brave_ads/core/internal/diagnostics/diagnostic_manager_unittest.cc +++ b/components/brave_ads/core/internal/diagnostics/diagnostic_manager_unittest.cc @@ -32,7 +32,7 @@ TEST_F(BraveAdsDiagnosticManagerTest, DiagnosticManager) { AdvanceClockTo(TimeFromString("Wed, 18 Nov 1970 12:34:56")); - SetCatalogId(kCatalogId); + SetCatalogId(test::kCatalogId); SetCatalogLastUpdated(Now()); AdvanceClockTo( diff --git a/components/brave_ads/core/internal/diagnostics/entries/catalog_id_diagnostic_entry_unittest.cc b/components/brave_ads/core/internal/diagnostics/entries/catalog_id_diagnostic_entry_unittest.cc index 9e9fe31e65e0..373db64a5311 100644 --- a/components/brave_ads/core/internal/diagnostics/entries/catalog_id_diagnostic_entry_unittest.cc +++ b/components/brave_ads/core/internal/diagnostics/entries/catalog_id_diagnostic_entry_unittest.cc @@ -18,14 +18,14 @@ class BraveAdsCatalogIdDiagnosticEntryTest : public UnitTestBase {}; TEST_F(BraveAdsCatalogIdDiagnosticEntryTest, CatalogId) { // Arrange - SetCatalogId(kCatalogId); + SetCatalogId(test::kCatalogId); const CatalogIdDiagnosticEntry diagnostic_entry; // Act & Assert EXPECT_EQ(DiagnosticEntryType::kCatalogId, diagnostic_entry.GetType()); EXPECT_EQ("Catalog ID", diagnostic_entry.GetName()); - EXPECT_EQ(kCatalogId, diagnostic_entry.GetValue()); + EXPECT_EQ(test::kCatalogId, diagnostic_entry.GetValue()); } TEST_F(BraveAdsCatalogIdDiagnosticEntryTest, EmptyCatalogId) { diff --git a/components/brave_ads/core/internal/history/ad_content_util_unittest.cc b/components/brave_ads/core/internal/history/ad_content_util_unittest.cc index 023263ae37ce..47173c904a21 100644 --- a/components/brave_ads/core/internal/history/ad_content_util_unittest.cc +++ b/components/brave_ads/core/internal/history/ad_content_util_unittest.cc @@ -37,14 +37,14 @@ TEST_F(BraveAdsAdContentUtilTest, Build) { ad, ConfirmationType::kViewedImpression, kTitle, kDescription); // Assert - EXPECT_THAT( - ad_content, - ::testing::FieldsAre(ad.type, ad.placement_id, ad.creative_instance_id, - ad.creative_set_id, ad.campaign_id, ad.advertiser_id, - kSegment, kTitle, kDescription, ad.target_url.host(), - ad.target_url, mojom::UserReactionType::kNeutral, - ConfirmationType::kViewedImpression, - /*is_saved*/ false, /*is_flagged*/ false)); + EXPECT_THAT(ad_content, + ::testing::FieldsAre( + ad.type, ad.placement_id, ad.creative_instance_id, + ad.creative_set_id, ad.campaign_id, ad.advertiser_id, + test::kSegment, kTitle, kDescription, ad.target_url.host(), + ad.target_url, mojom::UserReactionType::kNeutral, + ConfirmationType::kViewedImpression, + /*is_saved*/ false, /*is_flagged*/ false)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/history/ad_content_value_util_unittest.cc b/components/brave_ads/core/internal/history/ad_content_value_util_unittest.cc index 115e0411ed0a..faffffdc5dd2 100644 --- a/components/brave_ads/core/internal/history/ad_content_value_util_unittest.cc +++ b/components/brave_ads/core/internal/history/ad_content_value_util_unittest.cc @@ -58,7 +58,8 @@ TEST_F(BraveAdsAdContentValueUtilTest, FromValue) { // Assert const CreativeNotificationAdInfo creative_ad = test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/false); - const NotificationAdInfo ad = BuildNotificationAd(creative_ad, kPlacementId); + const NotificationAdInfo ad = + BuildNotificationAd(creative_ad, test::kPlacementId); EXPECT_EQ(BuildAdContent(ad, ConfirmationType::kViewedImpression, kTitle, kDescription), ad_content); @@ -68,7 +69,8 @@ TEST_F(BraveAdsAdContentValueUtilTest, ToValue) { // Arrange const CreativeNotificationAdInfo creative_ad = test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/false); - const NotificationAdInfo ad = BuildNotificationAd(creative_ad, kPlacementId); + const NotificationAdInfo ad = + BuildNotificationAd(creative_ad, test::kPlacementId); const AdContentInfo ad_content = BuildAdContent( ad, ConfirmationType::kViewedImpression, kTitle, kDescription); diff --git a/components/brave_ads/core/internal/history/category_content_util_unittest.cc b/components/brave_ads/core/internal/history/category_content_util_unittest.cc index 8bc5e64799d9..fd2ebff5125b 100644 --- a/components/brave_ads/core/internal/history/category_content_util_unittest.cc +++ b/components/brave_ads/core/internal/history/category_content_util_unittest.cc @@ -18,12 +18,13 @@ class BraveAdsCategoryContentUtilTest : public UnitTestBase {}; TEST_F(BraveAdsCategoryContentUtilTest, Build) { // Act - const CategoryContentInfo category_content = BuildCategoryContent(kSegment); + const CategoryContentInfo category_content = + BuildCategoryContent(test::kSegment); // Assert EXPECT_THAT( category_content, - ::testing::FieldsAre(kSegment, mojom::UserReactionType::kNeutral)); + ::testing::FieldsAre(test::kSegment, mojom::UserReactionType::kNeutral)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/history/category_content_value_util_unittest.cc b/components/brave_ads/core/internal/history/category_content_value_util_unittest.cc index 4af489bd054b..30b2ebd04174 100644 --- a/components/brave_ads/core/internal/history/category_content_value_util_unittest.cc +++ b/components/brave_ads/core/internal/history/category_content_value_util_unittest.cc @@ -36,12 +36,13 @@ TEST_F(BraveAdsCategoryContentValueUtilTest, FromValue) { const CategoryContentInfo category_content = CategoryContentFromValue(dict); // Assert - EXPECT_EQ(BuildCategoryContent(kSegment), category_content); + EXPECT_EQ(BuildCategoryContent(test::kSegment), category_content); } TEST_F(BraveAdsCategoryContentValueUtilTest, ToValue) { // Arrange - const CategoryContentInfo category_content = BuildCategoryContent(kSegment); + const CategoryContentInfo category_content = + BuildCategoryContent(test::kSegment); // Act const base::Value::Dict dict = CategoryContentToValue(category_content); diff --git a/components/brave_ads/core/internal/history/history_item_value_util_unittest.cc b/components/brave_ads/core/internal/history/history_item_value_util_unittest.cc index b568ace93c68..620302773080 100644 --- a/components/brave_ads/core/internal/history/history_item_value_util_unittest.cc +++ b/components/brave_ads/core/internal/history/history_item_value_util_unittest.cc @@ -78,7 +78,8 @@ constexpr char kJson[] = HistoryItemList BuildHistoryItems() { const CreativeNotificationAdInfo creative_ad = test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/false); - const NotificationAdInfo ad = BuildNotificationAd(creative_ad, kPlacementId); + const NotificationAdInfo ad = + BuildNotificationAd(creative_ad, test::kPlacementId); const HistoryItemInfo history_item = BuildHistoryItem( ad, ConfirmationType::kViewedImpression, ad.title, ad.body); diff --git a/components/brave_ads/core/internal/reminder/reminder_unittest.cc b/components/brave_ads/core/internal/reminder/reminder_unittest.cc index 4df1a101d666..e0b389ba14ab 100644 --- a/components/brave_ads/core/internal/reminder/reminder_unittest.cc +++ b/components/brave_ads/core/internal/reminder/reminder_unittest.cc @@ -43,7 +43,7 @@ class BraveAdsReminderTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - ads_observer_mock_ = AddAdsObserverMock(); + ads_observer_mock_ = test::AddAdsObserverMock(); reminder_ = std::make_unique(); } diff --git a/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc b/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc index bd9750cafb51..43c359ad8133 100644 --- a/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc +++ b/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc @@ -57,7 +57,7 @@ class BraveAdsClickedSameAdMultipleTimesReminderUtilTest : public UnitTestBase { void SetUp() override { UnitTestBase::SetUp(); - ads_observer_mock_ = AddAdsObserverMock(); + ads_observer_mock_ = test::AddAdsObserverMock(); } raw_ptr ads_observer_mock_ = nullptr; diff --git a/components/brave_ads/core/internal/segments/segment_test_constants.h b/components/brave_ads/core/internal/segments/segment_test_constants.h index 11c04ca1ee5c..cee38a10bf26 100644 --- a/components/brave_ads/core/internal/segments/segment_test_constants.h +++ b/components/brave_ads/core/internal/segments/segment_test_constants.h @@ -6,7 +6,7 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_SEGMENTS_SEGMENT_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_SEGMENTS_SEGMENT_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { inline constexpr const char* kSegments[] = {"architecture", "arts & entertainment", @@ -37,6 +37,6 @@ inline constexpr const char* kSegments[] = {"architecture", "travel", "weather"}; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_SEGMENTS_SEGMENT_TEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/segments/segment_util_unittest.cc b/components/brave_ads/core/internal/segments/segment_util_unittest.cc index cbaa1cefc534..fbc7e7232f7b 100644 --- a/components/brave_ads/core/internal/segments/segment_util_unittest.cc +++ b/components/brave_ads/core/internal/segments/segment_util_unittest.cc @@ -25,7 +25,7 @@ class BraveAdsSegmentUtilTest : public UnitTestBase {}; TEST_F(BraveAdsSegmentUtilTest, GetSegmentsFromCatalog) { // Arrange const std::optional contents = - MaybeReadFileToString(kCatalogWithMultipleCampaignsFilename); + MaybeReadFileToString(test::kCatalogWithMultipleCampaignsFilename); ASSERT_TRUE(contents); const std::optional catalog = diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/anti_targeting_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/anti_targeting_exclusion_rule_unittest.cc index 185f1661a085..8cb0da48ad09 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/anti_targeting_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/anti_targeting_exclusion_rule_unittest.cc @@ -40,7 +40,7 @@ TEST_F(BraveAdsAntiTargetingExclusionRuleTest, *resource_, /*browsing_history=*/{GURL(kAntiTargetedSite)}); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; // Act & Assert EXPECT_TRUE(exclusion_rule.ShouldInclude(creative_ad).has_value()); @@ -49,15 +49,15 @@ TEST_F(BraveAdsAntiTargetingExclusionRuleTest, TEST_F(BraveAdsAntiTargetingExclusionRuleTest, ShouldIncludeIfNotVisitedAntiTargetedSiteForCreativeSet) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); const AntiTargetingExclusionRule exclusion_rule( *resource_, /*browsing_history=*/{GURL(kAntiTargetedSite)}); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kMissingCreativeSetId; + creative_ad.creative_set_id = test::kMissingCreativeSetId; // Act & Assert EXPECT_TRUE(exclusion_rule.ShouldInclude(creative_ad).has_value()); @@ -66,15 +66,15 @@ TEST_F(BraveAdsAntiTargetingExclusionRuleTest, TEST_F(BraveAdsAntiTargetingExclusionRuleTest, ShouldIncludeIfNotVisitedAntiTargetedSite) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); const AntiTargetingExclusionRule exclusion_rule( *resource_, /*browsing_history=*/{GURL("https://www.foo.com")}); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; // Act & Assert EXPECT_TRUE(exclusion_rule.ShouldInclude(creative_ad).has_value()); @@ -83,15 +83,15 @@ TEST_F(BraveAdsAntiTargetingExclusionRuleTest, TEST_F(BraveAdsAntiTargetingExclusionRuleTest, ShouldExcludeIfVisitedAntiTargetedSite) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); const AntiTargetingExclusionRule exclusion_rule( *resource_, /*browsing_history=*/{GURL(kAntiTargetedSite)}); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; // Act & Assert EXPECT_FALSE(exclusion_rule.ShouldInclude(creative_ad).has_value()); diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule_unittest.cc index af6e8601c3bd..252f2026104d 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule_unittest.cc @@ -31,7 +31,7 @@ TEST_F(BraveAdsConversionExclusionRuleTest, ShouldIncludeIfThereIsNoConversionHistory) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; const ConversionExclusionRule exclusion_rule(/*ad_events=*/{}); diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule_unittest.cc index fe946b58e234..d1115e16c154 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule_unittest.cc @@ -27,7 +27,7 @@ TEST_F(BraveAdsCreativeInstanceExclusionRuleTest, ShouldAlwaysInclude) { {{"should_exclude_ad_if_creative_instance_exceeds_per_hour_cap", "0"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; const CreativeInstanceExclusionRule exclusion_rule(/*ad_events=*/{}); @@ -39,7 +39,7 @@ TEST_F(BraveAdsCreativeInstanceExclusionRuleTest, ShouldIncludeIfThereAreNoAdEvents) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; const CreativeInstanceExclusionRule exclusion_rule(/*ad_events=*/{}); @@ -50,7 +50,7 @@ TEST_F(BraveAdsCreativeInstanceExclusionRuleTest, TEST_F(BraveAdsCreativeInstanceExclusionRuleTest, ShouldIncludeAfter1Hour) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; AdEventList ad_events; const AdEventInfo ad_event = test::BuildAdEvent( @@ -71,7 +71,7 @@ TEST_F(BraveAdsCreativeInstanceExclusionRuleTest, ShouldIncludeAfter1HourForMultipleAdTypes) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; AdEventList ad_events; @@ -111,7 +111,7 @@ TEST_F(BraveAdsCreativeInstanceExclusionRuleTest, ShouldExcludeTheSameAdWithin1Hour) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; AdEventList ad_events; const AdEventInfo ad_event = test::BuildAdEvent( diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/daypart_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/daypart_exclusion_rule_unittest.cc index fd28d7aaf16c..629f7913d59e 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/daypart_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/daypart_exclusion_rule_unittest.cc @@ -30,7 +30,7 @@ class BraveAdsDaypartExclusionRuleTest : public UnitTestBase { TEST_F(BraveAdsDaypartExclusionRuleTest, ShouldIncludeIfNoDayparts) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; // Act & Assert EXPECT_TRUE(exclusion_rule_.ShouldInclude(creative_ad).has_value()); @@ -40,7 +40,7 @@ TEST_F(BraveAdsDaypartExclusionRuleTest, ShouldIncludeIfMatchesDayOfWeekAndTimeSlot) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; CreativeDaypartInfo daypart; daypart.days_of_week = "0"; // Sunday @@ -58,7 +58,7 @@ TEST_F(BraveAdsDaypartExclusionRuleTest, ShouldIncludeIfMatchesDayOfWeekAndTimeSlotWhenMultipleDaysOfWeek) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; CreativeDaypartInfo daypart; daypart.days_of_week = "0123456"; @@ -76,7 +76,7 @@ TEST_F(BraveAdsDaypartExclusionRuleTest, ShouldIncludeIfMatchesDayOfWeekAndTimeSlotWhenMultipleTimeSlots) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; CreativeDaypartInfo daypart_1; daypart_1.days_of_week = "1"; // Monday @@ -110,7 +110,7 @@ TEST_F(BraveAdsDaypartExclusionRuleTest, DisallowWhenMatchingDayOfWeekButOutsideTimeSlot) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; CreativeDaypartInfo daypart_1; daypart_1.days_of_week = "1"; // Monday @@ -143,7 +143,7 @@ TEST_F(BraveAdsDaypartExclusionRuleTest, TEST_F(BraveAdsDaypartExclusionRuleTest, DisallowForWrongDayOfWeek) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; CreativeDaypartInfo daypart; daypart.days_of_week = "2"; // Tuesday @@ -161,7 +161,7 @@ TEST_F(BraveAdsDaypartExclusionRuleTest, DisallowWhenMatchingDayOfWeekButOutsideCuspOfTimeSlot) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; CreativeDaypartInfo daypart_1; daypart_1.days_of_week = "0"; // Sunday diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/dislike_category_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/dislike_category_exclusion_rule_unittest.cc index a870dffffec3..df240f4a3de5 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/dislike_category_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/dislike_category_exclusion_rule_unittest.cc @@ -23,7 +23,7 @@ class BraveAdsDislikeCategoryExclusionRuleTest : public UnitTestBase { TEST_F(BraveAdsDislikeCategoryExclusionRuleTest, ShouldInclude) { // Arrange CreativeAdInfo creative_ad; - creative_ad.segment = kSegment; + creative_ad.segment = test::kSegment; // Act & Assert EXPECT_TRUE(exclusion_rule_.ShouldInclude(creative_ad).has_value()); @@ -32,7 +32,7 @@ TEST_F(BraveAdsDislikeCategoryExclusionRuleTest, ShouldInclude) { TEST_F(BraveAdsDislikeCategoryExclusionRuleTest, ShouldExclude) { // Arrange CreativeAdInfo creative_ad; - creative_ad.segment = kSegment; + creative_ad.segment = test::kSegment; CategoryContentInfo category_content; category_content.category = creative_ad.segment; diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/dislike_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/dislike_exclusion_rule_unittest.cc index 137c3b137d4c..40127b50f8fe 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/dislike_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/dislike_exclusion_rule_unittest.cc @@ -22,7 +22,7 @@ class BraveAdsDislikeExclusionRuleTest : public UnitTestBase { TEST_F(BraveAdsDislikeExclusionRuleTest, ShouldInclude) { // Arrange CreativeAdInfo creative_ad; - creative_ad.advertiser_id = kAdvertiserId; + creative_ad.advertiser_id = test::kAdvertiserId; // Act & Assert EXPECT_TRUE(exclusion_rule_.ShouldInclude(creative_ad).has_value()); @@ -31,10 +31,10 @@ TEST_F(BraveAdsDislikeExclusionRuleTest, ShouldInclude) { TEST_F(BraveAdsDislikeExclusionRuleTest, ShouldExclude) { // Arrange CreativeAdInfo creative_ad; - creative_ad.advertiser_id = kAdvertiserId; + creative_ad.advertiser_id = test::kAdvertiserId; AdContentInfo ad_content; - ad_content.advertiser_id = kAdvertiserId; + ad_content.advertiser_id = test::kAdvertiserId; ad_content.user_reaction_type = mojom::UserReactionType::kNeutral; ClientStateManager::GetInstance().ToggleDislikeAd(ad_content); diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/marked_as_inappropriate_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/marked_as_inappropriate_exclusion_rule_unittest.cc index 4696ef3f4a0b..022978c13ca4 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/marked_as_inappropriate_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/marked_as_inappropriate_exclusion_rule_unittest.cc @@ -22,8 +22,8 @@ class BraveAdsMarkedAsInappropriateExclusionRuleTest : public UnitTestBase { TEST_F(BraveAdsMarkedAsInappropriateExclusionRuleTest, ShouldInclude) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; + creative_ad.creative_set_id = test::kCreativeSetId; // Act & Assert EXPECT_TRUE(exclusion_rule_.ShouldInclude(creative_ad).has_value()); @@ -32,11 +32,11 @@ TEST_F(BraveAdsMarkedAsInappropriateExclusionRuleTest, ShouldInclude) { TEST_F(BraveAdsMarkedAsInappropriateExclusionRuleTest, ShouldExclude) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; + creative_ad.creative_set_id = test::kCreativeSetId; AdContentInfo ad_content; - ad_content.creative_set_id = kCreativeSetId; + ad_content.creative_set_id = test::kCreativeSetId; ad_content.is_flagged = false; ClientStateManager::GetInstance().ToggleMarkAdAsInappropriate(ad_content); diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule_unittest.cc index fdb006f0476b..dec56d212f23 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule_unittest.cc @@ -40,7 +40,7 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, ShouldAlwaysInclude) { {{"should_exclude_ad_if_dismissed_within_time_window", "0h"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; AdEventList ad_events; @@ -59,7 +59,7 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, ShouldAlwaysInclude) { TEST_F(BraveAdsDismissedExclusionRuleTest, ShouldIncludeIfThereAreNoAdEvents) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; const NotificationAdDismissedExclusionRule exclusion_rule(/*ad_events=*/{}); @@ -77,7 +77,7 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, {{"should_exclude_ad_if_dismissed_within_time_window", "2d"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; const std::vector confirmation_types = { @@ -111,7 +111,7 @@ TEST_F( {{"should_exclude_ad_if_dismissed_within_time_window", "2d"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; AdEventList ad_events; @@ -155,7 +155,7 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, {{"should_exclude_ad_if_dismissed_within_time_window", "2d"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; const std::vector confirmation_types = { @@ -187,7 +187,7 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, {{"should_exclude_ad_if_dismissed_within_time_window", "2d"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; const std::vector confirmation_types = { @@ -222,7 +222,7 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, {{"should_exclude_ad_if_dismissed_within_time_window", "2d"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; const std::vector confirmation_types = { @@ -254,7 +254,7 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, {{"should_exclude_ad_if_dismissed_within_time_window", "2d"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; const std::vector confirmation_types = { @@ -289,7 +289,7 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, {{"should_exclude_ad_if_dismissed_within_time_window", "2d"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; const std::vector confirmation_types = { @@ -324,7 +324,7 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, {{"should_exclude_ad_if_dismissed_within_time_window", "2d"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; const std::vector confirmation_types = { @@ -357,7 +357,7 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, {{"should_exclude_ad_if_dismissed_within_time_window", "0s"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; const std::vector confirmation_types = { @@ -389,11 +389,11 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, {{"should_exclude_ad_if_dismissed_within_time_window", "2d"}}); CreativeAdInfo creative_ad_1; - creative_ad_1.creative_instance_id = kCreativeInstanceId; + creative_ad_1.creative_instance_id = test::kCreativeInstanceId; creative_ad_1.campaign_id = kCampaignIds[0]; CreativeAdInfo creative_ad_2; - creative_ad_2.creative_instance_id = kCreativeInstanceId; + creative_ad_2.creative_instance_id = test::kCreativeInstanceId; creative_ad_2.campaign_id = kCampaignIds[1]; const std::vector confirmation_types = { @@ -420,11 +420,11 @@ TEST_F(BraveAdsDismissedExclusionRuleTest, ShouldIncludeWithDifferentCampaignIdAfter2Days) { // Arrange CreativeAdInfo creative_ad_1; - creative_ad_1.creative_instance_id = kCreativeInstanceId; + creative_ad_1.creative_instance_id = test::kCreativeInstanceId; creative_ad_1.campaign_id = kCampaignIds[0]; CreativeAdInfo creative_ad_2; - creative_ad_2.creative_instance_id = kCreativeInstanceId; + creative_ad_2.creative_instance_id = test::kCreativeInstanceId; creative_ad_2.campaign_id = kCampaignIds[1]; const std::vector confirmation_types = { diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/page_land_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/page_land_exclusion_rule_unittest.cc index 4c254346b32b..019554109fb1 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/page_land_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/page_land_exclusion_rule_unittest.cc @@ -38,7 +38,7 @@ TEST_F(BraveAdsPageLandExclusionRuleTest, ShouldAlwaysInclude) { {{"should_exclude_ad_if_landed_on_page_within_time_window", "0h"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; AdEventList ad_events; @@ -57,7 +57,7 @@ TEST_F(BraveAdsPageLandExclusionRuleTest, ShouldAlwaysInclude) { TEST_F(BraveAdsPageLandExclusionRuleTest, ShouldIncludeIfThereAreNoAdEvents) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; const PageLandExclusionRule exclusion_rule(/*ad_events=*/{}); @@ -75,11 +75,11 @@ TEST_F(BraveAdsPageLandExclusionRuleTest, {{"should_exclude_ad_if_landed_on_page_within_time_window", "2d"}}); CreativeAdInfo creative_ad_1; - creative_ad_1.creative_instance_id = kCreativeInstanceId; + creative_ad_1.creative_instance_id = test::kCreativeInstanceId; creative_ad_1.campaign_id = kCampaignIds[0]; CreativeAdInfo creative_ad_2; - creative_ad_2.creative_instance_id = kCreativeInstanceId; + creative_ad_2.creative_instance_id = test::kCreativeInstanceId; creative_ad_2.campaign_id = kCampaignIds[1]; AdEventList ad_events; @@ -105,11 +105,11 @@ TEST_F(BraveAdsPageLandExclusionRuleTest, {{"should_exclude_ad_if_landed_on_page_within_time_window", "2d"}}); CreativeAdInfo creative_ad_1; - creative_ad_1.creative_instance_id = kCreativeInstanceId; + creative_ad_1.creative_instance_id = test::kCreativeInstanceId; creative_ad_1.campaign_id = kCampaignIds[0]; CreativeAdInfo creative_ad_2; - creative_ad_2.creative_instance_id = kCreativeInstanceId; + creative_ad_2.creative_instance_id = test::kCreativeInstanceId; creative_ad_2.campaign_id = kCampaignIds[1]; AdEventList ad_events; @@ -161,7 +161,7 @@ TEST_F(BraveAdsPageLandExclusionRuleTest, /*disabled_features=*/{}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; AdEventList ad_events; @@ -188,7 +188,7 @@ TEST_F(BraveAdsPageLandExclusionRuleTest, {{"should_exclude_ad_if_landed_on_page_within_time_window", "0s"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; AdEventList ad_events; @@ -215,7 +215,7 @@ TEST_F(BraveAdsPageLandExclusionRuleTest, {{"should_exclude_ad_if_landed_on_page_within_time_window", "2d"}}); CreativeAdInfo creative_ad; - creative_ad.creative_instance_id = kCreativeInstanceId; + creative_ad.creative_instance_id = test::kCreativeInstanceId; creative_ad.campaign_id = kCampaignIds[0]; AdEventList ad_events; @@ -242,11 +242,11 @@ TEST_F(BraveAdsPageLandExclusionRuleTest, {{"should_exclude_ad_if_landed_on_page_within_time_window", "2d"}}); CreativeAdInfo creative_ad_1; - creative_ad_1.creative_instance_id = kCreativeInstanceId; + creative_ad_1.creative_instance_id = test::kCreativeInstanceId; creative_ad_1.campaign_id = kCampaignIds[0]; CreativeAdInfo creative_ad_2; - creative_ad_2.creative_instance_id = kCreativeInstanceId; + creative_ad_2.creative_instance_id = test::kCreativeInstanceId; creative_ad_2.campaign_id = kCampaignIds[1]; AdEventList ad_events; diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule_unittest.cc index ab9a89067916..e8c64fe40187 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule_unittest.cc @@ -20,7 +20,7 @@ class BraveAdsPerDayExclusionRuleTest : public UnitTestBase {}; TEST_F(BraveAdsPerDayExclusionRuleTest, ShouldIncludeIfThereAreNoAdEvents) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_day = 2; const PerDayExclusionRule exclusion_rule(/*ad_events=*/{}); @@ -32,7 +32,7 @@ TEST_F(BraveAdsPerDayExclusionRuleTest, ShouldIncludeIfThereAreNoAdEvents) { TEST_F(BraveAdsPerDayExclusionRuleTest, ShouldIncludeIfZero) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_day = 0; const PerDayExclusionRule exclusion_rule(/*ad_events=*/{}); @@ -44,7 +44,7 @@ TEST_F(BraveAdsPerDayExclusionRuleTest, ShouldIncludeIfZero) { TEST_F(BraveAdsPerDayExclusionRuleTest, ShouldIncludeIfDoesNotExceedCap) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_day = 2; AdEventList ad_events; @@ -64,7 +64,7 @@ TEST_F(BraveAdsPerDayExclusionRuleTest, ShouldIncludeIfDoesNotExceedCapAfter1Day) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_day = 2; AdEventList ad_events; @@ -86,7 +86,7 @@ TEST_F(BraveAdsPerDayExclusionRuleTest, TEST_F(BraveAdsPerDayExclusionRuleTest, ShouldExcludeIfExceedsCapWithin1Day) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_day = 2; AdEventList ad_events; @@ -108,7 +108,7 @@ TEST_F(BraveAdsPerDayExclusionRuleTest, ShouldExcludeIfExceedsCapWithin1Day) { TEST_F(BraveAdsPerDayExclusionRuleTest, ShouldExcludeIfExceedsCap) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_day = 2; AdEventList ad_events; diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule_unittest.cc index e249098da705..3f6196c7f4e0 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule_unittest.cc @@ -20,7 +20,7 @@ class BraveAdsPerMonthExclusionRuleTest : public UnitTestBase {}; TEST_F(BraveAdsPerMonthExclusionRuleTest, ShouldIncludeIfThereAreNoAdEvents) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_month = 2; const PerMonthExclusionRule exclusion_rule(/*ad_events=*/{}); @@ -32,7 +32,7 @@ TEST_F(BraveAdsPerMonthExclusionRuleTest, ShouldIncludeIfThereAreNoAdEvents) { TEST_F(BraveAdsPerMonthExclusionRuleTest, ShouldIncludeIfZero) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_month = 0; const PerMonthExclusionRule exclusion_rule(/*ad_events=*/{}); @@ -44,7 +44,7 @@ TEST_F(BraveAdsPerMonthExclusionRuleTest, ShouldIncludeIfZero) { TEST_F(BraveAdsPerMonthExclusionRuleTest, ShouldIncludeIfDoesNotExceedCap) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_month = 2; AdEventList ad_events; @@ -64,7 +64,7 @@ TEST_F(BraveAdsPerMonthExclusionRuleTest, ShouldIncludeIfDoesNotExceedCapAfter1Month) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_month = 2; AdEventList ad_events; @@ -87,7 +87,7 @@ TEST_F(BraveAdsPerMonthExclusionRuleTest, ShouldExcludeIfExceedsCapWithin1Month) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_month = 2; AdEventList ad_events; @@ -109,7 +109,7 @@ TEST_F(BraveAdsPerMonthExclusionRuleTest, TEST_F(BraveAdsPerMonthExclusionRuleTest, ShouldExcludeIfExceedsCap) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_month = 2; AdEventList ad_events; diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule_unittest.cc index a954c000b4f4..90581ab2e8f0 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule_unittest.cc @@ -20,7 +20,7 @@ class BraveAdsPerWeekExclusionRuleTest : public UnitTestBase {}; TEST_F(BraveAdsPerWeekExclusionRuleTest, ShouldIncludeIfThereAreNoAdEvents) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_week = 2; const PerWeekExclusionRule exclusion_rule(/*ad_events=*/{}); @@ -32,7 +32,7 @@ TEST_F(BraveAdsPerWeekExclusionRuleTest, ShouldIncludeIfThereAreNoAdEvents) { TEST_F(BraveAdsPerWeekExclusionRuleTest, ShouldIncludeIfZero) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_week = 0; const PerWeekExclusionRule exclusion_rule(/*ad_events=*/{}); @@ -44,7 +44,7 @@ TEST_F(BraveAdsPerWeekExclusionRuleTest, ShouldIncludeIfZero) { TEST_F(BraveAdsPerWeekExclusionRuleTest, ShouldIncludeIfDoesNotExceedCap) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_week = 2; AdEventList ad_events; @@ -64,7 +64,7 @@ TEST_F(BraveAdsPerWeekExclusionRuleTest, ShouldIncludeIfDoesNotExceedCapAfter1Week) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_week = 2; AdEventList ad_events; @@ -86,7 +86,7 @@ TEST_F(BraveAdsPerWeekExclusionRuleTest, TEST_F(BraveAdsPerWeekExclusionRuleTest, ShouldExcludeIfExceedsCapWithin1Week) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_week = 2; AdEventList ad_events; @@ -108,7 +108,7 @@ TEST_F(BraveAdsPerWeekExclusionRuleTest, ShouldExcludeIfExceedsCapWithin1Week) { TEST_F(BraveAdsPerWeekExclusionRuleTest, ShouldExcludeIfExceedsCap) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.per_week = 2; AdEventList ad_events; diff --git a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/split_test_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/split_test_exclusion_rule_unittest.cc index d727db8c321b..ae1d94af694f 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/split_test_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/exclusion_rules/split_test_exclusion_rule_unittest.cc @@ -39,7 +39,7 @@ TEST_F(BraveAdsSplitTestExclusionRuleTest, ShouldIncludeIfNoFieldTrialAndNoAdGroup) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; // Act & Assert EXPECT_TRUE(exclusion_rule_.ShouldInclude(creative_ad).has_value()); @@ -49,7 +49,7 @@ TEST_F(BraveAdsSplitTestExclusionRuleTest, ShouldExcludeIfNoFieldTrialAndAdGroup) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.split_test_group = "GroupA"; // Act & Assert @@ -60,7 +60,7 @@ TEST_F(BraveAdsSplitTestExclusionRuleTest, ShouldIncludeIfFieldTrialAndNoAdGroup) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; const scoped_refptr field_trial = CreateFieldTrial(kTrialName); @@ -74,7 +74,7 @@ TEST_F(BraveAdsSplitTestExclusionRuleTest, ShouldIncludeIfFieldTrialMatchesAdGroup) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.split_test_group = "GroupA"; const scoped_refptr field_trial = @@ -89,7 +89,7 @@ TEST_F(BraveAdsSplitTestExclusionRuleTest, ShouldExcludeIfFieldTrialDoesNotMatchAdGroup) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.split_test_group = "GroupB"; const scoped_refptr field_trial = 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 76f7f93ba80d..4c582483e99f 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 @@ -161,7 +161,7 @@ TEST_P( ShouldExcludeIfSubdivisionTargetingIsNotAllowedForGeoTargetWithSubdivisionCode) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {BuildSubdivisionForTestParam()}; // Act & Assert @@ -175,7 +175,7 @@ TEST_P( SetProfileBooleanPrefValue(prefs::kShouldAllowSubdivisionTargeting, false); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {GetParam().country_code}; // Act & Assert @@ -192,7 +192,7 @@ TEST_P(BraveAdsSubdivisionTargetingExclusionRuleTest, NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {BuildSubdivisionForTestParam()}; // Act & Assert @@ -210,7 +210,7 @@ TEST_P( NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {BuildSubdivisionForTestParam(), BuildOtherSubdivisionForTestParam()}; @@ -229,7 +229,7 @@ TEST_P( NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {GetParam().country_code}; // Act & Assert @@ -250,7 +250,7 @@ TEST_P( NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {BuildSubdivisionForTestParam()}; // Act & Assert @@ -271,7 +271,7 @@ TEST_P( NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {BuildSubdivisionForTestParam(), BuildOtherSubdivisionForTestParam()}; @@ -293,7 +293,7 @@ TEST_P( NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {GetParam().country_code}; // Act & Assert @@ -310,7 +310,7 @@ TEST_P(BraveAdsSubdivisionTargetingExclusionRuleTest, NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {test::BuildSubdivision( /*country_code=*/"US", /*subdivision_code=*/"XX")}; @@ -329,7 +329,7 @@ TEST_P( NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {test::BuildSubdivision( /*country_code=*/"GB", /*subdivision_code=*/"DEV")}; @@ -353,7 +353,7 @@ TEST_P( NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {"XX"}; // Act & Assert @@ -373,7 +373,7 @@ TEST_P(BraveAdsSubdivisionTargetingExclusionRuleTest, NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {BuildSubdivisionForTestParam()}; // Act & Assert @@ -394,7 +394,7 @@ TEST_P( NotifyDidInitializeAds(); CreativeAdInfo creative_ad; - creative_ad.creative_set_id = kCreativeSetId; + creative_ad.creative_set_id = test::kCreativeSetId; creative_ad.geo_targets = {"XX"}; // Act & Assert diff --git a/components/brave_ads/core/internal/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v2_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v2_unittest.cc index a41d6bd04aa1..758f141f3ac2 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v2_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v2_unittest.cc @@ -42,16 +42,16 @@ TEST_F(BraveAdsEligibleInlineContentAdsV2Test, GetAds) { CreativeInlineContentAdList creative_ads; const CreativeInlineContentAdInfo creative_ad_1 = - test::BuildCreativeInlineContentAd(/*should_use_random_uuids=*/true); + test::BuildCreativeInlineContentAd(/*should_generate_random_uuids=*/true); creative_ads.push_back(creative_ad_1); CreativeInlineContentAdInfo creative_ad_2 = - test::BuildCreativeInlineContentAd(/*should_use_random_uuids=*/true); + test::BuildCreativeInlineContentAd(/*should_generate_random_uuids=*/true); creative_ad_2.segment = "parent"; creative_ads.push_back(creative_ad_2); CreativeInlineContentAdInfo creative_ad_3 = - test::BuildCreativeInlineContentAd(/*should_use_random_uuids=*/true); + test::BuildCreativeInlineContentAd(/*should_generate_random_uuids=*/true); creative_ad_3.segment = "parent-child"; creative_ads.push_back(creative_ad_3); @@ -74,12 +74,12 @@ TEST_F(BraveAdsEligibleInlineContentAdsV2Test, GetAdsForNoMatchingSegments) { CreativeInlineContentAdList creative_ads; CreativeInlineContentAdInfo creative_ad_1 = - test::BuildCreativeInlineContentAd(/*should_use_random_uuids=*/true); + test::BuildCreativeInlineContentAd(/*should_generate_random_uuids=*/true); creative_ad_1.segment = "parent"; creative_ads.push_back(creative_ad_1); CreativeInlineContentAdInfo creative_ad_2 = - test::BuildCreativeInlineContentAd(/*should_use_random_uuids=*/true); + test::BuildCreativeInlineContentAd(/*should_generate_random_uuids=*/true); creative_ad_2.segment = "parent-child"; creative_ads.push_back(creative_ad_2); @@ -98,7 +98,7 @@ TEST_F(BraveAdsEligibleInlineContentAdsV2Test, CreativeInlineContentAdList creative_ads; const CreativeInlineContentAdInfo creative_ad = - test::BuildCreativeInlineContentAd(/*should_use_random_uuids=*/true); + test::BuildCreativeInlineContentAd(/*should_generate_random_uuids=*/true); creative_ads.push_back(creative_ad); database::SaveCreativeInlineContentAds(creative_ads); diff --git a/components/brave_ads/core/internal/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v2_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v2_unittest.cc index 3255fae00bb9..d75a95f14cb1 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v2_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v2_unittest.cc @@ -41,16 +41,16 @@ TEST_F(BraveAdsEligibleNewTabPageAdsV2Test, GetAds) { CreativeNewTabPageAdList creative_ads; const CreativeNewTabPageAdInfo creative_ad_1 = - test::BuildCreativeNewTabPageAd(/*should_use_random_uuids=*/true); + test::BuildCreativeNewTabPageAd(/*should_generate_random_uuids=*/true); creative_ads.push_back(creative_ad_1); CreativeNewTabPageAdInfo creative_ad_2 = - test::BuildCreativeNewTabPageAd(/*should_use_random_uuids=*/true); + test::BuildCreativeNewTabPageAd(/*should_generate_random_uuids=*/true); creative_ad_2.segment = "parent"; creative_ads.push_back(creative_ad_2); CreativeNewTabPageAdInfo creative_ad_3 = - test::BuildCreativeNewTabPageAd(/*should_use_random_uuids=*/true); + test::BuildCreativeNewTabPageAd(/*should_generate_random_uuids=*/true); creative_ad_3.segment = "parent-child"; creative_ads.push_back(creative_ad_3); @@ -70,12 +70,12 @@ TEST_F(BraveAdsEligibleNewTabPageAdsV2Test, GetAdsForNoMatchingSegments) { CreativeNewTabPageAdList creative_ads; CreativeNewTabPageAdInfo creative_ad_1 = - test::BuildCreativeNewTabPageAd(/*should_use_random_uuids=*/true); + test::BuildCreativeNewTabPageAd(/*should_generate_random_uuids=*/true); creative_ad_1.segment = "parent"; creative_ads.push_back(creative_ad_1); CreativeNewTabPageAdInfo creative_ad_2 = - test::BuildCreativeNewTabPageAd(/*should_use_random_uuids=*/true); + test::BuildCreativeNewTabPageAd(/*should_generate_random_uuids=*/true); creative_ad_2.segment = "parent-child"; creative_ads.push_back(creative_ad_2); diff --git a/components/brave_ads/core/internal/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v2_unittest.cc b/components/brave_ads/core/internal/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v2_unittest.cc index 4430195267f6..9cf268b7c325 100644 --- a/components/brave_ads/core/internal/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v2_unittest.cc +++ b/components/brave_ads/core/internal/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v2_unittest.cc @@ -41,12 +41,12 @@ TEST_F(BraveAdsEligibleNotificationAdsV2Test, GetAds) { CreativeNotificationAdList creative_ads; CreativeNotificationAdInfo creative_ad_1 = - test::BuildCreativeNotificationAd(/*should_use_random_uuids=*/true); + test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/true); creative_ad_1.segment = "parent-child-1"; creative_ads.push_back(creative_ad_1); CreativeNotificationAdInfo creative_ad_2 = - test::BuildCreativeNotificationAd(/*should_use_random_uuids=*/true); + test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/true); creative_ad_2.segment = "parent-child-3"; creative_ads.push_back(creative_ad_2); @@ -68,12 +68,12 @@ TEST_F(BraveAdsEligibleNotificationAdsV2Test, GetAdsForNoMatchingSegments) { CreativeNotificationAdList creative_ads; CreativeNotificationAdInfo creative_ad_1 = - test::BuildCreativeNotificationAd(/*should_use_random_uuids=*/true); + test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/true); creative_ad_1.segment = "parent"; creative_ads.push_back(creative_ad_1); CreativeNotificationAdInfo creative_ad_2 = - test::BuildCreativeNotificationAd(/*should_use_random_uuids=*/true); + test::BuildCreativeNotificationAd(/*should_generate_random_uuids=*/true); creative_ad_2.segment = "parent-child"; creative_ads.push_back(creative_ad_2); diff --git a/components/brave_ads/core/internal/serving/targeting/user_model/intent/intent_segments_unittest.cc b/components/brave_ads/core/internal/serving/targeting/user_model/intent/intent_segments_unittest.cc index 05bfe43c2c40..cda42b897791 100644 --- a/components/brave_ads/core/internal/serving/targeting/user_model/intent/intent_segments_unittest.cc +++ b/components/brave_ads/core/internal/serving/targeting/user_model/intent/intent_segments_unittest.cc @@ -27,8 +27,8 @@ class BraveAdsIntentSegmentsTest : public UnitTestBase { targeting_helper_ = std::make_unique(task_environment_); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); } std::unique_ptr targeting_helper_; diff --git a/components/brave_ads/core/internal/serving/targeting/user_model/interest/interest_segments_unittest.cc b/components/brave_ads/core/internal/serving/targeting/user_model/interest/interest_segments_unittest.cc index 72ef9bc8cb0d..79620f8d956e 100644 --- a/components/brave_ads/core/internal/serving/targeting/user_model/interest/interest_segments_unittest.cc +++ b/components/brave_ads/core/internal/serving/targeting/user_model/interest/interest_segments_unittest.cc @@ -26,8 +26,8 @@ class BraveAdsInterestSegmentsTest : public UnitTestBase { targeting_helper_ = std::make_unique(task_environment_); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); } std::unique_ptr targeting_helper_; diff --git a/components/brave_ads/core/internal/serving/targeting/user_model/user_model_builder_unittest.cc b/components/brave_ads/core/internal/serving/targeting/user_model/user_model_builder_unittest.cc index 934a49b6287d..52f4e21a3837 100644 --- a/components/brave_ads/core/internal/serving/targeting/user_model/user_model_builder_unittest.cc +++ b/components/brave_ads/core/internal/serving/targeting/user_model/user_model_builder_unittest.cc @@ -35,11 +35,11 @@ class BraveAdsUserModelBuilderTest : public UnitTestBase { targeting_helper_ = std::make_unique(task_environment_); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); } base::test::ScopedFeatureList scoped_feature_list_; diff --git a/components/brave_ads/core/internal/targeting/behavioral/anti_targeting/resource/anti_targeting_resource_unittest.cc b/components/brave_ads/core/internal/targeting/behavioral/anti_targeting/resource/anti_targeting_resource_unittest.cc index f4ff15959820..61c6c57dc2a3 100644 --- a/components/brave_ads/core/internal/targeting/behavioral/anti_targeting/resource/anti_targeting_resource_unittest.cc +++ b/components/brave_ads/core/internal/targeting/behavioral/anti_targeting/resource/anti_targeting_resource_unittest.cc @@ -44,8 +44,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, IsResourceNotLoaded) { TEST_F(BraveAdsAntiTargetingResourceTest, LoadResource) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -54,11 +54,11 @@ TEST_F(BraveAdsAntiTargetingResourceTest, LoadResource) { TEST_F(BraveAdsAntiTargetingResourceTest, DoNotLoadMalformedResource) { // Arrange ASSERT_TRUE( - CopyFileFromTestPathToTempPath(/*from_path=*/kMalformedResourceId, + CopyFileFromTestPathToTempPath(/*from_path=*/test::kMalformedResourceId, /*to_path=*/kAntiTargetingResourceId)); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -73,15 +73,16 @@ TEST_F(BraveAdsAntiTargetingResourceTest, DoNotLoadMissingResource) { const int /*version*/, LoadFileCallback callback) { const base::FilePath path = - ComponentResourcesTestDataPath().AppendASCII(kMissingResourceId); + ComponentResourcesTestDataPath().AppendASCII( + test::kMissingResourceId); base::File file( path, base::File::Flags::FLAG_OPEN | base::File::Flags::FLAG_READ); std::move(callback).Run(std::move(file)); })); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -89,8 +90,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, DoNotLoadMissingResource) { TEST_F(BraveAdsAntiTargetingResourceTest, DoNotLoadResourceWithInvalidCountryComponentId) { - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kInvalidCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kInvalidCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -103,8 +104,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, test::OptOutOfBraveNewsAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -115,8 +116,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, // Arrange test::DisableBraveRewards(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -126,8 +127,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, DoNotLoadResourceIfOptedOutOfAllAds) { // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -135,8 +136,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, DoNotLoadResourceIfOptedOutOfAllAds) { TEST_F(BraveAdsAntiTargetingResourceTest, LoadResourceForOnLocaleDidChange) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -151,8 +152,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -167,8 +168,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -186,8 +187,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, test::OptOutOfNotificationAds(); test::OptOutOfSearchResultAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -203,8 +204,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -225,8 +226,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, test::OptOutOfNotificationAds(); test::OptOutOfSearchResultAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -245,8 +246,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -263,8 +264,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, test::OptOutOfNewTabPageAds(); test::OptOutOfSearchResultAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -279,8 +280,8 @@ TEST_F(BraveAdsAntiTargetingResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -294,13 +295,13 @@ TEST_F( BraveAdsAntiTargetingResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithInvalidCountryComponentId) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kInvalidCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kInvalidCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -310,13 +311,13 @@ TEST_F( BraveAdsAntiTargetingResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithExistingManifestVersion) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -326,30 +327,31 @@ TEST_F( BraveAdsAntiTargetingResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithNewManifestVersion) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); - ASSERT_EQ(kCountryComponentManifestVersion, resource_->GetManifestVersion()); + ASSERT_EQ(test::kCountryComponentManifestVersion, + resource_->GetManifestVersion()); // Act - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersionUpdate, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersionUpdate, + test::kCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); - EXPECT_EQ(kCountryComponentManifestVersionUpdate, + EXPECT_EQ(test::kCountryComponentManifestVersionUpdate, resource_->GetManifestVersion()); } TEST_F(BraveAdsAntiTargetingResourceTest, ResetResourceForOnNotifyDidUnregisterResourceComponent) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUnregisterResourceComponent(kCountryComponentId); + NotifyDidUnregisterResourceComponent(test::kCountryComponentId); // Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -359,12 +361,12 @@ TEST_F( BraveAdsAntiTargetingResourceTest, DoNotResetResourceForOnNotifyDidUnregisterResourceComponentWithInvalidCountryComponentId) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUnregisterResourceComponent(kInvalidCountryComponentId); + NotifyDidUnregisterResourceComponent(test::kInvalidCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); diff --git a/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/model/purchase_intent_model_unittest.cc b/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/model/purchase_intent_model_unittest.cc index 0aade988586f..d3054afe0503 100644 --- a/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/model/purchase_intent_model_unittest.cc +++ b/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/model/purchase_intent_model_unittest.cc @@ -43,8 +43,8 @@ TEST_F(BraveAdsPurchaseIntentModelTest, TEST_F(BraveAdsPurchaseIntentModelTest, DoNotGetSegmentsForExpiredSignals) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); PurchaseIntentProcessor processor(*resource_); @@ -63,8 +63,8 @@ TEST_F(BraveAdsPurchaseIntentModelTest, DoNotGetSegmentsForExpiredSignals) { TEST_F(BraveAdsPurchaseIntentModelTest, DoNotGetSegmentsIfNeverProcessed) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -77,8 +77,8 @@ TEST_F(BraveAdsPurchaseIntentModelTest, DoNotGetSegmentsIfNeverProcessed) { TEST_F(BraveAdsPurchaseIntentModelTest, DoNotGetSegmentsIfNeverMatchedFunnelSites) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); PurchaseIntentProcessor processor(*resource_); @@ -93,8 +93,8 @@ TEST_F(BraveAdsPurchaseIntentModelTest, TEST_F(BraveAdsPurchaseIntentModelTest, GetSegmentsForPreviouslyMatchedSite) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); PurchaseIntentProcessor processor(*resource_); @@ -114,8 +114,8 @@ TEST_F(BraveAdsPurchaseIntentModelTest, GetSegmentsForPreviouslyMatchedSite) { TEST_F(BraveAdsPurchaseIntentModelTest, GetSegmentsForPreviouslyMatchedSegmentKeyphrases) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); const GURL url = GURL("https://duckduckgo.com/?q=segment+keyword+1&foo=bar"); @@ -136,8 +136,8 @@ TEST_F(BraveAdsPurchaseIntentModelTest, TEST_F(BraveAdsPurchaseIntentModelTest, GetSegmentsForPreviouslyMatchedFunnelKeywords) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); PurchaseIntentProcessor processor(*resource_); diff --git a/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/purchase_intent_processor_unittest.cc b/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/purchase_intent_processor_unittest.cc index 05bd7b12575d..5738eeee04c0 100644 --- a/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/purchase_intent_processor_unittest.cc +++ b/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/purchase_intent_processor_unittest.cc @@ -47,8 +47,8 @@ TEST_F(BraveAdsPurchaseIntentProcessorTest, TEST_F(BraveAdsPurchaseIntentProcessorTest, DoNotProcessForUnsupportedUrlScheme) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); PurchaseIntentProcessor processor(*resource_); @@ -64,8 +64,8 @@ TEST_F(BraveAdsPurchaseIntentProcessorTest, TEST_F(BraveAdsPurchaseIntentProcessorTest, DoNotProcessForInvalidUrl) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); PurchaseIntentProcessor processor(*resource_); @@ -81,8 +81,8 @@ TEST_F(BraveAdsPurchaseIntentProcessorTest, DoNotProcessForInvalidUrl) { TEST_F(BraveAdsPurchaseIntentProcessorTest, NeverProcessed) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act & Assert @@ -93,8 +93,8 @@ TEST_F(BraveAdsPurchaseIntentProcessorTest, NeverProcessed) { TEST_F(BraveAdsPurchaseIntentProcessorTest, ProcessSignalForUrl) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); PurchaseIntentProcessor processor(*resource_); @@ -119,8 +119,8 @@ TEST_F(BraveAdsPurchaseIntentProcessorTest, ProcessSignalForUrl) { TEST_F(BraveAdsPurchaseIntentProcessorTest, ProcessMultipleSignalsForMatchingUrls) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); const GURL url = GURL("https://www.brave.com/test?foo=bar"); @@ -150,8 +150,8 @@ TEST_F(BraveAdsPurchaseIntentProcessorTest, TEST_F(BraveAdsPurchaseIntentProcessorTest, ProcessMultipleSignalsForUniqueUrls) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); const base::Time at_before_advancing_clock = Now(); @@ -185,8 +185,8 @@ TEST_F(BraveAdsPurchaseIntentProcessorTest, TEST_F(BraveAdsPurchaseIntentProcessorTest, ProcessMultipleSearchQuerySignalsForMatchingKeywords) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); PurchaseIntentProcessor processor(*resource_); @@ -220,8 +220,8 @@ TEST_F(BraveAdsPurchaseIntentProcessorTest, TEST_F(BraveAdsPurchaseIntentProcessorTest, ProcessMultipleSearchQuerySignalsForUniqueKeywords) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); PurchaseIntentProcessor processor(*resource_); @@ -253,8 +253,8 @@ TEST_F(BraveAdsPurchaseIntentProcessorTest, TEST_F(BraveAdsPurchaseIntentProcessorTest, ProcessSearchQuerySignalForSegmentAndFunnelKeywords) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); PurchaseIntentProcessor processor(*resource_); diff --git a/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/resource/purchase_intent_resource_unittest.cc b/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/resource/purchase_intent_resource_unittest.cc index 41e2ebf440c3..c68484191d23 100644 --- a/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/resource/purchase_intent_resource_unittest.cc +++ b/components/brave_ads/core/internal/targeting/behavioral/purchase_intent/resource/purchase_intent_resource_unittest.cc @@ -44,8 +44,8 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, IsResourceNotLoaded) { TEST_F(BraveAdsPurchaseIntentResourceTest, LoadResource) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -54,11 +54,11 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, LoadResource) { TEST_F(BraveAdsPurchaseIntentResourceTest, DoNotLoadMalformedResource) { // Arrange ASSERT_TRUE( - CopyFileFromTestPathToTempPath(/*from_path=*/kMalformedResourceId, + CopyFileFromTestPathToTempPath(/*from_path=*/test::kMalformedResourceId, /*to_path=*/kPurchaseIntentResourceId)); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -73,15 +73,16 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, DoNotLoadMissingResource) { const int /*version*/, LoadFileCallback callback) { const base::FilePath path = - ComponentResourcesTestDataPath().AppendASCII(kMissingResourceId); + ComponentResourcesTestDataPath().AppendASCII( + test::kMissingResourceId); base::File file( path, base::File::Flags::FLAG_OPEN | base::File::Flags::FLAG_READ); std::move(callback).Run(std::move(file)); })); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -89,8 +90,8 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, DoNotLoadMissingResource) { TEST_F(BraveAdsPurchaseIntentResourceTest, DoNotLoadResourceWithInvalidCountryComponentId) { - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kInvalidCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kInvalidCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -101,8 +102,8 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -110,8 +111,8 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, TEST_F(BraveAdsPurchaseIntentResourceTest, LoadResourceForOnLocaleDidChange) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -126,8 +127,8 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -142,8 +143,8 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -159,8 +160,8 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -179,8 +180,8 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -197,8 +198,8 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, test::OptOutOfNewTabPageAds(); test::OptOutOfSearchResultAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -213,8 +214,8 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -228,13 +229,13 @@ TEST_F( BraveAdsPurchaseIntentResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithInvalidCountryComponentId) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kInvalidCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kInvalidCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -244,13 +245,13 @@ TEST_F( BraveAdsPurchaseIntentResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithExistingManifestVersion) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -260,30 +261,31 @@ TEST_F( BraveAdsPurchaseIntentResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithNewManifestVersion) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); - ASSERT_EQ(kCountryComponentManifestVersion, resource_->GetManifestVersion()); + ASSERT_EQ(test::kCountryComponentManifestVersion, + resource_->GetManifestVersion()); // Act - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersionUpdate, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersionUpdate, + test::kCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); - EXPECT_EQ(kCountryComponentManifestVersionUpdate, + EXPECT_EQ(test::kCountryComponentManifestVersionUpdate, resource_->GetManifestVersion()); } TEST_F(BraveAdsPurchaseIntentResourceTest, ResetResourceForOnNotifyDidUnregisterResourceComponent) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUnregisterResourceComponent(kCountryComponentId); + NotifyDidUnregisterResourceComponent(test::kCountryComponentId); // Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -293,12 +295,12 @@ TEST_F( BraveAdsPurchaseIntentResourceTest, DoNotResetResourceForOnNotifyDidUnregisterResourceComponentWithInvalidCountryComponentId) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUnregisterResourceComponent(kInvalidCountryComponentId); + NotifyDidUnregisterResourceComponent(test::kInvalidCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); diff --git a/components/brave_ads/core/internal/targeting/contextual/text_classification/model/text_classification_model_unittest.cc b/components/brave_ads/core/internal/targeting/contextual/text_classification/model/text_classification_model_unittest.cc index 2f20de28f085..dcd84d65887b 100644 --- a/components/brave_ads/core/internal/targeting/contextual/text_classification/model/text_classification_model_unittest.cc +++ b/components/brave_ads/core/internal/targeting/contextual/text_classification/model/text_classification_model_unittest.cc @@ -45,8 +45,8 @@ TEST_F(BraveAdsTextClassificationModelTest, TEST_F(BraveAdsTextClassificationModelTest, DoNotGetSegmentsForEmptyText) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); TextClassificationProcessor processor(*resource_); @@ -64,8 +64,8 @@ TEST_F(BraveAdsTextClassificationModelTest, DoNotGetSegmentsForEmptyText) { TEST_F(BraveAdsTextClassificationModelTest, GetSegmentsForPreviouslyClassifiedText) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); TextClassificationProcessor processor(*resource_); @@ -141,8 +141,8 @@ TEST_F(BraveAdsTextClassificationModelTest, TEST_F(BraveAdsTextClassificationModelTest, GetSegmentsForPreviouslyClassifiedTexts) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); const std::vector texts = { @@ -266,8 +266,8 @@ TEST_F(BraveAdsTextClassificationModelTest, TEST_F(BraveAdsTextClassificationModelTest, DoNotGetSegmentsIfNeverProcessed) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act diff --git a/components/brave_ads/core/internal/targeting/contextual/text_classification/resource/text_classification_resource_unittest.cc b/components/brave_ads/core/internal/targeting/contextual/text_classification/resource/text_classification_resource_unittest.cc index f563b6140e16..b748ac6740a0 100644 --- a/components/brave_ads/core/internal/targeting/contextual/text_classification/resource/text_classification_resource_unittest.cc +++ b/components/brave_ads/core/internal/targeting/contextual/text_classification/resource/text_classification_resource_unittest.cc @@ -44,8 +44,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, IsResourceNotLoaded) { TEST_F(BraveAdsTextClassificationResourceTest, LoadResource) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); // Act & Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -54,11 +54,11 @@ TEST_F(BraveAdsTextClassificationResourceTest, LoadResource) { TEST_F(BraveAdsTextClassificationResourceTest, DoNotLoadMalformedResource) { // Arrange ASSERT_TRUE(CopyFileFromTestPathToTempPath( - /*from_path=*/kMalformedResourceId, + /*from_path=*/test::kMalformedResourceId, /*to_path=*/kTextClassificationResourceId)); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -73,15 +73,16 @@ TEST_F(BraveAdsTextClassificationResourceTest, DoNotLoadMissingResource) { const int /*version*/, LoadFileCallback callback) { const base::FilePath path = - ComponentResourcesTestDataPath().AppendASCII(kMissingResourceId); + ComponentResourcesTestDataPath().AppendASCII( + test::kMissingResourceId); base::File file( path, base::File::Flags::FLAG_OPEN | base::File::Flags::FLAG_READ); std::move(callback).Run(std::move(file)); })); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -89,8 +90,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, DoNotLoadMissingResource) { TEST_F(BraveAdsTextClassificationResourceTest, DoNotLoadResourceWithInvalidLanguageComponentId) { - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kInvalidLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kInvalidLanguageComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -101,8 +102,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, // Arrange test::DisableBraveRewards(); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -113,8 +114,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -123,8 +124,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, TEST_F(BraveAdsTextClassificationResourceTest, LoadResourceForOnLocaleDidChange) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -139,8 +140,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -155,8 +156,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -172,8 +173,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -192,8 +193,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -210,8 +211,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, test::OptOutOfNewTabPageAds(); test::OptOutOfSearchResultAds(); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -226,8 +227,8 @@ TEST_F(BraveAdsTextClassificationResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -241,13 +242,13 @@ TEST_F( BraveAdsTextClassificationResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithInvalidLanguageComponentId) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kInvalidLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kInvalidLanguageComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -257,13 +258,13 @@ TEST_F( BraveAdsTextClassificationResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithExistingManifestVersion) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -273,30 +274,32 @@ TEST_F( BraveAdsTextClassificationResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithNewManifestVersion) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); - ASSERT_EQ(kLanguageComponentManifestVersion, resource_->GetManifestVersion()); + ASSERT_EQ(test::kLanguageComponentManifestVersion, + resource_->GetManifestVersion()); // Act - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersionUpdate, - kLanguageComponentId); + NotifyDidUpdateResourceComponent( + test::kLanguageComponentManifestVersionUpdate, + test::kLanguageComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); - EXPECT_EQ(kLanguageComponentManifestVersionUpdate, + EXPECT_EQ(test::kLanguageComponentManifestVersionUpdate, resource_->GetManifestVersion()); } TEST_F(BraveAdsTextClassificationResourceTest, ResetResourceForOnNotifyDidUnregisterResourceComponent) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUnregisterResourceComponent(kLanguageComponentId); + NotifyDidUnregisterResourceComponent(test::kLanguageComponentId); // Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -306,12 +309,12 @@ TEST_F( BraveAdsTextClassificationResourceTest, DoNotResetResourceForOnNotifyDidUnregisterResourceComponentWithInvalidLanguageComponentId) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUnregisterResourceComponent(kInvalidLanguageComponentId); + NotifyDidUnregisterResourceComponent(test::kInvalidLanguageComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); diff --git a/components/brave_ads/core/internal/targeting/contextual/text_classification/text_classification_processor_unittest.cc b/components/brave_ads/core/internal/targeting/contextual/text_classification/text_classification_processor_unittest.cc index b8bd5efe0d4c..bdb966a4685a 100644 --- a/components/brave_ads/core/internal/targeting/contextual/text_classification/text_classification_processor_unittest.cc +++ b/components/brave_ads/core/internal/targeting/contextual/text_classification/text_classification_processor_unittest.cc @@ -46,8 +46,8 @@ TEST_F(BraveAdsTextClassificationProcessorTest, TEST_F(BraveAdsTextClassificationProcessorTest, DoNotProcessForEmptyText) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); TextClassificationProcessor processor(*resource_); @@ -65,8 +65,8 @@ TEST_F(BraveAdsTextClassificationProcessorTest, DoNotProcessForEmptyText) { TEST_F(BraveAdsTextClassificationProcessorTest, NeverProcessed) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act & Assert @@ -78,8 +78,8 @@ TEST_F(BraveAdsTextClassificationProcessorTest, NeverProcessed) { TEST_F(BraveAdsTextClassificationProcessorTest, ProcessText) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); TextClassificationProcessor processor(*resource_); @@ -97,8 +97,8 @@ TEST_F(BraveAdsTextClassificationProcessorTest, ProcessText) { TEST_F(BraveAdsTextClassificationProcessorTest, ProcessMultipleText) { // Arrange - NotifyDidUpdateResourceComponent(kLanguageComponentManifestVersion, - kLanguageComponentId); + NotifyDidUpdateResourceComponent(test::kLanguageComponentManifestVersion, + test::kLanguageComponentId); ASSERT_TRUE(resource_->IsLoaded()); TextClassificationProcessor processor(*resource_); diff --git a/components/brave_ads/core/internal/user_engagement/ad_events/ad_event_builder_test_util.cc b/components/brave_ads/core/internal/user_engagement/ad_events/ad_event_builder_test_util.cc index a451212ad4a1..a43ee0ae39a6 100644 --- a/components/brave_ads/core/internal/user_engagement/ad_events/ad_event_builder_test_util.cc +++ b/components/brave_ads/core/internal/user_engagement/ad_events/ad_event_builder_test_util.cc @@ -23,7 +23,7 @@ AdEventInfo BuildAdEvent(const CreativeAdInfo& creative_ad, ad_event.type = ad_type; ad_event.confirmation_type = confirmation_type; ad_event.placement_id = - test::RandomUuidOr(should_generate_random_uuids, kPlacementId); + RandomUuidOr(should_generate_random_uuids, kPlacementId); ad_event.campaign_id = creative_ad.campaign_id; ad_event.creative_set_id = creative_ad.creative_set_id; ad_event.creative_instance_id = creative_ad.creative_instance_id; diff --git a/components/brave_ads/core/internal/user_engagement/ad_events/ad_event_builder_unittest.cc b/components/brave_ads/core/internal/user_engagement/ad_events/ad_event_builder_unittest.cc index 9b9c39451967..ca6aaa48b789 100644 --- a/components/brave_ads/core/internal/user_engagement/ad_events/ad_event_builder_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/ad_events/ad_event_builder_unittest.cc @@ -32,8 +32,9 @@ TEST_F(BraveAdsAdEventBuilderTest, BuildAdEvent) { EXPECT_THAT(ad_event, ::testing::FieldsAre( AdType::kNotificationAd, ConfirmationType::kViewedImpression, - kPlacementId, kCreativeInstanceId, kCreativeSetId, - kCampaignId, kAdvertiserId, kSegment, /*created_at*/ Now())); + test::kPlacementId, test::kCreativeInstanceId, + test::kCreativeSetId, test::kCampaignId, test::kAdvertiserId, + test::kSegment, /*created_at*/ Now())); } TEST_F(BraveAdsAdEventBuilderTest, RebuildAdEvent) { @@ -50,12 +51,13 @@ TEST_F(BraveAdsAdEventBuilderTest, RebuildAdEvent) { /*created_at=*/DistantFuture()); // Assert - EXPECT_THAT(rebuilt_ad_event, - ::testing::FieldsAre(AdType::kNotificationAd, - ConfirmationType::kConversion, kPlacementId, - kCreativeInstanceId, kCreativeSetId, - kCampaignId, kAdvertiserId, kSegment, - /*created_at*/ DistantFuture())); + EXPECT_THAT( + rebuilt_ad_event, + ::testing::FieldsAre( + AdType::kNotificationAd, ConfirmationType::kConversion, + test::kPlacementId, test::kCreativeInstanceId, test::kCreativeSetId, + test::kCampaignId, test::kAdvertiserId, test::kSegment, + /*created_at*/ DistantFuture())); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/user_engagement/ad_events/inline_content_ads/inline_content_ad_event_handler_unittest.cc b/components/brave_ads/core/internal/user_engagement/ad_events/inline_content_ads/inline_content_ad_event_handler_unittest.cc index de7ac8d1077e..0f38360df563 100644 --- a/components/brave_ads/core/internal/user_engagement/ad_events/inline_content_ads/inline_content_ad_event_handler_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/ad_events/inline_content_ads/inline_content_ad_event_handler_unittest.cc @@ -169,10 +169,10 @@ TEST_F(BraveAdsInlineContentAdEventHandlerTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFireInlineContentAdEvent( - kInvalidPlacementId, kCreativeInstanceId, + test::kInvalidPlacementId, test::kCreativeInstanceId, mojom::InlineContentAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - kInvalidPlacementId, kCreativeInstanceId, + test::kInvalidPlacementId, test::kCreativeInstanceId, mojom::InlineContentAdEventType::kServedImpression, /*should_fire_event=*/false); } @@ -182,10 +182,10 @@ TEST_F(BraveAdsInlineContentAdEventHandlerTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFireInlineContentAdEvent( - kPlacementId, kInvalidCreativeInstanceId, + test::kPlacementId, test::kInvalidCreativeInstanceId, mojom::InlineContentAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - kPlacementId, kInvalidCreativeInstanceId, + test::kPlacementId, test::kInvalidCreativeInstanceId, mojom::InlineContentAdEventType::kServedImpression, /*should_fire_event=*/false); } @@ -198,10 +198,10 @@ TEST_F(BraveAdsInlineContentAdEventHandlerTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFireInlineContentAdEvent( - ad.placement_id, kMissingCreativeInstanceId, + ad.placement_id, test::kMissingCreativeInstanceId, mojom::InlineContentAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - ad.placement_id, kMissingCreativeInstanceId, + ad.placement_id, test::kMissingCreativeInstanceId, mojom::InlineContentAdEventType::kServedImpression, /*should_fire_event=*/false); } diff --git a/components/brave_ads/core/internal/user_engagement/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_for_non_rewards_unittest.cc b/components/brave_ads/core/internal/user_engagement/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_for_non_rewards_unittest.cc index f1e1badcb991..fa24ac88b8f6 100644 --- a/components/brave_ads/core/internal/user_engagement/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_for_non_rewards_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_for_non_rewards_unittest.cc @@ -175,10 +175,10 @@ TEST_F(BraveAdsNewTabPageAdEventHandlerIfUserHasNotJoinedBraveRewardsTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFireNewTabPageAdEvent( - kInvalidPlacementId, kCreativeInstanceId, + test::kInvalidPlacementId, test::kCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - kInvalidPlacementId, kCreativeInstanceId, + test::kInvalidPlacementId, test::kCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression, /*should_fire_event=*/false); } @@ -188,10 +188,10 @@ TEST_F(BraveAdsNewTabPageAdEventHandlerIfUserHasNotJoinedBraveRewardsTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFireNewTabPageAdEvent( - kPlacementId, kInvalidCreativeInstanceId, + test::kPlacementId, test::kInvalidCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - kPlacementId, kInvalidCreativeInstanceId, + test::kPlacementId, test::kInvalidCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression, /*should_fire_event=*/false); } @@ -204,10 +204,10 @@ TEST_F(BraveAdsNewTabPageAdEventHandlerIfUserHasNotJoinedBraveRewardsTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFireNewTabPageAdEvent( - ad.placement_id, kMissingCreativeInstanceId, + ad.placement_id, test::kMissingCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - ad.placement_id, kMissingCreativeInstanceId, + ad.placement_id, test::kMissingCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression, /*should_fire_event=*/false); } diff --git a/components/brave_ads/core/internal/user_engagement/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_unittest.cc b/components/brave_ads/core/internal/user_engagement/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_unittest.cc index 84934c9789fc..02bbcd5f0614 100644 --- a/components/brave_ads/core/internal/user_engagement/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_unittest.cc @@ -168,10 +168,10 @@ TEST_F(BraveAdsNewTabPageAdEventHandlerTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFireNewTabPageAdEvent( - kInvalidPlacementId, kCreativeInstanceId, + test::kInvalidPlacementId, test::kCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - kInvalidPlacementId, kCreativeInstanceId, + test::kInvalidPlacementId, test::kCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression, /*should_fire_event=*/false); } @@ -181,10 +181,10 @@ TEST_F(BraveAdsNewTabPageAdEventHandlerTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFireNewTabPageAdEvent( - kPlacementId, kInvalidCreativeInstanceId, + test::kPlacementId, test::kInvalidCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - kPlacementId, kInvalidCreativeInstanceId, + test::kPlacementId, test::kInvalidCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression, /*should_fire_event=*/false); } @@ -197,10 +197,10 @@ TEST_F(BraveAdsNewTabPageAdEventHandlerTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFireNewTabPageAdEvent( - ad.placement_id, kMissingCreativeInstanceId, + ad.placement_id, test::kMissingCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - ad.placement_id, kMissingCreativeInstanceId, + ad.placement_id, test::kMissingCreativeInstanceId, mojom::NewTabPageAdEventType::kServedImpression, /*should_fire_event=*/false); } diff --git a/components/brave_ads/core/internal/user_engagement/ad_events/notification_ads/notification_ad_event_handler_unittest.cc b/components/brave_ads/core/internal/user_engagement/ad_events/notification_ads/notification_ad_event_handler_unittest.cc index 6a46247f12d8..b46500d90156 100644 --- a/components/brave_ads/core/internal/user_engagement/ad_events/notification_ads/notification_ad_event_handler_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/ad_events/notification_ads/notification_ad_event_handler_unittest.cc @@ -117,10 +117,11 @@ TEST_F(BraveAdsNotificationAdEventHandlerTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFireNotificationAdEvent( - kMissingPlacementId, + test::kMissingPlacementId, mojom::NotificationAdEventType::kViewedImpression)); FireEventAndVerifyExpectations( - kMissingPlacementId, mojom::NotificationAdEventType::kViewedImpression, + test::kMissingPlacementId, + mojom::NotificationAdEventType::kViewedImpression, /*should_fire_event=*/false); } diff --git a/components/brave_ads/core/internal/user_engagement/ad_events/promoted_content_ads/promoted_content_ad_event_handler_unittest.cc b/components/brave_ads/core/internal/user_engagement/ad_events/promoted_content_ads/promoted_content_ad_event_handler_unittest.cc index 9c70b4345334..f663928d8bcc 100644 --- a/components/brave_ads/core/internal/user_engagement/ad_events/promoted_content_ads/promoted_content_ad_event_handler_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/ad_events/promoted_content_ads/promoted_content_ad_event_handler_unittest.cc @@ -163,10 +163,10 @@ TEST_F(BraveAdsPromotedContentAdEventHandlerTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFirePromotedContentAdEvent( - kInvalidPlacementId, kCreativeInstanceId, + test::kInvalidPlacementId, test::kCreativeInstanceId, mojom::PromotedContentAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - kInvalidPlacementId, kCreativeInstanceId, + test::kInvalidPlacementId, test::kCreativeInstanceId, mojom::PromotedContentAdEventType::kServedImpression, /*should_fire_event=*/false); } @@ -176,10 +176,10 @@ TEST_F(BraveAdsPromotedContentAdEventHandlerTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFirePromotedContentAdEvent( - kPlacementId, kInvalidCreativeInstanceId, + test::kPlacementId, test::kInvalidCreativeInstanceId, mojom::PromotedContentAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - kPlacementId, kInvalidCreativeInstanceId, + test::kPlacementId, test::kInvalidCreativeInstanceId, mojom::PromotedContentAdEventType::kServedImpression, /*should_fire_event=*/false); } @@ -192,10 +192,10 @@ TEST_F(BraveAdsPromotedContentAdEventHandlerTest, // Act & Assert EXPECT_CALL(delegate_mock_, OnFailedToFirePromotedContentAdEvent( - ad.placement_id, kMissingCreativeInstanceId, + ad.placement_id, test::kMissingCreativeInstanceId, mojom::PromotedContentAdEventType::kServedImpression)); FireEventAndVerifyExpectations( - ad.placement_id, kMissingCreativeInstanceId, + ad.placement_id, test::kMissingCreativeInstanceId, mojom::PromotedContentAdEventType::kServedImpression, /*should_fire_event=*/false); } diff --git a/components/brave_ads/core/internal/user_engagement/ad_events/search_result_ads/search_result_ad_event_handler_unittest.cc b/components/brave_ads/core/internal/user_engagement/ad_events/search_result_ads/search_result_ad_event_handler_unittest.cc index 18e55c883961..ee8806d806fe 100644 --- a/components/brave_ads/core/internal/user_engagement/ad_events/search_result_ads/search_result_ad_event_handler_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/ad_events/search_result_ads/search_result_ad_event_handler_unittest.cc @@ -212,7 +212,7 @@ TEST_F(BraveAdsSearchResultAdEventHandlerTest, // Arrange mojom::CreativeSearchResultAdInfoPtr mojom_creative_ad = test::BuildCreativeSearchResultAd(/*should_generate_random_uuids=*/true); - mojom_creative_ad->placement_id = kMissingPlacementId; + mojom_creative_ad->placement_id = test::kMissingPlacementId; const SearchResultAdInfo ad = FromMojomBuildSearchResultAd(mojom_creative_ad); // Act & Assert @@ -231,7 +231,7 @@ TEST_F(BraveAdsSearchResultAdEventHandlerTest, // Arrange mojom::CreativeSearchResultAdInfoPtr mojom_creative_ad = test::BuildCreativeSearchResultAd(/*should_generate_random_uuids=*/true); - mojom_creative_ad->placement_id = kInvalidPlacementId; + mojom_creative_ad->placement_id = test::kInvalidPlacementId; const SearchResultAdInfo ad = FromMojomBuildSearchResultAd(mojom_creative_ad); // Act & Assert @@ -250,7 +250,7 @@ TEST_F(BraveAdsSearchResultAdEventHandlerTest, // Arrange mojom::CreativeSearchResultAdInfoPtr mojom_creative_ad = test::BuildCreativeSearchResultAd(/*should_generate_random_uuids=*/true); - mojom_creative_ad->creative_instance_id = kInvalidCreativeInstanceId; + mojom_creative_ad->creative_instance_id = test::kInvalidCreativeInstanceId; const SearchResultAdInfo ad = FromMojomBuildSearchResultAd(mojom_creative_ad); // Act & Assert diff --git a/components/brave_ads/core/internal/user_engagement/conversions/conversion/conversion_builder_unittest.cc b/components/brave_ads/core/internal/user_engagement/conversions/conversion/conversion_builder_unittest.cc index 6677c0106223..fbf6985486a7 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/conversion/conversion_builder_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/conversions/conversion/conversion_builder_unittest.cc @@ -36,10 +36,11 @@ TEST(BraveAdsConversionBuilderTest, BuildConversion) { // Assert EXPECT_THAT(conversion, - ::testing::FieldsAre(AdType::kNotificationAd, kCreativeInstanceId, - kCreativeSetId, kCampaignId, kAdvertiserId, - kSegment, ConversionActionType::kViewThrough, - /*verifable*/ std::nullopt)); + ::testing::FieldsAre( + AdType::kNotificationAd, test::kCreativeInstanceId, + test::kCreativeSetId, test::kCampaignId, test::kAdvertiserId, + test::kSegment, ConversionActionType::kViewThrough, + /*verifable*/ std::nullopt)); } TEST(BraveAdsConversionBuilderTest, BuildVerifiableConversion) { @@ -52,18 +53,19 @@ TEST(BraveAdsConversionBuilderTest, BuildVerifiableConversion) { // Act const ConversionInfo conversion = BuildConversion( - ad_event, - VerifiableConversionInfo{kVerifiableConversionId, - kVerifiableConversionAdvertiserPublicKey}); + ad_event, VerifiableConversionInfo{ + test::kVerifiableConversionId, + test::kVerifiableConversionAdvertiserPublicKeyBase64}); // Assert - EXPECT_THAT(conversion, ::testing::FieldsAre( - AdType::kNotificationAd, kCreativeInstanceId, - kCreativeSetId, kCampaignId, kAdvertiserId, - kSegment, ConversionActionType::kViewThrough, - VerifiableConversionInfo{ - kVerifiableConversionId, - kVerifiableConversionAdvertiserPublicKey})); + EXPECT_THAT(conversion, + ::testing::FieldsAre( + AdType::kNotificationAd, test::kCreativeInstanceId, + test::kCreativeSetId, test::kCampaignId, test::kAdvertiserId, + test::kSegment, ConversionActionType::kViewThrough, + VerifiableConversionInfo{ + test::kVerifiableConversionId, + test::kVerifiableConversionAdvertiserPublicKeyBase64})); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/user_engagement/conversions/conversion/conversion_util_unittest.cc b/components/brave_ads/core/internal/user_engagement/conversions/conversion/conversion_util_unittest.cc index c341d2a07c6e..8584cdaf974f 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/conversion/conversion_util_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/conversions/conversion/conversion_util_unittest.cc @@ -24,8 +24,9 @@ TEST(BraveAdsConversionInfoUtilTest, ConversionTypeToString) { TEST(BraveAdsConversionInfoUtilTest, VerifiableConversionTypeToString) { // Arrange ConversionInfo conversion; - conversion.verifiable = {kVerifiableConversionId, - kVerifiableConversionAdvertiserPublicKey}; + conversion.verifiable = { + test::kVerifiableConversionId, + test::kVerifiableConversionAdvertiserPublicKeyBase64}; // Act & Assert EXPECT_EQ("verifiable conversion", ConversionTypeToString(conversion)); diff --git a/components/brave_ads/core/internal/user_engagement/conversions/conversions_unittest.cc b/components/brave_ads/core/internal/user_engagement/conversions/conversions_unittest.cc index 7b580bfe1f90..4932334f4d77 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/conversions_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/conversions/conversions_unittest.cc @@ -786,8 +786,8 @@ TEST_F(BraveAdsConversionsTest, TEST_F(BraveAdsConversionsTest, FallbackToDefaultConversionIfVerifiableAdvertiserPublicKeyIsEmpty) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); const AdInfo ad = test::BuildAd(AdType::kNotificationAd, /*should_generate_random_uuids=*/false); @@ -795,7 +795,7 @@ TEST_F(BraveAdsConversionsTest, test::BuildAndSaveVerifiableCreativeSetConversion( ad.creative_set_id, kMatchingUrlPattern, /*observation_window=*/base::Days(3), - kEmptyVerifiableConversionAdvertiserPublicKey); + /*verifiable_advertiser_public_key_base64=*/""); RecordAdEventsAdvancingTheClockAfterEach( ad, {ConfirmationType::kServedImpression, @@ -816,8 +816,8 @@ TEST_F( BraveAdsConversionsTest, FallbackToDefaultConversionIfResourceIdPatternDoesNotMatchRedirectChain) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); const AdInfo ad = test::BuildAd(AdType::kNotificationAd, /*should_generate_random_uuids=*/false); @@ -826,7 +826,7 @@ TEST_F( ad.creative_set_id, /*url_pattern=*/"https://www.baz.com/*", /*observation_window=*/base::Days(3), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); RecordAdEventsAdvancingTheClockAfterEach( ad, {ConfirmationType::kServedImpression, @@ -849,8 +849,8 @@ TEST_F( TEST_F(BraveAdsConversionsTest, FallbackToDefaultConversionIfVerifiableUrlConversionIdDoesNotExist) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); const AdInfo ad = test::BuildAd(AdType::kNotificationAd, /*should_generate_random_uuids=*/false); @@ -858,7 +858,7 @@ TEST_F(BraveAdsConversionsTest, test::BuildAndSaveVerifiableCreativeSetConversion( ad.creative_set_id, kMatchingUrlPattern, /*observation_window=*/base::Days(3), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); RecordAdEventsAdvancingTheClockAfterEach( ad, {ConfirmationType::kServedImpression, @@ -877,8 +877,8 @@ TEST_F(BraveAdsConversionsTest, TEST_F(BraveAdsConversionsTest, ConvertAdIfVerifiableUrlConversionIdExists) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); const AdInfo ad = test::BuildAd(AdType::kNotificationAd, /*should_generate_random_uuids=*/false); @@ -886,7 +886,7 @@ TEST_F(BraveAdsConversionsTest, ConvertAdIfVerifiableUrlConversionIdExists) { test::BuildAndSaveVerifiableCreativeSetConversion( ad.creative_set_id, kMatchingUrlPattern, /*observation_window=*/base::Days(3), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); RecordAdEventsAdvancingTheClockAfterEach( ad, {ConfirmationType::kServedImpression, @@ -895,8 +895,9 @@ TEST_F(BraveAdsConversionsTest, ConvertAdIfVerifiableUrlConversionIdExists) { const ConversionInfo conversion = BuildConversion( BuildAdEvent(ad, ConfirmationType::kViewedImpression, /*created_at=*/Now()), - VerifiableConversionInfo{/*id=*/"xyzzy", - kVerifiableConversionAdvertiserPublicKey}); + VerifiableConversionInfo{ + /*id=*/"xyzzy", + test::kVerifiableConversionAdvertiserPublicKeyBase64}); // Act & Assert EXPECT_CALL(conversions_observer_mock_, OnDidConvertAd(conversion)); @@ -907,8 +908,8 @@ TEST_F(BraveAdsConversionsTest, ConvertAdIfVerifiableUrlConversionIdExists) { TEST_F(BraveAdsConversionsTest, FallbackToDefaultConversionIfVerifiableHtmlConversionIdDoesNotExist) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); const AdInfo ad = test::BuildAd(AdType::kNotificationAd, /*should_generate_random_uuids=*/false); @@ -916,7 +917,7 @@ TEST_F(BraveAdsConversionsTest, test::BuildAndSaveVerifiableCreativeSetConversion( ad.creative_set_id, kMatchingUrlPattern, /*observation_window=*/base::Days(3), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); RecordAdEventsAdvancingTheClockAfterEach( ad, {ConfirmationType::kServedImpression, @@ -935,8 +936,8 @@ TEST_F(BraveAdsConversionsTest, TEST_F(BraveAdsConversionsTest, ConvertAdIfVerifiableHtmlConversionIdExists) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); const AdInfo ad = test::BuildAd(AdType::kNotificationAd, /*should_generate_random_uuids=*/false); @@ -944,7 +945,7 @@ TEST_F(BraveAdsConversionsTest, ConvertAdIfVerifiableHtmlConversionIdExists) { test::BuildAndSaveVerifiableCreativeSetConversion( ad.creative_set_id, kMatchingUrlPattern, /*observation_window=*/base::Days(3), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); RecordAdEventsAdvancingTheClockAfterEach( ad, {ConfirmationType::kServedImpression, @@ -953,8 +954,9 @@ TEST_F(BraveAdsConversionsTest, ConvertAdIfVerifiableHtmlConversionIdExists) { const ConversionInfo conversion = BuildConversion( BuildAdEvent(ad, ConfirmationType::kViewedImpression, /*created_at=*/Now()), - VerifiableConversionInfo{/*id=*/"waldo", - kVerifiableConversionAdvertiserPublicKey}); + VerifiableConversionInfo{ + /*id=*/"waldo", + test::kVerifiableConversionAdvertiserPublicKeyBase64}); // Act & Assert EXPECT_CALL(conversions_observer_mock_, OnDidConvertAd(conversion)); @@ -967,8 +969,8 @@ TEST_F( BraveAdsConversionsTest, FallbackToDefaultConversionIfVerifiableHtmlMetaTagConversionIdDoesNotExist) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); const AdInfo ad = test::BuildAd(AdType::kNotificationAd, /*should_generate_random_uuids=*/false); @@ -976,7 +978,7 @@ TEST_F( test::BuildAndSaveVerifiableCreativeSetConversion( ad.creative_set_id, kAnotherMatchingUrlPattern, /*observation_window=*/base::Days(3), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); RecordAdEventsAdvancingTheClockAfterEach( ad, {ConfirmationType::kServedImpression, @@ -996,8 +998,8 @@ TEST_F( TEST_F(BraveAdsConversionsTest, ConvertAdIfVerifiableHtmlMetaTagConversionIdExists) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); const AdInfo ad = test::BuildAd(AdType::kNotificationAd, /*should_generate_random_uuids=*/false); @@ -1005,7 +1007,7 @@ TEST_F(BraveAdsConversionsTest, test::BuildAndSaveVerifiableCreativeSetConversion( ad.creative_set_id, kAnotherMatchingUrlPattern, /*observation_window=*/base::Days(3), - kVerifiableConversionAdvertiserPublicKey); + test::kVerifiableConversionAdvertiserPublicKeyBase64); RecordAdEventsAdvancingTheClockAfterEach( ad, {ConfirmationType::kServedImpression, @@ -1014,8 +1016,8 @@ TEST_F(BraveAdsConversionsTest, const ConversionInfo conversion = BuildConversion( BuildAdEvent(ad, ConfirmationType::kViewedImpression, /*created_at=*/Now()), - VerifiableConversionInfo{/*id=*/"fred", - kVerifiableConversionAdvertiserPublicKey}); + VerifiableConversionInfo{ + /*id=*/"fred", test::kVerifiableConversionAdvertiserPublicKeyBase64}); // Act & Assert EXPECT_CALL(conversions_observer_mock_, OnDidConvertAd(conversion)); diff --git a/components/brave_ads/core/internal/user_engagement/conversions/resource/conversion_resource_unittest.cc b/components/brave_ads/core/internal/user_engagement/conversions/resource/conversion_resource_unittest.cc index 74dfb293b6f7..02fb10b602d6 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/resource/conversion_resource_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/conversions/resource/conversion_resource_unittest.cc @@ -45,8 +45,8 @@ TEST_F(BraveAdsConversionResourceTest, IsResourceNotLoaded) { TEST_F(BraveAdsConversionResourceTest, LoadResource) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -55,11 +55,11 @@ TEST_F(BraveAdsConversionResourceTest, LoadResource) { TEST_F(BraveAdsConversionResourceTest, DoNotLoadMalformedResource) { // Arrange ASSERT_TRUE( - CopyFileFromTestPathToTempPath(/*from_path=*/kMalformedResourceId, + CopyFileFromTestPathToTempPath(/*from_path=*/test::kMalformedResourceId, /*to_path=*/kConversionResourceId)); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -74,15 +74,16 @@ TEST_F(BraveAdsConversionResourceTest, DoNotLoadMissingResource) { const int /*version*/, LoadFileCallback callback) { const base::FilePath path = - ComponentResourcesTestDataPath().AppendASCII(kMissingResourceId); + ComponentResourcesTestDataPath().AppendASCII( + test::kMissingResourceId); base::File file( path, base::File::Flags::FLAG_OPEN | base::File::Flags::FLAG_READ); std::move(callback).Run(std::move(file)); })); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -90,8 +91,8 @@ TEST_F(BraveAdsConversionResourceTest, DoNotLoadMissingResource) { TEST_F(BraveAdsConversionResourceTest, DoNotLoadResourceWithInvalidCountryComponentId) { - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kInvalidCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kInvalidCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -101,8 +102,8 @@ TEST_F(BraveAdsConversionResourceTest, DoNotLoadResourceForNonRewardsUser) { // Arrange test::DisableBraveRewards(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -112,8 +113,8 @@ TEST_F(BraveAdsConversionResourceTest, DoNotLoadResourceIfOptedOutOfAllAds) { // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Act & Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -121,8 +122,8 @@ TEST_F(BraveAdsConversionResourceTest, DoNotLoadResourceIfOptedOutOfAllAds) { TEST_F(BraveAdsConversionResourceTest, LoadResourceForOnLocaleDidChange) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -137,8 +138,8 @@ TEST_F(BraveAdsConversionResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -152,8 +153,8 @@ TEST_F(BraveAdsConversionResourceTest, LoadResourceWhenOptingInToBraveNewsAds) { // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -171,8 +172,8 @@ TEST_F(BraveAdsConversionResourceTest, test::OptOutOfNotificationAds(); test::OptOutOfSearchResultAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -188,8 +189,8 @@ TEST_F(BraveAdsConversionResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -210,8 +211,8 @@ TEST_F(BraveAdsConversionResourceTest, test::OptOutOfNotificationAds(); test::OptOutOfSearchResultAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -230,8 +231,8 @@ TEST_F(BraveAdsConversionResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -248,8 +249,8 @@ TEST_F(BraveAdsConversionResourceTest, test::OptOutOfNewTabPageAds(); test::OptOutOfSearchResultAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -264,8 +265,8 @@ TEST_F(BraveAdsConversionResourceTest, // Arrange test::OptOutOfAllAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_FALSE(resource_->IsLoaded()); // Act @@ -282,8 +283,8 @@ TEST_F(BraveAdsConversionResourceTest, test::OptOutOfNewTabPageAds(); test::OptOutOfNotificationAds(); - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act @@ -297,13 +298,13 @@ TEST_F( BraveAdsConversionResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithInvalidCountryComponentId) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kInvalidCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kInvalidCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -313,13 +314,13 @@ TEST_F( BraveAdsConversionResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithExistingManifestVersion) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); @@ -329,30 +330,31 @@ TEST_F( BraveAdsConversionResourceTest, DoNotResetResourceForOnDidUpdateResourceComponentWithNewManifestVersion) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); - ASSERT_EQ(kCountryComponentManifestVersion, resource_->GetManifestVersion()); + ASSERT_EQ(test::kCountryComponentManifestVersion, + resource_->GetManifestVersion()); // Act - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersionUpdate, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersionUpdate, + test::kCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); - EXPECT_EQ(kCountryComponentManifestVersionUpdate, + EXPECT_EQ(test::kCountryComponentManifestVersionUpdate, resource_->GetManifestVersion()); } TEST_F(BraveAdsConversionResourceTest, ResetResourceForOnNotifyDidUnregisterResourceComponent) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUnregisterResourceComponent(kCountryComponentId); + NotifyDidUnregisterResourceComponent(test::kCountryComponentId); // Assert EXPECT_FALSE(resource_->IsLoaded()); @@ -362,12 +364,12 @@ TEST_F( BraveAdsConversionResourceTest, DoNotResetResourceForOnNotifyDidUnregisterResourceComponentWithInvalidCountryComponentId) { // Arrange - NotifyDidUpdateResourceComponent(kCountryComponentManifestVersion, - kCountryComponentId); + NotifyDidUpdateResourceComponent(test::kCountryComponentManifestVersion, + test::kCountryComponentId); ASSERT_TRUE(resource_->IsLoaded()); // Act - NotifyDidUnregisterResourceComponent(kInvalidCountryComponentId); + NotifyDidUnregisterResourceComponent(test::kInvalidCountryComponentId); // Assert EXPECT_TRUE(resource_->IsLoaded()); diff --git a/components/brave_ads/core/internal/user_engagement/conversions/types/default_conversion/creative_set_conversion_url_pattern/creative_set_conversion_url_pattern_util_unittest.cc b/components/brave_ads/core/internal/user_engagement/conversions/types/default_conversion/creative_set_conversion_url_pattern/creative_set_conversion_url_pattern_util_unittest.cc index d3e5a16e9175..e850a10ff25b 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/types/default_conversion/creative_set_conversion_url_pattern/creative_set_conversion_url_pattern_util_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/conversions/types/default_conversion/creative_set_conversion_url_pattern/creative_set_conversion_url_pattern_util_unittest.cc @@ -19,7 +19,7 @@ TEST_F(BraveAdsCreativeConversionSetUrlPatternUtilTest, DoesCreativeSetConversionUrlPatternMatchRedirectChain) { // Arrange const CreativeSetConversionInfo creative_set_conversion = - test::BuildCreativeSetConversion(kCreativeSetId, + test::BuildCreativeSetConversion(test::kCreativeSetId, /*url_pattern=*/"https://foo.com/*", /*observation_window=*/base::Days(3)); @@ -33,7 +33,7 @@ TEST_F(BraveAdsCreativeConversionSetUrlPatternUtilTest, DoesCreativeSetConversionUrlPatternNotMatchRedirectChain) { // Arrange const CreativeSetConversionInfo creative_set_conversion = - test::BuildCreativeSetConversion(kCreativeSetId, + test::BuildCreativeSetConversion(test::kCreativeSetId, /*url_pattern=*/"https://foo.com/*", /*observation_window=*/base::Days(3)); diff --git a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_test_util.cc b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_test_util.cc index 53c5ea0bac5f..d94926607f14 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_test_util.cc +++ b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_test_util.cc @@ -17,8 +17,8 @@ namespace brave_ads::test { std::optional OpenVerifiableConversionEnvelope( const VerifiableConversionEnvelopeInfo& verifiable_conversion_envelope, - const std::string& advertiser_secret_key_base64) { - CHECK(!advertiser_secret_key_base64.empty()); + const std::string& verifiable_conversion_advertiser_secret_key_base64) { + CHECK(!verifiable_conversion_advertiser_secret_key_base64.empty()); if (!verifiable_conversion_envelope.IsValid()) { return std::nullopt; @@ -45,14 +45,16 @@ std::optional OpenVerifiableConversionEnvelope( return std::nullopt; } - const std::optional> advertiser_secret_key = - base::Base64Decode(advertiser_secret_key_base64); - if (!advertiser_secret_key) { + const std::optional> + verifiable_conversion_advertiser_secret_key = base::Base64Decode( + verifiable_conversion_advertiser_secret_key_base64); + if (!verifiable_conversion_advertiser_secret_key) { return std::nullopt; } - const std::vector plaintext = crypto::Decrypt( - *ciphertext, *nonce, *ephemeral_public_key, *advertiser_secret_key); + const std::vector plaintext = + crypto::Decrypt(*ciphertext, *nonce, *ephemeral_public_key, + *verifiable_conversion_advertiser_secret_key); return std::string(reinterpret_cast(plaintext.data())); } diff --git a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_test_util.h b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_test_util.h index 25c43ccee384..ba52a46efe52 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_test_util.h +++ b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_test_util.h @@ -17,7 +17,7 @@ namespace test { std::optional OpenVerifiableConversionEnvelope( const VerifiableConversionEnvelopeInfo& verifiable_conversion_envelope, - const std::string& advertiser_secret_key_base64); + const std::string& verifiable_conversion_advertiser_secret_key_base64); } // namespace test diff --git a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_util_unittest.cc b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_util_unittest.cc index b850e07b009c..a6f36ea04cd6 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_util_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/envelope/verifiable_conversion_envelope_util_unittest.cc @@ -20,7 +20,8 @@ TEST(BraveAdsVerifiableConversionEnvelopeUtilTest, SealVerifiableConversionEnvelope) { // Arrange const VerifiableConversionInfo verifiable_conversion{ - kVerifiableConversionId, kVerifiableConversionAdvertiserPublicKey}; + test::kVerifiableConversionId, + test::kVerifiableConversionAdvertiserPublicKeyBase64}; // Act const std::optional @@ -32,7 +33,7 @@ TEST(BraveAdsVerifiableConversionEnvelopeUtilTest, EXPECT_EQ(verifiable_conversion.id, test::OpenVerifiableConversionEnvelope( *sealed_verifiable_conversion_envelope, - kVerifiableConversionAdvertiserSecretKey)); + test::kVerifiableConversionAdvertiserSecretKeyBase64)); } TEST(BraveAdsVerifiableConversionEnvelopeUtilTest, @@ -42,7 +43,7 @@ TEST(BraveAdsVerifiableConversionEnvelopeUtilTest, verifiable_conversion.id = std::string(kMinVerifiableConversionEnvelopeMessageLength - 1, '-'); verifiable_conversion.advertiser_public_key_base64 = - kVerifiableConversionAdvertiserPublicKey; + test::kVerifiableConversionAdvertiserPublicKeyBase64; // Act & Assert EXPECT_FALSE(SealVerifiableConversionEnvelope(verifiable_conversion)); @@ -55,7 +56,7 @@ TEST(BraveAdsVerifiableConversionEnvelopeUtilTest, verifiable_conversion.id = std::string(kMaxVerifiableConversionEnvelopeMessageLength + 1, '-'); verifiable_conversion.advertiser_public_key_base64 = - kVerifiableConversionAdvertiserPublicKey; + test::kVerifiableConversionAdvertiserPublicKeyBase64; // Act & Assert EXPECT_FALSE(SealVerifiableConversionEnvelope(verifiable_conversion)); @@ -64,17 +65,17 @@ TEST(BraveAdsVerifiableConversionEnvelopeUtilTest, TEST(BraveAdsVerifiableConversionEnvelopeUtilTest, DoNotSealEnvelopeWithInvalidMessage) { // Act & Assert - EXPECT_FALSE(SealVerifiableConversionEnvelope( - VerifiableConversionInfo{kInvalidVerifiableConversionId, - kVerifiableConversionAdvertiserPublicKey})); + EXPECT_FALSE(SealVerifiableConversionEnvelope(VerifiableConversionInfo{ + test::kInvalidVerifiableConversionId, + test::kVerifiableConversionAdvertiserPublicKeyBase64})); } TEST(BraveAdsVerifiableConversionEnvelopeUtilTest, DoNotSealEnvelopeWithInvalidPublicKey) { // Act & Assert EXPECT_FALSE(SealVerifiableConversionEnvelope(VerifiableConversionInfo{ - kVerifiableConversionId, - kInvalidVerifiableConversionAdvertiserPublicKey})); + test::kVerifiableConversionId, + test::kInvalidVerifiableConversionAdvertiserPublicKeyBase64})); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/id_pattern/parsers/verifiable_conversion_id_html_parser_util_unittest.cc b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/id_pattern/parsers/verifiable_conversion_id_html_parser_util_unittest.cc index 0a98371761ce..b36da61e8e0d 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/id_pattern/parsers/verifiable_conversion_id_html_parser_util_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/id_pattern/parsers/verifiable_conversion_id_html_parser_util_unittest.cc @@ -19,7 +19,6 @@ constexpr char kMatchingHtml[] = R"(
waldo
)"; constexpr char kMismatchingHtml[] = R"(
waldo
)"; -constexpr char kEmptyHtml[] = ""; constexpr char kUrlPattern[] = "https://foo.com/bar"; constexpr ConversionResourceIdPatternSearchInType kSearchInType = @@ -51,7 +50,7 @@ TEST_F(BraveAdsVerifiableConversionIdHtmlParserUtilTest, DoNotParseVerifableConversionIdFromEmptyHtml) { // Act & Assert EXPECT_FALSE(MaybeParseVerifableConversionIdFromHtml( - kEmptyHtml, + /*html=*/"", ConversionResourceIdPatternInfo{kUrlPattern, kSearchInType, kIdPattern})); } diff --git a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/verifiable_conversion_builder_unittest.cc b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/verifiable_conversion_builder_unittest.cc index 5f23385192e8..285472076a07 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/verifiable_conversion_builder_unittest.cc +++ b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/verifiable_conversion_builder_unittest.cc @@ -35,7 +35,7 @@ TEST_F(BraveAdsVerifiableConversionBuilderTest, BuildVerifiableConversionId) { CreativeSetConversionInfo creative_set_conversion; creative_set_conversion.verifiable_advertiser_public_key_base64 = - kVerifiableConversionAdvertiserPublicKey; + test::kVerifiableConversionAdvertiserPublicKeyBase64; // Act const std::optional verifiable_conversion = @@ -45,9 +45,10 @@ TEST_F(BraveAdsVerifiableConversionBuilderTest, BuildVerifiableConversionId) { ASSERT_TRUE(verifiable_conversion); // Assert - EXPECT_THAT(*verifiable_conversion, - testing::FieldsAre(/*id*/ "waldo", - kVerifiableConversionAdvertiserPublicKey)); + EXPECT_THAT( + *verifiable_conversion, + testing::FieldsAre(/*id*/ "waldo", + test::kVerifiableConversionAdvertiserPublicKeyBase64)); } TEST_F(BraveAdsVerifiableConversionBuilderTest, diff --git a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/verifiable_conversion_test_constants.h b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/verifiable_conversion_test_constants.h index f043c9102a3a..39324b454171 100644 --- a/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/verifiable_conversion_test_constants.h +++ b/components/brave_ads/core/internal/user_engagement/conversions/types/verifiable_conversion/verifiable_conversion_test_constants.h @@ -6,20 +6,18 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_USER_ENGAGEMENT_CONVERSIONS_TYPES_VERIFIABLE_CONVERSION_VERIFIABLE_CONVERSION_TEST_CONSTANTS_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_USER_ENGAGEMENT_CONVERSIONS_TYPES_VERIFIABLE_CONVERSION_VERIFIABLE_CONVERSION_TEST_CONSTANTS_H_ -namespace brave_ads { +namespace brave_ads::test { inline constexpr char kVerifiableConversionId[] = "smartbrownfoxes42"; inline constexpr char kInvalidVerifiableConversionId[] = "smart brown foxes 16"; -inline constexpr char kEmptyVerifiableConversionId[] = ""; -inline constexpr char kVerifiableConversionAdvertiserPublicKey[] = +inline constexpr char kVerifiableConversionAdvertiserPublicKeyBase64[] = "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; -inline constexpr char kInvalidVerifiableConversionAdvertiserPublicKey[] = +inline constexpr char kInvalidVerifiableConversionAdvertiserPublicKeyBase64[] = "INVALID"; -inline constexpr char kEmptyVerifiableConversionAdvertiserPublicKey[] = ""; -inline constexpr char kVerifiableConversionAdvertiserSecretKey[] = +inline constexpr char kVerifiableConversionAdvertiserSecretKeyBase64[] = "Ete7+aKfrX25gt0eN4kBV1LqeF9YmB1go8OqnGXUGG4="; -} // namespace brave_ads +} // namespace brave_ads::test #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_USER_ENGAGEMENT_CONVERSIONS_TYPES_VERIFIABLE_CONVERSION_VERIFIABLE_CONVERSION_TEST_CONSTANTS_H_