Skip to content

Commit

Permalink
Fixes: NB#297410 - Notification group timestamp prefix is incorrect a…
Browse files Browse the repository at this point in the history
…fter removing a notification from the group and adding a new one

RevBy: Vesa Halttunen
  • Loading branch information
Eetu Lehmusvuo committed Jan 26, 2012
1 parent 52faa66 commit 1b2d526
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
system-ui (1.3.1~1) unstable; urgency=low

* [UNRELEASED]
* Fixes: NB#297410 - Notification group timestamp prefix is incorrect after removing a notification from the group and adding a new one

-- Vesa Halttunen <[email protected]> Wed, 25 Jan 2012 15:59:22 +0200

Expand Down
8 changes: 5 additions & 3 deletions src/systemui/notifications/notificationareasink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ void NotificationAreaSink::updateNotification(MBanner *infoBanner, const Notific
infoBanner->setProperty(USER_REMOVABLE_PROPERTY, determineUserRemovability(parameters));
infoBanner->setBannerTimeStamp(QDateTime::fromTime_t(parameters.value("timestamp").toUInt()));

updatePrefixForNotificationGroupBannerTimestamp(infoBanner, parameters.value("count").toUInt());

// Update the info banner's image, titles and actions
updateImage(infoBanner, parameters);
updateTitles(infoBanner);
Expand Down Expand Up @@ -245,13 +243,17 @@ void NotificationAreaSink::removeNotification(uint notificationId)
if(decreaseNotificationCountOfGroup(groupid) == 0) {
removeGroupBanner(groupid);
}
notificationIdToGroupId.remove(notificationId);
}
}

uint NotificationAreaSink::decreaseNotificationCountOfGroup(uint groupId)
{
uint notificationIdsCount = notificationCountOfGroup.value(groupId);
notificationCountOfGroup.insert(groupId, --notificationIdsCount);
if (notificationIdsCount > 0) {
notificationIdsCount--;
}
notificationCountOfGroup.insert(groupId, notificationIdsCount);
updatePrefixForNotificationGroupBannerTimestamp(groupIdToMBanner.value(groupId),
notificationCountOfGroup.value(groupId));
return notificationIdsCount;
Expand Down
4 changes: 4 additions & 0 deletions src/systemui/notifications/notificationareasink.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ private slots:
uint decreaseNotificationCountOfGroup(uint groupId);
//! Updates the latest prefix for notification group timestamp.
void updatePrefixForNotificationGroupBannerTimestamp(MBanner *infoBanner, uint count);

#ifdef UNIT_TEST
friend class Ut_NotificationAreaSink;
#endif
};

#endif /* NOTIFICATIONAREASINK_H_ */
14 changes: 14 additions & 0 deletions tests/ut_notificationareasink/ut_notificationareasink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ void Ut_NotificationAreaSink::testRemovingNotificationsWhenNoNotificationLeftGro
// Last notification in group removed, so banner will be removed
emit(removeNotification(1));
QCOMPARE(remSpy.count(), 1);
QCOMPARE(sink->notificationIdToGroupId.isEmpty(), true);
}

void Ut_NotificationAreaSink::testAddNotificationToGroup()
Expand Down Expand Up @@ -512,4 +513,17 @@ void Ut_NotificationAreaSink::testSetPrefixForNotificationGroupBannerWhenThereIs
QCOMPARE(prefixTimeStamps.value(notifications.at(0)).isEmpty(), true);
}

void Ut_NotificationAreaSink::testNotUpdatingGroupBannerTimestampPrefixWhenBannerUpdated()
{
emit addGroup(1, TestNotificationParameters());
emit addNotification(Notification(0, 1, 2, TestNotificationParameters(), Notification::ApplicationEvent, 1000));

QCOMPARE(prefixTimeStamps.count(), 1);

TestNotificationParameters groupParameters;
groupParameters.add(NotificationParameter("count", 2));
sink->updateNotification(notifications.at(0), groupParameters);
QCOMPARE(prefixTimeStamps.count(), 1);
}

QTEST_APPLESS_MAIN(Ut_NotificationAreaSink)
1 change: 1 addition & 0 deletions tests/ut_notificationareasink/ut_notificationareasink.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private slots:
void testApplyPrivacySetting();
void testNotificationsFetchedFromNotificationManager();
void testSetPrefixForNotificationGroupBannerWhenThereIsMoreThanOneNotificationInAGroup();
void testNotUpdatingGroupBannerTimestampPrefixWhenBannerUpdated();

signals:
void addGroup(uint groupId, const NotificationParameters &parameters);
Expand Down

0 comments on commit 1b2d526

Please sign in to comment.