mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
[fenix] Save logins and external links in custom tabs UI test
This commit is contained in:
parent
bee88db440
commit
c874f11dc7
@ -26,6 +26,8 @@ import org.mozilla.fenix.ui.robots.searchScreen
|
||||
class CustomTabsTest {
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
private val customMenuItem = "TestMenuItem"
|
||||
private val externalLinksPWAPage = "https://mozilla-mobile.github.io/testapp/externalLinks.html"
|
||||
private val loginPage = "https://mozilla-mobile.github.io/testapp/loginForm"
|
||||
|
||||
@get:Rule
|
||||
val activityTestRule = HomeActivityIntentTestRule()
|
||||
@ -53,6 +55,59 @@ class CustomTabsTest {
|
||||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun customTabsOpenExternalLinkTest() {
|
||||
|
||||
intentReceiverActivityTestRule.launchActivity(
|
||||
createCustomTabIntent(
|
||||
externalLinksPWAPage.toUri().toString(),
|
||||
customMenuItem
|
||||
)
|
||||
)
|
||||
|
||||
customTabScreen {
|
||||
waitForPageToLoad()
|
||||
clickLinkMatchingText("External link")
|
||||
waitForPageToLoad()
|
||||
verifyCustomTabToolbarTitle("Google")
|
||||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun customTabsSaveLoginTest() {
|
||||
|
||||
intentReceiverActivityTestRule.launchActivity(
|
||||
createCustomTabIntent(
|
||||
loginPage.toUri().toString(),
|
||||
customMenuItem
|
||||
)
|
||||
)
|
||||
|
||||
customTabScreen {
|
||||
waitForPageToLoad()
|
||||
fillAndSubmitLoginCredentials("mozilla", "firefox")
|
||||
}
|
||||
|
||||
browserScreen {
|
||||
verifySaveLoginPromptIsDisplayed()
|
||||
saveLoginFromPrompt("Save")
|
||||
}
|
||||
|
||||
openAppFromExternalLink(loginPage)
|
||||
|
||||
browserScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openLoginsAndPasswordSubMenu {
|
||||
}.openSavedLogins {
|
||||
verifySecurityPromptForLogins()
|
||||
tapSetupLater()
|
||||
verifySavedLoginFromPrompt("mozilla")
|
||||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun customTabCopyToolbarUrlTest() {
|
||||
|
@ -11,6 +11,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.UiObjectNotFoundException
|
||||
import androidx.test.uiautomator.UiSelector
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.mozilla.fenix.R
|
||||
@ -84,6 +85,48 @@ class CustomTabRobot {
|
||||
copyText.click()
|
||||
}
|
||||
|
||||
fun fillAndSubmitLoginCredentials(userName: String, password: String) {
|
||||
var currentTries = 0
|
||||
while (currentTries++ < 3) {
|
||||
try {
|
||||
mDevice.waitForIdle(waitingTime)
|
||||
userNameTextBox.setText(userName)
|
||||
passwordTextBox.setText(password)
|
||||
submitLoginButton.click()
|
||||
mDevice.waitForObjects(mDevice.findObject(UiSelector().resourceId("$packageName:id/save_confirm")))
|
||||
break
|
||||
} catch (e: UiObjectNotFoundException) {
|
||||
customTabScreen {
|
||||
}.openMainMenu {
|
||||
refreshButton().click()
|
||||
waitForPageToLoad()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun clickLinkMatchingText(expectedText: String) {
|
||||
var currentTries = 0
|
||||
while (currentTries++ < 3) {
|
||||
try {
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
||||
.waitForExists(waitingTime)
|
||||
mDevice.findObject(UiSelector().textContains(expectedText))
|
||||
.waitForExists(waitingTime)
|
||||
|
||||
val element = mDevice.findObject(UiSelector().textContains(expectedText))
|
||||
element.click()
|
||||
break
|
||||
} catch (e: UiObjectNotFoundException) {
|
||||
customTabScreen {
|
||||
}.openMainMenu {
|
||||
refreshButton().click()
|
||||
waitForPageToLoad()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun waitForPageToLoad() = progressBar.waitUntilGone(waitingTime)
|
||||
|
||||
class Transition {
|
||||
@ -131,3 +174,13 @@ private val progressBar =
|
||||
mDevice.findObject(
|
||||
UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_progress")
|
||||
)
|
||||
|
||||
private val submitLoginButton =
|
||||
mDevice.findObject(
|
||||
UiSelector()
|
||||
.index(2)
|
||||
.resourceId("submit")
|
||||
.textContains("Submit Query")
|
||||
.className("android.widget.Button")
|
||||
.packageName("$packageName")
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user