Merge branch 'develop' into feature/fga/room_list_filter_iteration

This commit is contained in:
ganfra 2024-03-13 12:07:20 +01:00
commit dbba95a830
177 changed files with 2324 additions and 870 deletions

View file

@ -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,

View file

@ -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.
*/