use of com.fsck.k9.mailstore.AttachmentViewInfo 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.mailstore.AttachmentViewInfo 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.mailstore.AttachmentViewInfo in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfo__fromLocalBodyPart__shouldReturnProvidedValues.
@Test
public void extractInfo__fromLocalBodyPart__shouldReturnProvidedValues() throws Exception {
LocalBodyPart part = new LocalBodyPart(TEST_ACCOUNT_UUID, null, TEST_ID, TEST_SIZE);
part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, TEST_MIME_TYPE);
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfo(part);
assertEquals(AttachmentProvider.getAttachmentUri(TEST_ACCOUNT_UUID, TEST_ID), attachmentViewInfo.internalUri);
assertEquals(TEST_SIZE, attachmentViewInfo.size);
assertEquals(TEST_MIME_TYPE, attachmentViewInfo.mimeType);
}
use of com.fsck.k9.mailstore.AttachmentViewInfo 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);
}
use of com.fsck.k9.mailstore.AttachmentViewInfo in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withTextMimeType__shouldReturnTxtExtension.
@Test
public void extractInfoForDb__withTextMimeType__shouldReturnTxtExtension() throws Exception {
MimeBodyPart part = new MimeBodyPart();
part.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/plain");
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
// MimeUtility.getExtensionByMimeType("text/plain"); -> "txt"
assertEquals("noname.txt", attachmentViewInfo.displayName);
assertEquals("text/plain", attachmentViewInfo.mimeType);
}
Aggregations