[fenix] For https://github.com/mozilla-mobile/fenix/issues/5074 - Add UI tests for logins and passwords setting menu (https://github.com/mozilla-mobile/fenix/pull/7291)
* For https://github.com/mozilla-mobile/fenix/issues/5074 - Add UI tests for logins and passwords setting menu * fix detekt failure * remove old file * fix scroll small screens * fix reviewer commentspull/600/head
parent
337e2fc0b7
commit
7aa2fd8263
@ -0,0 +1,62 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@file:Suppress("TooManyFunctions")
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.mozilla.fenix.helpers.click
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the Privacy Settings > logins and passwords sub menu
|
||||
*/
|
||||
class SettingsSubMenuLoginsAndPasswordRobot {
|
||||
|
||||
fun verifyDefaultView() = assertDefaultView()
|
||||
fun verifyDefaultValueSyncLogins() = asserDefaultValueSyncLogins()
|
||||
|
||||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||
|
||||
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
||||
goBackButton().perform(ViewActions.click())
|
||||
|
||||
SettingsRobot().interact()
|
||||
return SettingsRobot.Transition()
|
||||
}
|
||||
|
||||
fun openSavedLogins(interact: SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot.Transition {
|
||||
fun savedLoginsButton() = onView(ViewMatchers.withText("Saved logins"))
|
||||
savedLoginsButton().click()
|
||||
|
||||
SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot().interact()
|
||||
return SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot.Transition()
|
||||
}
|
||||
|
||||
fun openSyncLogins(interact: SettingsTurnOnSyncRobot.() -> Unit): SettingsTurnOnSyncRobot.Transition {
|
||||
fun syncLoginsButton() = onView(ViewMatchers.withText("Sync logins"))
|
||||
syncLoginsButton().click()
|
||||
|
||||
SettingsTurnOnSyncRobot().interact()
|
||||
return SettingsTurnOnSyncRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun goBackButton() =
|
||||
onView(CoreMatchers.allOf(ViewMatchers.withContentDescription("Navigate up")))
|
||||
|
||||
private fun assertDefaultView() = onView(ViewMatchers.withText("Sync logins"))
|
||||
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||
|
||||
private fun asserDefaultValueSyncLogins() = onView(ViewMatchers.withText("Sign in to Sync"))
|
||||
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
@ -0,0 +1,37 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import org.hamcrest.CoreMatchers
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the Privacy Settings > saved logins sub menu
|
||||
*/
|
||||
|
||||
class SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot {
|
||||
fun verifySavedLoginsView() = assertSavedLoginsView()
|
||||
|
||||
fun tapSetupLater() = onView(ViewMatchers.withText("Later")).perform(ViewActions.click())
|
||||
|
||||
class Transition {
|
||||
fun goBack(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition {
|
||||
goBackButton().perform(ViewActions.click())
|
||||
|
||||
SettingsSubMenuLoginsAndPasswordRobot().interact()
|
||||
return SettingsSubMenuLoginsAndPasswordRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun goBackButton() =
|
||||
onView(CoreMatchers.allOf(ViewMatchers.withContentDescription("Navigate up")))
|
||||
|
||||
private fun assertSavedLoginsView() = onView(ViewMatchers.withText("Secure your logins and passwords"))
|
||||
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
@ -0,0 +1,42 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.assertion.ViewAssertions
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import org.hamcrest.CoreMatchers
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the settings turn on sync option.
|
||||
*/
|
||||
class SettingsTurnOnSyncRobot {
|
||||
fun verifyUseEmailOption() = assertUseEmailField()
|
||||
|
||||
fun verifyReadyToScanOption() = assertReadyToScan()
|
||||
|
||||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||
|
||||
fun goBack(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition {
|
||||
goBackButton().perform(ViewActions.click())
|
||||
|
||||
SettingsSubMenuLoginsAndPasswordRobot().interact()
|
||||
return SettingsSubMenuLoginsAndPasswordRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun goBackButton() =
|
||||
Espresso.onView(CoreMatchers.allOf(ViewMatchers.withContentDescription("Navigate up")))
|
||||
|
||||
private fun assertUseEmailField() = Espresso.onView(ViewMatchers.withText("Use email instead"))
|
||||
.check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||
|
||||
private fun assertReadyToScan() = Espresso.onView(ViewMatchers.withText("Ready to scan"))
|
||||
.check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
Loading…
Reference in New Issue