Search in sources :

Example 16 with MessageReference

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());
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference) Test(org.junit.Test)

Example 17 with MessageReference

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);
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) MessageReference(com.fsck.k9.activity.MessageReference) Notification(android.app.Notification) Test(org.junit.Test)

Example 18 with MessageReference

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;
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) Address(com.fsck.k9.mail.Address)

Example 19 with MessageReference

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));
}
Also used : MessageReference(com.fsck.k9.activity.MessageReference) Test(org.junit.Test)

Example 20 with MessageReference

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);
}
Also used : PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference) Test(org.junit.Test)

Aggregations

MessageReference (com.fsck.k9.activity.MessageReference)54 PendingIntent (android.app.PendingIntent)25 Account (com.fsck.k9.Account)18 Test (org.junit.Test)14 NotificationCompat (android.support.v4.app.NotificationCompat)9 ArrayList (java.util.ArrayList)9 Notification (android.app.Notification)8 LocalMessage (com.fsck.k9.mailstore.LocalMessage)8 List (java.util.List)7 HashMap (java.util.HashMap)5 SearchAccount (com.fsck.k9.search.SearchAccount)4 Cursor (android.database.Cursor)3 Preferences (com.fsck.k9.Preferences)3 MessagingException (com.fsck.k9.mail.MessagingException)3 LocalFolder (com.fsck.k9.mailstore.LocalFolder)3 LinkedList (java.util.LinkedList)3 Map (java.util.Map)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 Message (com.fsck.k9.mail.Message)2