use of com.fsck.k9.activity.misc.Attachment in project k-9 by k9mail.
the class MessageBuilderTest method build_withAttachment_nonAscii_shouldSucceed.
@Test
public void build_withAttachment_nonAscii_shouldSucceed() throws Exception {
MessageBuilder messageBuilder = createSimpleMessageBuilder();
Attachment attachment = createAttachmentWithContent("text/plain", ATTACHMENT_FILENAME_NON_ASCII, TEST_ATTACHMENT_TEXT);
messageBuilder.setAttachments(Collections.singletonList(attachment));
messageBuilder.buildAsync(callback);
MimeMessage message = getMessageFromCallback();
assertEquals(MESSAGE_HEADERS + MESSAGE_CONTENT_WITH_ATTACH_NON_ASCII_FILENAME, getMessageContents(message));
}
use of com.fsck.k9.activity.misc.Attachment in project k-9 by k9mail.
the class MessageBuilderTest method build_withAttachment_longFileName.
@Test
public void build_withAttachment_longFileName() throws Exception {
MessageBuilder messageBuilder = createSimpleMessageBuilder();
Attachment attachment = createAttachmentWithContent("text/plain", "~~~~~~~~~1~~~~~~~~~2~~~~~~~~~3~~~~~~~~~4~~~~~~~~~5~~~~~~~~~6~~~~~~~~~7.txt", TEST_ATTACHMENT_TEXT);
messageBuilder.setAttachments(Collections.singletonList(attachment));
messageBuilder.buildAsync(callback);
MimeMessage message = getMessageFromCallback();
assertEquals(MESSAGE_HEADERS + MESSAGE_CONTENT_WITH_LONG_FILE_NAME, getMessageContents(message));
}
use of com.fsck.k9.activity.misc.Attachment in project k-9 by k9mail.
the class AttachmentPresenter method addAttachment.
private void addAttachment(Uri uri, String contentType, boolean allowMessageType, boolean internalAttachment) {
if (attachments.containsKey(uri)) {
return;
}
int loaderId = getNextFreeLoaderId();
Attachment attachment = Attachment.createAttachment(uri, loaderId, contentType, allowMessageType, internalAttachment);
addAttachmentAndStartLoader(attachment);
}
use of com.fsck.k9.activity.misc.Attachment in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withDispositionSizeParam__shouldReturnThatSize.
@Test
public void extractInfoForDb__withDispositionSizeParam__shouldReturnThatSize() throws Exception {
MimeBodyPart part = new MimeBodyPart();
part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment" + "; size=\"" + TEST_SIZE + "\"");
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertEquals(TEST_SIZE, attachmentViewInfo.size);
}
use of com.fsck.k9.activity.misc.Attachment in project k-9 by k9mail.
the class AttachmentInfoExtractorTest method extractInfoForDb__withDispositionInvalidSizeParam__shouldReturnUnknownSize.
@Test
public void extractInfoForDb__withDispositionInvalidSizeParam__shouldReturnUnknownSize() throws Exception {
MimeBodyPart part = new MimeBodyPart();
part.setHeader(MimeHeader.HEADER_CONTENT_DISPOSITION, "attachment" + "; size=\"notanint\"");
AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
assertEquals(AttachmentViewInfo.UNKNOWN_SIZE, attachmentViewInfo.size);
}
Aggregations