[fenix] Bug 1810528 - New PDFs open and save UI tests

pull/600/head
oana.horvath 1 year ago committed by mergify[bot]
parent bd61ac6f75
commit 7e9bda6d8c

@ -7,10 +7,12 @@ package org.mozilla.fenix.ui
import androidx.core.net.toUri
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.TestHelper.assertExternalAppOpens
import org.mozilla.fenix.helpers.TestHelper.deleteDownloadedFileOnStorage
import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.ui.robots.browserScreen
@ -30,6 +32,9 @@ class DownloadTest {
/* Remote test page managed by Mozilla Mobile QA team at https://github.com/mozilla-mobile/testapp */
private val downloadTestPage = "https://storage.googleapis.com/mobile_test_assets/test_app/downloads.html"
private var downloadFile: String = ""
private val pdfFileName = "washington.pdf"
private val pdfFileURL = "storage.googleapis.com/mobile_test_assets/public/washington.pdf"
private val pdfFileContent = "Washington Crossing the Delaware"
@get:Rule
val activityTestRule = HomeActivityIntentTestRule.withDefaultSettingsOverrides()
@ -184,4 +189,34 @@ class DownloadTest {
mDevice.pressBack()
}
}
@SmokeTest
@Test
fun openPDFInBrowserTest() {
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
clickLinkMatchingText(pdfFileName)
verifyUrl(pdfFileURL)
verifyPageContent(pdfFileContent)
}
}
@Ignore("Failing because of https://bugzilla.mozilla.org/show_bug.cgi?id=1810132")
@SmokeTest
@Test
fun saveAndOpenPdfTest() {
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
clickLinkMatchingText(pdfFileName)
verifyPageContent(pdfFileContent)
}.openThreeDotMenu {
}.clickShareButton {
}.clickSaveAsPDF {
// change back to simple filename
verifyDownloadPrompt(pdfFileName)
}.clickDownload {
}.clickOpen("application/pdf") {
assertExternalAppOpens("com.google.android.apps.docs")
}
}
}

@ -90,6 +90,7 @@ class DownloadRobot {
}
fun clickOpen(type: String, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
openDownloadButton().waitForExists(waitingTime)
openDownloadButton().click()
// verify open intent is matched with associated data type
@ -186,13 +187,12 @@ private fun closePromptButton() =
onView(withContentDescription("Close"))
private fun downloadButton() =
onView(withText("Download"))
onView(withId(R.id.download_button))
.inRoot(isDialog())
.check(matches(isDisplayed()))
private fun openDownloadButton() =
onView(withId(R.id.download_dialog_action_button))
.check(matches(isDisplayed()))
mDevice.findObject(UiSelector().resourceId("$packageName:id/download_dialog_action_button"))
private fun downloadedFile(fileName: String) = onView(withText(fileName))

@ -20,6 +20,7 @@ import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import org.hamcrest.Matchers.allOf
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.ext.waitNotNull
@ -71,7 +72,14 @@ class ShareOverlayRobot {
)
}
class Transition
class Transition {
fun clickSaveAsPDF(interact: DownloadRobot.() -> Unit): DownloadRobot.Transition {
itemContainingText("Save as PDF").click()
DownloadRobot().interact()
return DownloadRobot.Transition()
}
}
}
private fun shareTabsLayout() = onView(withResourceName("shareWrapper"))

Loading…
Cancel
Save