Bug 1888285 - Fix org.mozilla.fenix.ui.PwaTest UI tests r=android-reviewers,Roger...
[gecko.git] / mobile / android / fenix / app / src / androidTest / java / org / mozilla / fenix / ui / PwaTest.kt
blobd9ac033a9c3759a575b73ff8eae58fd1f54d2cfd
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.fenix.ui
7 import androidx.core.net.toUri
8 import org.junit.Rule
9 import org.junit.Test
10 import org.mozilla.fenix.customannotations.SmokeTest
11 import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
12 import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
13 import org.mozilla.fenix.helpers.TestHelper.mDevice
14 import org.mozilla.fenix.helpers.TestSetup
15 import org.mozilla.fenix.ui.robots.clickPageObject
16 import org.mozilla.fenix.ui.robots.customTabScreen
17 import org.mozilla.fenix.ui.robots.navigationToolbar
18 import org.mozilla.fenix.ui.robots.pwaScreen
20 class PwaTest : TestSetup() {
21     /* Updated externalLinks.html to v2.0,
22        changed the hypertext reference to mozilla-mobile.github.io/testapp/downloads for "External link"
23      */
24     private val externalLinksPWAPage = "https://mozilla-mobile.github.io/testapp/v2.0/externalLinks.html"
25     private val emailLink = "mailto://example@example.com"
26     private val phoneLink = "tel://1234567890"
27     private val shortcutTitle = "TEST_APP"
29     @get:Rule
30     val activityTestRule = HomeActivityIntentTestRule.withDefaultSettingsOverrides()
32     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/845695
33     @Test
34     fun externalLinkPWATest() {
35         val externalLinkURL = "https://mozilla-mobile.github.io/testapp/downloads"
37         navigationToolbar {
38         }.enterURLAndEnterToBrowser(externalLinksPWAPage.toUri()) {
39             waitForPageToLoad()
40         }.openThreeDotMenu {
41         }.clickInstall {
42             clickAddAutomaticallyButton()
43         }.openHomeScreenShortcut(shortcutTitle) {
44             clickPageObject(itemContainingText("External link"))
45         }
47         customTabScreen {
48             verifyCustomTabToolbarTitle(externalLinkURL)
49         }
50     }
52     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/845694
53     @Test
54     fun appLikeExperiencePWATest() {
55         navigationToolbar {
56         }.enterURLAndEnterToBrowser(externalLinksPWAPage.toUri()) {
57             waitForPageToLoad()
58         }.openThreeDotMenu {
59         }.clickInstall {
60             clickAddAutomaticallyButton()
61         }.openHomeScreenShortcut(shortcutTitle) {
62         }
64         pwaScreen {
65             verifyCustomTabToolbarIsNotDisplayed()
66             verifyPwaActivityInCurrentTask()
67         }
68     }
70     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/834200
71     @SmokeTest
72     @Test
73     fun installPWAFromTheMainMenuTest() {
74         val pwaPage = "https://mozilla-mobile.github.io/testapp/"
76         navigationToolbar {
77         }.enterURLAndEnterToBrowser(pwaPage.toUri()) {
78         }.openThreeDotMenu {
79         }.clickInstall {
80             clickAddAutomaticallyButton()
81         }.openHomeScreenShortcut("TEST_APP") {
82             mDevice.waitForIdle()
83             verifyNavURLBarHidden()
84         }
85     }