Bug 1880796 - Create TestSetup helper: Test classes O-R

fenix/125.0
oana.horvath 4 months ago committed by mergify[bot]
parent b51accb66f
commit b19419224d

@ -6,9 +6,10 @@ import org.junit.Test
import org.mozilla.fenix.customannotations.SmokeTest import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.helpers.AppAndSystemHelper.runWithLauncherIntent import org.mozilla.fenix.helpers.AppAndSystemHelper.runWithLauncherIntent
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.TestSetup
import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.homeScreen
class OnboardingTest { class OnboardingTest : TestSetup() {
@get:Rule @get:Rule
val activityTestRule = val activityTestRule =

@ -5,17 +5,10 @@
package org.mozilla.fenix.ui package org.mozilla.fenix.ui
import androidx.core.net.toUri import androidx.core.net.toUri
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.mozilla.fenix.customannotations.SmokeTest import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.AppAndSystemHelper.assertExternalAppOpens import org.mozilla.fenix.helpers.AppAndSystemHelper.assertExternalAppOpens
import org.mozilla.fenix.helpers.AppAndSystemHelper.clearDownloadsFolder
import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_DOCS import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_DOCS
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.MatcherHelper import org.mozilla.fenix.helpers.MatcherHelper
@ -23,12 +16,11 @@ import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText
import org.mozilla.fenix.helpers.MatcherHelper.itemWithText import org.mozilla.fenix.helpers.MatcherHelper.itemWithText
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
import org.mozilla.fenix.helpers.TestHelper.mDevice import org.mozilla.fenix.helpers.TestSetup
import org.mozilla.fenix.ui.robots.clickPageObject import org.mozilla.fenix.ui.robots.clickPageObject
import org.mozilla.fenix.ui.robots.navigationToolbar import org.mozilla.fenix.ui.robots.navigationToolbar
class PDFViewerTest { class PDFViewerTest : TestSetup() {
private lateinit var mockWebServer: MockWebServer
private val downloadTestPage = private val downloadTestPage =
"https://storage.googleapis.com/mobile_test_assets/test_app/downloads.html" "https://storage.googleapis.com/mobile_test_assets/test_app/downloads.html"
private val pdfFileName = "washington.pdf" private val pdfFileName = "washington.pdf"
@ -38,23 +30,6 @@ class PDFViewerTest {
@get:Rule @get:Rule
val activityTestRule = HomeActivityIntentTestRule.withDefaultSettingsOverrides() val activityTestRule = HomeActivityIntentTestRule.withDefaultSettingsOverrides()
@Before
fun setUp() {
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mockWebServer = MockWebServer().apply {
dispatcher = AndroidAssetDispatcher()
start()
}
}
@After
fun tearDown() {
mockWebServer.shutdown()
// Check and clear the downloads folder
clearDownloadsFolder()
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2048140 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2048140
@SmokeTest @SmokeTest
@Test @Test

@ -1,22 +1,20 @@
package org.mozilla.fenix.ui package org.mozilla.fenix.ui
import androidx.compose.ui.test.junit4.AndroidComposeTestRule import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.mozilla.fenix.helpers.Constants import org.mozilla.fenix.helpers.Constants
import org.mozilla.fenix.helpers.HomeActivityTestRule import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.RetryTestRule import org.mozilla.fenix.helpers.RetryTestRule
import org.mozilla.fenix.helpers.TestSetup
import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.homeScreen
/** /**
* Tests for verifying the presence of the Pocket section and its elements * Tests for verifying the presence of the Pocket section and its elements
*/ */
class PocketTest { class PocketTest : TestSetup() {
private lateinit var mDevice: UiDevice
private lateinit var firstPocketStoryPublisher: String private lateinit var firstPocketStoryPublisher: String
@get:Rule(order = 0) @get:Rule(order = 0)
@ -28,9 +26,8 @@ class PocketTest {
val retryTestRule = RetryTestRule(3) val retryTestRule = RetryTestRule(3)
@Before @Before
fun setUp() { override fun setUp() {
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) super.setUp()
// Workaround to make sure the Pocket articles are populated before starting the tests. // Workaround to make sure the Pocket articles are populated before starting the tests.
homeScreen { homeScreen {
}.openThreeDotMenu { }.openThreeDotMenu {

@ -11,12 +11,13 @@ import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
import org.mozilla.fenix.helpers.TestHelper.mDevice import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestSetup
import org.mozilla.fenix.ui.robots.clickPageObject import org.mozilla.fenix.ui.robots.clickPageObject
import org.mozilla.fenix.ui.robots.customTabScreen import org.mozilla.fenix.ui.robots.customTabScreen
import org.mozilla.fenix.ui.robots.navigationToolbar import org.mozilla.fenix.ui.robots.navigationToolbar
import org.mozilla.fenix.ui.robots.pwaScreen import org.mozilla.fenix.ui.robots.pwaScreen
class PwaTest { class PwaTest : TestSetup() {
/* Updated externalLinks.html to v2.0, /* Updated externalLinks.html to v2.0,
changed the hypertext reference to mozilla-mobile.github.io/testapp/downloads for "External link" changed the hypertext reference to mozilla-mobile.github.io/testapp/downloads for "External link"
*/ */

@ -5,20 +5,16 @@
package org.mozilla.fenix.ui package org.mozilla.fenix.ui
import android.view.View import android.view.View
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
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.AppAndSystemHelper.registerAndCleanupIdlingResources import org.mozilla.fenix.helpers.AppAndSystemHelper.registerAndCleanupIdlingResources
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.RetryTestRule import org.mozilla.fenix.helpers.RetryTestRule
import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestSetup
import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource
import org.mozilla.fenix.ui.robots.browserScreen import org.mozilla.fenix.ui.robots.browserScreen
import org.mozilla.fenix.ui.robots.navigationToolbar import org.mozilla.fenix.ui.robots.navigationToolbar
@ -32,9 +28,7 @@ import org.mozilla.fenix.ui.robots.navigationToolbar
* *
*/ */
class ReaderViewTest { class ReaderViewTest : TestSetup() {
private lateinit var mockWebServer: MockWebServer
private lateinit var mDevice: UiDevice
private val estimatedReadingTime = "1 - 2 minutes" private val estimatedReadingTime = "1 - 2 minutes"
@get:Rule @get:Rule
@ -44,20 +38,6 @@ class ReaderViewTest {
@JvmField @JvmField
val retryTestRule = RetryTestRule(3) val retryTestRule = RetryTestRule(3)
@Before
fun setUp() {
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mockWebServer = MockWebServer().apply {
dispatcher = AndroidAssetDispatcher()
start()
}
}
@After
fun tearDown() {
mockWebServer.shutdown()
}
/** /**
* Verify that Reader View capable pages * Verify that Reader View capable pages
* *

@ -6,21 +6,17 @@ package org.mozilla.fenix.ui
import androidx.compose.ui.test.junit4.AndroidComposeTestRule import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
import androidx.test.espresso.intent.Intents
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
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.AppAndSystemHelper.registerAndCleanupIdlingResources import org.mozilla.fenix.helpers.AppAndSystemHelper.registerAndCleanupIdlingResources
import org.mozilla.fenix.helpers.HomeActivityTestRule import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
import org.mozilla.fenix.helpers.TestHelper.longTapSelectItem import org.mozilla.fenix.helpers.TestHelper.longTapSelectItem
import org.mozilla.fenix.helpers.TestHelper.mDevice import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestSetup
import org.mozilla.fenix.ui.robots.browserScreen import org.mozilla.fenix.ui.robots.browserScreen
import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar import org.mozilla.fenix.ui.robots.navigationToolbar
@ -29,31 +25,14 @@ import org.mozilla.fenix.ui.robots.navigationToolbar
* Tests for verifying basic functionality of recently closed tabs history * Tests for verifying basic functionality of recently closed tabs history
* *
*/ */
class RecentlyClosedTabsTest { class RecentlyClosedTabsTest : TestSetup() {
private lateinit var mockWebServer: MockWebServer
@get:Rule @get:Rule
val activityTestRule = AndroidComposeTestRule( val activityTestRule = AndroidComposeTestRule(
HomeActivityTestRule.withDefaultSettingsOverrides( HomeActivityIntentTestRule.withDefaultSettingsOverrides(
tabsTrayRewriteEnabled = true, tabsTrayRewriteEnabled = true,
), ),
) { it.activity } ) { it.activity }
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
dispatcher = AndroidAssetDispatcher()
start()
}
Intents.init()
}
@After
fun tearDown() {
mockWebServer.shutdown()
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1065414 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1065414
// Verifies that a recently closed item is properly opened // Verifies that a recently closed item is properly opened
@SmokeTest @SmokeTest

@ -21,7 +21,6 @@ import org.junit.Test
import org.mozilla.fenix.customannotations.SmokeTest import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.AppAndSystemHelper
import org.mozilla.fenix.helpers.AppAndSystemHelper.assertNativeAppOpens import org.mozilla.fenix.helpers.AppAndSystemHelper.assertNativeAppOpens
import org.mozilla.fenix.helpers.AppAndSystemHelper.denyPermission import org.mozilla.fenix.helpers.AppAndSystemHelper.denyPermission
import org.mozilla.fenix.helpers.AppAndSystemHelper.grantSystemPermission import org.mozilla.fenix.helpers.AppAndSystemHelper.grantSystemPermission
@ -45,6 +44,7 @@ import org.mozilla.fenix.helpers.TestHelper.exitMenu
import org.mozilla.fenix.helpers.TestHelper.longTapSelectItem import org.mozilla.fenix.helpers.TestHelper.longTapSelectItem
import org.mozilla.fenix.helpers.TestHelper.mDevice import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestHelper.verifySnackBarText import org.mozilla.fenix.helpers.TestHelper.verifySnackBarText
import org.mozilla.fenix.helpers.TestSetup
import org.mozilla.fenix.ui.robots.clickContextMenuItem import org.mozilla.fenix.ui.robots.clickContextMenuItem
import org.mozilla.fenix.ui.robots.clickPageObject import org.mozilla.fenix.ui.robots.clickPageObject
import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.homeScreen
@ -64,7 +64,7 @@ import java.util.Locale
* *
*/ */
class SearchTest { class SearchTest : TestSetup() {
private lateinit var searchMockServer: MockWebServer private lateinit var searchMockServer: MockWebServer
private var queryString = "firefox" private var queryString = "firefox"
private val generalEnginesList = listOf("DuckDuckGo", "Google", "Bing") private val generalEnginesList = listOf("DuckDuckGo", "Google", "Bing")
@ -84,7 +84,8 @@ class SearchTest {
) { it.activity } ) { it.activity }
@Before @Before
fun setUp() { override fun setUp() {
super.setUp()
searchMockServer = MockWebServer().apply { searchMockServer = MockWebServer().apply {
dispatcher = SearchDispatcher() dispatcher = SearchDispatcher()
start() start()
@ -92,9 +93,8 @@ class SearchTest {
} }
@After @After
fun tearDown() { override fun tearDown() {
searchMockServer.shutdown() searchMockServer.shutdown()
AppAndSystemHelper.resetSystemLocaleToEnUS()
} }
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2154189 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2154189

Loading…
Cancel
Save