Skip to content

Commit

Permalink
[ads] Only load purchase intent resource if the user has joined Brave…
Browse files Browse the repository at this point in the history
… Rewards and opted-in to notification ads
  • Loading branch information
tmancey committed May 28, 2024
1 parent edc58ea commit d53b1a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace brave_ads {
namespace {

bool DoesRequireResource() {
return UserHasOptedInToBraveNewsAds() || UserHasOptedInToNotificationAds();
return UserHasOptedInToNotificationAds();
}

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ TEST_F(BraveAdsPurchaseIntentResourceTest, LoadResourceWhenLocaleDidChange) {
EXPECT_TRUE(resource_->IsInitialized());
}

TEST_F(
BraveAdsPurchaseIntentResourceTest,
DoNotLoadResourceWhenLocaleDidChangeIfOptedOutOfNotificationAdsAndBraveNewsAds) {
TEST_F(BraveAdsPurchaseIntentResourceTest,
DoNotLoadResourceWhenLocaleDidChangeIfOptedOutOfNotificationAds) {
// Arrange
test::OptOutOfNotificationAds();
test::OptOutOfBraveNewsAds();

ASSERT_FALSE(LoadResource(kCountryComponentId));

Expand Down Expand Up @@ -126,12 +124,11 @@ TEST_F(BraveAdsPurchaseIntentResourceTest,

TEST_F(
BraveAdsPurchaseIntentResourceTest,
DoNotLoadResourceWhenOptedInToNotificationAdsPrefDidChangeIfOptedOutOfNotificationAdsAndBraveNewsAds) {
DoNotLoadResourceWhenOptedInToNotificationAdsPrefDidChangeIfOptedOutOfNotificationAds) {
// Arrange
ASSERT_TRUE(LoadResource(kCountryComponentId));

test::OptOutOfNotificationAds();
test::OptOutOfBraveNewsAds();

// Act
NotifyPrefDidChange(prefs::kOptedInToNotificationAds);
Expand Down Expand Up @@ -167,10 +164,9 @@ TEST_F(

TEST_F(
BraveAdsPurchaseIntentResourceTest,
DoNotLoadResourceWhenDidUpdateResourceComponentIfOptedOutOfNotificationAdsAndBraveNewsAds) {
DoNotLoadResourceWhenDidUpdateResourceComponentIfOptedOutOfNotificationAds) {
// Arrange
test::OptOutOfNotificationAds();
test::OptOutOfBraveNewsAds();

// Act & Assert
EXPECT_FALSE(LoadResource(kCountryComponentId));
Expand Down

0 comments on commit d53b1a9

Please sign in to comment.