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

[fenix] For https://github.com/mozilla-mobile/fenix/issues/16615: UI smoke test mainMenuInstallPWATest

This commit is contained in:
Oana Horvath 2021-01-21 15:28:45 +02:00
parent 675ac17056
commit d193e6a919
3 changed files with 40 additions and 1 deletions

View File

@ -5,6 +5,7 @@
package org.mozilla.fenix.ui
import android.view.View
import androidx.core.net.toUri
import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.IdlingRegistry
import androidx.test.platform.app.InstrumentationRegistry
@ -63,6 +64,7 @@ class SmokeTest {
@get:Rule
val activityTestRule = HomeActivityTestRule()
@get:Rule
var mGrantPermissions = GrantPermissionRule.grant(
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
@ -1099,4 +1101,20 @@ class SmokeTest {
}.openHomeScreenShortcut("Private Firefox Preview") {
}
}
@Test
fun mainMenuInstallPWATest() {
val pwaPage = "https://rpappalax.github.io/testapp/"
navigationToolbar {
}.enterURLAndEnterToBrowser(pwaPage.toUri()) {
verifyNotificationDotOnMainMenu()
}.openThreeDotMenu {
}.clickInstall {
clickAddAutomaticallyButton()
}.openHomeScreenShortcut("yay app") {
mDevice.waitForIdle()
verifyNavURLBarHidden()
}
}
}

View File

@ -152,6 +152,8 @@ class BrowserRobot {
fun verifyNavURLBar() = assertNavURLBar()
fun verifyNavURLBarHidden() = assertNavURLBarHidden()
fun verifySecureConnectionLockIcon() = assertSecureConnectionLockIcon()
fun verifyEnhancedTrackingProtectionSwitch() = assertEnhancedTrackingProtectionSwitch()
@ -192,6 +194,13 @@ class BrowserRobot {
)
}
fun verifyNotificationDotOnMainMenu() {
assertTrue(
mDevice.findObject(UiSelector().resourceId("$packageName:id/notification_dot"))
.waitForExists(waitingTime)
)
}
fun dismissContentContextMenu(containsURL: Uri) {
onView(withText(containsURL.toString()))
.inRoot(isDialog())
@ -471,11 +480,14 @@ fun dismissTrackingOnboarding() {
dismissOnboardingButton().click()
}
fun navURLBar() = onView(withId(R.id.mozac_browser_toolbar_url_view))
fun navURLBar() = onView(withId(R.id.toolbar))
private fun assertNavURLBar() = navURLBar()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertNavURLBarHidden() = navURLBar()
.check(matches(not(isDisplayed())))
fun enhancedTrackingProtectionIndicator() =
onView(withId(R.id.mozac_browser_toolbar_tracking_protection_indicator))

View File

@ -347,6 +347,13 @@ class ThreeDotMenuMainRobot {
return AddToHomeScreenRobot.Transition()
}
fun clickInstall(interact: AddToHomeScreenRobot.() -> Unit): AddToHomeScreenRobot.Transition {
installPWAButton().click()
AddToHomeScreenRobot().interact()
return AddToHomeScreenRobot.Transition()
}
fun selectExistingCollection(title: String, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.waitNotNull(Until.findObject(By.text(title)), waitingTime)
onView(withText(title)).click()
@ -536,6 +543,8 @@ private fun assertAddToMobileHome() {
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun installPWAButton() = onView(allOf(withId(R.id.highlight_text), withText("Install")))
private fun desktopSiteButton() =
onView(allOf(withText(R.string.browser_menu_desktop_site)))
private fun assertDesktopSite() {