void Ut_NotificationManager::testSaveAndLoadNotificationState() { NotificationManager* nm = NotificationManager::instance(); CommHistory::Event event1 = createImEvent(CONTACT_1_REMOTE_ID, internalId(contact1)); CommHistory::Event event2 = createImEvent(CONTACT_1_REMOTE_ID, internalId(contact1)); CommHistory::Event event3 = createImEvent(CONTACT_2_REMOTE_ID, internalId(contact2)); CommHistory::Event event4 = createImEvent(CONTACT_2_REMOTE_ID, internalId(contact2)); nm->addNotification(createPersonalNotification(event1)); nm->addNotification(createPersonalNotification(event2)); nm->addNotification(createPersonalNotification(event3)); nm->addNotification(createPersonalNotification(event4)); nm->saveState(); nm->m_Notifications.clear(); nm->loadState(); NotificationGroup group = nm->notificationGroup(event1.type()); QVERIFY(nm->countContacts(group) == 2); QVERIFY(nm->countNotifications(group) == 4); QVERIFY(nm->removeNotificationGroup(event1.type())); QVERIFY(nm->countContacts(group) == 0); QVERIFY(nm->countNotifications(group) == 0); nm->saveState(); nm->m_Notifications.clear(); nm->loadState(); QVERIFY(nm->m_Notifications.count() == 0); }
void Ut_NotificationManager::testAddMissedCallNotification() { CommHistory::Event event = createMissedCallEvent(CONTACT_1_REMOTE_ID, internalId(contact1)); // One notification from contact 1 NotificationManager* nm = NotificationManager::instance(); nm->addNotification(createPersonalNotification(event)); NotificationGroup group = nm->notificationGroup(event.type()); QVERIFY(nm->countNotifications(group) == 1); QVERIFY(nm->countContacts(group) == 1); QVERIFY(nm->removeNotificationGroup(event.type())); QVERIFY(nm->countNotifications(group) == 0); QVERIFY(nm->countContacts(group) == 0); // Multiple notifications from contact 1 CommHistory::Event event1 = createMissedCallEvent(CONTACT_1_REMOTE_ID, internalId(contact1)); CommHistory::Event event2 = createMissedCallEvent(CONTACT_1_REMOTE_ID, internalId(contact1)); nm->addNotification(createPersonalNotification(event1)); nm->addNotification(createPersonalNotification(event2)); QVERIFY(nm->countNotifications(group) == 2); QVERIFY(nm->countContacts(group) == 1); QVERIFY(nm->removeNotificationGroup(event1.type())); QVERIFY(nm->countNotifications(group) == 0); QVERIFY(nm->countContacts(group) == 0); }
void Ut_NotificationManager::testRemoveNotificationGrouop() { NotificationManager* nm = NotificationManager::instance(); // One IM notification from contact 1 CommHistory::Event event = createImEvent(CONTACT_1_REMOTE_ID, internalId(contact1)); nm->addNotification(createPersonalNotification(event)); // 1st time to remove NotificationGroup, return true QVERIFY(nm->removeNotificationGroup(event.type())); // 2nd time to remove the same NotificationGroup, return false QVERIFY(!nm->removeNotificationGroup(event.type())); //Mutile IM notifications from contact 1 CommHistory::Event event1 = createMissedCallEvent(CONTACT_1_REMOTE_ID, internalId(contact1)); CommHistory::Event event2 = createMissedCallEvent(CONTACT_1_REMOTE_ID, internalId(contact1)); nm->addNotification(createPersonalNotification(event1)); nm->addNotification(createPersonalNotification(event2)); // 1st time to remove NotificationGroup, return true QVERIFY(nm->removeNotificationGroup(event1.type())); // 2nd time to remove the same NotificationGroup, return false QVERIFY(!nm->removeNotificationGroup(event1.type())); }
void Ut_NotificationManager::testAddGroupImNotification() { NotificationManager* nm = NotificationManager::instance(); CommHistory::Event event1 = createImEvent(CONTACT_1_REMOTE_ID, internalId(contact1)); CommHistory::Event event2 = createImEvent(CONTACT_2_REMOTE_ID, internalId(contact2)); nm->addNotification(createPersonalNotification(event1)); nm->addNotification(createPersonalNotification(event2)); NotificationGroup group = nm->notificationGroup(event1.type()); QVERIFY(nm->countContacts(group) == 2); QVERIFY(nm->countNotifications(group) == 2); QVERIFY(nm->removeNotificationGroup(event1.type())); QVERIFY(nm->countContacts(group) == 0); QVERIFY(nm->countNotifications(group) == 0); }