Merge pull request #7020 from vector-im/feature/nfe/app_layout_all_screens_test

fixed allscreens sanity test for enabled app layout flag
This commit is contained in:
Benoit Marty 2022-09-07 13:57:17 +02:00 committed by GitHub
commit bdfbbbb2e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 109 additions and 29 deletions

View File

@ -101,11 +101,11 @@ class UiAllScreensSanityTest {
val spaceName = UUID.randomUUID().toString() val spaceName = UUID.randomUUID().toString()
elementRobot.space { elementRobot.space {
createSpace { createSpace(true) {
createAndCrawl(spaceName) createAndCrawl(spaceName)
} }
val publicSpaceName = UUID.randomUUID().toString() val publicSpaceName = UUID.randomUUID().toString()
createSpace { createSpace(false) {
createPublicSpace(publicSpaceName) createPublicSpace(publicSpaceName)
} }

View File

@ -51,8 +51,7 @@ import im.vector.app.withIdlingResource
import timber.log.Timber import timber.log.Timber
class ElementRobot { class ElementRobot {
private val features: VectorFeatures = DefaultVectorFeatures()
var features: VectorFeatures = DefaultVectorFeatures()
fun onboarding(block: OnboardingRobot.() -> Unit) { fun onboarding(block: OnboardingRobot.() -> Unit) {
block(OnboardingRobot()) block(OnboardingRobot())
@ -84,33 +83,56 @@ class ElementRobot {
} }
fun settings(shouldGoBack: Boolean = true, block: SettingsRobot.() -> Unit) { fun settings(shouldGoBack: Boolean = true, block: SettingsRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) {
onView(withId((R.id.avatar))).perform(click())
} else {
openDrawer() openDrawer()
clickOn(R.id.homeDrawerHeaderSettingsView) clickOn(R.id.homeDrawerHeaderSettingsView)
}
block(SettingsRobot()) block(SettingsRobot())
if (shouldGoBack) pressBack() if (shouldGoBack) pressBack()
waitUntilViewVisible(withId(R.id.roomListContainer)) waitUntilViewVisible(withId(R.id.roomListContainer))
} }
fun newDirectMessage(block: NewDirectMessageRobot.() -> Unit) { fun newDirectMessage(block: NewDirectMessageRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) {
clickOn(R.id.newLayoutCreateChatButton)
waitUntilDialogVisible(withId(R.id.start_chat))
clickOn(R.id.start_chat)
} else {
clickOn(R.id.bottom_action_people) clickOn(R.id.bottom_action_people)
clickOn(R.id.createChatRoomButton) clickOn(R.id.createChatRoomButton)
}
waitUntilActivityVisible<CreateDirectRoomActivity> { waitUntilActivityVisible<CreateDirectRoomActivity> {
waitUntilViewVisible(withId(R.id.userListSearch)) waitUntilViewVisible(withId(R.id.userListSearch))
} }
closeSoftKeyboard() closeSoftKeyboard()
block(NewDirectMessageRobot()) block(NewDirectMessageRobot())
pressBack() pressBack()
if (features.isNewAppLayoutEnabled()) {
pressBack() // close create dialog
}
waitUntilViewVisible(withId(R.id.roomListContainer)) waitUntilViewVisible(withId(R.id.roomListContainer))
} }
fun newRoom(block: NewRoomRobot.() -> Unit) { fun newRoom(block: NewRoomRobot.() -> Unit) {
if (!features.isNewAppLayoutEnabled()) {
clickOn(R.id.bottom_action_rooms) clickOn(R.id.bottom_action_rooms)
}
RoomListRobot().newRoom { block() } RoomListRobot().newRoom { block() }
if (features.isNewAppLayoutEnabled()) {
pressBack() // close create dialog
}
waitUntilViewVisible(withId(R.id.roomListContainer)) waitUntilViewVisible(withId(R.id.roomListContainer))
} }
fun roomList(block: RoomListRobot.() -> Unit) { fun roomList(block: RoomListRobot.() -> Unit) {
if (!features.isNewAppLayoutEnabled()) {
clickOn(R.id.bottom_action_rooms) clickOn(R.id.bottom_action_rooms)
}
block(RoomListRobot()) block(RoomListRobot())
waitUntilViewVisible(withId(R.id.roomListContainer)) waitUntilViewVisible(withId(R.id.roomListContainer))
} }

View File

@ -21,13 +21,18 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import im.vector.app.R import im.vector.app.R
import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.espresso.tools.waitUntilViewVisible
import im.vector.app.features.DefaultVectorFeatures
import im.vector.app.features.VectorFeatures
class NewRoomRobot( class NewRoomRobot(
var createdRoom: Boolean = false var createdRoom: Boolean = false
) { ) {
private val features: VectorFeatures = DefaultVectorFeatures()
fun createNewRoom(block: CreateNewRoomRobot.() -> Unit) { fun createNewRoom(block: CreateNewRoomRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) {
clickOn(R.string.create_new_room) clickOn(R.string.create_new_room)
}
waitUntilViewVisible(withId(R.id.createRoomForm)) waitUntilViewVisible(withId(R.id.createRoomForm))
val createNewRoomRobot = CreateNewRoomRobot() val createNewRoomRobot = CreateNewRoomRobot()
block(createNewRoomRobot) block(createNewRoomRobot)

View File

@ -33,7 +33,6 @@ import im.vector.app.features.DefaultVectorFeatures
import im.vector.app.waitForView import im.vector.app.waitForView
class OnboardingRobot { class OnboardingRobot {
private val defaultVectorFeatures = DefaultVectorFeatures() private val defaultVectorFeatures = DefaultVectorFeatures()
fun crawl() { fun crawl() {

View File

@ -27,9 +27,13 @@ import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions
import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
import im.vector.app.R import im.vector.app.R
import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.espresso.tools.waitUntilActivityVisible
import im.vector.app.espresso.tools.waitUntilDialogVisible
import im.vector.app.features.DefaultVectorFeatures
import im.vector.app.features.VectorFeatures
import im.vector.app.features.roomdirectory.RoomDirectoryActivity import im.vector.app.features.roomdirectory.RoomDirectoryActivity
class RoomListRobot { class RoomListRobot {
private val features: VectorFeatures = DefaultVectorFeatures()
fun openRoom(roomName: String, block: RoomDetailRobot.() -> Unit) { fun openRoom(roomName: String, block: RoomDetailRobot.() -> Unit) {
clickOn(roomName) clickOn(roomName)
@ -49,10 +53,16 @@ class RoomListRobot {
} }
fun newRoom(block: NewRoomRobot.() -> Unit) { fun newRoom(block: NewRoomRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) {
clickOn(R.id.newLayoutCreateChatButton)
waitUntilDialogVisible(ViewMatchers.withId(R.id.create_room))
clickOn(R.id.create_room)
} else {
clickOn(R.id.createGroupRoomButton) clickOn(R.id.createGroupRoomButton)
waitUntilActivityVisible<RoomDirectoryActivity> { waitUntilActivityVisible<RoomDirectoryActivity> {
BaristaVisibilityAssertions.assertDisplayed(R.id.publicRoomsList) BaristaVisibilityAssertions.assertDisplayed(R.id.publicRoomsList)
} }
}
val newRoomRobot = NewRoomRobot() val newRoomRobot = NewRoomRobot()
block(newRoomRobot) block(newRoomRobot)
if (!newRoomRobot.createdRoom) { if (!newRoomRobot.createdRoom) {

View File

@ -31,6 +31,7 @@ import im.vector.app.espresso.tools.waitUntilActivityVisible
import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilDialogVisible
import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.espresso.tools.waitUntilViewVisible
import im.vector.app.features.home.HomeActivity import im.vector.app.features.home.HomeActivity
import im.vector.app.features.home.room.detail.RoomDetailActivity
import im.vector.app.features.spaces.manage.SpaceManageActivity import im.vector.app.features.spaces.manage.SpaceManageActivity
class SpaceCreateRobot { class SpaceCreateRobot {
@ -85,7 +86,9 @@ class SpaceCreateRobot {
clickOn(R.id.nextButton) clickOn(R.id.nextButton)
waitUntilViewVisible(withId(R.id.recyclerView)) waitUntilViewVisible(withId(R.id.recyclerView))
clickOn(R.id.nextButton) clickOn(R.id.nextButton)
waitUntilActivityVisible<RoomDetailActivity> {
waitUntilDialogVisible(withId(R.id.inviteByMxidButton)) waitUntilDialogVisible(withId(R.id.inviteByMxidButton))
}
// close invite dialog // close invite dialog
pressBack() pressBack()
waitUntilViewVisible(withId(R.id.timelineRecyclerView)) waitUntilViewVisible(withId(R.id.timelineRecyclerView))

View File

@ -18,6 +18,8 @@ package im.vector.app.ui.robot.space
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.Espresso import androidx.test.espresso.Espresso
import androidx.test.espresso.action.ViewActions.click
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 com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn
@ -26,18 +28,43 @@ import com.adevinta.android.barista.internal.viewaction.ClickChildAction
import im.vector.app.R import im.vector.app.R
import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilDialogVisible
import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.espresso.tools.waitUntilViewVisible
import im.vector.app.features.DefaultVectorFeatures
import im.vector.app.features.VectorFeatures
import org.hamcrest.Matchers import org.hamcrest.Matchers
class SpaceRobot { class SpaceRobot {
private val features: VectorFeatures = DefaultVectorFeatures()
fun createSpace(block: SpaceCreateRobot.() -> Unit) { fun createSpace(isFirstSpace: Boolean, block: SpaceCreateRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) {
clickOn(R.id.newLayoutOpenSpacesButton)
if (isFirstSpace) {
waitUntilDialogVisible(ViewMatchers.withId(R.id.spaces_empty_group))
clickOn(R.id.spaces_empty_button)
} else {
waitUntilDialogVisible(ViewMatchers.withId(R.id.groupListView))
Espresso.onView(ViewMatchers.withId(R.id.groupListView))
.perform(
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
ViewMatchers.hasDescendant(ViewMatchers.withId(R.id.plus)),
click()
).atPosition(0)
)
}
} else {
openDrawer() openDrawer()
clickOn(R.string.create_space) clickOn(R.string.create_space)
}
block(SpaceCreateRobot()) block(SpaceCreateRobot())
} }
fun spaceMenu(spaceName: String, block: SpaceMenuRobot.() -> Unit) { fun spaceMenu(spaceName: String, block: SpaceMenuRobot.() -> Unit) {
if (features.isNewAppLayoutEnabled()) {
clickOn(R.id.newLayoutOpenSpacesButton)
waitUntilDialogVisible(ViewMatchers.withId(R.id.groupListView))
} else {
openDrawer() openDrawer()
}
with(SpaceMenuRobot()) { with(SpaceMenuRobot()) {
openMenu(spaceName) openMenu(spaceName)
block() block()
@ -46,6 +73,15 @@ class SpaceRobot {
fun openMenu(spaceName: String) { fun openMenu(spaceName: String) {
waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView))
if (features.isNewAppLayoutEnabled()) {
Espresso.onView(ViewMatchers.withId(R.id.groupListView))
.perform(
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
ViewMatchers.hasDescendant(Matchers.allOf(ViewMatchers.withId(R.id.name), ViewMatchers.withText(spaceName))),
longClick()
).atPosition(0)
)
} else {
Espresso.onView(ViewMatchers.withId(R.id.groupListView)) Espresso.onView(ViewMatchers.withId(R.id.groupListView))
.perform( .perform(
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>( RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
@ -53,12 +89,16 @@ class SpaceRobot {
ClickChildAction.clickChildWithId(R.id.groupTmpLeave) ClickChildAction.clickChildWithId(R.id.groupTmpLeave)
).atPosition(0) ).atPosition(0)
) )
}
waitUntilDialogVisible(ViewMatchers.withId(R.id.spaceNameView)) waitUntilDialogVisible(ViewMatchers.withId(R.id.spaceNameView))
} }
fun selectSpace(spaceName: String) { fun selectSpace(spaceName: String) {
if (!features.isNewAppLayoutEnabled()) {
openDrawer() openDrawer()
waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView))
}
clickOn(spaceName) clickOn(spaceName)
} }
} }

View File

@ -9,6 +9,7 @@
android:id="@+id/groupListView" android:id="@+id/groupListView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:minHeight="195dp"
android:overScrollMode="always" android:overScrollMode="always"
tools:listitem="@layout/item_space" /> tools:listitem="@layout/item_space" />