@@ -13,11 +13,10 @@ import org.wordpress.aztec.source.Format
1313
1414@RunWith(RobolectricTestRunner ::class )
1515@Config(constants = BuildConfig ::class , sdk = intArrayOf(23 ))
16- class HtmlFormattingTest () : AndroidTestCase() {
16+ class HtmlFormattingTest : AndroidTestCase () {
1717
1818 private var parser = AztecParser ()
1919
20-
2120 private val HTML_LINE_BREAKS = " HI<br><br><br><br><br><br>BYE"
2221
2322 private val HTML_NESTED =
@@ -31,11 +30,11 @@ class HtmlFormattingTest() : AndroidTestCase() {
3130 " <div class=\" fifth\" ></div>" +
3231 " </div>" +
3332 " <span class=\" second last\" ></span>" +
34- " <span></ span><div ><div><div><span></span></div></div></div><div></div>" +
33+ " <div>< span></span ><div><div><span></span></div></div></div><div></div>" +
3534 " </div>" +
3635 " <br><br>"
3736
38- private val HTML_MIXED =
37+ private val HTML_MIXED_WITH_NEWLINES =
3938 " \n\n <span><i>Italic</i></span>\n\n " +
4039 " <b>Bold</b><br>" +
4140 " \t <div class=\" first\" >" +
@@ -52,9 +51,9 @@ class HtmlFormattingTest() : AndroidTestCase() {
5251 " </div>" +
5352 " <br>"
5453
55- private val HTML_MIXED_NO_WS =
54+ private val HTML_MIXED_WITHOUT_NEWLINES =
5655 " <span><i>Italic</i></span>" +
57- " <b>Bold</b><br>" +
56+ " <b>Bold</b><br>" +
5857 " <div class=\" first\" >" +
5958 " <a href=\" https://github.com/wordpress-mobile/WordPress-Aztec-Android\" >Link</a>" +
6059 " <div class=\" second\" >" +
@@ -69,6 +68,9 @@ class HtmlFormattingTest() : AndroidTestCase() {
6968 " </div>" +
7069 " <br>"
7170
71+ private val HTML_BLOCK_WITH_NEWLINES = " \n\n <div>Division</div>\n\n "
72+ private val HTML_BLOCK_WITHOUT_NEWLINES = " <div>Division</div>"
73+
7274 /* *
7375 * Initialize variables.
7476 */
@@ -113,9 +115,23 @@ class HtmlFormattingTest() : AndroidTestCase() {
113115 @Test
114116 @Throws(Exception ::class )
115117 fun formatMixedHtml () {
116- val input = HTML_MIXED
118+ val input = HTML_MIXED_WITH_NEWLINES
119+ val span = SpannableString (parser.fromHtml(input, null , null , context))
120+ val output = Format .clearFormatting(Format .addFormatting(parser.toHtml(span)))
121+ Assert .assertEquals(HTML_MIXED_WITHOUT_NEWLINES , output)
122+ }
123+
124+ /* *
125+ * Test block conversion from HTML to visual mode with newlines.
126+ *
127+ * @throws Exception
128+ */
129+ @Test
130+ @Throws(Exception ::class )
131+ fun formatNewlines () {
132+ val input = HTML_BLOCK_WITH_NEWLINES
117133 val span = SpannableString (parser.fromHtml(input, null , null , context))
118134 val output = Format .clearFormatting(Format .addFormatting(parser.toHtml(span)))
119- Assert .assertEquals(HTML_MIXED_NO_WS , output)
135+ Assert .assertEquals(HTML_BLOCK_WITHOUT_NEWLINES , output)
120136 }
121- }
137+ }
0 commit comments