From e800c59f57c0ad903e586e8cd322d7483ed2356e Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 4 Nov 2021 15:00:15 +0000 Subject: [PATCH] porting the new direct message checks to the robot pattern --- .../vector/app/ui/UiAllScreensSanityTest.kt | 27 ++++---------- .../im/vector/app/ui/robot/ElementRobot.kt | 18 ++++++++-- .../app/ui/robot/NewDirectMessageRobot.kt | 35 +++++++++++++++++++ 3 files changed, 57 insertions(+), 23 deletions(-) create mode 100644 vector/src/androidTest/java/im/vector/app/ui/robot/NewDirectMessageRobot.kt diff --git a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt index fef48c370d..1997cb32bb 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/UiAllScreensSanityTest.kt @@ -48,7 +48,6 @@ import im.vector.app.SleepViewAction import im.vector.app.activityIdlingResource import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.features.MainActivity -import im.vector.app.features.createdirect.CreateDirectRoomActivity import im.vector.app.features.home.HomeActivity import im.vector.app.features.home.room.detail.RoomDetailActivity import im.vector.app.features.login.LoginActivity @@ -74,7 +73,7 @@ class UiAllScreensSanityTest { val activityRule = ActivityScenarioRule(MainActivity::class.java) private val uiTestBase = UiTestBase() - private val appRobot = ElementRobot() + private val elementRobot = ElementRobot() // Last passing: // 2020-11-09 @@ -101,7 +100,7 @@ class UiAllScreensSanityTest { assertDisplayed(R.id.bottomNavigationView) // Settings - appRobot.settings { + elementRobot.settings { general { crawl() } notifications { crawl() } preferences { crawl() } @@ -113,9 +112,10 @@ class UiAllScreensSanityTest { helpAndAbout { crawl() } } - // Create DM - clickOn(R.id.bottom_action_people) - createDm() + elementRobot.newDirectMessage { + verifyQrCodeButton() + verifyInviteFriendsButton() + } // Create Room // First navigate to the other tab @@ -360,20 +360,5 @@ class UiAllScreensSanityTest { sleep(1000) clickBack() } - - private fun createDm() { - clickOn(R.id.createChatRoomButton) - - withIdlingResource(activityIdlingResource(CreateDirectRoomActivity::class.java)) { - onView(withId(R.id.userListRecyclerView)) - .perform(waitForView(withText(R.string.qr_code))) - onView(withId(R.id.userListRecyclerView)) - .perform(waitForView(withText(R.string.invite_friends))) - } - - closeSoftKeyboard() - pressBack() - pressBack() - } } diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt index f1053743cd..4b256170db 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt @@ -16,10 +16,14 @@ package im.vector.app.ui.robot -import androidx.test.espresso.Espresso +import androidx.test.espresso.Espresso.pressBack +import androidx.test.espresso.action.ViewActions import com.adevinta.android.barista.interaction.BaristaClickInteractions.clickOn import com.adevinta.android.barista.interaction.BaristaDrawerInteractions.openDrawer import im.vector.app.R +import im.vector.app.activityIdlingResource +import im.vector.app.features.createdirect.CreateDirectRoomActivity +import im.vector.app.withIdlingResource class ElementRobot { @@ -27,6 +31,16 @@ class ElementRobot { openDrawer() clickOn(R.id.homeDrawerHeaderSettingsView) block(SettingsRobot()) - Espresso.pressBack() + pressBack() + } + + fun newDirectMessage(block: NewDirectMessageRobot.() -> Unit) { + clickOn(R.id.bottom_action_people) + clickOn(R.id.createChatRoomButton) + ViewActions.closeSoftKeyboard() + withIdlingResource(activityIdlingResource(CreateDirectRoomActivity::class.java)) { + block(NewDirectMessageRobot()) + } + pressBack() } } diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/NewDirectMessageRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/NewDirectMessageRobot.kt new file mode 100644 index 0000000000..34c43c73f7 --- /dev/null +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/NewDirectMessageRobot.kt @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.ui.robot + +import androidx.test.espresso.Espresso +import androidx.test.espresso.matcher.ViewMatchers +import im.vector.app.R +import im.vector.app.waitForView + +class NewDirectMessageRobot { + + fun verifyQrCodeButton() { + Espresso.onView(ViewMatchers.withId(R.id.userListRecyclerView)) + .perform(waitForView(ViewMatchers.withText(R.string.qr_code))) + } + + fun verifyInviteFriendsButton() { + Espresso.onView(ViewMatchers.withId(R.id.userListRecyclerView)) + .perform(waitForView(ViewMatchers.withText(R.string.invite_friends))) + } +}