Bug 1906091 - Adjust MLS timeout fallback value to 5 r=emilio
[gecko.git] / mobile / android / fenix / app / src / androidTest / java / org / mozilla / fenix / ui / DownloadFileTypesTest.kt
blob25123c13182906f25f91c8ddd63e325f276c4e61
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.compose.ui.test.junit4.AndroidComposeTestRule
8 import androidx.core.net.toUri
9 import org.junit.Rule
10 import org.junit.Test
11 import org.junit.runner.RunWith
12 import org.junit.runners.Parameterized
13 import org.mozilla.fenix.customannotations.SmokeTest
14 import org.mozilla.fenix.helpers.HomeActivityTestRule
15 import org.mozilla.fenix.helpers.TestSetup
16 import org.mozilla.fenix.ui.robots.downloadRobot
18 /**
19  *  Test for verifying downloading a list of different file types:
20  *  - Initiates a download
21  *  - Verifies download prompt
22  *  - Verifies downloading of varying file types and the appearance inside the Downloads listing.
23  **/
24 @RunWith(Parameterized::class)
25 class DownloadFileTypesTest(fileName: String) : TestSetup() {
26     /* Remote test page managed by Mozilla Mobile QA team at https://github.com/mozilla-mobile/testapp */
27     private val downloadTestPage = "https://storage.googleapis.com/mobile_test_assets/test_app/downloads.html"
28     private var downloadFile: String = fileName
30     @get:Rule
31     val activityTestRule =
32         AndroidComposeTestRule(
33             HomeActivityTestRule.withDefaultSettingsOverrides(),
34         ) { it.activity }
36     companion object {
37         // Creating test data. The test will take each file name as a parameter and run it individually.
38         @JvmStatic
39         @Parameterized.Parameters
40         fun downloadList() = listOf(
41             "smallZip.zip",
42             "MyDocument.docx",
43             "audioSample.mp3",
44             "textfile.txt",
45             "web_icon.png",
46             "videoSample.webm",
47             "CSVfile.csv",
48             "XMLfile.xml",
49             "tAJwqaWjJsXS8AhzSninBMCfIZbHBGgcc001lx5DIdDwIcfEgQ6vE5Gb5VgAled17DFZ2A7ZDOHA0NpQPHXXFt.svg",
50         )
51     }
53     // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/251028
54     @SmokeTest
55     @Test
56     fun allFilesAppearInDownloadsMenuTest() {
57         downloadRobot {
58             openPageAndDownloadFile(url = downloadTestPage.toUri(), downloadFile = downloadFile)
59             verifyDownloadCompleteNotificationPopup()
60         }.closeDownloadPrompt {
61         }.openThreeDotMenu {
62         }.openDownloadsManager() {
63             verifyDownloadedFileExistsInDownloadsList(activityTestRule, downloadFile)
64         }.exitDownloadsManagerToBrowser { }
65     }