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
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
24 * Tests that verify errors encountered while browsing websites: unsafe pages, connection errors, etc
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)
34 val mActivityTestRule = HomeActivityTestRule.withDefaultSettingsOverrides()
38 val retryTestRule = RetryTestRule(3)
40 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2326774
43 fun verifyMalwareWebsiteWarningMessageTest() {
44 val malwareURl = "http://itisatrap.org/firefox/its-an-attack.html"
47 }.enterURLAndEnterToBrowser(malwareURl.toUri()) {
48 verifyPageContent(malwareWarning)
52 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2326773
55 fun verifyPhishingWebsiteWarningMessageTest() {
56 val phishingURl = "http://itisatrap.org/firefox/its-a-trap.html"
59 }.enterURLAndEnterToBrowser(phishingURl.toUri()) {
60 verifyPageContent(phishingWarning)
64 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2326772
67 fun verifyUnwantedSoftwareWebsiteWarningMessageTest() {
68 val unwantedURl = "http://itisatrap.org/firefox/unwanted.html"
71 }.enterURLAndEnterToBrowser(unwantedURl.toUri()) {
72 verifyPageContent(unwantedSoftwareWarning)
76 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/329877
79 fun verifyHarmfulWebsiteWarningMessageTest() {
80 val harmfulURl = "https://itisatrap.org/firefox/harmful.html"
83 }.enterURLAndEnterToBrowser(harmfulURl.toUri()) {
84 verifyPageContent(harmfulSiteWarning)
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
92 fun verifyConnectionInterruptedErrorMessageTest() {
93 val testUrl = getGenericAsset(mockWebServer, 1)
96 }.enterURLAndEnterToBrowser(testUrl.url) {
98 verifyPageContent(testUrl.content)
99 // Disconnecting the server
100 mockWebServer.shutdown()
104 verifyConnectionErrorMessage()
108 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/329881
110 fun verifyAddressNotFoundErrorMessageTest() {
111 val url = "ww.example.com"
114 }.enterURLAndEnterToBrowser(url.toUri()) {
116 verifyAddressNotFoundErrorMessage()
117 clickPageObject(itemWithResId("errorTryAgain"))
118 verifyAddressNotFoundErrorMessage()
122 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2140588
124 fun verifyNoInternetConnectionErrorMessageTest() {
125 val url = "www.example.com"
127 setNetworkEnabled(false)
130 }.enterURLAndEnterToBrowser(url.toUri()) {
131 verifyNoInternetConnectionErrorMessage()
134 setNetworkEnabled(true)
137 clickPageObject(itemWithResId("errorTryAgain"))
139 verifyPageContent("Example Domain")