Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Latest commit

 

History

History
41 lines (29 loc) · 1.47 KB

with-index.md

File metadata and controls

41 lines (29 loc) · 1.47 KB

kakao / com.agoda.kakao / ViewBuilder / withIndex

withIndex

fun withIndex(index: Int, function: ViewBuilder.() -> Unit): Unit

Matches only view at given [index](with-index.md#com.agoda.kakao.ViewBuilder$withIndex(kotlin.Int, kotlin.Function1((com.agoda.kakao.ViewBuilder, kotlin.Unit)))/index), if there are multiple views that matches

IMPORTANT: this matcher is single-use only, since it does not reset it's index counter due to specific espresso's matching process. Thus only one action and/or assertion can be performed on such a KView.

If you need to match view with index multiple times, each time you should match with new instance of withIndex

Take a look at the example:

class InputScreen : Screen<InputScreen>() {
    fun inputLayout(lambda: KEditText.() -> Unit) = KEditText { withIndex(0, { withId(R.id.input_layout) }) }.invoke(lambda)
}

@Test
fun test() {
    screen {
        inputLayout {
            replaceText("EXAMPLE")
        }

        inputLayout {
            hasAnyText()
        }
    }
}

Parameters

index - Index of the view to match

function - ViewBuilder that will result in matcher