mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
Bug 1833874 - Replace connection error test steps
This commit is contained in:
parent
11495e43b4
commit
b1df05835f
@ -15,6 +15,7 @@ import org.junit.runners.model.Statement
|
|||||||
import org.mozilla.fenix.components.PermissionStorage
|
import org.mozilla.fenix.components.PermissionStorage
|
||||||
import org.mozilla.fenix.helpers.IdlingResourceHelper.unregisterAllIdlingResources
|
import org.mozilla.fenix.helpers.IdlingResourceHelper.unregisterAllIdlingResources
|
||||||
import org.mozilla.fenix.helpers.TestHelper.appContext
|
import org.mozilla.fenix.helpers.TestHelper.appContext
|
||||||
|
import org.mozilla.fenix.helpers.TestHelper.setNetworkEnabled
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rule to retry flaky tests for a given number of times, catching some of the more common exceptions.
|
* Rule to retry flaky tests for a given number of times, catching some of the more common exceptions.
|
||||||
@ -34,6 +35,7 @@ class RetryTestRule(private val retryCount: Int = 5) : TestRule {
|
|||||||
base.evaluate()
|
base.evaluate()
|
||||||
break
|
break
|
||||||
} catch (t: AssertionError) {
|
} catch (t: AssertionError) {
|
||||||
|
setNetworkEnabled(true)
|
||||||
unregisterAllIdlingResources()
|
unregisterAllIdlingResources()
|
||||||
runBlocking {
|
runBlocking {
|
||||||
permissionStorage.deleteAllSitePermissions()
|
permissionStorage.deleteAllSitePermissions()
|
||||||
@ -50,6 +52,7 @@ class RetryTestRule(private val retryCount: Int = 5) : TestRule {
|
|||||||
throw t
|
throw t
|
||||||
}
|
}
|
||||||
} catch (t: UiObjectNotFoundException) {
|
} catch (t: UiObjectNotFoundException) {
|
||||||
|
setNetworkEnabled(true)
|
||||||
unregisterAllIdlingResources()
|
unregisterAllIdlingResources()
|
||||||
runBlocking {
|
runBlocking {
|
||||||
permissionStorage.deleteAllSitePermissions()
|
permissionStorage.deleteAllSitePermissions()
|
||||||
@ -58,6 +61,7 @@ class RetryTestRule(private val retryCount: Int = 5) : TestRule {
|
|||||||
throw t
|
throw t
|
||||||
}
|
}
|
||||||
} catch (t: NoMatchingViewException) {
|
} catch (t: NoMatchingViewException) {
|
||||||
|
setNetworkEnabled(true)
|
||||||
unregisterAllIdlingResources()
|
unregisterAllIdlingResources()
|
||||||
runBlocking {
|
runBlocking {
|
||||||
permissionStorage.deleteAllSitePermissions()
|
permissionStorage.deleteAllSitePermissions()
|
||||||
@ -66,6 +70,7 @@ class RetryTestRule(private val retryCount: Int = 5) : TestRule {
|
|||||||
throw t
|
throw t
|
||||||
}
|
}
|
||||||
} catch (t: IdlingResourceTimeoutException) {
|
} catch (t: IdlingResourceTimeoutException) {
|
||||||
|
setNetworkEnabled(true)
|
||||||
unregisterAllIdlingResources()
|
unregisterAllIdlingResources()
|
||||||
runBlocking {
|
runBlocking {
|
||||||
permissionStorage.deleteAllSitePermissions()
|
permissionStorage.deleteAllSitePermissions()
|
||||||
@ -74,6 +79,7 @@ class RetryTestRule(private val retryCount: Int = 5) : TestRule {
|
|||||||
throw t
|
throw t
|
||||||
}
|
}
|
||||||
} catch (t: RuntimeException) {
|
} catch (t: RuntimeException) {
|
||||||
|
setNetworkEnabled(true)
|
||||||
unregisterAllIdlingResources()
|
unregisterAllIdlingResources()
|
||||||
runBlocking {
|
runBlocking {
|
||||||
permissionStorage.deleteAllSitePermissions()
|
permissionStorage.deleteAllSitePermissions()
|
||||||
@ -82,6 +88,7 @@ class RetryTestRule(private val retryCount: Int = 5) : TestRule {
|
|||||||
throw t
|
throw t
|
||||||
}
|
}
|
||||||
} catch (t: NullPointerException) {
|
} catch (t: NullPointerException) {
|
||||||
|
setNetworkEnabled(true)
|
||||||
unregisterAllIdlingResources()
|
unregisterAllIdlingResources()
|
||||||
runBlocking {
|
runBlocking {
|
||||||
permissionStorage.deleteAllSitePermissions()
|
permissionStorage.deleteAllSitePermissions()
|
||||||
|
@ -5,15 +5,18 @@
|
|||||||
package org.mozilla.fenix.ui
|
package org.mozilla.fenix.ui
|
||||||
|
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import okhttp3.mockwebserver.MockWebServer
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Ignore
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.customannotations.SmokeTest
|
import org.mozilla.fenix.customannotations.SmokeTest
|
||||||
|
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
|
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
|
||||||
import org.mozilla.fenix.helpers.RetryTestRule
|
import org.mozilla.fenix.helpers.RetryTestRule
|
||||||
|
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
||||||
import org.mozilla.fenix.helpers.TestHelper.getStringResource
|
import org.mozilla.fenix.helpers.TestHelper.getStringResource
|
||||||
import org.mozilla.fenix.helpers.TestHelper.setNetworkEnabled
|
import org.mozilla.fenix.helpers.TestHelper.setNetworkEnabled
|
||||||
import org.mozilla.fenix.ui.robots.browserScreen
|
import org.mozilla.fenix.ui.robots.browserScreen
|
||||||
@ -29,6 +32,7 @@ class BrowsingErrorPagesTest {
|
|||||||
private val unwantedSoftwareWarning =
|
private val unwantedSoftwareWarning =
|
||||||
getStringResource(R.string.mozac_browser_errorpages_safe_browsing_unwanted_uri_title)
|
getStringResource(R.string.mozac_browser_errorpages_safe_browsing_unwanted_uri_title)
|
||||||
private val harmfulSiteWarning = getStringResource(R.string.mozac_browser_errorpages_safe_harmful_uri_title)
|
private val harmfulSiteWarning = getStringResource(R.string.mozac_browser_errorpages_safe_harmful_uri_title)
|
||||||
|
private lateinit var mockWebServer: MockWebServer
|
||||||
|
|
||||||
@get: Rule
|
@get: Rule
|
||||||
val mActivityTestRule = HomeActivityTestRule.withDefaultSettingsOverrides()
|
val mActivityTestRule = HomeActivityTestRule.withDefaultSettingsOverrides()
|
||||||
@ -37,10 +41,19 @@ class BrowsingErrorPagesTest {
|
|||||||
@JvmField
|
@JvmField
|
||||||
val retryTestRule = RetryTestRule(3)
|
val retryTestRule = RetryTestRule(3)
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
mockWebServer = MockWebServer().apply {
|
||||||
|
dispatcher = AndroidAssetDispatcher()
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
fun tearDown() {
|
fun tearDown() {
|
||||||
// Restoring network connection
|
// Restoring network connection
|
||||||
setNetworkEnabled(true)
|
setNetworkEnabled(true)
|
||||||
|
mockWebServer.shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
@SmokeTest
|
@SmokeTest
|
||||||
@ -87,34 +100,23 @@ class BrowsingErrorPagesTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("Failing, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1833874")
|
// Failing with network interruption, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1833874
|
||||||
|
// This tests the server ERROR_CONNECTION_REFUSED
|
||||||
@Test
|
@Test
|
||||||
fun connectionFailureErrorMessageTest() {
|
fun connectionRefusedErrorMessageTest() {
|
||||||
val url = "example.com"
|
val testUrl = getGenericAsset(mockWebServer, 1)
|
||||||
|
|
||||||
navigationToolbar {
|
navigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(url.toUri()) {
|
}.enterURLAndEnterToBrowser(testUrl.url) {
|
||||||
waitForPageToLoad()
|
waitForPageToLoad()
|
||||||
verifyPageContent("Example Domain")
|
verifyPageContent(testUrl.content)
|
||||||
}
|
// Disconnecting the server
|
||||||
|
mockWebServer.shutdown()
|
||||||
setNetworkEnabled(false)
|
|
||||||
|
|
||||||
browserScreen {
|
|
||||||
}.openThreeDotMenu {
|
}.openThreeDotMenu {
|
||||||
}.refreshPage {
|
}.refreshPage {
|
||||||
waitForPageToLoad()
|
waitForPageToLoad()
|
||||||
verifyConnectionErrorMessage()
|
verifyConnectionErrorMessage()
|
||||||
}
|
}
|
||||||
|
|
||||||
setNetworkEnabled(true)
|
|
||||||
|
|
||||||
browserScreen {
|
|
||||||
}.openThreeDotMenu {
|
|
||||||
}.refreshPage {
|
|
||||||
waitForPageToLoad()
|
|
||||||
verifyPageContent("Example Domain")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user