use of com.fsck.k9.mail.Part in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withNoBody__shouldReturnContentAvailable.
@Test
public void extractInfoForDb__withNoBody__shouldReturnContentAvailable() throws Exception {
MimeBodyPart part = new MimeBodyPart();
part.setBody(new TextBody("data"));
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertTrue(attachmentViewInfo.isContentAvailable);
}
use of com.fsck.k9.mail.Part in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withNoHeaders__shouldReturnEmptyValues.
@Test
public void extractInfoForDb__withNoHeaders__shouldReturnEmptyValues() throws Exception {
MimeBodyPart part = new MimeBodyPart();
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertEquals(Uri.EMPTY, attachmentViewInfo.internalUri);
assertEquals(AttachmentViewInfo.UNKNOWN_SIZE, attachmentViewInfo.size);
assertEquals("noname.txt", attachmentViewInfo.displayName);
assertEquals("text/plain", attachmentViewInfo.mimeType);
assertFalse(attachmentViewInfo.inlineAttachment);
}
use of com.fsck.k9.mail.Part in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withDispositionAttach__shouldReturnNamedAttachment.
@Test
public void extractInfoForDb__withDispositionAttach__shouldReturnNamedAttachment() throws Exception {
MimeBodyPart part = new MimeBodyPart();
part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment" + "; filename=\"filename.ext\"; meaningless=\"dummy\"");
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertEquals(Uri.EMPTY, attachmentViewInfo.internalUri);
assertEquals("filename.ext", attachmentViewInfo.displayName);
assertFalse(attachmentViewInfo.inlineAttachment);
}
use of com.fsck.k9.mail.Part in project k-9 by k9mail.
the class TextPartFinderTest method findFirstTextPart_withMultipartAlternativeNotContainingTextPart.
@Test
public void findFirstTextPart_withMultipartAlternativeNotContainingTextPart() throws Exception {
Part part = createMultipart("multipart/alternative", createPart("image/gif"), createPart("application/pdf"));
Part result = textPartFinder.findFirstTextPart(part);
assertNull(result);
}
use of com.fsck.k9.mail.Part in project k-9 by k9mail.
the class TextPartFinderTest method findFirstTextPart_withMultipartMixedContainingMultipartAlternativeWithTextPlainPartLast.
@Test
public void findFirstTextPart_withMultipartMixedContainingMultipartAlternativeWithTextPlainPartLast() throws Exception {
BodyPart expected = createTextPart("text/plain");
Part part = createMultipart("multipart/mixed", createMultipart("multipart/alternative", createTextPart("text/html"), expected));
Part result = textPartFinder.findFirstTextPart(part);
assertEquals(expected, result);
}
Aggregations