Bug 1853639 - Downloads TestRail matching

fenix/119.0
oana.horvath 8 months ago committed by mergify[bot]
parent eb106f2a0f
commit cb0bb9f0dd

@ -187,9 +187,11 @@ object TestHelper {
val storageVolume: StorageVolume = storageVolumes[0]
val file = File(storageVolume.directory!!.path + "/Download/" + fileName)
try {
file.delete()
Log.d("TestLog", "File delete try 1")
assertFalse("The file was not deleted", file.exists())
if (file.exists()) {
file.delete()
Log.d("TestLog", "File delete try 1")
assertFalse("The file was not deleted", file.exists())
}
} catch (e: AssertionError) {
file.delete()
Log.d("TestLog", "File delete retried")

@ -236,7 +236,7 @@ class ComposeContextMenusTest {
}
downloadRobot {
verifyDownloadNotificationPopup()
verifyDownloadCompleteNotificationPopup()
}.clickOpen("image/jpeg") {} // verify open intent is matched with associated data type
downloadRobot {
verifyPhotosAppOpens()

@ -199,7 +199,7 @@ class ComposeSettingsDeleteBrowsingDataOnQuitTest {
}.clickDownloadLink("smallZip.zip") {
verifyDownloadPrompt("smallZip.zip")
}.clickDownload {
verifyDownloadNotificationPopup()
verifyDownloadCompleteNotificationPopup()
}.closeCompletedDownloadPrompt {
}.goToHomescreen {
}.openThreeDotMenu {

@ -232,7 +232,7 @@ class ContextMenusTest {
}
downloadRobot {
verifyDownloadNotificationPopup()
verifyDownloadCompleteNotificationPopup()
}.clickOpen("image/jpeg") {} // verify open intent is matched with associated data type
downloadRobot {
verifyPhotosAppOpens()

@ -206,7 +206,7 @@ class CustomTabsTest {
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
verifyDownloadNotificationPopup()
verifyDownloadCompleteNotificationPopup()
}
mDevice.openNotification()
notificationShade {

@ -41,18 +41,20 @@ class DownloadFileTypesTest(fileName: String) {
"videoSample.webm",
"CSVfile.csv",
"XMLfile.xml",
"tAJwqaWjJsXS8AhzSninBMCfIZbHBGgcc001lx5DIdDwIcfEgQ6vE5Gb5VgAled17DFZ2A7ZDOHA0NpQPHXXFt.svg",
)
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/251028&group_by=cases:section_id&group_id=31659&group_order=asc
@SmokeTest
@Test
fun downloadMultipleFileTypesTest() {
fun allFilesAppearInDownloadsMenuTest() {
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
verifyDownloadNotificationPopup()
verifyDownloadCompleteNotificationPopup()
}.closeCompletedDownloadPrompt {
}.openThreeDotMenu {
}.openDownloadsManager {

@ -13,6 +13,7 @@ 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.Constants.PackageName.GOOGLE_APPS_PHOTOS
import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_DOCS
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.MatcherHelper.itemWithText
@ -20,6 +21,7 @@ import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper.assertExternalAppOpens
import org.mozilla.fenix.helpers.TestHelper.clickSnackbarButton
import org.mozilla.fenix.helpers.TestHelper.deleteDownloadedFileOnStorage
import org.mozilla.fenix.helpers.TestHelper.exitMenu
import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestHelper.setNetworkEnabled
import org.mozilla.fenix.ui.robots.browserScreen
@ -72,8 +74,9 @@ class DownloadTest {
setNetworkEnabled(enabled = true)
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/243844
@Test
fun testDownloadPrompt() {
fun verifyTheDownloadPromptsTest() {
downloadFile = "web_icon.png"
navigationToolbar {
@ -82,7 +85,7 @@ class DownloadTest {
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
verifyDownloadNotificationPopup()
verifyDownloadCompleteNotificationPopup()
}.clickOpen("image/png") {}
downloadRobot {
verifyPhotosAppOpens()
@ -91,25 +94,34 @@ class DownloadTest {
deleteDownloadedFileOnStorage(downloadFile)
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2299405
@Test
fun testCloseDownloadPrompt() {
downloadFile = "smallZip.zip"
fun verifyTheDownloadFailedNotificationsTest() {
downloadFile = "1GB.zip"
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
waitForPageToLoad()
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.closePrompt {
}.openThreeDotMenu {
}.openDownloadsManager {
verifyEmptyDownloadsList()
}.clickDownload {
setNetworkEnabled(enabled = false)
verifyDownloadFailedPrompt(downloadFile)
setNetworkEnabled(enabled = true)
clickTryAgainButton()
}
mDevice.openNotification()
notificationShade {
verifySystemNotificationDoesNotExist("Download failed")
verifySystemNotificationExists(downloadFile)
}.closeNotificationTray {}
deleteDownloadedFileOnStorage(downloadFile)
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2298616
@Test
fun testDownloadCompleteNotification() {
downloadFile = "smallZip.zip"
fun verifyDownloadCompleteNotificationTest() {
downloadFile = "web_icon.png"
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
@ -117,15 +129,26 @@ class DownloadTest {
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
verifyDownloadNotificationPopup()
verifyDownloadCompleteNotificationPopup()
}
mDevice.openNotification()
notificationShade {
verifySystemNotificationExists("Download completed")
}
clickNotification("Download completed")
assertExternalAppOpens(GOOGLE_APPS_PHOTOS)
mDevice.pressBack()
mDevice.openNotification()
swipeDownloadNotification(
direction = "Left",
shouldDismissNotification = true,
canExpandNotification = false,
)
verifySystemNotificationDoesNotExist("Firefox Fenix")
}.closeNotificationTray {}
deleteDownloadedFileOnStorage(downloadFile)
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/451563
@Ignore("Failing: Bug https://bugzilla.mozilla.org/show_bug.cgi?id=1813521")
@SmokeTest
@Test
@ -148,8 +171,10 @@ class DownloadTest {
verifySystemNotificationExists("Firefox Fenix")
expandNotificationMessage()
clickDownloadNotificationControlButton("PAUSE")
verifySystemNotificationExists("Download paused")
clickDownloadNotificationControlButton("RESUME")
clickDownloadNotificationControlButton("CANCEL")
verifySystemNotificationDoesNotExist(downloadFile)
mDevice.pressBack()
}
browserScreen {
@ -160,42 +185,9 @@ class DownloadTest {
deleteDownloadedFileOnStorage(downloadFile)
}
/* Verifies downloads in the Downloads Menu:
- downloads appear in the list
- deleting a download from device storage, removes it from the Downloads Menu too
*/
@SmokeTest
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2301474
@Test
fun manageDownloadsInDownloadsMenuTest() {
// a long filename to verify it's correctly displayed on the prompt and in the Downloads menu
downloadFile =
"tAJwqaWjJsXS8AhzSninBMCfIZbHBGgcc001lx5DIdDwIcfEgQ6vE5Gb5VgAled17DFZ2A7ZDOHA0NpQPHXXFt.svg"
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
waitForPageToLoad()
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
verifyDownloadNotificationPopup()
}
browserScreen {
}.openThreeDotMenu {
}.openDownloadsManager {
waitForDownloadsListToExist()
verifyDownloadedFileName(downloadFile)
verifyDownloadedFileIcon()
deleteDownloadedFileOnStorage(downloadFile)
}.exitDownloadsManagerToBrowser {
}.openThreeDotMenu {
}.openDownloadsManager {
verifyEmptyDownloadsList()
}
}
@SmokeTest
@Test
fun openDownloadedFileTest() {
fun openDownloadedFileFromDownloadsMenuTest() {
downloadFile = "web_icon.png"
navigationToolbar {
@ -204,7 +196,7 @@ class DownloadTest {
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
verifyDownloadNotificationPopup()
verifyDownloadCompleteNotificationPopup()
}
browserScreen {
}.openThreeDotMenu {
@ -239,32 +231,11 @@ class DownloadTest {
deleteDownloadedFileOnStorage(downloadFile)
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1114970
@Test
fun deleteDownloadedFileTest() {
downloadFile = "smallZip.zip"
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
waitForPageToLoad()
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
verifyDownloadedFileName(downloadFile)
}
browserScreen {
}.openThreeDotMenu {
}.openDownloadsManager {
verifyDownloadedFileName(downloadFile)
deleteDownloadedItem(downloadFile)
verifyEmptyDownloadsList()
}
deleteDownloadedFileOnStorage(downloadFile)
}
@Test
fun undoDeleteDownloadedFileTest() {
downloadFile = "smallZip.zip"
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
waitForPageToLoad()
@ -280,10 +251,13 @@ class DownloadTest {
deleteDownloadedItem(downloadFile)
clickSnackbarButton("UNDO")
verifyDownloadedFileName(downloadFile)
deleteDownloadedItem(downloadFile)
verifyEmptyDownloadsList()
}
deleteDownloadedFileOnStorage(downloadFile)
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2302662
@Test
fun deleteMultipleDownloadedFilesTest() {
val firstDownloadedFile = "smallZip.zip"
@ -305,6 +279,13 @@ class DownloadTest {
browserScreen {
}.openThreeDotMenu {
}.openDownloadsManager {
verifyDownloadedFileName(firstDownloadedFile)
verifyDownloadedFileName(secondDownloadedFile)
longClickDownloadedItem(firstDownloadedFile)
selectDownloadedItem(secondDownloadedFile)
openMultiSelectMoreOptionsMenu()
clickMultiSelectRemoveButton()
clickSnackbarButton("UNDO")
verifyDownloadedFileName(firstDownloadedFile)
verifyDownloadedFileName(secondDownloadedFile)
longClickDownloadedItem(firstDownloadedFile)
@ -317,70 +298,52 @@ class DownloadTest {
deleteDownloadedFileOnStorage(secondDownloadedFile)
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2301537
@Test
fun undoDeleteMultipleDownloadedFilesTest() {
val firstDownloadedFile = "smallZip.zip"
val secondDownloadedFile = "textfile.txt"
fun fileDeletedFromStorageIsDeletedEverywhereTest() {
val downloadFile = "smallZip.zip"
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
waitForPageToLoad()
}.clickDownloadLink(firstDownloadedFile) {
verifyDownloadPrompt(firstDownloadedFile)
}.clickDownload {
verifyDownloadedFileName(firstDownloadedFile)
}.closeCompletedDownloadPrompt {
}.clickDownloadLink(secondDownloadedFile) {
verifyDownloadPrompt(secondDownloadedFile)
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
verifyDownloadedFileName(secondDownloadedFile)
verifyDownloadCompleteNotificationPopup()
}
browserScreen {
}.openThreeDotMenu {
}.openDownloadsManager {
verifyDownloadedFileName(firstDownloadedFile)
verifyDownloadedFileName(secondDownloadedFile)
longClickDownloadedItem(firstDownloadedFile)
selectDownloadedItem(secondDownloadedFile)
openMultiSelectMoreOptionsMenu()
clickMultiSelectRemoveButton()
clickSnackbarButton("UNDO")
verifyDownloadedFileName(firstDownloadedFile)
verifyDownloadedFileName(secondDownloadedFile)
}
deleteDownloadedFileOnStorage(firstDownloadedFile)
deleteDownloadedFileOnStorage(secondDownloadedFile)
}
@Ignore("Failing: https://bugzilla.mozilla.org/show_bug.cgi?id=1840994")
@Test
fun systemNotificationCantBeDismissedWhileDownloadingTest() {
// Clear the "Firefox Fenix default browser notification"
notificationShade {
cancelAllShownNotifications()
waitForDownloadsListToExist()
verifyDownloadedFileName(downloadFile)
deleteDownloadedFileOnStorage(downloadFile)
}.exitDownloadsManagerToBrowser {
}.openThreeDotMenu {
}.openDownloadsManager {
verifyEmptyDownloadsList()
exitMenu()
}
downloadFile = "1GB.zip"
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
waitForPageToLoad()
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
verifyDownloadCompleteNotificationPopup()
}
browserScreen {
}.openNotificationShade {
verifySystemNotificationExists("Firefox Fenix")
expandNotificationMessage()
swipeDownloadNotification("Left", false)
clickDownloadNotificationControlButton("CANCEL")
}.openThreeDotMenu {
}.openDownloadsManager {
waitForDownloadsListToExist()
verifyDownloadedFileName(downloadFile)
}
deleteDownloadedFileOnStorage(downloadFile)
}
@Ignore("Failing: https://bugzilla.mozilla.org/show_bug.cgi?id=1840994")
@Test
fun systemNotificationCantBeDismissedWhileDownloadIsPausedTest() {
fun systemNotificationCantBeDismissedWhileInProgressTest() {
// Clear the "Firefox Fenix default browser notification"
notificationShade {
cancelAllShownNotifications()
@ -399,15 +362,9 @@ class DownloadTest {
}.openNotificationShade {
verifySystemNotificationExists("Firefox Fenix")
expandNotificationMessage()
swipeDownloadNotification(direction = "Left", shouldDismissNotification = false)
clickDownloadNotificationControlButton("PAUSE")
swipeDownloadNotification("Left", false)
verifySystemNotificationExists("Firefox Fenix")
}.closeNotificationTray {
}.openNotificationShade {
verifySystemNotificationExists("Firefox Fenix")
expandNotificationMessage()
swipeDownloadNotification("Right", false)
verifySystemNotificationExists("Firefox Fenix")
swipeDownloadNotification(direction = "Right", shouldDismissNotification = false)
clickDownloadNotificationControlButton("CANCEL")
}
deleteDownloadedFileOnStorage(downloadFile)
@ -427,8 +384,7 @@ class DownloadTest {
waitForPageToLoad()
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
}
}.clickDownload {}
setNetworkEnabled(enabled = false)
@ -438,8 +394,7 @@ class DownloadTest {
expandNotificationMessage()
swipeDownloadNotification("Left", true)
verifySystemNotificationDoesNotExist("Firefox Fenix")
}.closeNotificationTray {
}
}.closeNotificationTray {}
downloadRobot {
}.closeDownloadPrompt {
@ -449,56 +404,22 @@ class DownloadTest {
}
@Test
fun notificationCanBeDismissedIfDownloadIsCompletedTest() {
// Clear the "Firefox Fenix default browser notification"
notificationShade {
cancelAllShownNotifications()
}
downloadFile = "smallZip.zip"
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
waitForPageToLoad()
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
}
browserScreen {
}.openNotificationShade {
verifySystemNotificationExists("Download completed")
swipeDownloadNotification("Left", true, false)
verifySystemNotificationDoesNotExist("Firefox Fenix")
}.closeNotificationTray {
}
downloadRobot {
}.closeDownloadPrompt {
verifyDownloadPromptIsDismissed()
}
deleteDownloadedFileOnStorage(downloadFile)
}
fun warningWhenClosingPrivateTabsWhileDownloadingTest() {
downloadFile = "1GB.zip"
@Test
fun stayInPrivateBrowsingPromptTest() {
// Clear the "Firefox Fenix default browser notification"
notificationShade {
cancelAllShownNotifications()
}
downloadFile = "1GB.zip"
homeScreen {
}.togglePrivateBrowsingMode()
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
waitForPageToLoad()
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
}
}.clickDownload {}
browserScreen {
}.openTabDrawer {
closeTab()
@ -512,15 +433,16 @@ class DownloadTest {
deleteDownloadedFileOnStorage(downloadFile)
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2302663
@Test
fun cancelActiveDownloadsFromPrivateBrowsingPromptTest() {
fun cancelActivePrivateBrowsingDownloadsTest() {
downloadFile = "1GB.zip"
// Clear the "Firefox Fenix default browser notification"
notificationShade {
cancelAllShownNotifications()
}
downloadFile = "1GB.zip"
homeScreen {
}.togglePrivateBrowsingMode()
@ -529,8 +451,7 @@ class DownloadTest {
waitForPageToLoad()
}.clickDownloadLink(downloadFile) {
verifyDownloadPrompt(downloadFile)
}.clickDownload {
}
}.clickDownload {}
browserScreen {
}.openTabDrawer {
closeTab()

@ -196,7 +196,7 @@ class SettingsDeleteBrowsingDataOnQuitTest {
}.clickDownloadLink("smallZip.zip") {
verifyDownloadPrompt("smallZip.zip")
}.clickDownload {
verifyDownloadNotificationPopup()
verifyDownloadCompleteNotificationPopup()
}.closeCompletedDownloadPrompt {
}.goToHomescreen {
}.openThreeDotMenu {

@ -29,6 +29,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_APPS_PHOTOS
import org.mozilla.fenix.helpers.MatcherHelper.itemWithDescription
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdContainingText
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeLong
@ -48,7 +49,58 @@ class DownloadRobot {
fun verifyDownloadPrompt(fileName: String) = assertDownloadPrompt(fileName)
fun verifyDownloadNotificationPopup() = assertDownloadNotificationPopup()
fun verifyDownloadCompleteNotificationPopup() {
assertTrue(
"Download notification Open button not found",
mDevice.findObject(UiSelector().text("Open"))
.waitForExists(waitingTime),
)
assertTrue(
"Download completed notification text doesn't match",
mDevice.findObject(UiSelector().textContains("Download completed"))
.waitForExists(waitingTime),
)
assertTrue(
"Downloaded file name not visible",
mDevice.findObject(UiSelector().resourceId("$packageName:id/download_dialog_filename"))
.waitForExists(waitingTime),
)
}
fun verifyDownloadFailedPrompt(fileName: String) {
assertTrue(
itemWithResId("$packageName:id/download_dialog_icon")
.waitForExists(waitingTime),
)
assertTrue(
"Download dialog title not displayed",
itemWithResIdAndText(
"$packageName:id/download_dialog_title",
"Download failed",
).waitForExists(waitingTime),
)
assertTrue(
"Download file name not displayed",
itemWithResIdContainingText(
"$packageName:id/download_dialog_filename",
fileName,
).waitForExists(waitingTime),
)
assertTrue(
"Try again button not displayed",
itemWithResIdAndText(
"$packageName:id/download_dialog_action_button",
"Try Again",
).waitForExists(waitingTime),
)
}
fun clickTryAgainButton() {
itemWithResIdAndText(
"$packageName:id/download_dialog_action_button",
"Try Again",
).click()
}
fun verifyPhotosAppOpens() = assertExternalAppOpens(GOOGLE_APPS_PHOTOS)
@ -126,13 +178,6 @@ class DownloadRobot {
return BrowserRobot.Transition()
}
fun closePrompt(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
closePromptButton().click()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
fun closeDownloadPrompt(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
itemWithResId("$packageName:id/download_dialog_close_button").click()
@ -216,24 +261,6 @@ private fun assertDownloadPrompt(fileName: String) {
}
}
private fun assertDownloadNotificationPopup() {
assertTrue(
"Download notification Open button not found",
mDevice.findObject(UiSelector().text("Open"))
.waitForExists(waitingTime),
)
assertTrue(
"Download completed notification text doesn't match",
mDevice.findObject(UiSelector().textContains("Download completed"))
.waitForExists(waitingTime),
)
assertTrue(
"Downloaded file name not visible",
mDevice.findObject(UiSelector().resourceId("$packageName:id/download_dialog_filename"))
.waitForExists(waitingTime),
)
}
private fun closeCompletedDownloadButton() =
onView(withId(R.id.download_dialog_close_button))

@ -165,6 +165,11 @@ class NotificationRobot {
}
}
fun clickNotification(notificationMessage: String) {
mDevice.findObject(UiSelector().text(notificationMessage)).waitForExists(waitingTime)
mDevice.findObject(UiSelector().text(notificationMessage)).click()
}
class Transition {
fun clickClosePrivateTabsNotification(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {

Loading…
Cancel
Save