Search in sources :

Example 6 with AttachmentInfoExtractor

use of com.fsck.k9.message.extractors.AttachmentInfoExtractor in project k-9 by k9mail.

the class AttachmentResolverTest method buildCidMap__onMultipartWithEmptyBodyPart__shouldReturnEmptyMap.

@Test
public void buildCidMap__onMultipartWithEmptyBodyPart__shouldReturnEmptyMap() throws Exception {
    Multipart multipartBody = MimeMultipart.newInstance();
    BodyPart bodyPart = spy(new MimeBodyPart());
    Part multipartPart = new MimeBodyPart(multipartBody);
    multipartBody.addBodyPart(bodyPart);
    Map<String, Uri> result = AttachmentResolver.buildCidToAttachmentUriMap(attachmentInfoExtractor, multipartPart);
    verify(bodyPart).getContentId();
    assertTrue(result.isEmpty());
}
Also used : BodyPart(com.fsck.k9.mail.BodyPart) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MimeMultipart(com.fsck.k9.mail.internet.MimeMultipart) Multipart(com.fsck.k9.mail.Multipart) BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Uri(android.net.Uri) Test(org.junit.Test)

Example 7 with AttachmentInfoExtractor

use of com.fsck.k9.message.extractors.AttachmentInfoExtractor in project k-9 by k9mail.

the class AttachmentResolverTest method buildCidMap__onPartWithNoBody__shouldReturnEmptyMap.

@Test
public void buildCidMap__onPartWithNoBody__shouldReturnEmptyMap() throws Exception {
    Part part = new MimeBodyPart();
    Map<String, Uri> result = AttachmentResolver.buildCidToAttachmentUriMap(attachmentInfoExtractor, part);
    assertTrue(result.isEmpty());
}
Also used : BodyPart(com.fsck.k9.mail.BodyPart) Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Uri(android.net.Uri) Test(org.junit.Test)

Example 8 with AttachmentInfoExtractor

use of com.fsck.k9.message.extractors.AttachmentInfoExtractor in project k-9 by k9mail.

the class MessageViewInfoExtractor method getInstance.

public static MessageViewInfoExtractor getInstance() {
    Context context = Globals.getContext();
    AttachmentInfoExtractor attachmentInfoExtractor = AttachmentInfoExtractor.getInstance();
    HtmlSanitizer htmlSanitizer = HtmlSanitizer.getInstance();
    return new MessageViewInfoExtractor(context, attachmentInfoExtractor, htmlSanitizer);
}
Also used : Context(android.content.Context) AttachmentInfoExtractor(com.fsck.k9.message.extractors.AttachmentInfoExtractor) HtmlSanitizer(com.fsck.k9.message.html.HtmlSanitizer)

Example 9 with AttachmentInfoExtractor

use of com.fsck.k9.message.extractors.AttachmentInfoExtractor in project k-9 by k9mail.

the class AttachmentInfoExtractorTest method extractInfo__withDeferredFileBody.

@Test
public void extractInfo__withDeferredFileBody() throws Exception {
    attachmentInfoExtractor = new AttachmentInfoExtractor(context) {

        @Nullable
        @Override
        protected Uri getDecryptedFileProviderUri(DeferredFileBody decryptedTempFileBody, String mimeType) {
            return TEST_URI;
        }
    };
    DeferredFileBody body = mock(DeferredFileBody.class);
    when(body.getSize()).thenReturn(TEST_SIZE);
    MimeBodyPart part = new MimeBodyPart();
    part.setBody(body);
    part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, TEST_MIME_TYPE);
    AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfo(part);
    assertEquals(TEST_URI, attachmentViewInfo.internalUri);
    assertEquals(TEST_SIZE, attachmentViewInfo.size);
    assertEquals(TEST_MIME_TYPE, attachmentViewInfo.mimeType);
    assertFalse(attachmentViewInfo.inlineAttachment);
    assertTrue(attachmentViewInfo.isContentAvailable);
}
Also used : MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) Uri(android.net.Uri) Nullable(android.support.annotation.Nullable) DeferredFileBody(com.fsck.k9.mailstore.DeferredFileBody) AttachmentViewInfo(com.fsck.k9.mailstore.AttachmentViewInfo) Test(org.junit.Test)

Aggregations

Uri (android.net.Uri)7 Part (com.fsck.k9.mail.Part)6 BodyPart (com.fsck.k9.mail.BodyPart)5 Multipart (com.fsck.k9.mail.Multipart)5 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)5 Test (org.junit.Test)5 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)4 Body (com.fsck.k9.mail.Body)2 AttachmentInfoExtractor (com.fsck.k9.message.extractors.AttachmentInfoExtractor)2 Context (android.content.Context)1 Nullable (android.support.annotation.Nullable)1 VisibleForTesting (android.support.annotation.VisibleForTesting)1 WorkerThread (android.support.annotation.WorkerThread)1 Message (com.fsck.k9.mail.Message)1 MessagingException (com.fsck.k9.mail.MessagingException)1 BinaryTempFileBody (com.fsck.k9.mail.internet.BinaryTempFileBody)1 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)1 AttachmentViewInfo (com.fsck.k9.mailstore.AttachmentViewInfo)1 DeferredFileBody (com.fsck.k9.mailstore.DeferredFileBody)1 HtmlSanitizer (com.fsck.k9.message.html.HtmlSanitizer)1