From 030d9ef351092e644672680dd6f1280073469853 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 18 Jan 2022 12:50:00 +0000 Subject: [PATCH] extracting inner class to its own file and updating function names relative to their usage --- .../im/vector/app/ui/robot/OnboardingRobot.kt | 77 +-------------- .../app/ui/robot/OnboardingServersRobot.kt | 97 +++++++++++++++++++ 2 files changed, 99 insertions(+), 75 deletions(-) create mode 100644 vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingServersRobot.kt diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt index 57693709c6..62d446fe84 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingRobot.kt @@ -40,13 +40,13 @@ class OnboardingRobot { private fun crawlGetStarted() { clickOn(R.id.loginSplashSubmit) - AuthOptionsRobot().crawlGetStarted() + OnboardingServersRobot().crawlSignUp() pressBack() } private fun crawlAlreadyHaveAccount() { clickOn(R.id.loginSplashAlreadyHaveAccount) - AuthOptionsRobot().crawlAlreadyHaveAccount() + OnboardingServersRobot().crawlSignIn() pressBack() } @@ -92,76 +92,3 @@ class OnboardingRobot { clickOn(R.id.loginSubmit) } } - -class AuthOptionsRobot { - - fun crawlGetStarted() { - assertDisplayed(R.id.loginServerTitle, R.string.login_server_title) - crawlMatrixServer(isSignUp = true) - crawlEmsServer() - crawlOtherServer(isSignUp = true) - crawlSignInWithMatrixId() - } - - fun crawlAlreadyHaveAccount() { - assertDisplayed(R.id.loginServerTitle, R.string.login_server_title) - crawlMatrixServer(isSignUp = false) - crawlEmsServer() - crawlOtherServer(isSignUp = false) - crawlSignInWithMatrixId() - } - - private fun crawlOtherServer(isSignUp: Boolean) { - clickOn(R.id.loginServerChoiceOther) - waitUntilViewVisible(withId(R.id.loginServerUrlFormTitle)) - writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://chat.mozilla.org") - clickOn(R.id.loginServerUrlFormSubmit) - waitUntilViewVisible(withId(R.id.loginSignupSigninTitle)) - assertDisplayed(R.id.loginSignupSigninText, "Connect to chat.mozilla.org") - assertDisplayed(R.id.loginSignupSigninSubmit, R.string.login_signin_sso) - pressBack() - - writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://matrix.org") - clickOn(R.id.loginServerUrlFormSubmit) - assetMatrixSignInOptions(isSignUp) - pressBack() - pressBack() - } - - private fun crawlEmsServer() { - clickOn(R.id.loginServerChoiceEms) - waitUntilViewVisible(withId(R.id.loginServerUrlFormTitle)) - assertDisplayed(R.id.loginServerUrlFormTitle, R.string.login_connect_to_modular) - - writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://one.ems.host") - clickOn(R.id.loginServerUrlFormSubmit) - - waitUntilViewVisible(withId(R.id.loginSignupSigninTitle)) - assertDisplayed(R.id.loginSignupSigninText, "one.ems.host") - assertDisplayed(R.id.loginSignupSigninSubmit, R.string.login_signin_sso) - pressBack() - pressBack() - } - - private fun crawlMatrixServer(isSignUp: Boolean) { - clickOn(R.id.loginServerChoiceMatrixOrg) - assetMatrixSignInOptions(isSignUp) - pressBack() - } - - private fun assetMatrixSignInOptions(isSignUp: Boolean) { - waitUntilViewVisible(withId(R.id.loginTitle)) - when (isSignUp) { - true -> assertDisplayed(R.id.loginTitle, "Sign up to matrix.org") - false -> assertDisplayed(R.id.loginTitle, "Connect to matrix.org") - } - } - - private fun crawlSignInWithMatrixId() { - clickOn(R.id.loginServerIKnowMyIdSubmit) - waitUntilViewVisible(withId(R.id.loginTitle)) - assertDisplayed(R.id.loginTitle, R.string.login_signin_matrix_id_title) - pressBack() - } -} - diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingServersRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingServersRobot.kt new file mode 100644 index 0000000000..1625b4580d --- /dev/null +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingServersRobot.kt @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2022 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 com.adevinta.android.barista.assertion.BaristaVisibilityAssertions +import com.adevinta.android.barista.interaction.BaristaClickInteractions +import com.adevinta.android.barista.interaction.BaristaEditTextInteractions +import im.vector.app.R +import im.vector.app.espresso.tools.waitUntilViewVisible + +class OnboardingServersRobot { + + fun crawlSignUp() { + BaristaVisibilityAssertions.assertDisplayed(R.id.loginServerTitle, R.string.login_server_title) + crawlMatrixServer(isSignUp = true) + crawlEmsServer() + crawlOtherServer(isSignUp = true) + crawlSignInWithMatrixId() + } + + fun crawlSignIn() { + BaristaVisibilityAssertions.assertDisplayed(R.id.loginServerTitle, R.string.login_server_title) + crawlMatrixServer(isSignUp = false) + crawlEmsServer() + crawlOtherServer(isSignUp = false) + crawlSignInWithMatrixId() + } + + private fun crawlOtherServer(isSignUp: Boolean) { + BaristaClickInteractions.clickOn(R.id.loginServerChoiceOther) + waitUntilViewVisible(ViewMatchers.withId(R.id.loginServerUrlFormTitle)) + BaristaEditTextInteractions.writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://chat.mozilla.org") + BaristaClickInteractions.clickOn(R.id.loginServerUrlFormSubmit) + waitUntilViewVisible(ViewMatchers.withId(R.id.loginSignupSigninTitle)) + BaristaVisibilityAssertions.assertDisplayed(R.id.loginSignupSigninText, "Connect to chat.mozilla.org") + BaristaVisibilityAssertions.assertDisplayed(R.id.loginSignupSigninSubmit, R.string.login_signin_sso) + Espresso.pressBack() + + BaristaEditTextInteractions.writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://matrix.org") + BaristaClickInteractions.clickOn(R.id.loginServerUrlFormSubmit) + assetMatrixSignInOptions(isSignUp) + Espresso.pressBack() + Espresso.pressBack() + } + + private fun crawlEmsServer() { + BaristaClickInteractions.clickOn(R.id.loginServerChoiceEms) + waitUntilViewVisible(ViewMatchers.withId(R.id.loginServerUrlFormTitle)) + BaristaVisibilityAssertions.assertDisplayed(R.id.loginServerUrlFormTitle, R.string.login_connect_to_modular) + + BaristaEditTextInteractions.writeTo(R.id.loginServerUrlFormHomeServerUrl, "https://one.ems.host") + BaristaClickInteractions.clickOn(R.id.loginServerUrlFormSubmit) + + waitUntilViewVisible(ViewMatchers.withId(R.id.loginSignupSigninTitle)) + BaristaVisibilityAssertions.assertDisplayed(R.id.loginSignupSigninText, "one.ems.host") + BaristaVisibilityAssertions.assertDisplayed(R.id.loginSignupSigninSubmit, R.string.login_signin_sso) + Espresso.pressBack() + Espresso.pressBack() + } + + private fun crawlMatrixServer(isSignUp: Boolean) { + BaristaClickInteractions.clickOn(R.id.loginServerChoiceMatrixOrg) + assetMatrixSignInOptions(isSignUp) + Espresso.pressBack() + } + + private fun assetMatrixSignInOptions(isSignUp: Boolean) { + waitUntilViewVisible(ViewMatchers.withId(R.id.loginTitle)) + when (isSignUp) { + true -> BaristaVisibilityAssertions.assertDisplayed(R.id.loginTitle, "Sign up to matrix.org") + false -> BaristaVisibilityAssertions.assertDisplayed(R.id.loginTitle, "Connect to matrix.org") + } + } + + private fun crawlSignInWithMatrixId() { + BaristaClickInteractions.clickOn(R.id.loginServerIKnowMyIdSubmit) + waitUntilViewVisible(ViewMatchers.withId(R.id.loginTitle)) + BaristaVisibilityAssertions.assertDisplayed(R.id.loginTitle, R.string.login_signin_matrix_id_title) + Espresso.pressBack() + } +}