For #16615: UI smoke test updateSavedLoginTest

upstream-sync
Oana Horvath 4 years ago
parent 5e046c8f04
commit 80ad6dea32

@ -174,7 +174,7 @@ class SettingsPrivacyTest {
verifyDefaultValueAutofillLogins() verifyDefaultValueAutofillLogins()
verifyDefaultValueExceptions() verifyDefaultValueExceptions()
}.openSavedLogins { }.openSavedLogins {
verifySavedLoginsView() verifySecurityPromptForLogins()
tapSetupLater() tapSetupLater()
// Verify that logins list is empty // Verify that logins list is empty
// Issue #7272 nothing is shown // Issue #7272 nothing is shown
@ -205,7 +205,7 @@ class SettingsPrivacyTest {
verifyDefaultView() verifyDefaultView()
verifyDefaultValueSyncLogins() verifyDefaultValueSyncLogins()
}.openSavedLogins { }.openSavedLogins {
verifySavedLoginsView() verifySecurityPromptForLogins()
tapSetupLater() tapSetupLater()
// Verify that the login appears correctly // Verify that the login appears correctly
verifySavedLoginFromPrompt() verifySavedLoginFromPrompt()
@ -230,7 +230,7 @@ class SettingsPrivacyTest {
verifyDefaultView() verifyDefaultView()
verifyDefaultValueSyncLogins() verifyDefaultValueSyncLogins()
}.openSavedLogins { }.openSavedLogins {
verifySavedLoginsView() verifySecurityPromptForLogins()
tapSetupLater() tapSetupLater()
// Verify that the login list is empty // Verify that the login list is empty
verifyNotSavedLoginFromPrompt() verifyNotSavedLoginFromPrompt()

@ -19,6 +19,7 @@ import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource
import org.mozilla.fenix.ui.robots.clickUrlbar import org.mozilla.fenix.ui.robots.clickUrlbar
import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.homeScreen
@ -427,4 +428,35 @@ class SmokeTest {
verifyPageContent(secondWebPage.content) verifyPageContent(secondWebPage.content)
} }
} }
@Test
fun updateSavedLoginTest() {
val saveLoginTest =
TestAssetHelper.getSaveLoginAsset(mockWebServer)
navigationToolbar {
}.enterURLAndEnterToBrowser(saveLoginTest.url) {
verifySaveLoginPromptIsShown()
// Click Save to save the login
saveLoginFromPrompt("Save")
}.openNavigationToolbar {
}.enterURLAndEnterToBrowser(saveLoginTest.url) {
enterPassword("test")
verifyUpdateLoginPromptIsShown()
// Click Update to change the saved password
saveLoginFromPrompt("Update")
}.openThreeDotMenu {
}.openSettings {
TestHelper.scrollToElementByText("Logins and passwords")
}.openLoginsAndPasswordSubMenu {
}.openSavedLogins {
verifySecurityPromptForLogins()
tapSetupLater()
// Verify that the login appears correctly
verifySavedLoginFromPrompt()
viewSavedLoginDetails()
revealPassword()
verifyPasswordSaved("test")
}
}
} }

@ -9,6 +9,7 @@ package org.mozilla.fenix.ui.robots
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.widget.EditText
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.action.ViewActions import androidx.test.espresso.action.ViewActions
@ -312,17 +313,34 @@ class BrowserRobot {
} }
fun verifySaveLoginPromptIsShown() { fun verifySaveLoginPromptIsShown() {
mDevice.waitNotNull(Until.findObjects(text("test@example.com")), waitingTime) mDevice.findObject(UiSelector().text("test@example.com")).waitForExists(waitingTime)
val submitButton = mDevice.findObject(By.res("submit")) val submitButton = mDevice.findObject(By.res("submit"))
submitButton.clickAndWait(Until.newWindow(), waitingTime) submitButton.clickAndWait(Until.newWindow(), waitingTime)
// Click save to save the login // Click save to save the login
mDevice.waitNotNull(Until.findObjects(text("Save"))) mDevice.waitNotNull(Until.findObjects(text("Save")))
} }
fun verifyUpdateLoginPromptIsShown() {
val submitButton = mDevice.findObject(By.res("submit"))
submitButton.clickAndWait(Until.newWindow(), waitingTime)
mDevice.waitNotNull(Until.findObjects(text("Update")))
}
fun saveLoginFromPrompt(optionToSaveLogin: String) { fun saveLoginFromPrompt(optionToSaveLogin: String) {
mDevice.findObject(text(optionToSaveLogin)).click() mDevice.findObject(text(optionToSaveLogin)).click()
} }
fun enterPassword(password: String) {
val passwordField = mDevice.findObject(
UiSelector()
.resourceId("password")
.className(EditText::class.java)
)
passwordField.waitForExists(waitingTime)
passwordField.setText(password)
}
fun clickMediaPlayerPlayButton() { fun clickMediaPlayerPlayButton() {
mediaPlayerPlayButton().waitForExists(waitingTime) mediaPlayerPlayButton().waitForExists(waitingTime)
mediaPlayerPlayButton().click() mediaPlayerPlayButton().click()

@ -10,11 +10,15 @@ import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.uiautomator.By import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import org.hamcrest.CoreMatchers import org.hamcrest.CoreMatchers
import org.hamcrest.CoreMatchers.containsString import org.hamcrest.CoreMatchers.containsString
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull import org.mozilla.fenix.helpers.ext.waitNotNull
/** /**
@ -22,7 +26,7 @@ import org.mozilla.fenix.helpers.ext.waitNotNull
*/ */
class SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot { class SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot {
fun verifySavedLoginsView() = assertSavedLoginsView() fun verifySecurityPromptForLogins() = assertSavedLoginsView()
fun verifySavedLoginsAfterSync() { fun verifySavedLoginsAfterSync() {
mDevice.waitNotNull( mDevice.waitNotNull(
@ -43,6 +47,13 @@ class SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot {
fun verifyLocalhostExceptionAdded() = onView(ViewMatchers.withText(containsString("localhost"))) fun verifyLocalhostExceptionAdded() = onView(ViewMatchers.withText(containsString("localhost")))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
fun viewSavedLoginDetails() = onView(ViewMatchers.withText("test@example.com")).click()
fun revealPassword() = onView(withId(R.id.revealPasswordButton)).click()
fun verifyPasswordSaved(password: String) =
onView(withId(R.id.passwordText)).check(matches(withText(password)))
class Transition { class Transition {
fun goBack(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition { fun goBack(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition {
goBackButton().perform(ViewActions.click()) goBackButton().perform(ViewActions.click())

Loading…
Cancel
Save