Created
December 30, 2019 19:39
-
-
Save emmano/d50e6a2cfbecf639e4a6aceaf9182806 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestFragmentTest: RobolectricTest() { | |
@Test | |
fun `test adapter dsl`() { | |
val scenario = launchFragmentInContainer<TestFragment>() | |
scenario.onFragment { | |
val recyclerView = it.requireView().findViewById<RecyclerView>(R.id.recycler) | |
val headerViewHolder = | |
recyclerView.findViewHolderForLayoutPosition(0) ?: throw IllegalStateException() | |
val header = | |
headerViewHolder.itemView.findViewById<TextView>(R.id.header) | |
assertThat(header.text.toString(), equalTo("Title")) | |
header.performClick() | |
val titleText = ShadowToast.getTextOfLatestToast() | |
assertThat(titleText, equalTo("Title")) | |
val contentViewHolder = | |
recyclerView.findViewHolderForLayoutPosition(1) ?: throw IllegalStateException() | |
contentViewHolder.itemView.performClick() | |
val rowText = ShadowToast.getTextOfLatestToast() | |
assertThat(rowText, equalTo("Row Tapped")) | |
val content = | |
contentViewHolder.itemView.findViewById<TextView>(R.id.content) | |
assertThat(content.text.toString(), equalTo("Content")) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment