2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

Bug 1827868 - Use new local asset in PDF related UI tests

This commit is contained in:
AndiAJ 2023-04-19 12:49:35 +03:00 committed by mergify[bot]
parent b174327635
commit c8ae92a7fa
3 changed files with 57 additions and 48 deletions

View File

@ -5,13 +5,16 @@
package org.mozilla.fenix.ui
import androidx.core.net.toUri
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.customannotations.SmokeTest
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper.assertExternalAppOpens
import org.mozilla.fenix.helpers.TestHelper.deleteDownloadedFileOnStorage
import org.mozilla.fenix.helpers.TestHelper.mDevice
@ -29,18 +32,23 @@ import org.mozilla.fenix.ui.robots.notificationShade
* - Verifies managing downloads inside the Downloads listing.
**/
class DownloadTest {
private lateinit var mockWebServer: MockWebServer
/* 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()
@Before
fun setUp() {
mockWebServer = MockWebServer().apply {
dispatcher = AndroidAssetDispatcher()
start()
}
// clear all existing notifications
notificationShade {
mDevice.openNotification()
@ -53,6 +61,8 @@ class DownloadTest {
notificationShade {
cancelAllShownNotifications()
}
mockWebServer.shutdown()
}
@Test
@ -199,21 +209,25 @@ class DownloadTest {
@SmokeTest
@Test
fun openPDFInBrowserTest() {
val genericURL =
TestAssetHelper.getGenericAsset(mockWebServer, 3)
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
clickLinkMatchingText(pdfFileName)
verifyUrl(pdfFileURL)
verifyPageContent(pdfFileContent)
}.enterURLAndEnterToBrowser(genericURL.url) {
clickLinkMatchingText("PDF file")
verifyPageContent("Washington Crossing the Delaware")
}
}
@SmokeTest
@Test
fun saveAndOpenPdfTest() {
val genericURL =
TestAssetHelper.getGenericAsset(mockWebServer, 3)
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
clickLinkMatchingText(pdfFileName)
verifyPageContent(pdfFileContent)
}.enterURLAndEnterToBrowser(genericURL.url) {
clickLinkMatchingText("PDF file")
}.openThreeDotMenu {
}.clickShareButton {
}.clickSaveAsPDF {

View File

@ -34,11 +34,6 @@ import java.util.Locale
class NavigationToolbarTest {
private lateinit var mDevice: UiDevice
private lateinit var mockWebServer: MockWebServer
private val downloadTestPage =
"https://storage.googleapis.com/mobile_test_assets/test_app/downloads.html"
private val pdfFileName = "washington.pdf"
private val pdfFileURL = "storage.googleapis.com/mobile_test_assets/public/washington.pdf"
private val pdfFileContent = "Washington Crossing the Delaware"
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
@get:Rule
@ -192,11 +187,12 @@ class NavigationToolbarTest {
@Test
fun pdfFindInPageTest() {
val genericURL =
TestAssetHelper.getGenericAsset(mockWebServer, 3)
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
clickLinkMatchingText(pdfFileName)
verifyUrl(pdfFileURL)
verifyPageContent(pdfFileContent)
}.enterURLAndEnterToBrowser(genericURL.url) {
clickLinkMatchingText("PDF file")
}.openThreeDotMenu {
verifyThreeDotMenuExists()
verifyFindInPageButton()
@ -214,7 +210,7 @@ class NavigationToolbarTest {
verifyFindInPageBar(false)
}.openThreeDotMenu {
}.openFindInPage {
enterFindInPageQuery("l")
enterFindInPageQuery("p")
verifyFindNextInPageResult("1/1")
}.closeFindInPageWithBackButton {
verifyFindInPageBar(false)

View File

@ -1,6 +1,5 @@
package org.mozilla.fenix.ui
import androidx.core.net.toUri
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
@ -22,11 +21,6 @@ import org.mozilla.fenix.ui.robots.searchScreen
class TextSelectionTest {
private lateinit var mDevice: UiDevice
private lateinit var mockWebServer: MockWebServer
private val downloadTestPage =
"https://storage.googleapis.com/mobile_test_assets/test_app/downloads.html"
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 activityIntentTestRule = HomeActivityIntentTestRule.withDefaultSettingsOverrides()
@ -139,11 +133,12 @@ class TextSelectionTest {
@SmokeTest
@Test
fun selectAllAndCopyPDFTextTest() {
val genericURL =
TestAssetHelper.getGenericAsset(mockWebServer, 3)
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
clickLinkMatchingText(pdfFileName)
verifyUrl(pdfFileURL)
verifyPageContent(pdfFileContent)
}.enterURLAndEnterToBrowser(genericURL.url) {
clickLinkMatchingText("PDF file")
longClickAndCopyText("Crossing", true)
}.openNavigationToolbar {
openEditURLView()
@ -155,18 +150,19 @@ class TextSelectionTest {
clickPasteText()
// With Select all, white spaces are copied
// Potential bug https://bugzilla.mozilla.org/show_bug.cgi?id=1821310
verifyTypedToolbarText(" Washington Crossing the Delaware ")
verifyTypedToolbarText(" Washington Crossing the Delaware Wikipedia link ")
}
}
@SmokeTest
@Test
fun copyPDFTextTest() {
val genericURL =
TestAssetHelper.getGenericAsset(mockWebServer, 3)
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
clickLinkMatchingText(pdfFileName)
verifyUrl(pdfFileURL)
verifyPageContent(pdfFileContent)
}.enterURLAndEnterToBrowser(genericURL.url) {
clickLinkMatchingText("PDF file")
longClickAndCopyText("Crossing")
}.openNavigationToolbar {
openEditURLView()
@ -183,11 +179,12 @@ class TextSelectionTest {
@SmokeTest
@Test
fun shareSelectedPDFTextTest() {
val genericURL =
TestAssetHelper.getGenericAsset(mockWebServer, 3)
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
clickLinkMatchingText(pdfFileName)
verifyUrl(pdfFileURL)
verifyPageContent(pdfFileContent)
}.enterURLAndEnterToBrowser(genericURL.url) {
clickLinkMatchingText("PDF file")
longClickMatchingText("Crossing")
}.clickShareSelectedText {
verifyAndroidShareLayout()
@ -197,13 +194,14 @@ class TextSelectionTest {
@SmokeTest
@Test
fun selectAndSearchPDFTextTest() {
val genericURL =
TestAssetHelper.getGenericAsset(mockWebServer, 3)
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
clickLinkMatchingText(pdfFileName)
verifyUrl(pdfFileURL)
verifyPageContent(pdfFileContent)
}.enterURLAndEnterToBrowser(genericURL.url) {
clickLinkMatchingText("PDF file")
longClickAndSearchText("Search", "Crossing")
verifyTabCounter("3")
verifyTabCounter("2")
verifyUrl("google")
}
}
@ -211,16 +209,17 @@ class TextSelectionTest {
@SmokeTest
@Test
fun privateSelectAndSearchPDFTextTest() {
val genericURL =
TestAssetHelper.getGenericAsset(mockWebServer, 3)
homeScreen {
}.togglePrivateBrowsingMode()
navigationToolbar {
}.enterURLAndEnterToBrowser(downloadTestPage.toUri()) {
clickLinkMatchingText(pdfFileName)
verifyUrl(pdfFileURL)
verifyPageContent(pdfFileContent)
}.enterURLAndEnterToBrowser(genericURL.url) {
clickLinkMatchingText("PDF file")
longClickAndSearchText("Private Search", "Crossing")
verifyTabCounter("3")
verifyTabCounter("2")
verifyUrl("google")
}
}