From 78758714c21ca99eb1d6c9ea82a49ba3b1ff3be1 Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Wed, 31 Dec 2014 00:42:14 +0100 Subject: [PATCH] Add testcase for #525 --- .../fsck/k9/mailstore/LocalMessageTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 k9mail/src/androidTest/java/com/fsck/k9/mailstore/LocalMessageTest.java diff --git a/k9mail/src/androidTest/java/com/fsck/k9/mailstore/LocalMessageTest.java b/k9mail/src/androidTest/java/com/fsck/k9/mailstore/LocalMessageTest.java new file mode 100644 index 000000000..01b4d8e22 --- /dev/null +++ b/k9mail/src/androidTest/java/com/fsck/k9/mailstore/LocalMessageTest.java @@ -0,0 +1,44 @@ +package com.fsck.k9.mailstore; + + +import android.test.AndroidTestCase; + +import com.fsck.k9.Preferences; +import com.fsck.k9.mail.internet.MimeBodyPart; +import com.fsck.k9.mail.internet.MimeMultipart; + + +public class LocalMessageTest extends AndroidTestCase { + private LocalMessage message; + + @Override + public void setUp() throws Exception { + super.setUp(); + Preferences preferences = Preferences.getPreferences(getContext()); + LocalStore store = LocalStore.getInstance(preferences.newAccount(), getContext()); + message = new LocalMessage(store, "uid", new LocalFolder(store, "test")); + } + + public void testGetDisplayTextWithPlainTextPart() throws Exception { + String textBodyText = "text body"; + + MimeMultipart multipart = new MimeMultipart(); + MimeBodyPart bodyPart1 = new MimeBodyPart(new LocalTextBody(textBodyText, textBodyText), "text/plain"); + multipart.addBodyPart(bodyPart1); + message.setBody(multipart); + assertEquals("text body", message.getTextForDisplay()); + } + + public void testGetDisplayTextWithHtmlPart() throws Exception { + String htmlBodyText = "html body"; + String textBodyText = "text body"; + + MimeMultipart multipart = new MimeMultipart(); + MimeBodyPart bodyPart1 = new MimeBodyPart(new LocalTextBody(htmlBodyText, htmlBodyText), "text/html"); + MimeBodyPart bodyPart2 = new MimeBodyPart(new LocalTextBody(textBodyText, textBodyText), "text/plain"); + multipart.addBodyPart(bodyPart1); + multipart.addBodyPart(bodyPart2); + message.setBody(multipart); + assertEquals("html body", message.getTextForDisplay()); + } +}