For #10798 & #14526: Apply auto-download test file fix for download UI tests

upstream-sync
Oana Horvath 3 years ago
parent 23789c86c4
commit 7ac4af46bc

@ -121,9 +121,9 @@ object TestHelper {
)
}
//Remove test file from the device Downloads folder
// Remove test file from the device Downloads folder
@Suppress("Deprecation")
fun deleteDownloadFromStorage(fileName: String){
fun deleteDownloadFromStorage(fileName: String) {
runBlocking {
val downloadedFile = File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),

@ -4,25 +4,21 @@
package org.mozilla.fenix.ui
import android.os.Environment
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule
import androidx.test.uiautomator.UiDevice
import kotlinx.coroutines.runBlocking
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.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.ui.robots.downloadRobot
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
import org.mozilla.fenix.ui.robots.notificationShade
import java.io.File
/**
* Tests for verifying basic functionality of download prompt UI
@ -56,35 +52,20 @@ class DownloadTest {
}
}
@Suppress("Deprecation")
@After
fun tearDown() {
mockWebServer.shutdown()
// Clear Download
runBlocking {
val downloadedFile = File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
"Globe.svg.html"
)
if (downloadedFile.exists()) {
downloadedFile.delete()
}
}
TestHelper.deleteDownloadFromStorage("Globe.svg")
}
@Test
@Ignore("Temp disable flaky test - see: https://github.com/mozilla-mobile/fenix/issues/10798")
fun testDownloadPrompt() {
homeScreen { }.dismissOnboarding()
val defaultWebPage = TestAssetHelper.getDownloadAsset(mockWebServer)
navigationToolbar {
}.openNewTabAndEnterToBrowser(defaultWebPage.url) {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
mDevice.waitForIdle()
clickLinkMatchingText(defaultWebPage.content)
}
downloadRobot {
@ -97,9 +78,8 @@ class DownloadTest {
val defaultWebPage = TestAssetHelper.getDownloadAsset(mockWebServer)
navigationToolbar {
}.openNewTabAndEnterToBrowser(defaultWebPage.url) {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
mDevice.waitForIdle()
clickLinkMatchingText(defaultWebPage.content)
}
downloadRobot {

@ -30,7 +30,6 @@ import org.mozilla.fenix.ui.robots.downloadRobot
import org.mozilla.fenix.ui.robots.enhancedTrackingProtection
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
import java.io.File
/**
* Test Suite that contains tests defined as part of the Smoke and Sanity check defined in Test rail.

@ -7,9 +7,7 @@
package org.mozilla.fenix.ui.robots
import android.content.Intent
import android.os.Environment
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.ViewInteraction
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers
@ -23,9 +21,7 @@ import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import kotlinx.coroutines.runBlocking
import org.hamcrest.CoreMatchers
import org.hamcrest.core.StringContains.containsString
import org.junit.Assert.assertTrue
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper
@ -34,7 +30,6 @@ import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull
import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_APPS_PHOTOS
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import java.io.File
/**
* Implementation of Robot Pattern for download UI handling.
@ -161,4 +156,4 @@ private fun assertPhotosOpens() {
private fun downloadedFile(fileName: String) = onView(withText(fileName))
private fun assertDownloadedFileIcon() = onView(withId(R.id.favicon)).check(matches(isDisplayed()))
private fun assertDownloadedFileIcon() = onView(withId(R.id.favicon)).check(matches(isDisplayed()))

Loading…
Cancel
Save