зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1838206 - Focus UI tests: add PDF reader smoke test coverage r=ajoltan
Try run: https://treeherder.mozilla.org/jobs?repo=try&revision=9a664dfc6a66b8c7ca058380e80aa98ca0da54b2&selectedTaskRun=YYoo008xS46u65SbPtQFEA.0 Differential Revision: https://phabricator.services.mozilla.com/D217801
This commit is contained in:
Родитель
8c02e0e509
Коммит
aa144f349b
|
@ -9,6 +9,8 @@
|
|||
<h1 id="header">focus test page</h1>
|
||||
<!-- More random words that should not end up on disk -->
|
||||
<p>groovy rabbits</p>
|
||||
<p>This test page does nothing.</p>
|
||||
<p>
|
||||
<a href="/resources/pdfFile.pdf">PDF file</a>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Двоичные данные
mobile/android/focus-android/app/src/androidTest/assets/resources/pdfFile.pdf
Normal file
Двоичные данные
mobile/android/focus-android/app/src/androidTest/assets/resources/pdfFile.pdf
Normal file
Двоичный файл не отображается.
|
@ -138,21 +138,6 @@ class DownloadFileTest {
|
|||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun openPdfFileTest() {
|
||||
downloadFileName = "washington.pdf"
|
||||
val pdfFileURL = "https://storage.googleapis.com/mobile_test_assets/public/washington.pdf"
|
||||
val pdfFileContent = "Washington Crossing the Delaware"
|
||||
searchScreen {
|
||||
}.loadPage(downloadTestPage) {
|
||||
progressBar.waitUntilGone(waitingTime)
|
||||
clickLinkMatchingText(downloadFileName)
|
||||
verifyPageURL(pdfFileURL)
|
||||
verifyPageContent(pdfFileContent)
|
||||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun downloadAndOpenWebmFileTest() {
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package org.mozilla.focus.activity
|
||||
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.focus.activity.robots.searchScreen
|
||||
import org.mozilla.focus.helpers.DeleteFilesHelper.deleteFileUsingDisplayName
|
||||
import org.mozilla.focus.helpers.FeatureSettingsHelper
|
||||
import org.mozilla.focus.helpers.MainActivityIntentsTestRule
|
||||
import org.mozilla.focus.helpers.MockWebServerHelper
|
||||
import org.mozilla.focus.helpers.TestAssetHelper.getGenericAsset
|
||||
import org.mozilla.focus.helpers.TestAssetHelper.getPDFTestAsset
|
||||
import org.mozilla.focus.helpers.TestHelper.getTargetContext
|
||||
import org.mozilla.focus.helpers.TestHelper.permAllowBtn
|
||||
import org.mozilla.focus.helpers.TestHelper.verifyDownloadedFileOnStorage
|
||||
import org.mozilla.focus.helpers.TestHelper.waitingTime
|
||||
import org.mozilla.focus.testAnnotations.SmokeTest
|
||||
|
||||
class PDFViewerTest {
|
||||
private lateinit var webServer: MockWebServer
|
||||
private val featureSettingsHelper = FeatureSettingsHelper()
|
||||
private val pdfLink = "PDF file"
|
||||
|
||||
@get: Rule
|
||||
var mActivityTestRule = MainActivityIntentsTestRule(showFirstRun = false)
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
featureSettingsHelper.setCfrForTrackingProtectionEnabled(false)
|
||||
webServer = MockWebServer().apply {
|
||||
dispatcher = MockWebServerHelper.AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
webServer.shutdown()
|
||||
featureSettingsHelper.resetAllFeatureFlags()
|
||||
deleteFileUsingDisplayName(getTargetContext.applicationContext, "pdfFile.pdf")
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun openPdfFileTest() {
|
||||
val genericPageUrl = getGenericAsset(webServer).url
|
||||
val pdfDoc = getPDFTestAsset(webServer)
|
||||
|
||||
searchScreen {
|
||||
}.loadPage(genericPageUrl) {
|
||||
progressBar.waitUntilGone(waitingTime)
|
||||
clickLinkMatchingText(pdfLink)
|
||||
verifyPageURL(pdfDoc.url)
|
||||
verifyPageContent(pdfDoc.content)
|
||||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun downloadPdfTest() {
|
||||
val pdfDoc = getPDFTestAsset(webServer)
|
||||
|
||||
searchScreen {
|
||||
}.loadPage(pdfDoc.url) {
|
||||
verifyPageContent(pdfDoc.content)
|
||||
clickButtonWithText("Download")
|
||||
// If permission dialog appears, grant it
|
||||
if (permAllowBtn.waitForExists(waitingTime)) {
|
||||
permAllowBtn.click()
|
||||
}
|
||||
verifyDownloadedFileOnStorage(pdfDoc.title)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,4 +68,10 @@ object TestAssetHelper {
|
|||
|
||||
return TestAsset(url, "", pageTitle)
|
||||
}
|
||||
|
||||
fun getPDFTestAsset(server: MockWebServer): TestAsset {
|
||||
val url = server.url("/resources/pdfFile.pdf").toString()
|
||||
|
||||
return TestAsset(url, "Page 1", "pdfFile.pdf")
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче