mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
Bug 1876734 - Add more test logs to ComposeTopSitesRobot
This commit is contained in:
parent
7122973f6a
commit
f1b67e9866
@ -20,8 +20,10 @@ import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource
|
||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
||||
import org.mozilla.fenix.helpers.TestHelper.clickSnackbarButton
|
||||
import org.mozilla.fenix.helpers.TestHelper.verifySnackBarText
|
||||
import org.mozilla.fenix.helpers.TestHelper.waitUntilSnackbarGone
|
||||
import org.mozilla.fenix.ui.robots.browserScreen
|
||||
import org.mozilla.fenix.ui.robots.homeScreen
|
||||
import org.mozilla.fenix.ui.robots.homeScreenWithComposeTopSites
|
||||
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
|
||||
@ -259,9 +261,11 @@ class ComposeTopSitesTest {
|
||||
verifyExistingTopSitesList()
|
||||
verifyExistingTopSiteItem(defaultWebPage.title)
|
||||
}.openContextMenuOnTopSitesWithTitle(defaultWebPage.title) {
|
||||
}.deleteTopSiteFromHistory {
|
||||
}.removeTopSite {
|
||||
verifySnackBarText(getStringResource(R.string.snackbar_top_site_removed))
|
||||
waitUntilSnackbarGone()
|
||||
}
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openHistory {
|
||||
verifyEmptyHistoryView()
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.ui.test.ExperimentalTestApi
|
||||
import androidx.compose.ui.test.filter
|
||||
import androidx.compose.ui.test.hasAnyChild
|
||||
@ -16,6 +17,7 @@ import androidx.compose.ui.test.onFirst
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performScrollTo
|
||||
import androidx.compose.ui.test.performTouchInput
|
||||
import org.mozilla.fenix.helpers.Constants.TAG
|
||||
import org.mozilla.fenix.helpers.HomeActivityComposeTestRule
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
|
||||
@ -32,14 +34,17 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR
|
||||
|
||||
@OptIn(ExperimentalTestApi::class)
|
||||
fun verifyExistingTopSitesList() {
|
||||
Log.i(TAG, "verifyExistingTopSitesList: Waiting for top sites list to exist")
|
||||
composeTestRule.waitUntilAtLeastOneExists(hasTestTag(TopSitesTestTag.topSites), timeoutMillis = waitingTime)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalTestApi::class)
|
||||
fun verifyExistingTopSiteItem(vararg titles: String) {
|
||||
titles.forEach { title ->
|
||||
Log.i(TAG, "verifyExistingTopSiteItem: Waiting for top site: $title to exist")
|
||||
composeTestRule.waitUntilAtLeastOneExists(hasText(title), timeoutMillis = waitingTime)
|
||||
composeTestRule.topSiteItem(title).assertExists()
|
||||
Log.i(TAG, "verifyExistingTopSiteItem: Top site with $title exists")
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +52,7 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR
|
||||
titles.forEach { title ->
|
||||
itemContainingText(title).waitForExists(waitingTime)
|
||||
composeTestRule.topSiteItem(title).assertDoesNotExist()
|
||||
Log.i(TAG, "verifyNotExistingTopSiteItem: Top site with $title does not exist")
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,14 +64,17 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR
|
||||
|
||||
fun verifyTopSiteContextMenuOpenInPrivateTabButton() {
|
||||
composeTestRule.contextMenuItemOpenInPrivateTab().assertExists()
|
||||
Log.i(TAG, "verifyTopSiteContextMenuOpenInPrivateTabButton: Verified \"Open in private tab\" menu button exists")
|
||||
}
|
||||
|
||||
fun verifyTopSiteContextMenuRenameButton() {
|
||||
composeTestRule.contextMenuItemRename().assertExists()
|
||||
Log.i(TAG, "verifyTopSiteContextMenuRenameButton: Verified \"Rename\" menu button exists")
|
||||
}
|
||||
|
||||
fun verifyTopSiteContextMenuRemoveButton() {
|
||||
composeTestRule.contextMenuItemRemove().assertExists()
|
||||
Log.i(TAG, "verifyTopSiteContextMenuRemoveButton: Verified \"Remove\" menu button exists")
|
||||
}
|
||||
|
||||
class Transition(private val composeTestRule: HomeActivityComposeTestRule) {
|
||||
@ -75,6 +84,7 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR
|
||||
interact: BrowserRobot.() -> Unit,
|
||||
): BrowserRobot.Transition {
|
||||
composeTestRule.topSiteItem(title).performScrollTo().performClick()
|
||||
Log.i(TAG, "openTopSiteTabWithTitle: Scrolled and clicked top site with title: $title")
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
@ -84,6 +94,7 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR
|
||||
interact: BrowserRobot.() -> Unit,
|
||||
): BrowserRobot.Transition {
|
||||
composeTestRule.contextMenuItemOpenInPrivateTab().performClick()
|
||||
Log.i(TAG, "openTopSiteInPrivate: Clicked \"Open in private tab\" menu button")
|
||||
composeTestRule.waitForIdle()
|
||||
|
||||
BrowserRobot().interact()
|
||||
@ -97,6 +108,7 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR
|
||||
composeTestRule.topSiteItem(title).performScrollTo().performTouchInput {
|
||||
longClick()
|
||||
}
|
||||
Log.i(TAG, "openContextMenuOnTopSitesWithTitle: Long clicked top site with title: $title")
|
||||
|
||||
ComposeTopSitesRobot(composeTestRule).interact()
|
||||
return Transition(composeTestRule)
|
||||
@ -107,12 +119,15 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR
|
||||
interact: ComposeTopSitesRobot.() -> Unit,
|
||||
): Transition {
|
||||
composeTestRule.contextMenuItemRename().performClick()
|
||||
Log.i(TAG, "renameTopSite: Clicked \"Rename\" menu button")
|
||||
itemWithResId("$packageName:id/top_site_title")
|
||||
.also {
|
||||
it.waitForExists(waitingTimeShort)
|
||||
it.setText(title)
|
||||
}
|
||||
Log.i(TAG, "renameTopSite: Top site rename text box was set to: $title")
|
||||
itemWithResIdContainingText("android:id/button1", "OK").click()
|
||||
Log.i(TAG, "renameTopSite: Clicked \"Ok\" dialog button")
|
||||
|
||||
ComposeTopSitesRobot(composeTestRule).interact()
|
||||
return Transition(composeTestRule)
|
||||
@ -123,22 +138,13 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR
|
||||
interact: ComposeTopSitesRobot.() -> Unit,
|
||||
): Transition {
|
||||
composeTestRule.contextMenuItemRemove().performClick()
|
||||
Log.i(TAG, "removeTopSite: Clicked \"Remove\" menu button")
|
||||
composeTestRule.waitUntilDoesNotExist(hasTestTag(TopSitesTestTag.remove), waitingTime)
|
||||
Log.i(TAG, "removeTopSite: Waited for \"Remove\" menu button to not exist")
|
||||
|
||||
ComposeTopSitesRobot(composeTestRule).interact()
|
||||
return Transition(composeTestRule)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalTestApi::class)
|
||||
fun deleteTopSiteFromHistory(
|
||||
interact: BrowserRobot.() -> Unit,
|
||||
): BrowserRobot.Transition {
|
||||
composeTestRule.contextMenuItemRemove().performClick()
|
||||
composeTestRule.waitUntilDoesNotExist(hasTestTag(TopSitesTestTag.remove), waitingTime)
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user