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());
}
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());
}
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);
}
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);
}
Aggregations