Skip to content

Commit

Permalink
Uplift of #19896 (squashed) to beta
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-builds committed Aug 29, 2023
1 parent 5b01ea1 commit b5b5c73
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ void ViewCounterModel::RegisterPageViewForBackgroundImages() {
return;

// Don't count when SI will be visible.
if (show_branded_wallpaper_ && count_to_branded_wallpaper_ == 0)
if (show_branded_wallpaper_ && total_campaign_count_ != 0 &&
count_to_branded_wallpaper_ == 0) {
return;
}

// Increase background image index
current_wallpaper_image_index_++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ class ViewCounterModel {
FRIEND_TEST_ALL_PREFIXES(ViewCounterModelTest,
NTPSponsoredImagesCountToBrandedWallpaperTest);
FRIEND_TEST_ALL_PREFIXES(ViewCounterModelTest, NTPBackgroundImagesTest);
FRIEND_TEST_ALL_PREFIXES(ViewCounterModelTest, NTPBackgroundImagesOnlyTest);
FRIEND_TEST_ALL_PREFIXES(ViewCounterModelTest,
NTPBackgroundImagesWithSIDisabledTest);
FRIEND_TEST_ALL_PREFIXES(ViewCounterModelTest,
NTPBackgroundImagesWithEmptyCampaignTest);
FRIEND_TEST_ALL_PREFIXES(ViewCounterModelTest,
NTPFailedToLoadSponsoredImagesTest);
FRIEND_TEST_ALL_PREFIXES(NTPBackgroundImagesViewCounterTest, ModelTest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ TEST_F(ViewCounterModelTest, NTPBackgroundImagesTest) {
}
}

// Test for background images only case (SI not active)
TEST_F(ViewCounterModelTest, NTPBackgroundImagesOnlyTest) {
// Test for background images only case (SI option is disabled)
TEST_F(ViewCounterModelTest, NTPBackgroundImagesWithSIDisabledTest) {
ViewCounterModel model(prefs());

model.set_total_image_count(kTestImageCount);
Expand Down Expand Up @@ -177,6 +177,25 @@ TEST_F(ViewCounterModelTest, NTPBackgroundImagesOnlyTest) {
}
}

// Test for background images only case (SI option is enabled but no campaign)
TEST_F(ViewCounterModelTest, NTPBackgroundImagesWithEmptyCampaignTest) {
ViewCounterModel model(prefs());

// Check background wallpaper index is properly updated when SI option is
// enabled but there is no campaign.
model.Reset();
model.set_total_image_count(kTestImageCount);
model.set_show_branded_wallpaper(true);
model.count_to_branded_wallpaper_ = 0;

constexpr int kTestPageViewCount = 30;
for (int i = 0; i < kTestPageViewCount; ++i) {
EXPECT_EQ(i % model.total_image_count_,
model.current_wallpaper_image_index());
model.RegisterPageView();
}
}

TEST_F(ViewCounterModelTest, NTPSuperReferralTest) {
ViewCounterModel model(prefs());

Expand Down

0 comments on commit b5b5c73

Please sign in to comment.