You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iceraven-browser/app/src/androidTest/java/org/mozilla/fenix/ui/NoNetworkAccessStartupTests.kt

105 lines
2.7 KiB
Kotlin

/* 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
import androidx.core.net.toUri
import org.junit.After
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.TestHelper.setNetworkEnabled
import org.mozilla.fenix.helpers.TestHelper.verifyUrl
import org.mozilla.fenix.ui.robots.browserScreen
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
/**
* Tests to verify some main UI flows with Network connection off
*
*/
class NoNetworkAccessStartupTests {
@get:Rule
val activityTestRule = HomeActivityTestRule(launchActivity = false)
@After
fun tearDown() {
// Restoring network connection
setNetworkEnabled(true)
}
@Test
// Test running on beta/release builds in CI:
// caution when making changes to it, so they don't block the builds
// Based on STR from https://github.com/mozilla-mobile/fenix/issues/16886
fun noNetworkConnectionStartupTest() {
setNetworkEnabled(false)
activityTestRule.launchActivity(null)
homeScreen {
}.dismissOnboarding()
homeScreen {
verifyHomeScreen()
}
}
@Test
// Based on STR from https://github.com/mozilla-mobile/fenix/issues/16886
fun networkInterruptedFromBrowserToHomeTest() {
val url = "example.com"
activityTestRule.launchActivity(null)
navigationToolbar {
}.enterURLAndEnterToBrowser(url.toUri()) {}
setNetworkEnabled(false)
browserScreen {
}.goToHomescreen {
verifyHomeScreen()
}
}
@Test
fun testPageReloadAfterNetworkInterrupted() {
val url = "example.com"
activityTestRule.launchActivity(null)
navigationToolbar {
}.enterURLAndEnterToBrowser(url.toUri()) {}
setNetworkEnabled(false)
browserScreen {
}.openThreeDotMenu {
}.refreshPage { }
}
@Test
fun testSignInPageWithNoNetworkConnection() {
setNetworkEnabled(false)
activityTestRule.launchActivity(null)
homeScreen {
}.openThreeDotMenu {
}.openSettings {
}.openTurnOnSyncMenu {
tapOnUseEmailToSignIn()
verifyUrl(
"firefox.com",
"$packageName:id/mozac_browser_toolbar_url_view",
R.id.mozac_browser_toolbar_url_view
)
}
}
}