Search in sources :

Example 76 with Account

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

the class SyncNotificationsTest method testGetFetchingMailNotificationId.

@Test
public void testGetFetchingMailNotificationId() throws Exception {
    Folder folder = createFakeFolder();
    int notificationId = NotificationIds.getFetchingMailNotificationId(account);
    syncNotifications.showFetchingMailNotification(account, folder);
    verify(notificationManager).notify(eq(notificationId), any(Notification.class));
    verify(builder).setSmallIcon(R.drawable.ic_notify_check_mail);
    verify(builder).setTicker("Checking mail: " + ACCOUNT_NAME + ":" + FOLDER_NAME);
    verify(builder).setContentTitle("Checking mail");
    verify(builder).setContentText(ACCOUNT_NAME + ":" + FOLDER_NAME);
    verify(builder).setContentIntent(contentIntent);
    verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
}
Also used : Folder(com.fsck.k9.mail.Folder) Notification(android.app.Notification) Test(org.junit.Test)

Example 77 with Account

use of com.fsck.k9.Account 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 78 with Account

use of com.fsck.k9.Account 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 79 with Account

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

the class NewMailNotificationsTest method testAddNewMailNotificationWithCancelingExistingNotification.

@Test
public void testAddNewMailNotificationWithCancelingExistingNotification() throws Exception {
    int notificationIndex = 0;
    LocalMessage message = createLocalMessage();
    NotificationContent content = createNotificationContent();
    NotificationHolder holder = createNotificationHolder(content, notificationIndex);
    addToNotificationContentCreator(message, content);
    whenAddingContentReturn(content, AddNotificationResult.replaceNotification(holder));
    Notification wearNotification = createNotification();
    Notification summaryNotification = createNotification();
    addToWearNotifications(holder, wearNotification);
    addToDeviceNotifications(summaryNotification);
    newMailNotifications.addNewMailNotification(account, message, 42);
    int wearNotificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex);
    int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account);
    verify(notificationManager).notify(wearNotificationId, wearNotification);
    verify(notificationManager).cancel(wearNotificationId);
    verify(notificationManager).notify(summaryNotificationId, summaryNotification);
}
Also used : LocalMessage(com.fsck.k9.mailstore.LocalMessage) Notification(android.app.Notification) Test(org.junit.Test)

Example 80 with Account

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

the class NewMailNotificationsTest method createAccount.

private Account createAccount() {
    Account account = mock(Account.class);
    when(account.getAccountNumber()).thenReturn(ACCOUNT_NUMBER);
    return account;
}
Also used : Account(com.fsck.k9.Account)

Aggregations

Account (com.fsck.k9.Account)122 Test (org.junit.Test)81 MessagingException (com.fsck.k9.mail.MessagingException)53 LocalFolder (com.fsck.k9.mailstore.LocalFolder)44 LocalMessage (com.fsck.k9.mailstore.LocalMessage)43 LocalStore (com.fsck.k9.mailstore.LocalStore)42 ArrayList (java.util.ArrayList)34 MessageReference (com.fsck.k9.activity.MessageReference)32 Message (com.fsck.k9.mail.Message)29 Folder (com.fsck.k9.mail.Folder)27 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)25 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)22 IOException (java.io.IOException)22 Cursor (android.database.Cursor)21 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)20 Store (com.fsck.k9.mail.Store)20 SearchAccount (com.fsck.k9.search.SearchAccount)20 PendingIntent (android.app.PendingIntent)19 Pop3Store (com.fsck.k9.mail.store.pop3.Pop3Store)19 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)18