Commit 55cf3a4e authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Fix unread badge logic in BadgeMediator

Made a mistake in the final patchset of crrev.com/c/1832157. Modified
a unittest to cover this mistake.

Bug: 976901
Change-Id: I21b06444ca31ba174d217051266c8edaba97aca9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835097
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Auto-Submit: Chris Lu <thegreenfrog@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702211}
parent 4c0208fd
......@@ -186,7 +186,7 @@ const int kMinimumNonFullScreenBadgesForOverflow = 2;
// non-fullscreen badges.
- (void)updateConsumerReadStatus {
for (id<BadgeItem> item in self.badges) {
if (!item.fullScreen && item.badgeState & BadgeStateRead) {
if (!item.fullScreen && !(item.badgeState & BadgeStateRead)) {
[self.consumer markDisplayedBadgeAsRead:NO];
return;
}
......
......@@ -123,6 +123,13 @@ class BadgeMediatorTest : public PlatformTest {
InfobarType::kInfobarTypePasswordUpdate);
}
// Inform InfobarBadgeTabHelper that the infobar added in AddSecondInfobar()
// is accepted.
void MarkSecondInfobarAccepted() {
GetFakeInfobarBadgeTabHelper()->UpdateBadgeForInfobarAccepted(
InfobarType::kInfobarTypePasswordUpdate);
}
// Removes the Infobar created in AddSecondInfobar() to the
// FakeInfoBarBadgeTabHelper.
void RemoveInfobar() {
......@@ -172,10 +179,17 @@ TEST_F(BadgeMediatorTest, BadgeMediatorTestRemoveInfobar) {
TEST_F(BadgeMediatorTest, BadgeMediatorTestMarkAsRead) {
AddAndActivateWebState(/*index=*/0, /*incognito=*/false);
AddInfobar();
// Since there is only one badge, it should be marked as read.
EXPECT_FALSE(badge_consumer_.hasUnreadBadge);
AddSecondInfobar();
ASSERT_EQ(BadgeType::kBadgeTypeOverflow,
badge_consumer_.displayedBadge.badgeType);
// Second badge should be unread since the overflow badge is being shown as
// the displayed badge.
EXPECT_TRUE(badge_consumer_.hasUnreadBadge);
MarkSecondInfobarAccepted();
// Second badge should be read since its infobar is accepted.
EXPECT_FALSE(badge_consumer_.hasUnreadBadge);
}
// Test that the BadgeMediator updates the current badges to none when switching
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment