From fc865682b1e6a84346a3564bedc90cb5727283b8 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 9 Nov 2021 10:32:13 +0000 Subject: [PATCH] waiting for the message actions bottom sheet when interacting with the message options --- .../vector/app/ui/robot/MessageMenuRobot.kt | 26 ++++++++++--------- .../im/vector/app/ui/robot/RoomDetailRobot.kt | 18 ++++++------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/MessageMenuRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/MessageMenuRobot.kt index 0948ecb30d..8c77cb5757 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/MessageMenuRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/MessageMenuRobot.kt @@ -16,44 +16,46 @@ package im.vector.app.ui.robot -import androidx.test.espresso.Espresso -import com.adevinta.android.barista.interaction.BaristaClickInteractions +import androidx.test.espresso.Espresso.pressBack +import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaListInteractions +import com.adevinta.android.barista.interaction.BaristaListInteractions.clickListItem import im.vector.app.R +import java.lang.Thread.sleep class MessageMenuRobot( var autoClosed: Boolean = false ) { fun viewSource() { - BaristaClickInteractions.clickOn(R.string.view_source) + clickOn(R.string.view_source) // wait for library - Thread.sleep(1000) - Espresso.pressBack() + sleep(1000) + pressBack() autoClosed = true } fun editHistory() { - BaristaClickInteractions.clickOn(R.string.message_view_edit_history) - Espresso.pressBack() + clickOn(R.string.message_view_edit_history) + pressBack() autoClosed = true } fun addQuickReaction(quickReaction: String) { - BaristaClickInteractions.clickOn(quickReaction) + clickOn(quickReaction) autoClosed = true } fun addReactionFromEmojiPicker() { - BaristaClickInteractions.clickOn(R.string.message_add_reaction) + clickOn(R.string.message_add_reaction) // Wait for emoji to load, it's async now - Thread.sleep(2000) - BaristaListInteractions.clickListItem(R.id.emojiRecyclerView, 4) + sleep(2000) + clickListItem(R.id.emojiRecyclerView, 4) autoClosed = true } fun edit() { - BaristaClickInteractions.clickOn(R.string.edit) + clickOn(R.string.edit) autoClosed = true } } diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/RoomDetailRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/RoomDetailRobot.kt index f2978aa35f..5b3d7f4e77 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/RoomDetailRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/RoomDetailRobot.kt @@ -31,7 +31,9 @@ import com.adevinta.android.barista.interaction.BaristaMenuClickInteractions.cli import com.adevinta.android.barista.interaction.BaristaMenuClickInteractions.openMenu import im.vector.app.R import im.vector.app.espresso.tools.waitUntilViewVisible +import im.vector.app.features.home.room.detail.timeline.action.MessageActionsBottomSheet import im.vector.app.features.reactions.data.EmojiDataSource +import im.vector.app.interactWithSheet import im.vector.app.waitForView import java.lang.Thread.sleep @@ -39,6 +41,7 @@ class RoomDetailRobot { fun postMessage(content: String) { writeTo(R.id.composerEditText, content) + waitUntilViewVisible(withId(R.id.sendButton)) clickOn(R.id.sendButton) } @@ -63,7 +66,6 @@ class RoomDetailRobot { openMessageMenu(message) { addQuickReaction(quickReaction) } - waitUntilViewVisible(withId(R.id.composerEditText)) // Open reactions longClickOn(quickReaction) // wait for bottom sheet @@ -72,16 +74,13 @@ class RoomDetailRobot { openMessageMenu(message) { addReactionFromEmojiPicker() } - waitUntilViewVisible(withId(R.id.composerEditText)) // Test Edit mode openMessageMenu(message) { edit() } - waitUntilViewVisible(withId(R.id.composerEditText)) // TODO Cancel action writeTo(R.id.composerEditText, "Hello universe!") // Wait a bit for the keyboard layout to update - sleep(30) waitUntilViewVisible(withId(R.id.sendButton)) clickOn(R.id.sendButton) // Wait for the UI to update @@ -100,11 +99,12 @@ class RoomDetailRobot { ViewActions.longClick() ) ) - waitUntilViewVisible(withId(R.id.bottomSheetRecyclerView)) - val messageMenuRobot = MessageMenuRobot() - block(messageMenuRobot) - if (!messageMenuRobot.autoClosed) { - pressBack() + interactWithSheet(contentMatcher = withId(R.id.bottomSheetRecyclerView)) { + val messageMenuRobot = MessageMenuRobot() + block(messageMenuRobot) + if (!messageMenuRobot.autoClosed) { + pressBack() + } } }