Search in sources :

Example 26 with Text

use of com.fsck.k9.mail.internet.Viewable.Text in project k-9 by k9mail.

the class PreviewTextExtractorTest method extractPreview_shouldStripQuoteHeaderAndQuotedText.

@Test
public void extractPreview_shouldStripQuoteHeaderAndQuotedText() throws Exception {
    String text = "" + "some text\r\n" + "On 01/02/03 someone wrote\r\n" + "> some quoted text\r\n" + "# some other quoted text\r\n";
    Part part = createTextPart("text/plain", text);
    String preview = previewTextExtractor.extractPreview(part);
    assertEquals("some text", preview);
}
Also used : Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MessageCreationHelper.createTextPart(com.fsck.k9.message.MessageCreationHelper.createTextPart) Test(org.junit.Test)

Example 27 with Text

use of com.fsck.k9.mail.internet.Viewable.Text in project k-9 by k9mail.

the class PreviewTextExtractorTest method extractPreview_withLongTextPlain.

@Test
public void extractPreview_withLongTextPlain() throws Exception {
    String text = "" + "10--------20--------30--------40--------50--------" + "60--------70--------80--------90--------100-------" + "110-------120-------130-------140-------150-------" + "160-------170-------180-------190-------200-------" + "210-------220-------230-------240-------250-------" + "260-------270-------280-------290-------300-------" + "310-------320-------330-------340-------350-------" + "360-------370-------380-------390-------400-------" + "410-------420-------430-------440-------450-------" + "460-------470-------480-------490-------500-------" + "510-------520-------";
    Part part = createTextPart("text/plain", text);
    String preview = previewTextExtractor.extractPreview(part);
    assertEquals(text.substring(0, 511) + "…", preview);
}
Also used : Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MessageCreationHelper.createTextPart(com.fsck.k9.message.MessageCreationHelper.createTextPart) Test(org.junit.Test)

Example 28 with Text

use of com.fsck.k9.mail.internet.Viewable.Text in project k-9 by k9mail.

the class PreviewTextExtractorTest method extractPreview_shouldStripGenericQuoteHeader.

@Test
public void extractPreview_shouldStripGenericQuoteHeader() throws Exception {
    String text = "" + "Am 13.12.2015 um 23:42 schrieb Hans:\r\n" + "> hallo\r\n" + "hi there\r\n";
    Part part = createTextPart("text/plain", text);
    String preview = previewTextExtractor.extractPreview(part);
    assertEquals("hi there", preview);
}
Also used : Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MessageCreationHelper.createTextPart(com.fsck.k9.message.MessageCreationHelper.createTextPart) Test(org.junit.Test)

Example 29 with Text

use of com.fsck.k9.mail.internet.Viewable.Text 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);
}
Also used : MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) AttachmentViewInfo(com.fsck.k9.mailstore.AttachmentViewInfo) Test(org.junit.Test)

Example 30 with Text

use of com.fsck.k9.mail.internet.Viewable.Text in project k-9 by k9mail.

the class EncryptionDetectorTest method isEncrypted_withTextPlain_shouldReturnFalse.

@Test
public void isEncrypted_withTextPlain_shouldReturnFalse() throws Exception {
    Message message = createTextMessage("text/plain", "plain text");
    boolean encrypted = encryptionDetector.isEncrypted(message);
    assertFalse(encrypted);
}
Also used : MessageCreationHelper.createMultipartMessage(com.fsck.k9.message.MessageCreationHelper.createMultipartMessage) MessageCreationHelper.createMessage(com.fsck.k9.message.MessageCreationHelper.createMessage) MessageCreationHelper.createTextMessage(com.fsck.k9.message.MessageCreationHelper.createTextMessage) Message(com.fsck.k9.mail.Message) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)74 Part (com.fsck.k9.mail.Part)64 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)37 BodyPart (com.fsck.k9.mail.BodyPart)34 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)33 MessageCreationHelper.createTextPart (com.fsck.k9.message.MessageCreationHelper.createTextPart)27 Message (com.fsck.k9.mail.Message)22 TextBody (com.fsck.k9.mail.internet.TextBody)18 MessageCreationHelper.createEmptyPart (com.fsck.k9.message.MessageCreationHelper.createEmptyPart)16 ArrayList (java.util.ArrayList)16 Body (com.fsck.k9.mail.Body)13 MessagingException (com.fsck.k9.mail.MessagingException)13 MessageCreationHelper.createPart (com.fsck.k9.message.MessageCreationHelper.createPart)13 Multipart (com.fsck.k9.mail.Multipart)10 Viewable (com.fsck.k9.mail.internet.Viewable)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)8 Intent (android.content.Intent)6 BinaryMemoryBody (com.fsck.k9.mailstore.BinaryMemoryBody)6 ViewableExtractedText (com.fsck.k9.mailstore.MessageViewInfoExtractor.ViewableExtractedText)6