[ads][CodeHealth] Add param= comments to EXPECT_CALL and EXPECT_THAT matchers (#35884)

Add missing /*param=*/ comments to ::testing::_ wildcards in
TriggerSearchResultAdEvent and Log EXPECT_CALL calls, and fix existing
/*param*/ (no =) style to /*param=*/ across all affected test files.

No behavioral changes.
This commit is contained in:
Terry Mancey
2026-04-24 20:12:22 +01:00
committed by GitHub
parent faa9db41a8
commit 7bc334727a
8 changed files with 88 additions and 85 deletions
@@ -113,11 +113,11 @@ TEST_F(BraveAdsCreativeSearchResultAdHandlerTest,
ASSERT_TRUE(mojom_web_page);
// Act & Assert
EXPECT_CALL(
ads_service_mock_,
TriggerSearchResultAdEvent(
::testing::_, mojom::SearchResultAdEventType::kViewedImpression,
::testing::_))
EXPECT_CALL(ads_service_mock_,
TriggerSearchResultAdEvent(
/*mojom_creative_ad=*/::testing::_,
mojom::SearchResultAdEventType::kViewedImpression,
/*callback=*/::testing::_))
.Times(0);
SimulateMaybeExtractCreativeAdPlacementIdsFromWebPageCallback(
@@ -134,11 +134,11 @@ TEST_F(BraveAdsCreativeSearchResultAdHandlerTest,
ASSERT_TRUE(creative_search_result_ad_handler);
// Act & Assert
EXPECT_CALL(
ads_service_mock_,
TriggerSearchResultAdEvent(
::testing::_, mojom::SearchResultAdEventType::kViewedImpression,
::testing::_))
EXPECT_CALL(ads_service_mock_,
TriggerSearchResultAdEvent(
/*mojom_creative_ad=*/::testing::_,
mojom::SearchResultAdEventType::kViewedImpression,
/*callback=*/::testing::_))
.Times(0);
SimulateMaybeExtractCreativeAdPlacementIdsFromWebPageCallback(
@@ -155,11 +155,11 @@ TEST_F(BraveAdsCreativeSearchResultAdHandlerTest,
ASSERT_TRUE(creative_search_result_ad_handler);
// Act & Assert
EXPECT_CALL(
ads_service_mock_,
TriggerSearchResultAdEvent(
::testing::_, mojom::SearchResultAdEventType::kViewedImpression,
::testing::_))
EXPECT_CALL(ads_service_mock_,
TriggerSearchResultAdEvent(
/*mojom_creative_ad=*/::testing::_,
mojom::SearchResultAdEventType::kViewedImpression,
/*callback=*/::testing::_))
.Times(0);
SimulateMaybeExtractCreativeAdPlacementIdsFromWebPageCallback(
@@ -176,11 +176,11 @@ TEST_F(BraveAdsCreativeSearchResultAdHandlerTest,
ASSERT_TRUE(creative_search_result_ad_handler);
// Act & Assert
EXPECT_CALL(
ads_service_mock_,
TriggerSearchResultAdEvent(
::testing::_, mojom::SearchResultAdEventType::kViewedImpression,
::testing::_))
EXPECT_CALL(ads_service_mock_,
TriggerSearchResultAdEvent(
/*mojom_creative_ad=*/::testing::_,
mojom::SearchResultAdEventType::kViewedImpression,
/*callback=*/::testing::_))
.Times(0);
SimulateMaybeExtractCreativeAdPlacementIdsFromWebPageCallback(
@@ -199,11 +199,11 @@ TEST_F(BraveAdsCreativeSearchResultAdHandlerTest,
ASSERT_TRUE(creative_search_result_ad_handler);
// Act & Assert
EXPECT_CALL(
ads_service_mock_,
TriggerSearchResultAdEvent(
::testing::_, mojom::SearchResultAdEventType::kViewedImpression,
::testing::_))
EXPECT_CALL(ads_service_mock_,
TriggerSearchResultAdEvent(
/*mojom_creative_ad=*/::testing::_,
mojom::SearchResultAdEventType::kViewedImpression,
/*callback=*/::testing::_))
.WillOnce([](mojom::CreativeSearchResultAdInfoPtr mojom_creative_ad,
mojom::SearchResultAdEventType /*mojom_ad_event_type*/,
ResultCallback /*callback*/) {
@@ -230,11 +230,11 @@ TEST_F(BraveAdsCreativeSearchResultAdHandlerTest, TriggerAdViewedEvent) {
ASSERT_TRUE(mojom_web_page);
// Act & Assert
EXPECT_CALL(
ads_service_mock_,
TriggerSearchResultAdEvent(
::testing::_, mojom::SearchResultAdEventType::kViewedImpression,
::testing::_))
EXPECT_CALL(ads_service_mock_,
TriggerSearchResultAdEvent(
/*mojom_creative_ad=*/::testing::_,
mojom::SearchResultAdEventType::kViewedImpression,
/*callback=*/::testing::_))
.WillOnce([&mojom_web_page](
mojom::CreativeSearchResultAdInfoPtr mojom_creative_ad,
mojom::SearchResultAdEventType /*mojom_ad_event_type*/,
@@ -270,11 +270,11 @@ TEST_F(BraveAdsCreativeSearchResultAdHandlerTest,
ASSERT_TRUE(mojom_web_page);
// Act & Assert
EXPECT_CALL(
ads_service_mock_,
TriggerSearchResultAdEvent(
::testing::_, mojom::SearchResultAdEventType::kViewedImpression,
::testing::_))
EXPECT_CALL(ads_service_mock_,
TriggerSearchResultAdEvent(
/*mojom_creative_ad=*/::testing::_,
mojom::SearchResultAdEventType::kViewedImpression,
/*callback=*/::testing::_))
.WillOnce([&mojom_web_page](
mojom::CreativeSearchResultAdInfoPtr mojom_creative_ad,
mojom::SearchResultAdEventType /*mojom_ad_event_type*/,
@@ -34,7 +34,7 @@ void VerifyRequiredMojomCreativeAdExpectations(
GURL(test::kCreativeAdLandingPage), test::kCreativeAdHeadlineText,
test::kCreativeAdDescription,
::testing::DoubleEq(test::kCreativeAdRewardsValue),
/*creative_set_conversion*/ ::testing::_));
/*creative_set_conversion=*/::testing::_));
}
void VerifyRequiredMojomCreativeSetConversionExpectations(
@@ -208,11 +208,11 @@ TEST_F(BraveAdsAccountTest, DepositForCash) {
base::RunLoop on_did_process_deposit_run_loop;
EXPECT_CALL(account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, test::kValue,
mojom::AdType::kNotificationAd,
mojom::ConfirmationType::kViewedImpression,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(
on_did_process_deposit_run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);
@@ -244,11 +244,11 @@ TEST_F(BraveAdsAccountTest, DepositForCashWithUserData) {
base::RunLoop on_did_process_deposit_run_loop;
EXPECT_CALL(account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, test::kValue,
mojom::AdType::kNotificationAd,
mojom::ConfirmationType::kViewedImpression,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(
on_did_process_deposit_run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);
@@ -275,10 +275,10 @@ TEST_F(BraveAdsAccountTest, DepositForNonCash) {
EXPECT_CALL(
account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value*/ 0.0,
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value=*/0.0,
mojom::AdType::kNotificationAd, mojom::ConfirmationType::kClicked,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(
on_did_process_deposit_run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);
@@ -304,10 +304,10 @@ TEST_F(BraveAdsAccountTest, DepositForNonCashWithUserData) {
EXPECT_CALL(
account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value*/ 0.0,
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value=*/0.0,
mojom::AdType::kNotificationAd, mojom::ConfirmationType::kClicked,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(
on_did_process_deposit_run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);
@@ -357,11 +357,11 @@ TEST_F(BraveAdsAccountTest, AddTransactionWhenDepositingCashForRewardsUser) {
base::RunLoop on_did_process_deposit_run_loop;
EXPECT_CALL(account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, test::kValue,
mojom::AdType::kNotificationAd,
mojom::ConfirmationType::kViewedImpression,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(
on_did_process_deposit_run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);
@@ -402,10 +402,10 @@ TEST_F(BraveAdsAccountTest, AddTransactionWhenDepositingNonCashForRewardsUser) {
EXPECT_CALL(
account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value*/ 0.0,
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value=*/0.0,
mojom::AdType::kNotificationAd, mojom::ConfirmationType::kClicked,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(
on_did_process_deposit_run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);
@@ -445,11 +445,11 @@ TEST_F(BraveAdsAccountTest,
base::RunLoop on_did_process_deposit_run_loop;
EXPECT_CALL(account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value*/ 0.0,
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value=*/0.0,
mojom::AdType::kNewTabPageAd,
mojom::ConfirmationType::kViewedImpression,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(
on_did_process_deposit_run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);
@@ -316,8 +316,8 @@ TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest,
// Assert
EXPECT_THAT(*catalog, ::testing::FieldsAre(
test::kCatalogId, /*version*/ 9,
/*ping*/ base::Milliseconds(7'200'000),
test::kCatalogId, /*version=*/9,
/*ping=*/base::Milliseconds(7'200'000),
CatalogCampaignList{BuildCatalogCampaign1()}));
}
@@ -335,8 +335,8 @@ TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest,
// Assert
EXPECT_THAT(*catalog, ::testing::FieldsAre(
test::kCatalogId, /*version*/ 9,
/*ping*/ base::Milliseconds(7'200'000),
test::kCatalogId, /*version=*/9,
/*ping=*/base::Milliseconds(7'200'000),
CatalogCampaignList{BuildCatalogCampaign1(),
BuildCatalogCampaign2()}));
}
@@ -355,9 +355,9 @@ TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest,
// Assert
EXPECT_THAT(*catalog,
::testing::FieldsAre(test::kCatalogId, /*version*/ 9,
/*ping*/ base::Milliseconds(7'200'000),
/*campaigns*/ ::testing::IsEmpty()));
::testing::FieldsAre(test::kCatalogId, /*version=*/9,
/*ping=*/base::Milliseconds(7'200'000),
/*campaigns=*/::testing::IsEmpty()));
}
TEST_F(BraveAdsCatalogUrlRequestJsonReaderTest, DoNotReadMalformedCatalog) {
@@ -56,9 +56,9 @@ TEST_F(BraveAdsLegacyConfirmationMigrationConfirmationsJsonParserTest,
"546fe7b0-5047-4f28-a11c-81f14edcf0f6",
mojom::ConfirmationType::kViewedImpression,
mojom::AdType::kNotificationAd,
/*created_at*/ ::testing::_,
/*created_at=*/::testing::_,
/*reward*/ std::nullopt,
/*user_data*/ ::testing::_))));
/*user_data=*/::testing::_))));
}
TEST_F(BraveAdsLegacyConfirmationMigrationConfirmationsJsonParserTest,
@@ -83,11 +83,11 @@ TEST_F(BraveAdsLegacyConfirmationMigrationPaymentTokensJsonParserTest,
// Assert
EXPECT_THAT(payment_tokens,
::testing::Optional(::testing::ElementsAre(::testing::FieldsAre(
/*transaction_id*/ ::testing::Not(::testing::IsEmpty()),
/*unblinded_token*/ ::testing::_,
/*public_key*/ ::testing::_,
/*confirmation_type*/ ::testing::_,
/*ad_type*/ ::testing::_))));
/*transaction_id=*/::testing::Not(::testing::IsEmpty()),
/*unblinded_token=*/::testing::_,
/*public_key=*/::testing::_,
/*confirmation_type=*/::testing::_,
/*ad_type=*/::testing::_))));
}
TEST_F(BraveAdsLegacyConfirmationMigrationPaymentTokensJsonParserTest,
@@ -15,8 +15,9 @@ class BraveAdsUserIdleDetectionTest : public test::TestBase {};
TEST_F(BraveAdsUserIdleDetectionTest, RewardsUserDidBecomeActive) {
// Act & Assert
EXPECT_CALL(ads_client_mock_, Log).Times(::testing::AnyNumber());
EXPECT_CALL(ads_client_mock_, Log(::testing::_, ::testing::_, ::testing::_,
"User is active after 10 s"));
EXPECT_CALL(ads_client_mock_,
Log(/*file=*/::testing::_, /*line=*/::testing::_,
/*verbose_level=*/::testing::_, "User is active after 10 s"));
ads_client_notifier_.NotifyUserDidBecomeActive(
/*idle_time=*/base::Seconds(10),
/*screen_was_locked=*/false);
@@ -37,10 +38,12 @@ TEST_F(BraveAdsUserIdleDetectionTest,
RewardsUserDidBecomeActiveWhileScreenWasLocked) {
// Act & Assert
EXPECT_CALL(ads_client_mock_, Log).Times(::testing::AnyNumber());
EXPECT_CALL(ads_client_mock_, Log(::testing::_, ::testing::_, ::testing::_,
"User is active after 10 s"));
EXPECT_CALL(ads_client_mock_,
Log(::testing::_, ::testing::_, ::testing::_,
Log(/*file=*/::testing::_, /*line=*/::testing::_,
/*verbose_level=*/::testing::_, "User is active after 10 s"));
EXPECT_CALL(ads_client_mock_,
Log(/*file=*/::testing::_, /*line=*/::testing::_,
/*verbose_level=*/::testing::_,
"Screen was locked before the user become active"));
ads_client_notifier_.NotifyUserDidBecomeActive(
/*idle_time=*/base::Seconds(10),
@@ -59,10 +59,10 @@ TEST_F(BraveAdsReactionsTest, ToggleLikeAd) {
EXPECT_CALL(
account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value*/ 0.0,
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value=*/0.0,
mojom::AdType::kNotificationAd, mojom::ConfirmationType::kLikedAd,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);
@@ -86,10 +86,10 @@ TEST_F(BraveAdsReactionsTest, ToggleDislikeAd) {
EXPECT_CALL(
account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value*/ 0.0,
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value=*/0.0,
mojom::AdType::kNotificationAd, mojom::ConfirmationType::kDislikedAd,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);
@@ -248,10 +248,10 @@ TEST_F(BraveAdsReactionsTest, ToggleSaveAd) {
EXPECT_CALL(
account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value*/ 0.0,
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value=*/0.0,
mojom::AdType::kNotificationAd, mojom::ConfirmationType::kSavedAd,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);
@@ -278,11 +278,11 @@ TEST_F(BraveAdsReactionsTest, ToggleMarkAdAsInappropriate) {
base::RunLoop run_loop;
EXPECT_CALL(account_observer_mock_,
OnDidProcessDeposit(/*transaction=*/::testing::FieldsAre(
/*id*/ ::testing::_, /*created_at*/ test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value*/ 0.0,
/*id=*/::testing::_, /*created_at=*/test::Now(),
test::kCreativeInstanceId, test::kSegment, /*value=*/0.0,
mojom::AdType::kNotificationAd,
mojom::ConfirmationType::kMarkAdAsInappropriate,
/*reconciled_at*/ std::nullopt)))
/*reconciled_at=*/std::nullopt)))
.WillOnce(base::test::RunOnceClosure(run_loop.QuitClosure()));
EXPECT_CALL(account_observer_mock_, OnFailedToProcessDeposit).Times(0);