Bug 1861361 - Fenix: add UI tests for the Print feature

fenix/121.0
oana.horvath 8 months ago committed by mergify[bot]
parent de391e74a5
commit 458caede01

@ -18,6 +18,7 @@ object Constants {
const val GMAIL_APP = "com.google.android.gm"
const val PHONE_APP = "com.android.dialer"
const val ANDROID_SETTINGS = "com.android.settings"
const val PRINT_SPOOLER = "com.android.printspooler"
}
const val SPEECH_RECOGNITION = "android.speech.action.RECOGNIZE_SPEECH"

@ -16,10 +16,12 @@ import org.junit.Test
import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.Constants.PackageName.PRINT_SPOOLER
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.MatcherHelper
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.TestHelper.assertNativeAppOpens
import org.mozilla.fenix.helpers.TestHelper.assertYoutubeAppOpens
import org.mozilla.fenix.helpers.TestHelper.runWithCondition
import org.mozilla.fenix.ui.robots.browserScreen
@ -351,4 +353,33 @@ class MainMenuTest {
verifyPageContent("REFRESHED")
}
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2282411
@Test
fun printWebPageFromMainMenuTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
mDevice.waitForIdle()
}.openThreeDotMenu {
}.clickPrintButton {
assertNativeAppOpens(PRINT_SPOOLER)
}
}
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2282408
@Test
fun printWebPageFromShareMenuTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
mDevice.waitForIdle()
}.openThreeDotMenu {
}.clickShareButton {
}.clickPrintButton {
assertNativeAppOpens(PRINT_SPOOLER)
}
}
}

@ -26,6 +26,8 @@ import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdExists
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdContainingText
import org.mozilla.fenix.helpers.MatcherHelper.itemWithText
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper.getStringResource
import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestHelper.packageName
@ -139,6 +141,14 @@ class ShareOverlayRobot {
DownloadRobot().interact()
return DownloadRobot.Transition()
}
fun clickPrintButton(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
itemWithText("Print").waitForExists(TestAssetHelper.waitingTime)
itemWithText("Print").click()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
}
}

@ -469,6 +469,16 @@ class ThreeDotMenuMainRobot {
ShareOverlayRobot().interact()
return ShareOverlayRobot.Transition()
}
fun clickPrintButton(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
threeDotMenuRecyclerView().perform(swipeUp())
threeDotMenuRecyclerView().perform(swipeUp())
printButton.waitForExists(waitingTime)
printButton.click()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
}
}
private fun threeDotMenuRecyclerView() =
@ -596,3 +606,4 @@ private val backButton = itemWithDescription(getStringResource(R.string.browser_
private val forwardButton = itemWithDescription(getStringResource(R.string.browser_menu_forward))
private val shareButton = itemWithDescription(getStringResource(R.string.share_button_content_description))
private val refreshButton = itemWithDescription(getStringResource(R.string.browser_menu_refresh))
private val printButton = itemWithText("Print")

Loading…
Cancel
Save