mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Improve test framework.
This commit is contained in:
committed by
Benoit Marty
parent
67190bdd1d
commit
849f1021fd
+1
-1
@@ -29,7 +29,7 @@ class EnsureCalledOnce : () -> Unit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ensureCalledOnce(block: (callback: EnsureCalledOnce) -> Unit) {
|
fun ensureCalledOnce(block: (callback: () -> Unit) -> Unit) {
|
||||||
val callback = EnsureCalledOnce()
|
val callback = EnsureCalledOnce()
|
||||||
block(callback)
|
block(callback)
|
||||||
callback.assertSuccess()
|
callback.assertSuccess()
|
||||||
|
|||||||
+10
@@ -34,11 +34,21 @@ fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.clickOn(@StringR
|
|||||||
.performClick()
|
.performClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Press the back button in the app bar.
|
||||||
|
*/
|
||||||
fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.pressBack() {
|
fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.pressBack() {
|
||||||
val text = activity.getString(CommonStrings.action_back)
|
val text = activity.getString(CommonStrings.action_back)
|
||||||
onNode(hasContentDescription(text)).performClick()
|
onNode(hasContentDescription(text)).performClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Press the back key.
|
||||||
|
*/
|
||||||
|
fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.pressBackKey() {
|
||||||
|
activity.onBackPressedDispatcher.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
fun SemanticsNodeInteractionsProvider.pressTag(tag: String) {
|
fun SemanticsNodeInteractionsProvider.pressTag(tag: String) {
|
||||||
onNode(hasTestTag(tag)).performClick()
|
onNode(hasTestTag(tag)).performClick()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user