From fa38639322a5b749dc5f460b693a8c9fa0597765 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Wed, 8 Mar 2023 14:26:20 +0200 Subject: [PATCH] Bug 1821035 - New PDF text selection UI smoke tests --- .../org/mozilla/fenix/ui/TextSelectionTest.kt | 98 ++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/TextSelectionTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/TextSelectionTest.kt index b1121c06b4..5481b80eaa 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/TextSelectionTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/TextSelectionTest.kt @@ -1,5 +1,6 @@ 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 @@ -20,6 +21,11 @@ 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() @@ -58,7 +64,8 @@ class TextSelectionTest { clickClearButton() longClickToolbar() clickPasteText() - // with Select all, some white space is copied over, so we need to include that too + // With Select all, white spaces are copied + // Potential bug https://bugzilla.mozilla.org/show_bug.cgi?id=1821310 verifyTypedToolbarText(" Page content: 1 ") } } @@ -126,4 +133,93 @@ class TextSelectionTest { verifyUrl("google") } } + + @SmokeTest + @Test + fun selectAllAndCopyPDFTextTest() { + navigationToolbar { + }.enterURLAndEnterToBrowser(downloadTestPage.toUri()) { + clickLinkMatchingText(pdfFileName) + verifyUrl(pdfFileURL) + verifyPageContent(pdfFileContent) + longClickAndCopyText("Crossing", true) + }.openNavigationToolbar { + openEditURLView() + } + + searchScreen { + clickClearButton() + longClickToolbar() + clickPasteText() + // With Select all, white spaces are copied + // Potential bug https://bugzilla.mozilla.org/show_bug.cgi?id=1821310 + verifyTypedToolbarText(" Washington Crossing the Delaware ") + } + } + + @SmokeTest + @Test + fun copyPDFTextTest() { + navigationToolbar { + }.enterURLAndEnterToBrowser(downloadTestPage.toUri()) { + clickLinkMatchingText(pdfFileName) + verifyUrl(pdfFileURL) + verifyPageContent(pdfFileContent) + longClickAndCopyText("Crossing") + }.openNavigationToolbar { + openEditURLView() + } + + searchScreen { + clickClearButton() + longClickToolbar() + clickPasteText() + verifyTypedToolbarText("Crossing") + } + } + + @SmokeTest + @Test + fun shareSelectedPDFTextTest() { + navigationToolbar { + }.enterURLAndEnterToBrowser(downloadTestPage.toUri()) { + clickLinkMatchingText(pdfFileName) + verifyUrl(pdfFileURL) + verifyPageContent(pdfFileContent) + longClickMatchingText("Crossing") + }.clickShareSelectedText { + verifyAndroidShareLayout() + } + } + + @SmokeTest + @Test + fun selectAndSearchPDFTextTest() { + navigationToolbar { + }.enterURLAndEnterToBrowser(downloadTestPage.toUri()) { + clickLinkMatchingText(pdfFileName) + verifyUrl(pdfFileURL) + verifyPageContent(pdfFileContent) + longClickAndSearchText("Search", "Crossing") + verifyTabCounter("3") + verifyUrl("google") + } + } + + @SmokeTest + @Test + fun privateSelectAndSearchPDFTextTest() { + homeScreen { + }.togglePrivateBrowsingMode() + + navigationToolbar { + }.enterURLAndEnterToBrowser(downloadTestPage.toUri()) { + clickLinkMatchingText(pdfFileName) + verifyUrl(pdfFileURL) + verifyPageContent(pdfFileContent) + longClickAndSearchText("Private Search", "Crossing") + verifyTabCounter("3") + verifyUrl("google") + } + } }