Change a room's permissions power levels (#2525)

* Change a room's permissions power levels

* Make `currentPermissions` use a `MatrixRoomPowerLevels?` instance instead.

* Update strings

* Update screenshots

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
Jorge Martin Espinosa 2024-03-12 15:45:06 +01:00 committed by GitHub
parent 3453738344
commit 59a682b407
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
71 changed files with 1556 additions and 58 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.
*/