1
0
Fork 0

For #5074 - Add UI tests for logins and passwords setting menu (#7291)

* For #5074 - Add UI tests for logins and passwords setting menu

* fix detekt failure

* remove old file

* fix scroll small screens

* fix reviewer comments
master
isabelrios 2019-12-26 23:22:40 +01:00 committed by Richard Pappalardo
parent 24f1846017
commit 491a198fae
5 changed files with 175 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import org.junit.Ignore
import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.ui.robots.homeScreen
/**
@ -107,6 +108,31 @@ class SettingsPrivacyTest {
}
}
// Tests only for initial state without signing in.
// For tests after singing in, see SyncIntegration test suite
@Test
fun loginsAndPasswordsTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
// Necessary to scroll a little bit for all screen sizes
TestHelper.scrollToElementByText("Logins and passwords")
}.openLoginsAndPasswordSubMenu {
verifyDefaultView()
verifyDefaultValueSyncLogins()
}.openSavedLogins {
verifySavedLoginsView()
tapSetupLater()
// Verify that logins list is empty
// Issue #7272 nothing is shown
}.goBack {
}.openSyncLogins {
verifyReadyToScanOption()
verifyUseEmailOption()
}
}
@Ignore("This is a stub test, ignore for now")
@Test
fun toggleTrackingProtection() {

View File

@ -121,6 +121,14 @@ class SettingsRobot {
SettingsSubMenuEnhancedTrackingProtectionRobot().interact()
return SettingsSubMenuEnhancedTrackingProtectionRobot.Transition()
}
fun openLoginsAndPasswordSubMenu(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition {
fun loginsAndPasswordsButton() = onView(ViewMatchers.withText("Logins and passwords"))
loginsAndPasswordsButton().click()
SettingsSubMenuLoginsAndPasswordRobot().interact()
return SettingsSubMenuLoginsAndPasswordRobot.Transition()
}
}
}

View File

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

View File

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

View File

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