diff --git a/app/core/src/test/java/com/fsck/k9/message/html/HtmlConverterTest.java b/app/core/src/test/java/com/fsck/k9/message/html/HtmlConverterTest.java index 32a38fb56..7109f8908 100644 --- a/app/core/src/test/java/com/fsck/k9/message/html/HtmlConverterTest.java +++ b/app/core/src/test/java/com/fsck/k9/message/html/HtmlConverterTest.java @@ -1,36 +1,12 @@ package com.fsck.k9.message.html; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import com.fsck.k9.K9; -import org.apache.commons.io.IOUtils; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import static junit.framework.Assert.assertEquals; public class HtmlConverterTest { - // Useful if you want to write stuff to a file for debugging in a browser. - private static final boolean WRITE_TO_FILE = Boolean.parseBoolean(System.getProperty("k9.htmlConverterTest.writeToFile", "false")); - private static final String OUTPUT_FILE = "C:/temp/parse.html"; - private K9.Theme priorMessageViewTheme; - - @Before - public void before() { - priorMessageViewTheme = K9.getK9MessageViewTheme(); - } - - @After - public void after() { - K9.setK9MessageViewThemeSetting(priorMessageViewTheme); - } - @Test public void testTextQuoteToHtmlBlockquote() { String message = "Panama!\r\n" + @@ -44,8 +20,9 @@ public class HtmlConverterTest { "\r\n" + "Nice job :)\r\n" + ">> Guess!"; + String result = HtmlConverter.textToHtml(message); - writeToFile(result); + assertEquals("
" + "Panama!
" + "
" @@ -83,8 +60,9 @@ public class HtmlConverterTest { "> LOL F1RST!!!!!\r\n" + ">\r\n" + "> :)"; + String result = HtmlConverter.textToHtml(message); - writeToFile(result); + assertEquals("" + "*facepalm*
" + "
" @@ -108,8 +86,9 @@ public class HtmlConverterTest { ">>>> four\r\n" + ">>>>> five\r\n" + ">>>>>> six"; + String result = HtmlConverter.textToHtml(message); - writeToFile(result); + assertEquals("" + "zero", result); } - private void writeToFile(final String content) { - if (!WRITE_TO_FILE) { - return; - } - - FileWriter fstream = null; - - try { - File f = new File(OUTPUT_FILE); - if (f.exists() && !f.delete()) { - throw new RuntimeException("Unable to delete existing output"); - } - - fstream = new FileWriter(OUTPUT_FILE); - BufferedWriter out = new BufferedWriter(fstream); - out.write(content); - out.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - IOUtils.closeQuietly(fstream); - } - } - @Test public void testPreserveSpacesAtFirst() { String message = "foo\r\n" + " bar\r\n" + " baz\r\n"; + String result = HtmlConverter.textToHtml(message); - writeToFile(result); + assertEquals("
" + "" @@ -133,37 +112,14 @@ public class HtmlConverterTest { + "" + "foo
" + " bar
" @@ -179,8 +135,9 @@ public class HtmlConverterTest { + " \n" + " <\r\n" + " > \r\n"; + String result = HtmlConverter.textToHtml(message); - writeToFile(result); + assertEquals("" + "
" + " &
"