use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class NewMailNotificationsTest method testRemoveNewMailNotificationWithoutNotificationData.
@Test
public void testRemoveNewMailNotificationWithoutNotificationData() throws Exception {
MessageReference messageReference = createMessageReference(1);
newMailNotifications.removeNewMailNotification(account, messageReference);
verify(notificationManager, never()).cancel(anyInt());
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class NewMailNotificationsTest method testRemoveNewMailNotification.
@Test
public void testRemoveNewMailNotification() throws Exception {
enablePrivacyMode();
MessageReference messageReference = createMessageReference(1);
int notificationIndex = 0;
int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
LocalMessage message = createLocalMessage();
NotificationContent content = createNotificationContent();
NotificationHolder holder = createNotificationHolder(content, notificationIndex);
addToNotificationContentCreator(message, content);
whenAddingContentReturn(content, AddNotificationResult.newNotification(holder));
Notification summaryNotification = createNotification();
addToDeviceNotifications(summaryNotification);
newMailNotifications.addNewMailNotification(account, message, 23);
whenRemovingContentReturn(messageReference, RemoveNotificationResult.cancelNotification(notificationId));
newMailNotifications.removeNewMailNotification(account, messageReference);
int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
verify(notificationManager).cancel(notificationId);
verify(notificationManager, times(2)).notify(summaryNotificationId, summaryNotification);
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class NotificationContentCreatorTest method createFakeLocalMessage.
private LocalMessage createFakeLocalMessage(MessageReference messageReference) throws Exception {
LocalMessage message = mock(LocalMessage.class);
when(message.makeMessageReference()).thenReturn(messageReference);
when(message.getPreviewType()).thenReturn(PreviewType.TEXT);
when(message.getPreview()).thenReturn(PREVIEW);
when(message.getSubject()).thenReturn(SUBJECT);
when(message.getFrom()).thenReturn(new Address[] { new Address(SENDER_ADDRESS, SENDER_NAME) });
when(message.getRecipients(RecipientType.TO)).thenReturn(new Address[] { new Address(RECIPIENT_ADDRESS, RECIPIENT_NAME) });
return message;
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class NotificationDataTest method testGetAllMessageReferences.
@Test
public void testGetAllMessageReferences() throws Exception {
MessageReference messageReference0 = createMessageReference("1");
MessageReference messageReference1 = createMessageReference("2");
MessageReference messageReference2 = createMessageReference("3");
MessageReference messageReference3 = createMessageReference("4");
MessageReference messageReference4 = createMessageReference("5");
MessageReference messageReference5 = createMessageReference("6");
MessageReference messageReference6 = createMessageReference("7");
MessageReference messageReference7 = createMessageReference("8");
MessageReference messageReference8 = createMessageReference("9");
notificationData.addNotificationContent(createNotificationContent(messageReference8));
notificationData.addNotificationContent(createNotificationContent(messageReference7));
notificationData.addNotificationContent(createNotificationContent(messageReference6));
notificationData.addNotificationContent(createNotificationContent(messageReference5));
notificationData.addNotificationContent(createNotificationContent(messageReference4));
notificationData.addNotificationContent(createNotificationContent(messageReference3));
notificationData.addNotificationContent(createNotificationContent(messageReference2));
notificationData.addNotificationContent(createNotificationContent(messageReference1));
notificationData.addNotificationContent(createNotificationContent(messageReference0));
List<MessageReference> messageReferences = notificationData.getAllMessageReferences();
assertEquals(9, messageReferences.size());
assertEquals(messageReference0, messageReferences.get(0));
assertEquals(messageReference1, messageReferences.get(1));
assertEquals(messageReference2, messageReferences.get(2));
assertEquals(messageReference3, messageReferences.get(3));
assertEquals(messageReference4, messageReferences.get(4));
assertEquals(messageReference5, messageReferences.get(5));
assertEquals(messageReference6, messageReferences.get(6));
assertEquals(messageReference7, messageReferences.get(7));
assertEquals(messageReference8, messageReferences.get(8));
}
use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.
the class WearNotificationsTest method testAddSummaryActions.
@Test
public void testAddSummaryActions() throws Exception {
disableOptionalSummaryActions();
int notificationId = NotificationIds.getNewMailSummaryNotificationId(account);
ArrayList<MessageReference> messageReferences = createMessageReferenceList();
NotificationData notificationData = createNotificationData(messageReferences);
PendingIntent markAllAsReadPendingIntent = createFakePendingIntent(1);
when(actionCreator.getMarkAllAsReadPendingIntent(account, messageReferences, notificationId)).thenReturn(markAllAsReadPendingIntent);
wearNotifications.addSummaryActions(builder, notificationData);
verifyExtendWasOnlyCalledOnce();
verifyAddAction(R.drawable.ic_action_mark_as_read_dark, "Mark All Read", markAllAsReadPendingIntent);
verifyNumberOfActions(1);
}
Aggregations