adding expected open/closed state to the bottom sheet waiting

This commit is contained in:
Adam Brown 2021-11-11 10:15:07 +00:00
parent 69745ea74e
commit 97d768e392

View file

@ -235,11 +235,16 @@ fun clickOnAndGoBack(@StringRes name: Int, block: () -> Unit) {
Espresso.pressBack()
}
inline fun <reified T : VectorBaseBottomSheetDialogFragment<*>> interactWithSheet(contentMatcher: Matcher<View>, noinline block: () -> Unit = {}) {
inline fun <reified T : VectorBaseBottomSheetDialogFragment<*>> interactWithSheet(
contentMatcher: Matcher<View>,
@BottomSheetBehavior.State openState: Int = BottomSheetBehavior.STATE_EXPANDED,
@BottomSheetBehavior.State exitState: Int = BottomSheetBehavior.STATE_HIDDEN,
noinline block: () -> Unit = {}
) {
waitUntilViewVisible(contentMatcher)
val behaviour = (EspressoHelper.getBottomSheetDialog<T>()!!.dialog as BottomSheetDialog).behavior
withIdlingResource(BottomSheetResource(behaviour, BottomSheetBehavior.STATE_EXPANDED), block)
withIdlingResource(BottomSheetResource(behaviour, BottomSheetBehavior.STATE_HIDDEN)) {}
withIdlingResource(BottomSheetResource(behaviour, openState), block)
withIdlingResource(BottomSheetResource(behaviour, exitState)) {}
}
class BottomSheetResource(