Remove unused code from HtmlConverterTest
This commit is contained in:
parent
3e0855c5e1
commit
2d746e64ce
1 changed files with 10 additions and 53 deletions
|
@ -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("<pre class=\"k9mail\">"
|
||||
+ "Panama!<br>"
|
||||
+ "<br>"
|
||||
|
@ -83,8 +60,9 @@ public class HtmlConverterTest {
|
|||
"> LOL F1RST!!!!!\r\n" +
|
||||
">\r\n" +
|
||||
"> :)";
|
||||
|
||||
String result = HtmlConverter.textToHtml(message);
|
||||
writeToFile(result);
|
||||
|
||||
assertEquals("<pre class=\"k9mail\">"
|
||||
+ "*facepalm*<br>"
|
||||
+ "<br>"
|
||||
|
@ -108,8 +86,9 @@ public class HtmlConverterTest {
|
|||
">>>> four\r\n" +
|
||||
">>>>> five\r\n" +
|
||||
">>>>>> six";
|
||||
|
||||
String result = HtmlConverter.textToHtml(message);
|
||||
writeToFile(result);
|
||||
|
||||
assertEquals("<pre class=\"k9mail\">"
|
||||
+ "zero<br>"
|
||||
+ "<blockquote class=\"gmail_quote\" style=\"margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;\">"
|
||||
|
@ -133,37 +112,14 @@ public class HtmlConverterTest {
|
|||
+ "</pre>", 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("<pre class=\"k9mail\">"
|
||||
+ "foo<br>"
|
||||
+ " bar<br>"
|
||||
|
@ -179,8 +135,9 @@ public class HtmlConverterTest {
|
|||
+ " \n"
|
||||
+ " <\r\n"
|
||||
+ " > \r\n";
|
||||
|
||||
String result = HtmlConverter.textToHtml(message);
|
||||
writeToFile(result);
|
||||
|
||||
assertEquals("<pre class=\"k9mail\">"
|
||||
+ " <br>"
|
||||
+ " &<br>"
|
||||
|
|
Loading…
Reference in a new issue