Merge pull request #5093 from vector-im/feature/adm/test-code-quality-warnings

UI test clean ups
This commit is contained in:
Benoit Marty 2022-01-28 18:49:03 +01:00 committed by GitHub
commit 0dce0342b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View file

@ -195,6 +195,9 @@ fun activityIdlingResource(activityClass: Class<*>): IdlingResource {
println("*** [$name] onActivityLifecycleChanged callback: $callback") println("*** [$name] onActivityLifecycleChanged callback: $callback")
callback?.onTransitionToIdle() callback?.onTransitionToIdle()
} }
else -> {
// do nothing, we're blocking until the activity resumes
}
} }
} }
} }

View file

@ -17,12 +17,16 @@
package im.vector.app.ui.robot package im.vector.app.ui.robot
import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.matcher.ViewMatchers.withText
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import com.adevinta.android.barista.interaction.BaristaListInteractions.clickListItem import com.adevinta.android.barista.interaction.BaristaListInteractions.clickListItem
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import im.vector.app.R import im.vector.app.R
import im.vector.app.espresso.tools.waitUntilActivityVisible
import im.vector.app.espresso.tools.waitUntilViewVisible
import im.vector.app.features.home.room.detail.timeline.edithistory.ViewEditHistoryBottomSheet import im.vector.app.features.home.room.detail.timeline.edithistory.ViewEditHistoryBottomSheet
import im.vector.app.features.reactions.EmojiReactionPickerActivity
import im.vector.app.interactWithSheet import im.vector.app.interactWithSheet
import java.lang.Thread.sleep import java.lang.Thread.sleep
@ -54,7 +58,10 @@ class MessageMenuRobot(
fun addReactionFromEmojiPicker() { fun addReactionFromEmojiPicker() {
clickOn(R.string.message_add_reaction) clickOn(R.string.message_add_reaction)
// Wait for emoji to load, it's async now // Wait for emoji to load, it's async now
sleep(2000) waitUntilActivityVisible<EmojiReactionPickerActivity> {
waitUntilViewVisible(withId(R.id.emojiRecyclerView))
waitUntilViewVisible(withText("😀"))
}
clickListItem(R.id.emojiRecyclerView, 4) clickListItem(R.id.emojiRecyclerView, 4)
autoClosed = true autoClosed = true
} }

View file

@ -20,13 +20,13 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.action.ViewActions import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.longClick
import androidx.test.espresso.contrib.RecyclerViewActions import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.matcher.ViewMatchers.withText
import com.adevinta.android.barista.interaction.BaristaClickInteractions import com.adevinta.android.barista.interaction.BaristaClickInteractions
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import com.adevinta.android.barista.interaction.BaristaClickInteractions.longClickOn
import com.adevinta.android.barista.interaction.BaristaEditTextInteractions.writeTo import com.adevinta.android.barista.interaction.BaristaEditTextInteractions.writeTo
import com.adevinta.android.barista.interaction.BaristaMenuClickInteractions.clickMenu import com.adevinta.android.barista.interaction.BaristaMenuClickInteractions.clickMenu
import com.adevinta.android.barista.interaction.BaristaMenuClickInteractions.openMenu import com.adevinta.android.barista.interaction.BaristaMenuClickInteractions.openMenu
@ -70,6 +70,7 @@ class RoomDetailRobot {
openMessageMenu(message) { openMessageMenu(message) {
addQuickReaction(quickReaction) addQuickReaction(quickReaction)
} }
waitUntilViewVisible(withText(quickReaction))
println("Open reactions bottom sheet") println("Open reactions bottom sheet")
// Open reactions // Open reactions
longClickReaction(quickReaction) longClickReaction(quickReaction)
@ -103,7 +104,7 @@ class RoomDetailRobot {
private fun longClickReaction(quickReaction: String) { private fun longClickReaction(quickReaction: String) {
withRetry { withRetry {
longClickOn(quickReaction) onView(withText(quickReaction)).perform(longClick())
} }
} }