2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

New External links PWA tests

This commit is contained in:
AndiAJ 2022-01-26 15:34:18 +02:00 committed by mergify[bot]
parent 82a6f8cae4
commit 7ed5bf9cc5
4 changed files with 122 additions and 0 deletions

View File

@ -10,6 +10,8 @@ object Constants {
const val GOOGLE_PLAY_SERVICES = "com.android.vending"
const val GOOGLE_APPS_PHOTOS = "com.google.android.apps.photos"
const val YOUTUBE_APP = "com.google.android.youtube"
const val GMAIL_APP = "com.google.android.gm"
const val PHONE_APP = "com.google.android.dialer"
}
const val LONG_CLICK_DURATION: Long = 5000

View File

@ -0,0 +1,86 @@
package org.mozilla.fenix.ui
import androidx.core.net.toUri
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.helpers.Constants.PackageName.GMAIL_APP
import org.mozilla.fenix.helpers.Constants.PackageName.PHONE_APP
import org.mozilla.fenix.helpers.FeatureSettingsHelper
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.TestHelper.assertNativeAppOpens
import org.mozilla.fenix.ui.robots.customTabScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
class PwaTest {
private val featureSettingsHelper = FeatureSettingsHelper()
private val externalLinksPWAPage = "https://mozilla-mobile.github.io/testapp/externalLinks.html"
private val emailLink = "mailto://example@example.com"
private val phoneLink = "tel://1234567890"
private val shortcutTitle = "TEST_APP"
@get:Rule
val activityTestRule = HomeActivityIntentTestRule()
@Before
fun setUp() {
featureSettingsHelper.disablePwaCFR(true)
}
@After
fun tearDown() {
featureSettingsHelper.resetAllFeatureFlags()
}
@SmokeTest
@Test
fun externalLinkPWATest() {
val customTabTitle = "Mozilla - Google Search"
navigationToolbar {
}.enterURLAndEnterToBrowser(externalLinksPWAPage.toUri()) {
}.openThreeDotMenu {
}.clickInstall {
clickAddAutomaticallyButton()
}.openHomeScreenShortcut(shortcutTitle) {
clickLinkMatchingText("External link")
fillAndSubmitGoogleSearchQuery("Mozilla")
}
customTabScreen {
verifyCustomTabToolbarTitle(customTabTitle)
}
}
@SmokeTest
@Test
fun emailLinkPWATest() {
navigationToolbar {
}.enterURLAndEnterToBrowser(externalLinksPWAPage.toUri()) {
}.openThreeDotMenu {
}.clickInstall {
clickAddAutomaticallyButton()
}.openHomeScreenShortcut(shortcutTitle) {
clickLinkMatchingText("Email link")
assertNativeAppOpens(GMAIL_APP, emailLink)
}
}
@SmokeTest
@Test
fun telephoneLinkPWATest() {
navigationToolbar {
}.enterURLAndEnterToBrowser(externalLinksPWAPage.toUri()) {
}.openThreeDotMenu {
}.clickInstall {
clickAddAutomaticallyButton()
}.openHomeScreenShortcut(shortcutTitle) {
clickLinkMatchingText("Telephone link")
assertNativeAppOpens(PHONE_APP, phoneLink)
}
}
}

View File

@ -565,6 +565,15 @@ class BrowserRobot {
tabCrashRestoreButton.click()
}
fun fillAndSubmitGoogleSearchQuery(searchString: String) {
mDevice.findObject(
UiSelector().resourceId("$packageName:id/engineView")
).waitForExists(waitingTime)
googleSearchBox.setText(searchString)
mDevice.pressEnter()
mDevice.waitForIdle(waitingTime)
}
fun fillAndSubmitLoginCredentials(userName: String, password: String) {
userNameTextBox.click()
userNameTextBox.setText(userName)
@ -850,3 +859,12 @@ val passwordTextBox =
.className("android.widget.EditText")
.packageName("$packageName")
)
val googleSearchBox =
mDevice.findObject(
UiSelector()
.index(0)
.resourceId("mib")
.className("android.widget.EditText")
.packageName("$packageName")
)

View File

@ -15,6 +15,8 @@ import junit.framework.TestCase.assertTrue
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestHelper.appName
import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.TestHelper.waitForObjects
/**
* Implementation of the robot pattern for Custom tabs
@ -54,6 +56,17 @@ class CustomTabRobot {
closeButton().check(matches(isDisplayed()))
}
fun verifyCustomTabToolbarTitle(title: String) {
mDevice.waitForObjects(
mDevice.findObject(
UiSelector()
.resourceId("$packageName:id/mozac_browser_toolbar_title_view")
.textContains(title)
)
)
assertTrue(customTabToolbarTitle().text.equals(title))
}
class Transition {
fun openMainMenu(interact: CustomTabRobot.() -> Unit): Transition {
mainMenuButton().waitForExists(waitingTime)
@ -92,3 +105,6 @@ private fun forwardButton() = mDevice.findObject(UiSelector().description("Forwa
private fun backButton() = mDevice.findObject(UiSelector().description("Back"))
private fun closeButton() = onView(withContentDescription("Return to previous app"))
private fun customTabToolbarTitle() =
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_title_view"))