mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
Bug 1880087 - Create TestSetup helper: Test classes D-L
This commit is contained in:
parent
9582c71045
commit
edc60d77fd
@ -5,16 +5,12 @@
|
||||
package org.mozilla.fenix.ui
|
||||
|
||||
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.Ignore
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
import org.mozilla.fenix.helpers.TestSetup
|
||||
import org.mozilla.fenix.ui.robots.DeepLinkRobot
|
||||
|
||||
/**
|
||||
@ -31,29 +27,12 @@ import org.mozilla.fenix.ui.robots.DeepLinkRobot
|
||||
**/
|
||||
|
||||
@Ignore("All tests perma-failing, see: https://github.com/mozilla-mobile/fenix/issues/13491")
|
||||
class DeepLinkTest {
|
||||
private lateinit var mDevice: UiDevice
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
|
||||
class DeepLinkTest : TestSetup() {
|
||||
private val robot = DeepLinkRobot()
|
||||
|
||||
@get:Rule
|
||||
val activityIntentTestRule = HomeActivityIntentTestRule()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||
mockWebServer = MockWebServer().apply {
|
||||
dispatcher = AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun openHomeScreen() {
|
||||
robot.openHomeScreen {
|
||||
|
@ -5,14 +5,13 @@
|
||||
package org.mozilla.fenix.ui
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import org.junit.After
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
import org.mozilla.fenix.customannotations.SmokeTest
|
||||
import org.mozilla.fenix.helpers.AppAndSystemHelper.clearDownloadsFolder
|
||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||
import org.mozilla.fenix.helpers.TestSetup
|
||||
import org.mozilla.fenix.ui.robots.downloadRobot
|
||||
|
||||
/**
|
||||
@ -22,7 +21,7 @@ import org.mozilla.fenix.ui.robots.downloadRobot
|
||||
* - Verifies downloading of varying file types and the appearance inside the Downloads listing.
|
||||
**/
|
||||
@RunWith(Parameterized::class)
|
||||
class DownloadFileTypesTest(fileName: String) {
|
||||
class DownloadFileTypesTest(fileName: String) : TestSetup() {
|
||||
/* Remote test page managed by Mozilla Mobile QA team at https://github.com/mozilla-mobile/testapp */
|
||||
private val downloadTestPage = "https://storage.googleapis.com/mobile_test_assets/test_app/downloads.html"
|
||||
private var downloadFile: String = fileName
|
||||
@ -30,12 +29,6 @@ class DownloadFileTypesTest(fileName: String) {
|
||||
@get:Rule
|
||||
val activityTestRule = HomeActivityIntentTestRule.withDefaultSettingsOverrides()
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
// Check and clear the downloads folder
|
||||
clearDownloadsFolder()
|
||||
}
|
||||
|
||||
companion object {
|
||||
// Creating test data. The test will take each file name as a parameter and run it individually.
|
||||
@JvmStatic
|
||||
|
@ -5,16 +5,11 @@
|
||||
package org.mozilla.fenix.ui
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
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.clearDownloadsFolder
|
||||
import org.mozilla.fenix.helpers.AppAndSystemHelper.deleteDownloadedFileOnStorage
|
||||
import org.mozilla.fenix.helpers.AppAndSystemHelper.setNetworkEnabled
|
||||
import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_APPS_PHOTOS
|
||||
@ -25,6 +20,7 @@ import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
import org.mozilla.fenix.helpers.TestHelper.clickSnackbarButton
|
||||
import org.mozilla.fenix.helpers.TestHelper.exitMenu
|
||||
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.clickPageObject
|
||||
import org.mozilla.fenix.ui.robots.downloadRobot
|
||||
@ -40,9 +36,7 @@ import org.mozilla.fenix.ui.robots.notificationShade
|
||||
* - Verifies download notification and actions
|
||||
* - Verifies managing downloads inside the Downloads listing.
|
||||
**/
|
||||
class DownloadTest {
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
|
||||
class DownloadTest : TestSetup() {
|
||||
/* Remote test page managed by Mozilla Mobile QA team at https://github.com/mozilla-mobile/testapp */
|
||||
private val downloadTestPage = "https://storage.googleapis.com/mobile_test_assets/test_app/downloads.html"
|
||||
private var downloadFile: String = ""
|
||||
@ -50,34 +44,6 @@ class DownloadTest {
|
||||
@get:Rule
|
||||
val activityTestRule = HomeActivityIntentTestRule.withDefaultSettingsOverrides()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mockWebServer = MockWebServer().apply {
|
||||
dispatcher = AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
|
||||
// clear all existing notifications
|
||||
notificationShade {
|
||||
mDevice.openNotification()
|
||||
clearNotifications()
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
notificationShade {
|
||||
cancelAllShownNotifications()
|
||||
}
|
||||
|
||||
mockWebServer.shutdown()
|
||||
|
||||
setNetworkEnabled(enabled = true)
|
||||
|
||||
// Check and clear the downloads folder
|
||||
clearDownloadsFolder()
|
||||
}
|
||||
|
||||
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/243844
|
||||
@Test
|
||||
fun verifyTheDownloadPromptsTest() {
|
||||
|
@ -6,14 +6,10 @@ package org.mozilla.fenix.ui
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import androidx.test.espresso.Espresso.pressBack
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.customannotations.SmokeTest
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.getEnhancedTrackingProtectionAsset
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
||||
@ -22,6 +18,7 @@ import org.mozilla.fenix.helpers.TestHelper.exitMenu
|
||||
import org.mozilla.fenix.helpers.TestHelper.mDevice
|
||||
import org.mozilla.fenix.helpers.TestHelper.restartApp
|
||||
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
|
||||
import org.mozilla.fenix.helpers.TestSetup
|
||||
import org.mozilla.fenix.ui.robots.browserScreen
|
||||
import org.mozilla.fenix.ui.robots.enhancedTrackingProtection
|
||||
import org.mozilla.fenix.ui.robots.homeScreen
|
||||
@ -40,9 +37,7 @@ import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
* - Verifying Enhanced Tracking Protection site exceptions
|
||||
*/
|
||||
|
||||
class EnhancedTrackingProtectionTest {
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
|
||||
class EnhancedTrackingProtectionTest : TestSetup() {
|
||||
@get:Rule
|
||||
val activityTestRule = HomeActivityIntentTestRule(
|
||||
isJumpBackInCFREnabled = false,
|
||||
@ -50,19 +45,6 @@ class EnhancedTrackingProtectionTest {
|
||||
isWallpaperOnboardingEnabled = false,
|
||||
)
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mockWebServer = MockWebServer().apply {
|
||||
dispatcher = AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/416046
|
||||
@Test
|
||||
fun testETPSettingsItemsAndSubMenus() {
|
||||
|
@ -14,6 +14,7 @@ import org.mozilla.fenix.helpers.AppAndSystemHelper.runWithCondition
|
||||
import org.mozilla.fenix.helpers.DataGenerationHelper.getSponsoredFxSuggestPlaceHolder
|
||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||
import org.mozilla.fenix.helpers.TestHelper
|
||||
import org.mozilla.fenix.helpers.TestSetup
|
||||
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
|
||||
/**
|
||||
@ -21,7 +22,7 @@ import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
*
|
||||
*/
|
||||
|
||||
class FirefoxSuggestTest {
|
||||
class FirefoxSuggestTest : TestSetup() {
|
||||
|
||||
@get:Rule
|
||||
val activityTestRule = AndroidComposeTestRule(
|
||||
|
@ -4,15 +4,13 @@
|
||||
|
||||
package org.mozilla.fenix.ui
|
||||
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.TestAsset
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.getGPCTestAsset
|
||||
import org.mozilla.fenix.helpers.TestSetup
|
||||
import org.mozilla.fenix.ui.robots.homeScreen
|
||||
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
|
||||
@ -20,8 +18,7 @@ import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
* Tests for Global Privacy Control setting.
|
||||
*/
|
||||
|
||||
class GlobalPrivacyControlTest {
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
class GlobalPrivacyControlTest : TestSetup() {
|
||||
private lateinit var gpcPage: TestAsset
|
||||
|
||||
@get:Rule
|
||||
@ -33,20 +30,11 @@ class GlobalPrivacyControlTest {
|
||||
)
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mockWebServer = MockWebServer().apply {
|
||||
dispatcher = AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
gpcPage = getGPCTestAsset(mockWebServer)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2429327
|
||||
@Test
|
||||
fun testGPCinNormalBrowsing() {
|
||||
|
@ -4,24 +4,14 @@
|
||||
|
||||
package org.mozilla.fenix.ui
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
|
||||
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
||||
import androidx.test.espresso.Espresso.pressBack
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.customannotations.SmokeTest
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.AppAndSystemHelper.registerAndCleanupIdlingResources
|
||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||
import org.mozilla.fenix.helpers.MockBrowserDataHelper
|
||||
@ -29,7 +19,9 @@ import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
import org.mozilla.fenix.helpers.TestHelper.exitMenu
|
||||
import org.mozilla.fenix.helpers.TestHelper.longTapSelectItem
|
||||
import org.mozilla.fenix.helpers.TestHelper.mDevice
|
||||
import org.mozilla.fenix.helpers.TestHelper.verifySnackBarText
|
||||
import org.mozilla.fenix.helpers.TestSetup
|
||||
import org.mozilla.fenix.ui.robots.browserScreen
|
||||
import org.mozilla.fenix.ui.robots.historyMenu
|
||||
import org.mozilla.fenix.ui.robots.homeScreen
|
||||
@ -40,40 +32,13 @@ import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
* Tests for verifying basic functionality of history
|
||||
*
|
||||
*/
|
||||
class HistoryTest {
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
private lateinit var mDevice: UiDevice
|
||||
|
||||
class HistoryTest : TestSetup() {
|
||||
@get:Rule
|
||||
val activityTestRule =
|
||||
AndroidComposeTestRule(
|
||||
HomeActivityIntentTestRule.withDefaultSettingsOverrides(),
|
||||
HomeActivityIntentTestRule(isJumpBackInCFREnabled = false),
|
||||
) { it.activity }
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
InstrumentationRegistry.getInstrumentation().targetContext.settings()
|
||||
.shouldShowJumpBackInCFR = false
|
||||
|
||||
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||
mockWebServer = MockWebServer().apply {
|
||||
dispatcher = AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
mockWebServer.shutdown()
|
||||
// Clearing all history data after each test to avoid overlapping data
|
||||
val applicationContext: Context = activityTestRule.activity.applicationContext
|
||||
val historyStorage = PlacesHistoryStorage(applicationContext)
|
||||
|
||||
runBlocking {
|
||||
historyStorage.deleteEverything()
|
||||
}
|
||||
}
|
||||
|
||||
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/243285
|
||||
@Test
|
||||
fun verifyEmptyHistoryMenuTest() {
|
||||
|
@ -5,19 +5,14 @@
|
||||
package org.mozilla.fenix.ui
|
||||
|
||||
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
|
||||
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.Test
|
||||
import org.mozilla.fenix.customannotations.SmokeTest
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||
import org.mozilla.fenix.helpers.RetryTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
import org.mozilla.fenix.helpers.TestHelper
|
||||
import org.mozilla.fenix.helpers.TestSetup
|
||||
import org.mozilla.fenix.ui.robots.homeScreen
|
||||
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
import org.mozilla.fenix.ui.robots.searchScreen
|
||||
@ -29,10 +24,7 @@ import org.mozilla.fenix.ui.robots.searchScreen
|
||||
*
|
||||
*/
|
||||
|
||||
class HomeScreenTest {
|
||||
private lateinit var mDevice: UiDevice
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
|
||||
class HomeScreenTest : TestSetup() {
|
||||
@get:Rule(order = 0)
|
||||
val activityTestRule =
|
||||
AndroidComposeTestRule(HomeActivityTestRule.withDefaultSettingsOverrides()) { it.activity }
|
||||
@ -41,21 +33,6 @@ class HomeScreenTest {
|
||||
@JvmField
|
||||
val retryTestRule = RetryTestRule(3)
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||
|
||||
mockWebServer = MockWebServer().apply {
|
||||
dispatcher = AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/235396
|
||||
@Test
|
||||
fun homeScreenItemsTest() {
|
||||
|
@ -7,14 +7,11 @@ package org.mozilla.fenix.ui
|
||||
import android.os.Build
|
||||
import android.view.autofill.AutofillManager
|
||||
import androidx.core.net.toUri
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.customannotations.SmokeTest
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||
import org.mozilla.fenix.helpers.MatcherHelper
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
|
||||
@ -29,6 +26,7 @@ import org.mozilla.fenix.helpers.TestHelper.restartApp
|
||||
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
|
||||
import org.mozilla.fenix.helpers.TestHelper.verifySnackBarText
|
||||
import org.mozilla.fenix.helpers.TestHelper.waitForAppWindowToBeUpdated
|
||||
import org.mozilla.fenix.helpers.TestSetup
|
||||
import org.mozilla.fenix.ui.robots.browserScreen
|
||||
import org.mozilla.fenix.ui.robots.clearTextFieldItem
|
||||
import org.mozilla.fenix.ui.robots.clickPageObject
|
||||
@ -42,20 +40,14 @@ import org.mozilla.fenix.ui.robots.setPageObjectText
|
||||
* - save login prompts.
|
||||
* - saving logins based on the user's preferences.
|
||||
*/
|
||||
class LoginsTest {
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
|
||||
class LoginsTest : TestSetup() {
|
||||
@get:Rule
|
||||
val activityTestRule =
|
||||
HomeActivityIntentTestRule.withDefaultSettingsOverrides(skipOnboarding = true)
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mockWebServer = MockWebServer().apply {
|
||||
dispatcher = AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
|
||||
val autofillManager: AutofillManager =
|
||||
TestHelper.appContext.getSystemService(AutofillManager::class.java)
|
||||
@ -63,11 +55,6 @@ class LoginsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2092713
|
||||
// Tests the Logins and passwords menu items and default values
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user