mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
adding retrying to the reaction long pressing and extra visibilty check for dialogs
This commit is contained in:
parent
1b5868644a
commit
1c6b2ceb4b
3 changed files with 22 additions and 1 deletions
|
@ -68,6 +68,18 @@ object EspressoHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun withRetry(attempts: Int = 3, action: () -> Unit) {
|
||||||
|
runCatching { action() }.onFailure {
|
||||||
|
val remainingAttempts = attempts - 1
|
||||||
|
if (remainingAttempts <= 0) {
|
||||||
|
throw it
|
||||||
|
} else {
|
||||||
|
Thread.sleep(500)
|
||||||
|
withRetry(remainingAttempts, action)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getString(@StringRes id: Int): String {
|
fun getString(@StringRes id: Int): String {
|
||||||
return EspressoHelper.getCurrentActivity()!!.resources.getString(id)
|
return EspressoHelper.getCurrentActivity()!!.resources.getString(id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import im.vector.app.activityIdlingResource
|
||||||
import im.vector.app.waitForView
|
import im.vector.app.waitForView
|
||||||
import im.vector.app.withIdlingResource
|
import im.vector.app.withIdlingResource
|
||||||
import org.hamcrest.Matcher
|
import org.hamcrest.Matcher
|
||||||
|
import org.hamcrest.Matchers.not
|
||||||
|
|
||||||
inline fun <reified T : Activity> waitUntilActivityVisible(noinline block: (() -> Unit) = {}) {
|
inline fun <reified T : Activity> waitUntilActivityVisible(noinline block: (() -> Unit) = {}) {
|
||||||
withIdlingResource(activityIdlingResource(T::class.java), block)
|
withIdlingResource(activityIdlingResource(T::class.java), block)
|
||||||
|
@ -37,4 +38,5 @@ fun waitUntilViewVisible(viewMatcher: Matcher<View>) {
|
||||||
|
|
||||||
fun waitUntilDialogVisible(viewMatcher: Matcher<View>) {
|
fun waitUntilDialogVisible(viewMatcher: Matcher<View>) {
|
||||||
onView(viewMatcher).inRoot(isDialog()).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
onView(viewMatcher).inRoot(isDialog()).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
|
||||||
|
waitUntilViewVisible(viewMatcher)
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import im.vector.app.features.home.room.detail.timeline.reactions.ViewReactionsB
|
||||||
import im.vector.app.features.reactions.data.EmojiDataSource
|
import im.vector.app.features.reactions.data.EmojiDataSource
|
||||||
import im.vector.app.interactWithSheet
|
import im.vector.app.interactWithSheet
|
||||||
import im.vector.app.waitForView
|
import im.vector.app.waitForView
|
||||||
|
import im.vector.app.withRetry
|
||||||
import java.lang.Thread.sleep
|
import java.lang.Thread.sleep
|
||||||
|
|
||||||
class RoomDetailRobot {
|
class RoomDetailRobot {
|
||||||
|
@ -71,7 +72,7 @@ class RoomDetailRobot {
|
||||||
addQuickReaction(quickReaction)
|
addQuickReaction(quickReaction)
|
||||||
}
|
}
|
||||||
// Open reactions
|
// Open reactions
|
||||||
longClickOn(quickReaction)
|
longClickReaction(quickReaction)
|
||||||
// wait for bottom sheet
|
// wait for bottom sheet
|
||||||
interactWithSheet<ViewReactionsBottomSheet>(withText(R.string.reactions), openState = BottomSheetBehavior.STATE_COLLAPSED) {
|
interactWithSheet<ViewReactionsBottomSheet>(withText(R.string.reactions), openState = BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
pressBack()
|
pressBack()
|
||||||
|
@ -99,6 +100,12 @@ class RoomDetailRobot {
|
||||||
waitUntilViewVisible(withId(R.id.composerEditText))
|
waitUntilViewVisible(withId(R.id.composerEditText))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun longClickReaction(quickReaction: String) {
|
||||||
|
withRetry {
|
||||||
|
longClickOn(quickReaction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun openMessageMenu(message: String, block: MessageMenuRobot.() -> Unit) {
|
fun openMessageMenu(message: String, block: MessageMenuRobot.() -> Unit) {
|
||||||
onView(withId(R.id.timelineRecyclerView))
|
onView(withId(R.id.timelineRecyclerView))
|
||||||
.perform(
|
.perform(
|
||||||
|
|
Loading…
Reference in a new issue