pull/600/head
Oana Horvath 4 years ago
parent e4659fac17
commit 5ac58d8b6e

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

@ -4,25 +4,21 @@
package org.mozilla.fenix.ui package org.mozilla.fenix.ui
import android.os.Environment
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule import androidx.test.rule.GrantPermissionRule
import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiDevice
import kotlinx.coroutines.runBlocking
import okhttp3.mockwebserver.MockWebServer import okhttp3.mockwebserver.MockWebServer
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before
import org.junit.Ignore
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestAssetHelper 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.downloadRobot
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar import org.mozilla.fenix.ui.robots.navigationToolbar
import org.mozilla.fenix.ui.robots.notificationShade import org.mozilla.fenix.ui.robots.notificationShade
import java.io.File
/** /**
* Tests for verifying basic functionality of download prompt UI * Tests for verifying basic functionality of download prompt UI
@ -56,35 +52,20 @@ class DownloadTest {
} }
} }
@Suppress("Deprecation")
@After @After
fun tearDown() { fun tearDown() {
mockWebServer.shutdown() mockWebServer.shutdown()
// Clear Download TestHelper.deleteDownloadFromStorage("Globe.svg")
runBlocking {
val downloadedFile = File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
"Globe.svg.html"
)
if (downloadedFile.exists()) {
downloadedFile.delete()
}
}
} }
@Test @Test
@Ignore("Temp disable flaky test - see: https://github.com/mozilla-mobile/fenix/issues/10798")
fun testDownloadPrompt() { fun testDownloadPrompt() {
homeScreen { }.dismissOnboarding()
val defaultWebPage = TestAssetHelper.getDownloadAsset(mockWebServer) val defaultWebPage = TestAssetHelper.getDownloadAsset(mockWebServer)
navigationToolbar { navigationToolbar {
}.openNewTabAndEnterToBrowser(defaultWebPage.url) { }.enterURLAndEnterToBrowser(defaultWebPage.url) {
mDevice.waitForIdle() mDevice.waitForIdle()
clickLinkMatchingText(defaultWebPage.content)
} }
downloadRobot { downloadRobot {
@ -97,9 +78,8 @@ class DownloadTest {
val defaultWebPage = TestAssetHelper.getDownloadAsset(mockWebServer) val defaultWebPage = TestAssetHelper.getDownloadAsset(mockWebServer)
navigationToolbar { navigationToolbar {
}.openNewTabAndEnterToBrowser(defaultWebPage.url) { }.enterURLAndEnterToBrowser(defaultWebPage.url) {
mDevice.waitForIdle() mDevice.waitForIdle()
clickLinkMatchingText(defaultWebPage.content)
} }
downloadRobot { 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.enhancedTrackingProtection
import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar 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. * 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 package org.mozilla.fenix.ui.robots
import android.content.Intent import android.content.Intent
import android.os.Environment
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.ViewInteraction
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.intent.Intents import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers 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.UiDevice
import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import kotlinx.coroutines.runBlocking
import org.hamcrest.CoreMatchers import org.hamcrest.CoreMatchers
import org.hamcrest.core.StringContains.containsString
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper 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.ext.waitNotNull
import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_APPS_PHOTOS import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_APPS_PHOTOS
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import java.io.File
/** /**
* Implementation of Robot Pattern for download UI handling. * 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 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