Skip to content

Commit 2cad3ce

Browse files
committed
Check VIEW_LEVEL alignment approach in parser and block tests
1 parent 88589b6 commit 2cad3ce

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

aztec/src/test/kotlin/org/wordpress/aztec/AztecParserTest.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ import org.junit.Before
1111
import org.junit.Ignore
1212
import org.junit.Test
1313
import org.junit.runner.RunWith
14-
import org.robolectric.RobolectricTestRunner
14+
import org.robolectric.ParameterizedRobolectricTestRunner
1515
import org.robolectric.RuntimeEnvironment
1616
import org.robolectric.annotation.Config
1717

1818
/**
1919
* Tests for [AztecParser].
2020
*/
21-
@RunWith(RobolectricTestRunner::class)
21+
@RunWith(ParameterizedRobolectricTestRunner::class)
2222
@Config(sdk = intArrayOf(23))
23-
class AztecParserTest : AndroidTestCase() {
24-
private var mParser = AztecParser(AlignmentApproach.SPAN_LEVEL)
23+
class AztecParserTest(alignmentApproach: AlignmentApproach) : AndroidTestCase() {
24+
private var mParser = AztecParser(alignmentApproach)
2525
private val HTML_BOLD = "<b>Bold</b><br><br>"
2626
private val HTML_LIST_ORDERED = "<ol><li>Ordered</li></ol>"
2727
private val HTML_LIST_ORDERED_WITH_EMPTY_ITEM = "<ol><li>Ordered 1</li><li></li><li>Ordered 2</li></ol>"
@@ -87,6 +87,17 @@ class AztecParserTest : AndroidTestCase() {
8787
private val SPAN_UNDERLINE = "Underline\n\n"
8888
private val SPAN_UNKNOWN = "\uFFFC\n\n"
8989

90+
companion object {
91+
@JvmStatic
92+
@ParameterizedRobolectricTestRunner.Parameters(name = "Testing parser with AlignmentApproach.{0}")
93+
fun data(): Collection<Array<AlignmentApproach>> {
94+
return listOf(
95+
arrayOf(AlignmentApproach.SPAN_LEVEL),
96+
arrayOf(AlignmentApproach.VIEW_LEVEL)
97+
)
98+
}
99+
}
100+
90101
/**
91102
* Initialize variables.
92103
*/

aztec/src/test/kotlin/org/wordpress/aztec/BlockElementsTest.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import org.junit.Assert
55
import org.junit.Before
66
import org.junit.Test
77
import org.junit.runner.RunWith
8+
import org.robolectric.ParameterizedRobolectricTestRunner
89
import org.robolectric.Robolectric
9-
import org.robolectric.RobolectricTestRunner
1010
import org.robolectric.annotation.Config
1111

1212
import org.wordpress.aztec.TestUtils.backspaceAt
@@ -17,18 +17,29 @@ import org.wordpress.aztec.TestUtils.safeLength
1717
/**
1818
* Testing interactions of multiple block elements
1919
*/
20-
@RunWith(RobolectricTestRunner::class)
20+
@RunWith(ParameterizedRobolectricTestRunner::class)
2121
@Config(sdk = intArrayOf(23))
22-
class BlockElementsTest {
22+
class BlockElementsTest(val alignmentApproach: AlignmentApproach) {
2323
lateinit var editText: AztecText
2424

25+
companion object {
26+
@JvmStatic
27+
@ParameterizedRobolectricTestRunner.Parameters(name = "Testing parser with AlignmentApproach.{0}")
28+
fun data(): Collection<Array<AlignmentApproach>> {
29+
return listOf(
30+
arrayOf(AlignmentApproach.SPAN_LEVEL),
31+
arrayOf(AlignmentApproach.VIEW_LEVEL)
32+
)
33+
}
34+
}
35+
2536
/**
2637
* Initialize variables.
2738
*/
2839
@Before
2940
fun init() {
3041
val activity = Robolectric.buildActivity(Activity::class.java).create().visible().get()
31-
editText = AztecText(activity)
42+
editText = AztecText(activity, alignmentApproach)
3243
editText.setCalypsoMode(false)
3344
activity.setContentView(editText)
3445
}

0 commit comments

Comments
 (0)