porting the new direct message checks to the robot pattern

This commit is contained in:
Adam Brown 2021-11-04 15:00:15 +00:00
parent 67fe07a385
commit e800c59f57
3 changed files with 57 additions and 23 deletions

View File

@ -48,7 +48,6 @@ import im.vector.app.SleepViewAction
import im.vector.app.activityIdlingResource import im.vector.app.activityIdlingResource
import im.vector.app.espresso.tools.waitUntilActivityVisible import im.vector.app.espresso.tools.waitUntilActivityVisible
import im.vector.app.features.MainActivity 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.HomeActivity
import im.vector.app.features.home.room.detail.RoomDetailActivity import im.vector.app.features.home.room.detail.RoomDetailActivity
import im.vector.app.features.login.LoginActivity import im.vector.app.features.login.LoginActivity
@ -74,7 +73,7 @@ class UiAllScreensSanityTest {
val activityRule = ActivityScenarioRule(MainActivity::class.java) val activityRule = ActivityScenarioRule(MainActivity::class.java)
private val uiTestBase = UiTestBase() private val uiTestBase = UiTestBase()
private val appRobot = ElementRobot() private val elementRobot = ElementRobot()
// Last passing: // Last passing:
// 2020-11-09 // 2020-11-09
@ -101,7 +100,7 @@ class UiAllScreensSanityTest {
assertDisplayed(R.id.bottomNavigationView) assertDisplayed(R.id.bottomNavigationView)
// Settings // Settings
appRobot.settings { elementRobot.settings {
general { crawl() } general { crawl() }
notifications { crawl() } notifications { crawl() }
preferences { crawl() } preferences { crawl() }
@ -113,9 +112,10 @@ class UiAllScreensSanityTest {
helpAndAbout { crawl() } helpAndAbout { crawl() }
} }
// Create DM elementRobot.newDirectMessage {
clickOn(R.id.bottom_action_people) verifyQrCodeButton()
createDm() verifyInviteFriendsButton()
}
// Create Room // Create Room
// First navigate to the other tab // First navigate to the other tab
@ -360,20 +360,5 @@ class UiAllScreensSanityTest {
sleep(1000) sleep(1000)
clickBack() 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()
}
} }

View File

@ -16,10 +16,14 @@
package im.vector.app.ui.robot 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.BaristaClickInteractions.clickOn
import com.adevinta.android.barista.interaction.BaristaDrawerInteractions.openDrawer import com.adevinta.android.barista.interaction.BaristaDrawerInteractions.openDrawer
import im.vector.app.R import im.vector.app.R
import im.vector.app.activityIdlingResource
import im.vector.app.features.createdirect.CreateDirectRoomActivity
import im.vector.app.withIdlingResource
class ElementRobot { class ElementRobot {
@ -27,6 +31,16 @@ class ElementRobot {
openDrawer() openDrawer()
clickOn(R.id.homeDrawerHeaderSettingsView) clickOn(R.id.homeDrawerHeaderSettingsView)
block(SettingsRobot()) 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()
} }
} }

View File

@ -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)))
}
}