extracting inner class to its own file and updating function names relative to their usage

This commit is contained in:
Adam Brown 2022-01-18 12:50:00 +00:00
parent 37c4d94109
commit 030d9ef351
2 changed files with 99 additions and 75 deletions

View File

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

View File

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