Skip to content

Instantly share code, notes, and snippets.

@valokafor
Forked from 10zgurr/UITestHelper.kt
Created September 27, 2022 21:39
Show Gist options
  • Save valokafor/fd72b699af0a4b4e07102964fb64792a to your computer and use it in GitHub Desktop.
Save valokafor/fd72b699af0a4b4e07102964fb64792a to your computer and use it in GitHub Desktop.
package com.theozgurr.apparchitecture.common
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
import androidx.test.ext.junit.rules.ActivityScenarioRule
import com.theozgurr.apparchitecture.ui.MainActivity
@OptIn(
ExperimentalComposeUiApi::class,
ExperimentalAnimationApi::class
)
private typealias MainActivityRule = AndroidComposeTestRule<ActivityScenarioRule<MainActivity>, MainActivity>
@OptIn(ExperimentalAnimationApi::class)
@ExperimentalComposeUiApi
fun MainActivityRule.typeInputToTextFieldWithTag(
input: String,
tag: String
) {
onNodeWithTag(tag)
.performTextInput(input)
}
@OptIn(ExperimentalAnimationApi::class)
@ExperimentalComposeUiApi
fun MainActivityRule.clickToTagOwner(
tag: String
) {
onNodeWithTag(tag)
.performClick()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment