[fenix] Closes https://github.com/mozilla-mobile/fenix/issues/7611: Add UI tests for content context menus (https://github.com/mozilla-mobile/fenix/pull/7631)
Closes https://github.com/mozilla-mobile/fenix/issues/7611: Add UI tests for content context menuspull/600/head
parent
e36fd53543
commit
397dddaf0a
@ -0,0 +1,19 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Test_Page_4</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p id="testContent">Page content: 4</p>
|
||||||
|
<a href="generic1.html">Link 1</a>
|
||||||
|
<a href="generic2.html">Link 2</a>
|
||||||
|
<a href="generic3.html">Link 3</a>
|
||||||
|
<p>
|
||||||
|
<a href="../resources/rabbit.jpg">
|
||||||
|
<img src="../resources/rabbit.jpg" title="test_link_image">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<img src="../resources/rabbit.jpg" title="test_no_link_image">
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
@ -0,0 +1,220 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
package org.mozilla.fenix.ui
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.uiautomator.UiDevice
|
||||||
|
import okhttp3.mockwebserver.MockWebServer
|
||||||
|
import org.junit.After
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||||
|
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||||
|
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||||
|
import org.mozilla.fenix.ui.robots.downloadRobot
|
||||||
|
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for verifying basic functionality of content context menus
|
||||||
|
*
|
||||||
|
* - Verifies long click "Open link in new tab" UI and functionality
|
||||||
|
* - Verifies long click "Open link in new Private tab" UI and functionality
|
||||||
|
* - Verifies long click "Copy Link" UI and functionality
|
||||||
|
* - Verifies long click "Share Link" UI and functionality
|
||||||
|
* - Verifies long click "Open image in new tab" UI and functionality
|
||||||
|
* - Verifies long click "Save Image" UI and functionality
|
||||||
|
* - Verifies long click "Copy image location" UI and functionality
|
||||||
|
* - Verifies long click items of mixed hypertext items
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ContextMenusTest {
|
||||||
|
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||||
|
private lateinit var mockWebServer: MockWebServer
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val activityIntentTestRule = HomeActivityIntentTestRule()
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
mockWebServer = MockWebServer().apply {
|
||||||
|
setDispatcher(AndroidAssetDispatcher())
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun tearDown() {
|
||||||
|
mockWebServer.shutdown()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyContextOpenLinkNewTab() {
|
||||||
|
val pageLinks =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 4)
|
||||||
|
val genericURL =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
|
verifyPageContent(pageLinks.content)
|
||||||
|
longClickMatchingText("Link 1")
|
||||||
|
verifyLinkContextMenuItems(genericURL.url)
|
||||||
|
clickContextOpenLinkInNewTab()
|
||||||
|
verifySnackBarText("New tab opened")
|
||||||
|
snackBarButtonClick("Switch")
|
||||||
|
verifyUrl(genericURL.url.toString())
|
||||||
|
}.openHomeScreen {
|
||||||
|
verifyHomeScreen()
|
||||||
|
verifyExistingOpenTabs("Test_Page_1")
|
||||||
|
verifyExistingOpenTabs("Test_Page_4")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyContextOpenLinkPrivateTab() {
|
||||||
|
val pageLinks =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 4)
|
||||||
|
val genericURL =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 2)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
|
verifyPageContent(pageLinks.content)
|
||||||
|
longClickMatchingText("Link 2")
|
||||||
|
verifyLinkContextMenuItems(genericURL.url)
|
||||||
|
clickContextOpenLinkInPrivateTab()
|
||||||
|
verifySnackBarText("New private tab opened")
|
||||||
|
snackBarButtonClick("Switch")
|
||||||
|
verifyUrl(genericURL.url.toString())
|
||||||
|
}.openHomeScreen {
|
||||||
|
verifyPrivateSessionHeader()
|
||||||
|
verifyExistingOpenTabs("Test_Page_2")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyContextCopyLink() {
|
||||||
|
val pageLinks =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 4)
|
||||||
|
val genericURL =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 3)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
|
verifyPageContent(pageLinks.content)
|
||||||
|
longClickMatchingText("Link 3")
|
||||||
|
verifyLinkContextMenuItems(genericURL.url)
|
||||||
|
clickContextCopyLink()
|
||||||
|
verifySnackBarText("Link copied to clipboard")
|
||||||
|
}.openNavigationToolbar {
|
||||||
|
}.visitLinkFromClipboard(genericURL.url) {
|
||||||
|
verifyUrl(genericURL.url.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyContextShareLink() {
|
||||||
|
val pageLinks =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 4)
|
||||||
|
val genericURL =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
|
verifyPageContent(pageLinks.content)
|
||||||
|
longClickMatchingText("Link 1")
|
||||||
|
verifyLinkContextMenuItems(genericURL.url)
|
||||||
|
clickContextShareLink(genericURL.url) // verify share intent is matched with associated URL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyContextOpenImageNewTab() {
|
||||||
|
val pageLinks =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 4)
|
||||||
|
val imageResource =
|
||||||
|
TestAssetHelper.getImageAsset(mockWebServer)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
|
verifyPageContent(pageLinks.content)
|
||||||
|
longClickMatchingText("test_link_image")
|
||||||
|
verifyLinkImageContextMenuItems(imageResource.url)
|
||||||
|
clickContextOpenImageNewTab()
|
||||||
|
verifySnackBarText("New tab opened")
|
||||||
|
snackBarButtonClick("Switch")
|
||||||
|
verifyUrl(imageResource.url.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyContextCopyImageLocation() {
|
||||||
|
val pageLinks =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 4)
|
||||||
|
val imageResource =
|
||||||
|
TestAssetHelper.getImageAsset(mockWebServer)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
|
verifyPageContent(pageLinks.content)
|
||||||
|
longClickMatchingText("test_link_image")
|
||||||
|
verifyLinkImageContextMenuItems(imageResource.url)
|
||||||
|
clickContextCopyImageLocation()
|
||||||
|
verifySnackBarText("Link copied to clipboard")
|
||||||
|
}.openNavigationToolbar {
|
||||||
|
}.visitLinkFromClipboard(imageResource.url) {
|
||||||
|
verifyUrl(imageResource.url.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyContextSaveImage() {
|
||||||
|
val pageLinks =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 4)
|
||||||
|
val imageResource =
|
||||||
|
TestAssetHelper.getImageAsset(mockWebServer)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
|
verifyPageContent(pageLinks.content)
|
||||||
|
longClickMatchingText("test_link_image")
|
||||||
|
verifyLinkImageContextMenuItems(imageResource.url)
|
||||||
|
clickContextSaveImage()
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadRobot {
|
||||||
|
}.clickAllowPermission {
|
||||||
|
verifyDownloadNotificationPopup()
|
||||||
|
}.clickOpen("image/jpeg") {} // verify open intent is matched with associated data type
|
||||||
|
downloadRobot {
|
||||||
|
verifyPhotosAppOpens()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyContextMixedVariations() {
|
||||||
|
val pageLinks =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 4)
|
||||||
|
val genericURL =
|
||||||
|
TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||||
|
val imageResource =
|
||||||
|
TestAssetHelper.getImageAsset(mockWebServer)
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
|
verifyPageContent(pageLinks.content)
|
||||||
|
longClickMatchingText("Link 1")
|
||||||
|
verifyLinkContextMenuItems(genericURL.url)
|
||||||
|
mDevice.pressBack()
|
||||||
|
longClickMatchingText("test_link_image")
|
||||||
|
verifyLinkImageContextMenuItems(imageResource.url)
|
||||||
|
mDevice.pressBack()
|
||||||
|
longClickMatchingText("test_no_link_image")
|
||||||
|
verifyNoLinkImageContextMenuItems("test_no_link_image")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue