diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt index 58bbcf950..ba6977929 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt @@ -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() + } + } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt index 13372a3d9..efce62eec 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt @@ -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)) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt index 145f26b48..5718d137a 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt @@ -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() {