Skip to content

Commit

Permalink
For mozilla-mobile#16615: UI smoke test updateSavedLoginTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Oana Horvath committed Dec 8, 2020
1 parent 5e046c8 commit 80ad6de
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class SettingsPrivacyTest {
verifyDefaultValueAutofillLogins()
verifyDefaultValueExceptions()
}.openSavedLogins {
verifySavedLoginsView()
verifySecurityPromptForLogins()
tapSetupLater()
// Verify that logins list is empty
// Issue #7272 nothing is shown
Expand Down Expand Up @@ -205,7 +205,7 @@ class SettingsPrivacyTest {
verifyDefaultView()
verifyDefaultValueSyncLogins()
}.openSavedLogins {
verifySavedLoginsView()
verifySecurityPromptForLogins()
tapSetupLater()
// Verify that the login appears correctly
verifySavedLoginFromPrompt()
Expand All @@ -230,7 +230,7 @@ class SettingsPrivacyTest {
verifyDefaultView()
verifyDefaultValueSyncLogins()
}.openSavedLogins {
verifySavedLoginsView()
verifySecurityPromptForLogins()
tapSetupLater()
// Verify that the login list is empty
verifyNotSavedLoginFromPrompt()
Expand Down
32 changes: 32 additions & 0 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource
import org.mozilla.fenix.ui.robots.clickUrlbar
import org.mozilla.fenix.ui.robots.homeScreen
Expand Down Expand Up @@ -427,4 +428,35 @@ class SmokeTest {
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")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package org.mozilla.fenix.ui.robots
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.widget.EditText
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.action.ViewActions
Expand Down Expand Up @@ -312,17 +313,34 @@ class BrowserRobot {
}

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"))
submitButton.clickAndWait(Until.newWindow(), waitingTime)
// Click save to save the login
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) {
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() {
mediaPlayerPlayButton().waitForExists(waitingTime)
mediaPlayerPlayButton().click()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
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.Until
import org.hamcrest.CoreMatchers
import org.hamcrest.CoreMatchers.containsString
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull

/**
* Implementation of Robot Pattern for the Privacy Settings > saved logins sub menu
*/

class SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot {
fun verifySavedLoginsView() = assertSavedLoginsView()
fun verifySecurityPromptForLogins() = assertSavedLoginsView()

fun verifySavedLoginsAfterSync() {
mDevice.waitNotNull(
Expand All @@ -43,6 +47,13 @@ class SettingsSubMenuLoginsAndPasswordsSavedLoginsRobot {
fun verifyLocalhostExceptionAdded() = onView(ViewMatchers.withText(containsString("localhost")))
.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 {
fun goBack(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition {
goBackButton().perform(ViewActions.click())
Expand Down

0 comments on commit 80ad6de

Please sign in to comment.