From 67b7bc3d83794797ef8a8547b6ab92986f1630bf Mon Sep 17 00:00:00 2001 From: NIkita Fedrunov Date: Tue, 6 Sep 2022 00:00:35 +0200 Subject: [PATCH] fixed allscreens sanity test for enabled app layout flag --- .../vector/app/ui/UiAllScreensSanityTest.kt | 4 +- .../im/vector/app/ui/robot/ElementRobot.kt | 35 ++++++++-- .../im/vector/app/ui/robot/NewRoomRobot.kt | 8 ++- .../im/vector/app/ui/robot/RoomListRobot.kt | 17 ++++- .../app/ui/robot/space/SpaceCreateRobot.kt | 5 +- .../vector/app/ui/robot/space/SpaceRobot.kt | 68 +++++++++++++++---- .../main/res/layout/fragment_space_list.xml | 1 + 7 files changed, 112 insertions(+), 26 deletions(-) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt b/vector-app/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt index 9434006060..ad11d953d4 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt @@ -101,11 +101,11 @@ class UiAllScreensSanityTest { val spaceName = UUID.randomUUID().toString() elementRobot.space { - createSpace { + createSpace(true) { createAndCrawl(spaceName) } val publicSpaceName = UUID.randomUUID().toString() - createSpace { + createSpace(false) { createPublicSpace(publicSpaceName) } diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt index 528589d616..73e16f7796 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt @@ -84,33 +84,56 @@ class ElementRobot { } fun settings(shouldGoBack: Boolean = true, block: SettingsRobot.() -> Unit) { - openDrawer() - clickOn(R.id.homeDrawerHeaderSettingsView) + if (features.isNewAppLayoutEnabled()) { + onView(withId((R.id.avatar))).perform(click()) + } else { + openDrawer() + clickOn(R.id.homeDrawerHeaderSettingsView) + } + block(SettingsRobot()) if (shouldGoBack) pressBack() waitUntilViewVisible(withId(R.id.roomListContainer)) } fun newDirectMessage(block: NewDirectMessageRobot.() -> Unit) { - clickOn(R.id.bottom_action_people) - clickOn(R.id.createChatRoomButton) + 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.createChatRoomButton) + } + waitUntilActivityVisible { waitUntilViewVisible(withId(R.id.userListSearch)) } closeSoftKeyboard() block(NewDirectMessageRobot()) pressBack() + if (features.isNewAppLayoutEnabled()) { + pressBack() // close create dialog + } waitUntilViewVisible(withId(R.id.roomListContainer)) } fun newRoom(block: NewRoomRobot.() -> Unit) { - clickOn(R.id.bottom_action_rooms) + if (!features.isNewAppLayoutEnabled()) { + clickOn(R.id.bottom_action_rooms) + } RoomListRobot().newRoom { block() } + if (features.isNewAppLayoutEnabled()) { + pressBack() // close create dialog + } waitUntilViewVisible(withId(R.id.roomListContainer)) } fun roomList(block: RoomListRobot.() -> Unit) { - clickOn(R.id.bottom_action_rooms) + if (!features.isNewAppLayoutEnabled()) { + clickOn(R.id.bottom_action_rooms) + } + block(RoomListRobot()) waitUntilViewVisible(withId(R.id.roomListContainer)) } diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt index 09ff1162c0..979650fefe 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/NewRoomRobot.kt @@ -21,13 +21,19 @@ import androidx.test.espresso.matcher.ViewMatchers.withId import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import im.vector.app.R import im.vector.app.espresso.tools.waitUntilViewVisible +import im.vector.app.features.DefaultVectorFeatures +import im.vector.app.features.VectorFeatures class NewRoomRobot( var createdRoom: Boolean = false ) { + var features: VectorFeatures = DefaultVectorFeatures() + fun createNewRoom(block: CreateNewRoomRobot.() -> Unit) { - clickOn(R.string.create_new_room) + if (features.isNewAppLayoutEnabled()) { + clickOn(R.string.create_new_room) + } waitUntilViewVisible(withId(R.id.createRoomForm)) val createNewRoomRobot = CreateNewRoomRobot() block(createNewRoomRobot) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt index dc07f06202..203e43dd36 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/RoomListRobot.kt @@ -27,10 +27,15 @@ import com.adevinta.android.barista.assertion.BaristaVisibilityAssertions import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import im.vector.app.R 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 class RoomListRobot { + var features: VectorFeatures = DefaultVectorFeatures() + fun openRoom(roomName: String, block: RoomDetailRobot.() -> Unit) { clickOn(roomName) block(RoomDetailRobot()) @@ -49,9 +54,15 @@ class RoomListRobot { } fun newRoom(block: NewRoomRobot.() -> Unit) { - clickOn(R.id.createGroupRoomButton) - waitUntilActivityVisible { - BaristaVisibilityAssertions.assertDisplayed(R.id.publicRoomsList) + if (features.isNewAppLayoutEnabled()) { + clickOn(R.id.newLayoutCreateChatButton) + waitUntilDialogVisible(ViewMatchers.withId(R.id.create_room)) + clickOn(R.id.create_room) + } else { + clickOn(R.id.createGroupRoomButton) + waitUntilActivityVisible { + BaristaVisibilityAssertions.assertDisplayed(R.id.publicRoomsList) + } } val newRoomRobot = NewRoomRobot() block(newRoomRobot) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceCreateRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceCreateRobot.kt index 018f3097ba..e5147c2085 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceCreateRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceCreateRobot.kt @@ -31,6 +31,7 @@ import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilViewVisible import im.vector.app.features.home.HomeActivity +import im.vector.app.features.home.room.detail.RoomDetailActivity import im.vector.app.features.spaces.manage.SpaceManageActivity class SpaceCreateRobot { @@ -85,7 +86,9 @@ class SpaceCreateRobot { clickOn(R.id.nextButton) waitUntilViewVisible(withId(R.id.recyclerView)) clickOn(R.id.nextButton) - waitUntilDialogVisible(withId(R.id.inviteByMxidButton)) + waitUntilActivityVisible { + waitUntilDialogVisible(withId(R.id.inviteByMxidButton)) + } // close invite dialog pressBack() waitUntilViewVisible(withId(R.id.timelineRecyclerView)) diff --git a/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt b/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt index b8a2f4313b..c86743e89b 100644 --- a/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt +++ b/vector-app/src/androidTest/java/im/vector/app/ui/robot/space/SpaceRobot.kt @@ -18,6 +18,8 @@ package im.vector.app.ui.robot.space import androidx.recyclerview.widget.RecyclerView 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.matcher.ViewMatchers import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn @@ -26,18 +28,44 @@ import com.adevinta.android.barista.internal.viewaction.ClickChildAction import im.vector.app.R import im.vector.app.espresso.tools.waitUntilDialogVisible import im.vector.app.espresso.tools.waitUntilViewVisible +import im.vector.app.features.DefaultVectorFeatures +import im.vector.app.features.VectorFeatures import org.hamcrest.Matchers class SpaceRobot { - fun createSpace(block: SpaceCreateRobot.() -> Unit) { - openDrawer() - clickOn(R.string.create_space) + var features: VectorFeatures = DefaultVectorFeatures() + + 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( + ViewMatchers.hasDescendant(ViewMatchers.withId(R.id.plus)), + click() + ).atPosition(0) + ) + } + } else { + openDrawer() + clickOn(R.string.create_space) + } block(SpaceCreateRobot()) } fun spaceMenu(spaceName: String, block: SpaceMenuRobot.() -> Unit) { - openDrawer() + if (features.isNewAppLayoutEnabled()) { + clickOn(R.id.newLayoutOpenSpacesButton) + waitUntilDialogVisible(ViewMatchers.withId(R.id.groupListView)) + } else { + openDrawer() + } with(SpaceMenuRobot()) { openMenu(spaceName) block() @@ -46,19 +74,33 @@ class SpaceRobot { fun openMenu(spaceName: String) { waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) - Espresso.onView(ViewMatchers.withId(R.id.groupListView)) - .perform( - RecyclerViewActions.actionOnItem( - ViewMatchers.hasDescendant(Matchers.allOf(ViewMatchers.withId(R.id.groupNameView), ViewMatchers.withText(spaceName))), - ClickChildAction.clickChildWithId(R.id.groupTmpLeave) - ).atPosition(0) - ) + if (features.isNewAppLayoutEnabled()) { + Espresso.onView(ViewMatchers.withId(R.id.groupListView)) + .perform( + RecyclerViewActions.actionOnItem( + ViewMatchers.hasDescendant(Matchers.allOf(ViewMatchers.withId(R.id.name), ViewMatchers.withText(spaceName))), + longClick() + ).atPosition(0) + ) + } else { + Espresso.onView(ViewMatchers.withId(R.id.groupListView)) + .perform( + RecyclerViewActions.actionOnItem( + ViewMatchers.hasDescendant(Matchers.allOf(ViewMatchers.withId(R.id.groupNameView), ViewMatchers.withText(spaceName))), + ClickChildAction.clickChildWithId(R.id.groupTmpLeave) + ).atPosition(0) + ) + } + + waitUntilDialogVisible(ViewMatchers.withId(R.id.spaceNameView)) } fun selectSpace(spaceName: String) { - openDrawer() - waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) + if (!features.isNewAppLayoutEnabled()) { + openDrawer() + waitUntilViewVisible(ViewMatchers.withId(R.id.groupListView)) + } clickOn(spaceName) } } diff --git a/vector/src/main/res/layout/fragment_space_list.xml b/vector/src/main/res/layout/fragment_space_list.xml index 8dfbb4a9c6..e2822495bf 100644 --- a/vector/src/main/res/layout/fragment_space_list.xml +++ b/vector/src/main/res/layout/fragment_space_list.xml @@ -9,6 +9,7 @@ android:id="@+id/groupListView" android:layout_width="match_parent" android:layout_height="match_parent" + android:minHeight="195dp" android:overScrollMode="always" tools:listitem="@layout/item_space" />