Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed NTP shows same background images #19896

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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