diff --git a/app/src/androidTest/java/org/mozilla/fenix/helpers/TestHelper.kt b/app/src/androidTest/java/org/mozilla/fenix/helpers/TestHelper.kt index 62ba4f069..77360a5ce 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/helpers/TestHelper.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/helpers/TestHelper.kt @@ -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), diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/DownloadTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/DownloadTest.kt index c0919cce8..92774c7aa 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/DownloadTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/DownloadTest.kt @@ -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 { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt index 17c5f6e18..362b6a2de 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt @@ -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. diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/DownloadRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/DownloadRobot.kt index 8733d4401..909582c26 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/DownloadRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/DownloadRobot.kt @@ -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())) \ No newline at end of file +private fun assertDownloadedFileIcon() = onView(withId(R.id.favicon)).check(matches(isDisplayed()))