mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] No issue: Refactor web page items long clicks
This commit is contained in:
parent
39d8566832
commit
3cf57466d4
@ -72,7 +72,7 @@ class ContextMenusTest {
|
|||||||
navigationToolbar {
|
navigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
mDevice.waitForIdle()
|
mDevice.waitForIdle()
|
||||||
longClickMatchingText("Link 1")
|
longClickLink("Link 1")
|
||||||
verifyLinkContextMenuItems(genericURL.url)
|
verifyLinkContextMenuItems(genericURL.url)
|
||||||
clickContextOpenLinkInNewTab()
|
clickContextOpenLinkInNewTab()
|
||||||
verifySnackBarText("New tab opened")
|
verifySnackBarText("New tab opened")
|
||||||
@ -96,7 +96,7 @@ class ContextMenusTest {
|
|||||||
navigationToolbar {
|
navigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
mDevice.waitForIdle()
|
mDevice.waitForIdle()
|
||||||
longClickMatchingText("Link 2")
|
longClickLink("Link 2")
|
||||||
verifyLinkContextMenuItems(genericURL.url)
|
verifyLinkContextMenuItems(genericURL.url)
|
||||||
clickContextOpenLinkInPrivateTab()
|
clickContextOpenLinkInPrivateTab()
|
||||||
verifySnackBarText("New private tab opened")
|
verifySnackBarText("New private tab opened")
|
||||||
@ -118,7 +118,7 @@ class ContextMenusTest {
|
|||||||
navigationToolbar {
|
navigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
mDevice.waitForIdle()
|
mDevice.waitForIdle()
|
||||||
longClickMatchingText("Link 3")
|
longClickLink("Link 3")
|
||||||
verifyLinkContextMenuItems(genericURL.url)
|
verifyLinkContextMenuItems(genericURL.url)
|
||||||
clickContextCopyLink()
|
clickContextCopyLink()
|
||||||
verifySnackBarText("Link copied to clipboard")
|
verifySnackBarText("Link copied to clipboard")
|
||||||
@ -138,7 +138,7 @@ class ContextMenusTest {
|
|||||||
navigationToolbar {
|
navigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
mDevice.waitForIdle()
|
mDevice.waitForIdle()
|
||||||
longClickMatchingText("Link 1")
|
longClickLink("Link 1")
|
||||||
verifyLinkContextMenuItems(genericURL.url)
|
verifyLinkContextMenuItems(genericURL.url)
|
||||||
clickContextShareLink(genericURL.url) // verify share intent is matched with associated URL
|
clickContextShareLink(genericURL.url) // verify share intent is matched with associated URL
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ class ContextMenusTest {
|
|||||||
navigationToolbar {
|
navigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
mDevice.waitForIdle()
|
mDevice.waitForIdle()
|
||||||
longClickMatchingText("test_link_image")
|
longClickLink("test_link_image")
|
||||||
verifyLinkImageContextMenuItems(imageResource.url)
|
verifyLinkImageContextMenuItems(imageResource.url)
|
||||||
clickContextOpenImageNewTab()
|
clickContextOpenImageNewTab()
|
||||||
verifySnackBarText("New tab opened")
|
verifySnackBarText("New tab opened")
|
||||||
@ -173,7 +173,7 @@ class ContextMenusTest {
|
|||||||
navigationToolbar {
|
navigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
mDevice.waitForIdle()
|
mDevice.waitForIdle()
|
||||||
longClickMatchingText("test_link_image")
|
longClickLink("test_link_image")
|
||||||
verifyLinkImageContextMenuItems(imageResource.url)
|
verifyLinkImageContextMenuItems(imageResource.url)
|
||||||
clickContextCopyImageLocation()
|
clickContextCopyImageLocation()
|
||||||
verifySnackBarText("Link copied to clipboard")
|
verifySnackBarText("Link copied to clipboard")
|
||||||
@ -193,7 +193,7 @@ class ContextMenusTest {
|
|||||||
navigationToolbar {
|
navigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
mDevice.waitForIdle()
|
mDevice.waitForIdle()
|
||||||
longClickMatchingText("test_link_image")
|
longClickLink("test_link_image")
|
||||||
verifyLinkImageContextMenuItems(imageResource.url)
|
verifyLinkImageContextMenuItems(imageResource.url)
|
||||||
clickContextSaveImage()
|
clickContextSaveImage()
|
||||||
}
|
}
|
||||||
@ -218,13 +218,13 @@ class ContextMenusTest {
|
|||||||
navigationToolbar {
|
navigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
}.enterURLAndEnterToBrowser(pageLinks.url) {
|
||||||
mDevice.waitForIdle()
|
mDevice.waitForIdle()
|
||||||
longClickMatchingText("Link 1")
|
longClickLink("Link 1")
|
||||||
verifyLinkContextMenuItems(genericURL.url)
|
verifyLinkContextMenuItems(genericURL.url)
|
||||||
dismissContentContextMenu(genericURL.url)
|
dismissContentContextMenu(genericURL.url)
|
||||||
longClickMatchingText("test_link_image")
|
longClickLink("test_link_image")
|
||||||
verifyLinkImageContextMenuItems(imageResource.url)
|
verifyLinkImageContextMenuItems(imageResource.url)
|
||||||
dismissContentContextMenu(imageResource.url)
|
dismissContentContextMenu(imageResource.url)
|
||||||
longClickMatchingText("test_no_link_image")
|
longClickLink("test_no_link_image")
|
||||||
verifyNoLinkImageContextMenuItems(imageResource.url)
|
verifyNoLinkImageContextMenuItems(imageResource.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ class ContextMenusTest {
|
|||||||
|
|
||||||
navigationToolbar {
|
navigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(genericURL.url) {
|
}.enterURLAndEnterToBrowser(genericURL.url) {
|
||||||
longClickMatchingText(genericURL.content)
|
longClickLink(genericURL.content)
|
||||||
}.clickShareSelectedText {
|
}.clickShareSelectedText {
|
||||||
verifyAndroidShareLayout()
|
verifyAndroidShareLayout()
|
||||||
}
|
}
|
||||||
|
@ -186,9 +186,9 @@ class SearchTest {
|
|||||||
homeScreen {
|
homeScreen {
|
||||||
}.openSearch {
|
}.openSearch {
|
||||||
}.submitQuery("test search") {
|
}.submitQuery("test search") {
|
||||||
longClickMatchingText("Link 1")
|
longClickLink("Link 1")
|
||||||
clickContextOpenLinkInNewTab()
|
clickContextOpenLinkInNewTab()
|
||||||
longClickMatchingText("Link 2")
|
longClickLink("Link 2")
|
||||||
clickContextOpenLinkInNewTab()
|
clickContextOpenLinkInNewTab()
|
||||||
}.goToHomescreen {
|
}.goToHomescreen {
|
||||||
verifyJumpBackInSectionIsDisplayed()
|
verifyJumpBackInSectionIsDisplayed()
|
||||||
@ -221,9 +221,9 @@ class SearchTest {
|
|||||||
homeScreen {
|
homeScreen {
|
||||||
}.openSearch {
|
}.openSearch {
|
||||||
}.submitQuery("test search") {
|
}.submitQuery("test search") {
|
||||||
longClickMatchingText("Link 1")
|
longClickLink("Link 1")
|
||||||
clickContextOpenLinkInPrivateTab()
|
clickContextOpenLinkInPrivateTab()
|
||||||
longClickMatchingText("Link 2")
|
longClickLink("Link 2")
|
||||||
clickContextOpenLinkInPrivateTab()
|
clickContextOpenLinkInPrivateTab()
|
||||||
}.goToHomescreen {
|
}.goToHomescreen {
|
||||||
verifyCurrentSearchGroupIsDisplayed(false, "test search", 3)
|
verifyCurrentSearchGroupIsDisplayed(false, "test search", 3)
|
||||||
@ -254,9 +254,9 @@ class SearchTest {
|
|||||||
homeScreen {
|
homeScreen {
|
||||||
}.openSearch {
|
}.openSearch {
|
||||||
}.submitQuery("test search") {
|
}.submitQuery("test search") {
|
||||||
longClickMatchingText("Link 1")
|
longClickLink("Link 1")
|
||||||
clickContextOpenLinkInPrivateTab()
|
clickContextOpenLinkInPrivateTab()
|
||||||
longClickMatchingText("Link 2")
|
longClickLink("Link 2")
|
||||||
clickContextOpenLinkInPrivateTab()
|
clickContextOpenLinkInPrivateTab()
|
||||||
}.openTabDrawer {
|
}.openTabDrawer {
|
||||||
}.openTab(firstPage) {
|
}.openTab(firstPage) {
|
||||||
@ -290,9 +290,9 @@ class SearchTest {
|
|||||||
homeScreen {
|
homeScreen {
|
||||||
}.openSearch {
|
}.openSearch {
|
||||||
}.submitQuery("test search") {
|
}.submitQuery("test search") {
|
||||||
longClickMatchingText("Link 1")
|
longClickLink("Link 1")
|
||||||
clickContextOpenLinkInNewTab()
|
clickContextOpenLinkInNewTab()
|
||||||
longClickMatchingText("Link 2")
|
longClickLink("Link 2")
|
||||||
clickContextOpenLinkInNewTab()
|
clickContextOpenLinkInNewTab()
|
||||||
}.openTabDrawer {
|
}.openTabDrawer {
|
||||||
}.openTabFromGroup(firstPage) {
|
}.openTabFromGroup(firstPage) {
|
||||||
|
@ -347,116 +347,35 @@ class BrowserRobot {
|
|||||||
fun clickLinkMatchingText(expectedText: String) =
|
fun clickLinkMatchingText(expectedText: String) =
|
||||||
clickPageObject(webPageItemContainingText(expectedText))
|
clickPageObject(webPageItemContainingText(expectedText))
|
||||||
|
|
||||||
fun longClickMatchingText(expectedText: String) {
|
fun longClickLink(expectedText: String) =
|
||||||
try {
|
longClickPageObject(webPageItemWithText(expectedText))
|
||||||
mDevice.waitForWindowUpdate(packageName, waitingTime)
|
|
||||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
||||||
.waitForExists(waitingTime)
|
|
||||||
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime)
|
|
||||||
val link = mDevice.findObject(By.textContains(expectedText))
|
|
||||||
link.click(LONG_CLICK_DURATION)
|
|
||||||
} catch (e: NullPointerException) {
|
|
||||||
println(e)
|
|
||||||
|
|
||||||
// Refresh the page in case the first long click didn't succeed
|
fun longClickMatchingText(expectedText: String) =
|
||||||
navigationToolbar {
|
longClickPageObject(webPageItemContainingText(expectedText))
|
||||||
}.openThreeDotMenu {
|
|
||||||
}.refreshPage {
|
|
||||||
mDevice.waitForIdle()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Long click again the desired text
|
|
||||||
mDevice.waitForWindowUpdate(packageName, waitingTime)
|
|
||||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
||||||
.waitForExists(waitingTime)
|
|
||||||
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime)
|
|
||||||
val link = mDevice.findObject(By.textContains(expectedText))
|
|
||||||
link.click(LONG_CLICK_DURATION)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun longClickAndCopyText(expectedText: String, selectAll: Boolean = false) {
|
fun longClickAndCopyText(expectedText: String, selectAll: Boolean = false) {
|
||||||
try {
|
longClickPageObject(webPageItemContainingText(expectedText))
|
||||||
// Long click desired text
|
|
||||||
mDevice.waitForWindowUpdate(packageName, waitingTime)
|
|
||||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
||||||
.waitForExists(waitingTime)
|
|
||||||
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime)
|
|
||||||
val link = mDevice.findObject(By.textContains(expectedText))
|
|
||||||
link.click(LONG_CLICK_DURATION)
|
|
||||||
|
|
||||||
// Click Select all from the text selection toolbar
|
// Click Select all from the text selection toolbar
|
||||||
if (selectAll) {
|
if (selectAll) {
|
||||||
mDevice.findObject(UiSelector().textContains("Select all")).waitForExists(waitingTime)
|
mDevice.findObject(UiSelector().textContains("Select all")).waitForExists(waitingTime)
|
||||||
val selectAllText = mDevice.findObject(By.textContains("Select all"))
|
val selectAllText = mDevice.findObject(By.textContains("Select all"))
|
||||||
selectAllText.click()
|
selectAllText.click()
|
||||||
}
|
|
||||||
|
|
||||||
// Click Copy from the text selection toolbar
|
|
||||||
mDevice.findObject(UiSelector().textContains("Copy")).waitForExists(waitingTime)
|
|
||||||
val copyText = mDevice.findObject(By.textContains("Copy"))
|
|
||||||
copyText.click()
|
|
||||||
} catch (e: NullPointerException) {
|
|
||||||
println("Failed to long click desired text: ${e.localizedMessage}")
|
|
||||||
|
|
||||||
// Refresh the page in case the first long click didn't succeed
|
|
||||||
navigationToolbar {
|
|
||||||
}.openThreeDotMenu {
|
|
||||||
}.refreshPage {
|
|
||||||
mDevice.waitForIdle()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Long click again the desired text
|
|
||||||
mDevice.waitForWindowUpdate(packageName, waitingTime)
|
|
||||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
||||||
.waitForExists(waitingTime)
|
|
||||||
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime)
|
|
||||||
val link = mDevice.findObject(By.textContains(expectedText))
|
|
||||||
link.click(LONG_CLICK_DURATION)
|
|
||||||
|
|
||||||
// Click again Select all from the text selection toolbar
|
|
||||||
if (selectAll) {
|
|
||||||
mDevice.findObject(UiSelector().textContains("Select all")).waitForExists(waitingTime)
|
|
||||||
val selectAllText = mDevice.findObject(By.textContains("Select all"))
|
|
||||||
selectAllText.click()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Click again Copy from the text selection toolbar
|
|
||||||
mDevice.findObject(UiSelector().textContains("Copy")).waitForExists(waitingTime)
|
|
||||||
val copyText = mDevice.findObject(By.textContains("Copy"))
|
|
||||||
copyText.click()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Click Copy from the text selection toolbar
|
||||||
|
mDevice.findObject(UiSelector().textContains("Copy")).waitForExists(waitingTime)
|
||||||
|
val copyText = mDevice.findObject(By.textContains("Copy"))
|
||||||
|
copyText.click()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun longClickAndSearchText(searchButton: String, expectedText: String) {
|
fun longClickAndSearchText(searchButton: String, expectedText: String) {
|
||||||
var currentTries = 0
|
longClickPageObject(webPageItemContainingText(expectedText))
|
||||||
while (currentTries++ < 3) {
|
|
||||||
try {
|
|
||||||
// Long click desired text
|
|
||||||
mDevice.waitForWindowUpdate(packageName, waitingTime)
|
|
||||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/engineView"))
|
|
||||||
.waitForExists(waitingTime)
|
|
||||||
mDevice.findObject(UiSelector().textContains(expectedText)).waitForExists(waitingTime)
|
|
||||||
val link = mDevice.findObject(By.textContains(expectedText))
|
|
||||||
link.click(LONG_CLICK_DURATION)
|
|
||||||
|
|
||||||
// Click search from the text selection toolbar
|
// Click search from the text selection toolbar
|
||||||
mDevice.findObject(UiSelector().textContains(searchButton)).waitForExists(waitingTime)
|
mDevice.findObject(UiSelector().textContains(searchButton)).waitForExists(waitingTime)
|
||||||
val searchText = mDevice.findObject(By.textContains(searchButton))
|
val searchText = mDevice.findObject(By.textContains(searchButton))
|
||||||
searchText.click()
|
searchText.click()
|
||||||
|
|
||||||
break
|
|
||||||
} catch (e: NullPointerException) {
|
|
||||||
println("Failed to long click desired text: ${e.localizedMessage}")
|
|
||||||
|
|
||||||
// Refresh the page in case the first long click didn't succeed
|
|
||||||
navigationToolbar {
|
|
||||||
}.openThreeDotMenu {
|
|
||||||
}.refreshPage {
|
|
||||||
mDevice.waitForIdle()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun snackBarButtonClick() {
|
fun snackBarButtonClick() {
|
||||||
@ -985,6 +904,29 @@ private fun clickPageObject(webPageItem: UiObject) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun longClickPageObject(webPageItem: UiObject) {
|
||||||
|
for (i in 1..RETRY_COUNT) {
|
||||||
|
try {
|
||||||
|
webPageItem.also {
|
||||||
|
it.waitForExists(waitingTime)
|
||||||
|
it.longClick()
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
} catch (e: UiObjectNotFoundException) {
|
||||||
|
if (i == RETRY_COUNT) {
|
||||||
|
throw e
|
||||||
|
} else {
|
||||||
|
browserScreen {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.refreshPage {
|
||||||
|
}
|
||||||
|
progressBar.waitUntilGone(waitingTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun webPageItemContainingText(itemText: String) =
|
private fun webPageItemContainingText(itemText: String) =
|
||||||
mDevice.findObject(UiSelector().textContains(itemText))
|
mDevice.findObject(UiSelector().textContains(itemText))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user