Search in sources :

Example 61 with MessageReference

use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.

the class WearNotificationsTest method testBuildStackedNotificationWithArchiveActionEnabled.

@Test
public void testBuildStackedNotificationWithArchiveActionEnabled() throws Exception {
    enableArchiveAction();
    int notificationIndex = 0;
    int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
    MessageReference messageReference = createMessageReference(1);
    NotificationContent content = createNotificationContent(messageReference);
    NotificationHolder holder = createNotificationHolder(notificationId, content);
    PendingIntent archivePendingIntent = createFakePendingIntent(1);
    when(actionCreator.createArchiveMessagePendingIntent(messageReference, notificationId)).thenReturn(archivePendingIntent);
    Notification result = wearNotifications.buildStackedNotification(account, holder);
    assertEquals(notification, result);
    verifyExtendWasOnlyCalledOnce();
    verifyAddAction(R.drawable.ic_action_archive_dark, "Archive", archivePendingIntent);
}
Also used : PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference) Notification(android.app.Notification) Test(org.junit.Test)

Example 62 with MessageReference

use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.

the class WearNotificationsTest method testBuildStackedNotificationWithMarkAsSpamActionEnabled.

@Test
public void testBuildStackedNotificationWithMarkAsSpamActionEnabled() throws Exception {
    enableSpamAction();
    int notificationIndex = 0;
    int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
    MessageReference messageReference = createMessageReference(1);
    NotificationContent content = createNotificationContent(messageReference);
    NotificationHolder holder = createNotificationHolder(notificationId, content);
    PendingIntent markAsSpamPendingIntent = createFakePendingIntent(1);
    when(actionCreator.createMarkMessageAsSpamPendingIntent(messageReference, notificationId)).thenReturn(markAsSpamPendingIntent);
    Notification result = wearNotifications.buildStackedNotification(account, holder);
    assertEquals(notification, result);
    verifyExtendWasOnlyCalledOnce();
    verifyAddAction(R.drawable.ic_action_spam_dark, "Spam", markAsSpamPendingIntent);
}
Also used : PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference) Notification(android.app.Notification) Test(org.junit.Test)

Example 63 with MessageReference

use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.

the class WearNotificationsTest method testBuildStackedNotificationWithDeleteActionEnabled.

@Test
public void testBuildStackedNotificationWithDeleteActionEnabled() throws Exception {
    enableDeleteAction();
    int notificationIndex = 0;
    int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
    MessageReference messageReference = createMessageReference(1);
    NotificationContent content = createNotificationContent(messageReference);
    NotificationHolder holder = createNotificationHolder(notificationId, content);
    PendingIntent deletePendingIntent = createFakePendingIntent(1);
    when(actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId)).thenReturn(deletePendingIntent);
    Notification result = wearNotifications.buildStackedNotification(account, holder);
    assertEquals(notification, result);
    verifyExtendWasOnlyCalledOnce();
    verifyAddAction(R.drawable.ic_action_delete_dark, "Delete", deletePendingIntent);
}
Also used : PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference) Notification(android.app.Notification) Test(org.junit.Test)

Example 64 with MessageReference

use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.

the class WearNotificationsTest method testBuildStackedNotification.

@Test
public void testBuildStackedNotification() throws Exception {
    disableOptionalActions();
    int notificationIndex = 0;
    int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
    MessageReference messageReference = createMessageReference(1);
    NotificationContent content = createNotificationContent(messageReference);
    NotificationHolder holder = createNotificationHolder(notificationId, content);
    PendingIntent replyPendingIntent = createFakePendingIntent(1);
    when(actionCreator.createReplyPendingIntent(messageReference, notificationId)).thenReturn(replyPendingIntent);
    PendingIntent markAsReadPendingIntent = createFakePendingIntent(2);
    when(actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId)).thenReturn(markAsReadPendingIntent);
    Notification result = wearNotifications.buildStackedNotification(account, holder);
    assertEquals(notification, result);
    verifyExtendWasOnlyCalledOnce();
    verifyAddAction(R.drawable.ic_action_single_message_options_dark, "Reply", replyPendingIntent);
    verifyAddAction(R.drawable.ic_action_mark_as_read_dark, "Mark Read", markAsReadPendingIntent);
    verifyNumberOfActions(2);
}
Also used : PendingIntent(android.app.PendingIntent) MessageReference(com.fsck.k9.activity.MessageReference) Notification(android.app.Notification) Test(org.junit.Test)

Example 65 with MessageReference

use of com.fsck.k9.activity.MessageReference in project k-9 by k9mail.

the class NewMailNotificationsTest method testRemoveNewMailNotificationWithUnknownMessageReference.

@Test
public void testRemoveNewMailNotificationWithUnknownMessageReference() throws Exception {
    enablePrivacyMode();
    MessageReference messageReference = createMessageReference(1);
    int notificationIndex = 0;
    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.unknownNotification());
    newMailNotifications.removeNewMailNotification(account, messageReference);
    verify(notificationManager, never()).cancel(anyInt());
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) MessageReference(com.fsck.k9.activity.MessageReference) Notification(android.app.Notification) Test(org.junit.Test)

Aggregations

MessageReference (com.fsck.k9.activity.MessageReference)49 PendingIntent (android.app.PendingIntent)25 Account (com.fsck.k9.Account)22 Test (org.junit.Test)14 LocalMessage (com.fsck.k9.mailstore.LocalMessage)13 MessageReference (com.fsck.k9.controller.MessageReference)12 NotificationCompat (android.support.v4.app.NotificationCompat)9 ArrayList (java.util.ArrayList)9 Notification (android.app.Notification)8 List (java.util.List)7 MessagingException (com.fsck.k9.mail.MessagingException)6 LocalFolder (com.fsck.k9.mailstore.LocalFolder)5 SearchAccount (com.fsck.k9.search.SearchAccount)5 HashMap (java.util.HashMap)5 Cursor (android.database.Cursor)3 Message (com.fsck.k9.mail.Message)3 LinkedList (java.util.LinkedList)3 Map (java.util.Map)3 Intent (android.content.Intent)2 Uri (android.net.Uri)2