Skip to content

Commit

Permalink
Check VIEW_LEVEL alignment approach in parser and block tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mchowning committed Apr 22, 2020
1 parent 85510a9 commit 61402e5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
18 changes: 15 additions & 3 deletions aztec/src/test/kotlin/org/wordpress/aztec/AztecParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.ParameterizedRobolectricTestRunner
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config

/**
* Tests for [AztecParser].
*/
@RunWith(RobolectricTestRunner::class)
@RunWith(ParameterizedRobolectricTestRunner::class)
@Config(sdk = intArrayOf(23))
class AztecParserTest : AndroidTestCase() {
private var mParser = AztecParser(AlignmentApproach.SPAN_LEVEL)
class AztecParserTest(alignmentApproach: AlignmentApproach) : AndroidTestCase() {
private var mParser = AztecParser(alignmentApproach)
private val HTML_BOLD = "<b>Bold</b><br><br>"
private val HTML_LIST_ORDERED = "<ol><li>Ordered</li></ol>"
private val HTML_LIST_ORDERED_WITH_EMPTY_ITEM = "<ol><li>Ordered 1</li><li></li><li>Ordered 2</li></ol>"
Expand Down Expand Up @@ -87,6 +88,17 @@ class AztecParserTest : AndroidTestCase() {
private val SPAN_UNDERLINE = "Underline\n\n"
private val SPAN_UNKNOWN = "\uFFFC\n\n"

companion object {
@JvmStatic
@ParameterizedRobolectricTestRunner.Parameters(name = "Testing parser with AlignmentApproach.{0}")
fun data(): Collection<Array<AlignmentApproach>> {
return listOf(
arrayOf(AlignmentApproach.SPAN_LEVEL),
arrayOf(AlignmentApproach.VIEW_LEVEL)
)
}
}

/**
* Initialize variables.
*/
Expand Down
18 changes: 15 additions & 3 deletions aztec/src/test/kotlin/org/wordpress/aztec/BlockElementsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.ParameterizedRobolectricTestRunner
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
Expand All @@ -17,18 +18,29 @@ import org.wordpress.aztec.TestUtils.safeLength
/**
* Testing interactions of multiple block elements
*/
@RunWith(RobolectricTestRunner::class)
@RunWith(ParameterizedRobolectricTestRunner::class)
@Config(sdk = intArrayOf(23))
class BlockElementsTest {
class BlockElementsTest(val alignmentApproach: AlignmentApproach) {
lateinit var editText: AztecText

companion object {
@JvmStatic
@ParameterizedRobolectricTestRunner.Parameters(name = "Testing parser with AlignmentApproach.{0}")
fun data(): Collection<Array<AlignmentApproach>> {
return listOf(
arrayOf(AlignmentApproach.SPAN_LEVEL),
arrayOf(AlignmentApproach.VIEW_LEVEL)
)
}
}

/**
* Initialize variables.
*/
@Before
fun init() {
val activity = Robolectric.buildActivity(Activity::class.java).create().visible().get()
editText = AztecText(activity)
editText = AztecText(activity, alignmentApproach)
editText.setCalypsoMode(false)
activity.setContentView(editText)
}
Expand Down

0 comments on commit 61402e5

Please sign in to comment.