Skip to content

Commit

Permalink
Add test for sub selection
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensousa committed Nov 14, 2024
1 parent 985f5d3 commit d2656f3
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ import com.rubensousa.dpadrecyclerview.test.TestViewHolder
import com.rubensousa.dpadrecyclerview.test.assertions.ViewHolderAlignmentCountAssertion
import com.rubensousa.dpadrecyclerview.test.assertions.ViewHolderSelectionCountAssertion
import com.rubensousa.dpadrecyclerview.test.helpers.assertFocusAndSelection
import com.rubensousa.dpadrecyclerview.test.helpers.onRecyclerView
import com.rubensousa.dpadrecyclerview.test.helpers.runOnMainThread
import com.rubensousa.dpadrecyclerview.test.helpers.selectPosition
import com.rubensousa.dpadrecyclerview.test.helpers.selectSubPosition
import com.rubensousa.dpadrecyclerview.test.helpers.waitForIdleScrollState
import com.rubensousa.dpadrecyclerview.test.helpers.waitForLayout
import com.rubensousa.dpadrecyclerview.test.tests.DpadRecyclerViewTest
import com.rubensousa.dpadrecyclerview.testfixtures.DpadSelectionEvent
import com.rubensousa.dpadrecyclerview.testing.KeyEvents
Expand Down Expand Up @@ -175,6 +178,32 @@ class SubSelectionTest : DpadRecyclerViewTest() {
)
}

@Test
fun testSubSelectionIsAppliedForNextLayout() = report {
val position = 10
val subPosition = 1
param("position", position.toString())
param("subPosition", subPosition.toString())

var recyclerView: DpadRecyclerView? = null
Given("Launch fragment") {
launchSubPositionFragment()
onRecyclerView("Retrieve recyclerView instance") {
recyclerView = it
}
}

When("Select target positions") {
runOnMainThread {
recyclerView?.setSelectedSubPosition(position, subPosition)
}
waitForLayout()
}

Then("Assert selection is at position $position and sub position $subPosition") {
assertFocusAndSelection(position, subPosition)
}
}

private fun getSelectionsFromTasks(): List<DpadSelectionEvent> {
var events = listOf<DpadSelectionEvent>()
Expand Down

0 comments on commit d2656f3

Please sign in to comment.