For #26144 new App-like experience in PWAs UI test

This commit is contained in:
AndiAJ 2022-07-28 10:11:25 +03:00 committed by mergify[bot]
parent 20911100d9
commit c356982a4d
3 changed files with 64 additions and 0 deletions

View File

@ -4,6 +4,7 @@
package org.mozilla.fenix.helpers
import android.app.ActivityManager
import android.app.PendingIntent
import android.content.ActivityNotFoundException
import android.content.Context
@ -45,6 +46,7 @@ import org.hamcrest.Matcher
import org.junit.Assert
import org.junit.Assert.assertTrue
import org.mozilla.fenix.R
import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_APPS_PHOTOS
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
@ -240,6 +242,19 @@ object TestHelper {
}
}
/**
* Checks whether the latest activity of the application is used for custom tabs or PWAs.
*
* @return Boolean value that helps us know if the current activity supports custom tabs or PWAs.
*/
fun isExternalAppBrowserActivityInCurrentTask(): Boolean {
val activityManager = appContext.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
mDevice.waitForIdle(waitingTimeShort)
return activityManager.appTasks[0].taskInfo.topActivity!!.className == ExternalAppBrowserActivity::class.java.name
}
// exit from Menus to home screen or browser
fun exitMenu() {
val toolbar =

View File

@ -13,6 +13,7 @@ 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
import org.mozilla.fenix.ui.robots.pwaScreen
class PwaTest {
private val featureSettingsHelper = FeatureSettingsHelper()
@ -91,4 +92,24 @@ class PwaTest {
assertNativeAppOpens(PHONE_APP, phoneLink)
}
}
@SmokeTest
@Test
fun appLikeExperiencePWATest() {
navigationToolbar {
}.enterURLAndEnterToBrowser(externalLinksPWAPage.toUri()) {
waitForPageToLoad()
verifyNotificationDotOnMainMenu()
}.openThreeDotMenu {
}.clickInstall {
clickAddAutomaticallyButton()
}.openHomeScreenShortcut(shortcutTitle) {
}
pwaScreen {
verifyCustomTabToolbarIsNotDisplayed()
verifyPwaActivityInCurrentTask()
}
}
}

View File

@ -0,0 +1,28 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.ui.robots
import androidx.test.uiautomator.UiSelector
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.mozilla.fenix.helpers.TestHelper.isExternalAppBrowserActivityInCurrentTask
import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestHelper.packageName
class PwaRobot {
fun verifyCustomTabToolbarIsNotDisplayed() = assertFalse(customTabToolbar().exists())
fun verifyPwaActivityInCurrentTask() = assertTrue(isExternalAppBrowserActivityInCurrentTask())
class Transition
}
fun pwaScreen(interact: PwaRobot.() -> Unit): PwaRobot.Transition {
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
PwaRobot().interact()
return PwaRobot.Transition()
}
private fun customTabToolbar() = mDevice.findObject(UiSelector().resourceId("$packageName:id/toolbar"))