1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Add testcase for #525

This commit is contained in:
Jan Berkel 2014-12-31 00:42:14 +01:00
parent e8c6a56fd2
commit 78758714c2

View File

@ -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());
}
}