mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
waiting for the message actions bottom sheet when interacting with the message options
This commit is contained in:
parent
39b4116699
commit
fc865682b1
2 changed files with 23 additions and 21 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<MessageActionsBottomSheet>(contentMatcher = withId(R.id.bottomSheetRecyclerView)) {
|
||||
val messageMenuRobot = MessageMenuRobot()
|
||||
block(messageMenuRobot)
|
||||
if (!messageMenuRobot.autoClosed) {
|
||||
pressBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue