mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
Merge branch 'develop' into feature/fga/room_list_filter_iteration
This commit is contained in:
+19
@@ -29,12 +29,31 @@ class EnsureCalledOnce : () -> Unit {
|
||||
}
|
||||
}
|
||||
|
||||
class EnsureCalledTimes(val times: Int) : () -> Unit {
|
||||
private var counter = 0
|
||||
override fun invoke() {
|
||||
counter++
|
||||
}
|
||||
|
||||
fun assertSuccess() {
|
||||
if (counter != times) {
|
||||
throw AssertionError("Expected to be called $times, but was called $counter times")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun ensureCalledOnce(block: (callback: () -> Unit) -> Unit) {
|
||||
val callback = EnsureCalledOnce()
|
||||
block(callback)
|
||||
callback.assertSuccess()
|
||||
}
|
||||
|
||||
fun ensureCalledTimes(times: Int, block: (callback: () -> Unit) -> Unit) {
|
||||
val callback = EnsureCalledTimes(times)
|
||||
block(callback)
|
||||
callback.assertSuccess()
|
||||
}
|
||||
|
||||
class EnsureCalledOnceWithParam<T, R>(
|
||||
private val expectedParam: T,
|
||||
private val result: R,
|
||||
|
||||
+11
@@ -24,6 +24,7 @@ import androidx.compose.ui.test.hasContentDescription
|
||||
import androidx.compose.ui.test.hasTestTag
|
||||
import androidx.compose.ui.test.hasText
|
||||
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
|
||||
import androidx.compose.ui.test.onFirst
|
||||
import androidx.compose.ui.test.performClick
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
import org.junit.rules.TestRule
|
||||
@@ -34,6 +35,16 @@ fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.clickOn(@StringR
|
||||
.performClick()
|
||||
}
|
||||
|
||||
fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.clickOnFirst(@StringRes res: Int) {
|
||||
val text = activity.getString(res)
|
||||
onAllNodes(hasText(text) and hasClickAction()).onFirst().performClick()
|
||||
}
|
||||
|
||||
fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.clickOnLast(@StringRes res: Int) {
|
||||
val text = activity.getString(res)
|
||||
onAllNodes(hasText(text) and hasClickAction()).onFirst().performClick()
|
||||
}
|
||||
|
||||
/**
|
||||
* Press the back button in the app bar.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user