use of com.fsck.k9.mail.internet.MimeBodyPart 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.mail.internet.MimeBodyPart in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withContentTypeAndName__shouldReturnNamedAttachment.
@Test
public void extractInfoForDb__withContentTypeAndName__shouldReturnNamedAttachment() throws Exception {
MimeBodyPart part = new MimeBodyPart();
part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, TEST_MIME_TYPE + "; name=\"filename.ext\"");
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertEquals(Uri.EMPTY, attachmentViewInfo.internalUri);
assertEquals(TEST_MIME_TYPE, attachmentViewInfo.mimeType);
assertEquals("filename.ext", attachmentViewInfo.displayName);
assertFalse(attachmentViewInfo.inlineAttachment);
}
use of com.fsck.k9.mail.internet.MimeBodyPart 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);
}
use of com.fsck.k9.mail.internet.MimeBodyPart in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withDispositionInlineAndContentId__shouldReturnInlineAttachment.
@Test
public void extractInfoForDb__withDispositionInlineAndContentId__shouldReturnInlineAttachment() throws Exception {
Part part = new MimeBodyPart();
part.addRawHeader(MimeHeader.HEADER_CONTENT_ID, MimeHeader.HEADER_CONTENT_ID + ": " + TEST_CONTENT_ID);
part.addRawHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, MimeHeader.HEADER_CONTENT_DISPOSITION + ": " + "inline" + ";\n filename=\"filename.ext\";\n meaningless=\"dummy\"");
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertTrue(attachmentViewInfo.inlineAttachment);
}
use of com.fsck.k9.mail.internet.MimeBodyPart in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withContentTypeAndEncodedWordName__shouldReturnDecodedName.
@Test
public void extractInfoForDb__withContentTypeAndEncodedWordName__shouldReturnDecodedName() throws Exception {
Part part = new MimeBodyPart();
part.addRawHeader(MimeHeader.HEADER_CONTENT_TYPE, MimeHeader.HEADER_CONTENT_TYPE + ": " + TEST_MIME_TYPE + "; name=\"=?ISO-8859-1?Q?Sm=F8rrebr=F8d?=\"");
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertEquals("Smørrebrød", attachmentViewInfo.displayName);
}
Aggregations