Merge branch 'develop' into feature/valere/call/decline_timeline_rendering

This commit is contained in:
Valere 2026-05-04 09:00:00 +02:00
commit 18fbe91fc7
171 changed files with 2932 additions and 3196 deletions

View file

@ -6,15 +6,17 @@
* Please see LICENSE files in the repository root for full details.
*/
@file:OptIn(ExperimentalTestApi::class)
package io.element.android.tests.testutils
import androidx.activity.ComponentActivity
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.AndroidComposeUiTest
import androidx.compose.ui.test.ExperimentalTestApi
import io.element.android.libraries.designsystem.utils.LocalUiTestMode
import org.junit.Assert.assertFalse
import org.junit.rules.TestRule
import kotlin.coroutines.CoroutineContext
object RobolectricDispatcherCleaner {
@ -52,7 +54,7 @@ object RobolectricDispatcherCleaner {
}
}
fun <R : TestRule, A : ComponentActivity> AndroidComposeTestRule<R, A>.setSafeContent(
fun AndroidComposeUiTest<ComponentActivity>.setSafeContent(
clearAndroidUiDispatcher: Boolean = false,
content: @Composable () -> Unit,
) {

View file

@ -6,10 +6,14 @@
* Please see LICENSE files in the repository root for full details.
*/
@file:OptIn(ExperimentalTestApi::class)
package io.element.android.tests.testutils
import androidx.activity.ComponentActivity
import androidx.annotation.StringRes
import androidx.compose.ui.test.AndroidComposeUiTest
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
import androidx.compose.ui.test.assertIsDisplayed
@ -19,19 +23,17 @@ import androidx.compose.ui.test.hasContentDescription
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.isDialog
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import io.element.android.libraries.ui.strings.CommonStrings
import org.junit.rules.TestRule
val trueMatcher = SemanticsMatcher("true matcher") { true }
fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.clickOn(
fun AndroidComposeUiTest<ComponentActivity>.clickOn(
@StringRes res: Int,
inDialog: Boolean = false,
) {
val text = activity.getString(res)
val text = activity!!.getString(res)
onNode(
hasText(text) and hasClickAction() and if (inDialog) hasAnyAncestor(isDialog()) else trueMatcher
)
@ -41,28 +43,28 @@ fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.clickOn(
/**
* Press the back button in the app bar.
*/
fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.pressBack() {
val text = activity.getString(CommonStrings.action_back)
fun AndroidComposeUiTest<ComponentActivity>.pressBack() {
val text = activity!!.getString(CommonStrings.action_back)
onNode(hasContentDescription(text)).performClick()
}
/**
* Press the back key.
*/
fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.pressBackKey() {
activity.onBackPressedDispatcher.onBackPressed()
fun AndroidComposeUiTest<ComponentActivity>.pressBackKey() {
activity!!.onBackPressedDispatcher.onBackPressed()
}
fun SemanticsNodeInteractionsProvider.pressTag(tag: String) {
onNode(hasTestTag(tag)).performClick()
}
fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.assertNoNodeWithText(@StringRes res: Int) {
val text = activity.getString(res)
fun AndroidComposeUiTest<ComponentActivity>.assertNoNodeWithText(@StringRes res: Int) {
val text = activity!!.getString(res)
onNodeWithText(text).assertDoesNotExist()
}
fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.assertNodeWithTextIsDisplayed(@StringRes res: Int) {
val text = activity.getString(res)
fun AndroidComposeUiTest<ComponentActivity>.assertNodeWithTextIsDisplayed(@StringRes res: Int) {
val text = activity!!.getString(res)
onNodeWithText(text).assertIsDisplayed()
}