Bug 1807268 - Re-enable verifyShowClipboardSuggestionsToggleTest UI test r=jajohnson
[gecko.git] / mobile / android / fenix / app / src / androidTest / java / org / mozilla / fenix / ui / BrowsingErrorPagesTest.kt
blob608c0e9191c09c79041fb86dfdd356b7122d72f8
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.R
11 import org.mozilla.fenix.customannotations.SmokeTest
12 import org.mozilla.fenix.helpers.AppAndSystemHelper.setNetworkEnabled
13 import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource
14 import org.mozilla.fenix.helpers.HomeActivityTestRule
15 import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
16 import org.mozilla.fenix.helpers.RetryTestRule
17 import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
18 import org.mozilla.fenix.helpers.TestSetup
19 import org.mozilla.fenix.ui.robots.browserScreen
20 import org.mozilla.fenix.ui.robots.clickPageObject
21 import org.mozilla.fenix.ui.robots.navigationToolbar
23 /**
24  * Tests that verify errors encountered while browsing websites: unsafe pages, connection errors, etc
25  */
26 class BrowsingErrorPagesTest : TestSetup() {
27     private val malwareWarning = getStringResource(R.string.mozac_browser_errorpages_safe_browsing_malware_uri_title)
28     private val phishingWarning = getStringResource(R.string.mozac_browser_errorpages_safe_phishing_uri_title)
29     private val unwantedSoftwareWarning =
30         getStringResource(R.string.mozac_browser_errorpages_safe_browsing_unwanted_uri_title)
31     private val harmfulSiteWarning = getStringResource(R.string.mozac_browser_errorpages_safe_harmful_uri_title)
33     @get: Rule
34     val mActivityTestRule = HomeActivityTestRule.withDefaultSettingsOverrides()
36     @Rule
37     @JvmField
38     val retryTestRule = RetryTestRule(3)
40     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2326774
41     @SmokeTest
42     @Test
43     fun verifyMalwareWebsiteWarningMessageTest() {
44         val malwareURl = "http://itisatrap.org/firefox/its-an-attack.html"
46         navigationToolbar {
47         }.enterURLAndEnterToBrowser(malwareURl.toUri()) {
48             verifyPageContent(malwareWarning)
49         }
50     }
52     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2326773
53     @SmokeTest
54     @Test
55     fun verifyPhishingWebsiteWarningMessageTest() {
56         val phishingURl = "http://itisatrap.org/firefox/its-a-trap.html"
58         navigationToolbar {
59         }.enterURLAndEnterToBrowser(phishingURl.toUri()) {
60             verifyPageContent(phishingWarning)
61         }
62     }
64     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2326772
65     @SmokeTest
66     @Test
67     fun verifyUnwantedSoftwareWebsiteWarningMessageTest() {
68         val unwantedURl = "http://itisatrap.org/firefox/unwanted.html"
70         navigationToolbar {
71         }.enterURLAndEnterToBrowser(unwantedURl.toUri()) {
72             verifyPageContent(unwantedSoftwareWarning)
73         }
74     }
76     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/329877
77     @SmokeTest
78     @Test
79     fun verifyHarmfulWebsiteWarningMessageTest() {
80         val harmfulURl = "https://itisatrap.org/firefox/harmful.html"
82         navigationToolbar {
83         }.enterURLAndEnterToBrowser(harmfulURl.toUri()) {
84             verifyPageContent(harmfulSiteWarning)
85         }
86     }
88     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/329882
89     // Failing with network interruption, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1833874
90     // This tests the server ERROR_CONNECTION_REFUSED
91     @Test
92     fun verifyConnectionInterruptedErrorMessageTest() {
93         val testUrl = getGenericAsset(mockWebServer, 1)
95         navigationToolbar {
96         }.enterURLAndEnterToBrowser(testUrl.url) {
97             waitForPageToLoad()
98             verifyPageContent(testUrl.content)
99             // Disconnecting the server
100             mockWebServer.shutdown()
101         }.openThreeDotMenu {
102         }.refreshPage {
103             waitForPageToLoad()
104             verifyConnectionErrorMessage()
105         }
106     }
108     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/329881
109     @Test
110     fun verifyAddressNotFoundErrorMessageTest() {
111         val url = "ww.example.com"
113         navigationToolbar {
114         }.enterURLAndEnterToBrowser(url.toUri()) {
115             waitForPageToLoad()
116             verifyAddressNotFoundErrorMessage()
117             clickPageObject(itemWithResId("errorTryAgain"))
118             verifyAddressNotFoundErrorMessage()
119         }
120     }
122     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2140588
123     @Test
124     fun verifyNoInternetConnectionErrorMessageTest() {
125         val url = "www.example.com"
127         setNetworkEnabled(false)
129         navigationToolbar {
130         }.enterURLAndEnterToBrowser(url.toUri()) {
131             verifyNoInternetConnectionErrorMessage()
132         }
134         setNetworkEnabled(true)
136         browserScreen {
137             clickPageObject(itemWithResId("errorTryAgain"))
138             waitForPageToLoad()
139             verifyPageContent("Example Domain")
140         }
141     }