mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] Issue https://github.com/mozilla-mobile/fenix/issues/27522: Search groups tests refactoring
This commit is contained in:
parent
4daa618db6
commit
74c551336e
@ -7,7 +7,6 @@ package org.mozilla.fenix.ui
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.hardware.camera2.CameraManager
|
import android.hardware.camera2.CameraManager
|
||||||
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
|
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
|
||||||
import androidx.core.net.toUri
|
|
||||||
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
|
||||||
import mozilla.components.browser.icons.IconRequest
|
import mozilla.components.browser.icons.IconRequest
|
||||||
import mozilla.components.browser.icons.generator.DefaultIconGenerator
|
import mozilla.components.browser.icons.generator.DefaultIconGenerator
|
||||||
@ -23,6 +22,7 @@ import org.mozilla.fenix.customannotations.SmokeTest
|
|||||||
import org.mozilla.fenix.helpers.Constants.PackageName.ANDROID_SETTINGS
|
import org.mozilla.fenix.helpers.Constants.PackageName.ANDROID_SETTINGS
|
||||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||||
import org.mozilla.fenix.helpers.SearchDispatcher
|
import org.mozilla.fenix.helpers.SearchDispatcher
|
||||||
|
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
||||||
import org.mozilla.fenix.helpers.TestHelper.appContext
|
import org.mozilla.fenix.helpers.TestHelper.appContext
|
||||||
import org.mozilla.fenix.helpers.TestHelper.assertNativeAppOpens
|
import org.mozilla.fenix.helpers.TestHelper.assertNativeAppOpens
|
||||||
import org.mozilla.fenix.helpers.TestHelper.denyPermission
|
import org.mozilla.fenix.helpers.TestHelper.denyPermission
|
||||||
@ -153,10 +153,11 @@ class SearchTest {
|
|||||||
@SmokeTest
|
@SmokeTest
|
||||||
@Test
|
@Test
|
||||||
fun searchGroupShowsInRecentlyVisitedTest() {
|
fun searchGroupShowsInRecentlyVisitedTest() {
|
||||||
val firstPage = searchMockServer.url("generic1.html").toString()
|
val firstPage = getGenericAsset(searchMockServer, 1)
|
||||||
val secondPage = searchMockServer.url("generic2.html").toString()
|
val secondPage = getGenericAsset(searchMockServer, 2)
|
||||||
// setting our custom mockWebServer search URL
|
// setting our custom mockWebServer search URL
|
||||||
val searchString = "http://localhost:${searchMockServer.port}/searchResults.html?search={searchTerms}"
|
val searchString =
|
||||||
|
"http://localhost:${searchMockServer.port}/searchResults.html?search={searchTerms}"
|
||||||
val customSearchEngine = createSearchEngine(
|
val customSearchEngine = createSearchEngine(
|
||||||
name = "TestSearchEngine",
|
name = "TestSearchEngine",
|
||||||
url = searchString,
|
url = searchString,
|
||||||
@ -172,14 +173,10 @@ class SearchTest {
|
|||||||
clickContextOpenLinkInNewTab()
|
clickContextOpenLinkInNewTab()
|
||||||
longClickLink("Link 2")
|
longClickLink("Link 2")
|
||||||
clickContextOpenLinkInNewTab()
|
clickContextOpenLinkInNewTab()
|
||||||
}.goToHomescreen {
|
|
||||||
verifyJumpBackInSectionIsDisplayed()
|
|
||||||
verifyCurrentSearchGroupIsDisplayed(true, "test search", 3)
|
|
||||||
verifyRecentlyVisitedSearchGroupDisplayed(false, "test search", 3)
|
|
||||||
}.openTabDrawer {
|
}.openTabDrawer {
|
||||||
}.openTabFromGroup(firstPage) {
|
}.openTab(firstPage.title) {
|
||||||
}.openTabDrawer {
|
}.openTabDrawer {
|
||||||
}.openTabFromGroup(secondPage) {
|
}.openTab(secondPage.title) {
|
||||||
}.openTabDrawer {
|
}.openTabDrawer {
|
||||||
}.openTabsListThreeDotMenu {
|
}.openTabsListThreeDotMenu {
|
||||||
}.closeAllTabs {
|
}.closeAllTabs {
|
||||||
@ -189,7 +186,7 @@ class SearchTest {
|
|||||||
|
|
||||||
@SmokeTest
|
@SmokeTest
|
||||||
@Test
|
@Test
|
||||||
fun noCurrentSearchGroupFromPrivateBrowsingTest() {
|
fun noSearchGroupFromPrivateBrowsingTest() {
|
||||||
// setting our custom mockWebServer search URL
|
// setting our custom mockWebServer search URL
|
||||||
val searchString = "http://localhost:${searchMockServer.port}/searchResults.html?search={searchTerms}"
|
val searchString = "http://localhost:${searchMockServer.port}/searchResults.html?search={searchTerms}"
|
||||||
val customSearchEngine = createSearchEngine(
|
val customSearchEngine = createSearchEngine(
|
||||||
@ -207,7 +204,15 @@ class SearchTest {
|
|||||||
clickContextOpenLinkInPrivateTab()
|
clickContextOpenLinkInPrivateTab()
|
||||||
longClickLink("Link 2")
|
longClickLink("Link 2")
|
||||||
clickContextOpenLinkInPrivateTab()
|
clickContextOpenLinkInPrivateTab()
|
||||||
}.goToHomescreen {
|
}.openTabDrawer {
|
||||||
|
}.toggleToPrivateTabs {
|
||||||
|
}.openTabWithIndex(0) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
}.openTabWithIndex(1) {
|
||||||
|
}.openTabDrawer {
|
||||||
|
}.openTabsListThreeDotMenu {
|
||||||
|
}.closeAllTabs {
|
||||||
|
togglePrivateBrowsingModeOnOff()
|
||||||
verifyCurrentSearchGroupIsDisplayed(false, "test search", 3)
|
verifyCurrentSearchGroupIsDisplayed(false, "test search", 3)
|
||||||
}.openThreeDotMenu {
|
}.openThreeDotMenu {
|
||||||
}.openHistory {
|
}.openHistory {
|
||||||
@ -215,50 +220,12 @@ class SearchTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SmokeTest
|
|
||||||
@Test
|
|
||||||
@Ignore("Failing after compose migration. See: https://github.com/mozilla-mobile/fenix/issues/26087")
|
|
||||||
fun noRecentlyVisitedSearchGroupInPrivateBrowsingTest() {
|
|
||||||
val firstPage = searchMockServer.url("generic1.html").toString()
|
|
||||||
val secondPage = searchMockServer.url("generic2.html").toString()
|
|
||||||
// setting our custom mockWebServer search URL
|
|
||||||
val searchString = "http://localhost:${searchMockServer.port}/searchResults.html?search={searchTerms}"
|
|
||||||
val customSearchEngine = createSearchEngine(
|
|
||||||
name = "TestSearchEngine",
|
|
||||||
url = searchString,
|
|
||||||
icon = DefaultIconGenerator().generate(appContext, IconRequest(searchString)).bitmap,
|
|
||||||
)
|
|
||||||
setCustomSearchEngine(customSearchEngine)
|
|
||||||
|
|
||||||
// Performs a search and opens 2 dummy search results links to create a search group
|
|
||||||
homeScreen {
|
|
||||||
}.togglePrivateBrowsingMode()
|
|
||||||
homeScreen {
|
|
||||||
}.openSearch {
|
|
||||||
}.submitQuery("test search") {
|
|
||||||
longClickLink("Link 1")
|
|
||||||
clickContextOpenLinkInPrivateTab()
|
|
||||||
longClickLink("Link 2")
|
|
||||||
clickContextOpenLinkInPrivateTab()
|
|
||||||
}.openTabDrawer {
|
|
||||||
}.openTab(firstPage) {
|
|
||||||
}.openTabDrawer {
|
|
||||||
}.openTab(secondPage) {
|
|
||||||
}.openTabDrawer {
|
|
||||||
}.openTabsListThreeDotMenu {
|
|
||||||
}.closeAllTabs {
|
|
||||||
homeScreen {
|
|
||||||
}.togglePrivateBrowsingMode()
|
|
||||||
verifyRecentlyVisitedSearchGroupDisplayed(false, "test search", 3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Ignore("Failure caused by bugs: https://github.com/mozilla-mobile/fenix/issues/23818")
|
@Ignore("Failure caused by bugs: https://github.com/mozilla-mobile/fenix/issues/23818")
|
||||||
@SmokeTest
|
@SmokeTest
|
||||||
@Test
|
@Test
|
||||||
fun deleteItemsFromSearchGroupsHistoryTest() {
|
fun deleteItemsFromSearchGroupsHistoryTest() {
|
||||||
val firstPage = searchMockServer.url("generic1.html").toString()
|
val firstPage = getGenericAsset(searchMockServer, 1)
|
||||||
val secondPage = searchMockServer.url("generic2.html").toString()
|
val secondPage = getGenericAsset(searchMockServer, 2)
|
||||||
// setting our custom mockWebServer search URL
|
// setting our custom mockWebServer search URL
|
||||||
val searchString = "http://localhost:${searchMockServer.port}/searchResults.html?search={searchTerms}"
|
val searchString = "http://localhost:${searchMockServer.port}/searchResults.html?search={searchTerms}"
|
||||||
val customSearchEngine = createSearchEngine(
|
val customSearchEngine = createSearchEngine(
|
||||||
@ -277,16 +244,16 @@ class SearchTest {
|
|||||||
longClickLink("Link 2")
|
longClickLink("Link 2")
|
||||||
clickContextOpenLinkInNewTab()
|
clickContextOpenLinkInNewTab()
|
||||||
}.openTabDrawer {
|
}.openTabDrawer {
|
||||||
}.openTabFromGroup(firstPage) {
|
}.openTab(firstPage.title) {
|
||||||
}.openTabDrawer {
|
}.openTabDrawer {
|
||||||
}.openTabFromGroup(secondPage) {
|
}.openTab(secondPage.title) {
|
||||||
}.openTabDrawer {
|
}.openTabDrawer {
|
||||||
}.openTabsListThreeDotMenu {
|
}.openTabsListThreeDotMenu {
|
||||||
}.closeAllTabs {
|
}.closeAllTabs {
|
||||||
verifyRecentlyVisitedSearchGroupDisplayed(true, "test search", 3)
|
verifyRecentlyVisitedSearchGroupDisplayed(true, "test search", 3)
|
||||||
}.openRecentlyVisitedSearchGroupHistoryList("test search") {
|
}.openRecentlyVisitedSearchGroupHistoryList("test search") {
|
||||||
clickDeleteHistoryButton(firstPage)
|
clickDeleteHistoryButton(firstPage.url.toString())
|
||||||
longTapSelectItem(secondPage.toUri())
|
longTapSelectItem(secondPage.url)
|
||||||
multipleSelectionToolbar {
|
multipleSelectionToolbar {
|
||||||
openActionBarOverflowOrOptionsMenu(activityTestRule.activity)
|
openActionBarOverflowOrOptionsMenu(activityTestRule.activity)
|
||||||
clickMultiSelectionDelete()
|
clickMultiSelectionDelete()
|
||||||
|
@ -192,10 +192,7 @@ class HomeScreenRobot {
|
|||||||
fun verifyRecentlyVisitedSearchGroupDisplayed(shouldBeDisplayed: Boolean, searchTerm: String, groupSize: Int) {
|
fun verifyRecentlyVisitedSearchGroupDisplayed(shouldBeDisplayed: Boolean, searchTerm: String, groupSize: Int) {
|
||||||
// checks if the search group exists in the Recently visited section
|
// checks if the search group exists in the Recently visited section
|
||||||
if (shouldBeDisplayed) {
|
if (shouldBeDisplayed) {
|
||||||
recentlyVisitedList.waitForExists(waitingTime)
|
|
||||||
scrollToElementByText("Recently visited")
|
scrollToElementByText("Recently visited")
|
||||||
recentlyVisitedList.getChildByText(UiSelector().text(searchTerm), searchTerm, true)
|
|
||||||
.waitForExists(waitingTimeShort)
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
mDevice.findObject(UiSelector().text(searchTerm))
|
mDevice.findObject(UiSelector().text(searchTerm))
|
||||||
.getFromParent(UiSelector().text("$groupSize sites"))
|
.getFromParent(UiSelector().text("$groupSize sites"))
|
||||||
@ -580,7 +577,7 @@ class HomeScreenRobot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun openRecentlyVisitedSearchGroupHistoryList(title: String, interact: HistoryRobot.() -> Unit): HistoryRobot.Transition {
|
fun openRecentlyVisitedSearchGroupHistoryList(title: String, interact: HistoryRobot.() -> Unit): HistoryRobot.Transition {
|
||||||
val searchGroup = recentlyVisitedList.getChildByText(UiSelector().text(title), title, true)
|
val searchGroup = mDevice.findObject(UiSelector().text(title))
|
||||||
searchGroup.waitForExists(waitingTimeShort)
|
searchGroup.waitForExists(waitingTimeShort)
|
||||||
searchGroup.click()
|
searchGroup.click()
|
||||||
|
|
||||||
|
@ -340,19 +340,19 @@ class TabDrawerRobot {
|
|||||||
return BrowserRobot.Transition()
|
return BrowserRobot.Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openTabFromGroup(
|
// Temporary method to use indexes instead of tab titles, until the compose migration is complete
|
||||||
title: String,
|
fun openTabWithIndex(
|
||||||
|
tabPosition: Int,
|
||||||
interact: BrowserRobot.() -> Unit,
|
interact: BrowserRobot.() -> Unit,
|
||||||
): BrowserRobot.Transition {
|
): BrowserRobot.Transition {
|
||||||
val tab = UiScrollable(UiSelector().resourceId("$packageName:id/tab_group_list"))
|
val tab = mDevice.findObject(
|
||||||
.setAsHorizontalList()
|
UiSelector()
|
||||||
.getChildByText(
|
.className("androidx.compose.ui.platform.ComposeView")
|
||||||
UiSelector()
|
.index(tabPosition),
|
||||||
.resourceId("$packageName:id/mozac_browser_tabstray_title")
|
)
|
||||||
.textContains(title),
|
|
||||||
title,
|
UiScrollable(UiSelector().resourceId("$packageName:id/tray_list_item")).scrollIntoView(tab)
|
||||||
true,
|
tab.waitForExists(waitingTime)
|
||||||
)
|
|
||||||
tab.click()
|
tab.click()
|
||||||
|
|
||||||
BrowserRobot().interact()
|
BrowserRobot().interact()
|
||||||
|
Loading…
Reference in New Issue
Block a user