From 8f39d7ceb4328c546e8ea820540a20391ff52c58 Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Thu, 8 Feb 2024 16:18:35 +0200 Subject: [PATCH] Bug 1879339 - Add missing pairs of logs to ComposeTopSitesRobot --- .../fenix/ui/robots/ComposeTopSitesRobot.kt | 59 +++++++++++++------ 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ComposeTopSitesRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ComposeTopSitesRobot.kt index 1a25a39e6..53f1121bf 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ComposeTopSitesRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ComposeTopSitesRobot.kt @@ -34,25 +34,31 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR @OptIn(ExperimentalTestApi::class) fun verifyExistingTopSitesList() { - Log.i(TAG, "verifyExistingTopSitesList: Waiting for top sites list to exist") + Log.i(TAG, "verifyExistingTopSitesList: Waiting for $waitingTime ms until the top sites list exists") composeTestRule.waitUntilAtLeastOneExists(hasTestTag(TopSitesTestTag.topSites), timeoutMillis = waitingTime) + Log.i(TAG, "verifyExistingTopSitesList: Waited for $waitingTime ms until the top sites list to exists") } @OptIn(ExperimentalTestApi::class) fun verifyExistingTopSiteItem(vararg titles: String) { titles.forEach { title -> - Log.i(TAG, "verifyExistingTopSiteItem: Waiting for top site: $title to exist") + Log.i(TAG, "verifyExistingTopSiteItem: Waiting for $waitingTime ms until the top site with title: $title exists") composeTestRule.waitUntilAtLeastOneExists(hasText(title), timeoutMillis = waitingTime) + Log.i(TAG, "verifyExistingTopSiteItem: Waited for $waitingTime ms until the top site with title: $title exists") + Log.i(TAG, "verifyExistingTopSiteItem: Trying to verify that the top site with title: $title exists") composeTestRule.topSiteItem(title).assertExists() - Log.i(TAG, "verifyExistingTopSiteItem: Top site with $title exists") + Log.i(TAG, "verifyExistingTopSiteItem: Verified that the top site with title: $title exists") } } fun verifyNotExistingTopSiteItem(vararg titles: String) { titles.forEach { title -> + Log.i(TAG, "verifyNotExistingTopSiteItem: Waiting for $waitingTime ms for top site with title: $title to exist") itemContainingText(title).waitForExists(waitingTime) + Log.i(TAG, "verifyNotExistingTopSiteItem: Waited for $waitingTime ms for top site with title: $title to exist") + Log.i(TAG, "verifyNotExistingTopSiteItem: Trying to verify that top site with title: $title does not exist") composeTestRule.topSiteItem(title).assertDoesNotExist() - Log.i(TAG, "verifyNotExistingTopSiteItem: Top site with $title does not exist") + Log.i(TAG, "verifyNotExistingTopSiteItem: Verified that top site with title: $title does not exist") } } @@ -63,18 +69,21 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR } fun verifyTopSiteContextMenuOpenInPrivateTabButton() { + Log.i(TAG, "verifyTopSiteContextMenuOpenInPrivateTabButton: Trying to verify that the \"Open in private tab\" menu button exists") composeTestRule.contextMenuItemOpenInPrivateTab().assertExists() - Log.i(TAG, "verifyTopSiteContextMenuOpenInPrivateTabButton: Verified \"Open in private tab\" menu button exists") + Log.i(TAG, "verifyTopSiteContextMenuOpenInPrivateTabButton: Verified that the \"Open in private tab\" menu button exists") } fun verifyTopSiteContextMenuRenameButton() { + Log.i(TAG, "verifyTopSiteContextMenuRenameButton: Trying to verify that the \"Rename\" menu button exists") composeTestRule.contextMenuItemRename().assertExists() - Log.i(TAG, "verifyTopSiteContextMenuRenameButton: Verified \"Rename\" menu button exists") + Log.i(TAG, "verifyTopSiteContextMenuRenameButton: Verified that the \"Rename\" menu button exists") } fun verifyTopSiteContextMenuRemoveButton() { + Log.i(TAG, "verifyTopSiteContextMenuRemoveButton: Trying to verify that the \"Remove\" menu button exists") composeTestRule.contextMenuItemRemove().assertExists() - Log.i(TAG, "verifyTopSiteContextMenuRemoveButton: Verified \"Remove\" menu button exists") + Log.i(TAG, "verifyTopSiteContextMenuRemoveButton: Verified that the \"Remove\" menu button exists") } class Transition(private val composeTestRule: HomeActivityComposeTestRule) { @@ -83,8 +92,12 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR title: String, interact: BrowserRobot.() -> Unit, ): BrowserRobot.Transition { - composeTestRule.topSiteItem(title).performScrollTo().performClick() - Log.i(TAG, "openTopSiteTabWithTitle: Scrolled and clicked top site with title: $title") + Log.i(TAG, "openTopSiteTabWithTitle: Trying to scroll to top site with title: $title") + composeTestRule.topSiteItem(title).performScrollTo() + Log.i(TAG, "openTopSiteTabWithTitle: Scrolled to top site with title: $title") + Log.i(TAG, "openTopSiteTabWithTitle: Trying to click top site with title: $title") + composeTestRule.topSiteItem(title).performClick() + Log.i(TAG, "openTopSiteTabWithTitle: Clicked top site with title: $title") BrowserRobot().interact() return BrowserRobot.Transition() @@ -93,8 +106,9 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR fun openTopSiteInPrivate( interact: BrowserRobot.() -> Unit, ): BrowserRobot.Transition { + Log.i(TAG, "openTopSiteInPrivate: Trying to click the \"Open in private tab\" menu button") composeTestRule.contextMenuItemOpenInPrivateTab().performClick() - Log.i(TAG, "openTopSiteInPrivate: Clicked \"Open in private tab\" menu button") + Log.i(TAG, "openTopSiteInPrivate: Clicked the \"Open in private tab\" menu button") composeTestRule.waitForIdle() BrowserRobot().interact() @@ -105,9 +119,11 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR title: String, interact: ComposeTopSitesRobot.() -> Unit, ): Transition { - composeTestRule.topSiteItem(title).performScrollTo().performTouchInput { - longClick() - } + Log.i(TAG, "openContextMenuOnTopSitesWithTitle: Trying to scroll to top site with title: $title") + composeTestRule.topSiteItem(title).performScrollTo() + Log.i(TAG, "openContextMenuOnTopSitesWithTitle: Scrolled to top site with title: $title") + Log.i(TAG, "openContextMenuOnTopSitesWithTitle: Trying to long click top site with title: $title") + composeTestRule.topSiteItem(title).performTouchInput { longClick() } Log.i(TAG, "openContextMenuOnTopSitesWithTitle: Long clicked top site with title: $title") ComposeTopSitesRobot(composeTestRule).interact() @@ -118,16 +134,21 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR title: String, interact: ComposeTopSitesRobot.() -> Unit, ): Transition { + Log.i(TAG, "renameTopSite: Trying to click the \"Rename\" menu button") composeTestRule.contextMenuItemRename().performClick() - Log.i(TAG, "renameTopSite: Clicked \"Rename\" menu button") + Log.i(TAG, "renameTopSite: Clicked the \"Rename\" menu button") itemWithResId("$packageName:id/top_site_title") .also { + Log.i(TAG, "renameTopSite: Waiting for $waitingTimeShort ms for top site rename text box to exist") it.waitForExists(waitingTimeShort) + Log.i(TAG, "renameTopSite: Waited for $waitingTimeShort ms for top site rename text box to exist") + Log.i(TAG, "renameTopSite: Trying to set top site rename text box text to: $title") it.setText(title) + Log.i(TAG, "renameTopSite: Top site rename text box text was set to: $title") } - Log.i(TAG, "renameTopSite: Top site rename text box was set to: $title") + Log.i(TAG, "renameTopSite: Trying to click the \"Ok\" dialog button") itemWithResIdContainingText("android:id/button1", "OK").click() - Log.i(TAG, "renameTopSite: Clicked \"Ok\" dialog button") + Log.i(TAG, "renameTopSite: Clicked the \"Ok\" dialog button") ComposeTopSitesRobot(composeTestRule).interact() return Transition(composeTestRule) @@ -137,10 +158,12 @@ class ComposeTopSitesRobot(private val composeTestRule: HomeActivityComposeTestR fun removeTopSite( interact: ComposeTopSitesRobot.() -> Unit, ): Transition { + Log.i(TAG, "removeTopSite: Trying to click the \"Remove\" menu button") composeTestRule.contextMenuItemRemove().performClick() - Log.i(TAG, "removeTopSite: Clicked \"Remove\" menu button") + Log.i(TAG, "removeTopSite: Clicked the \"Remove\" menu button") + Log.i(TAG, "removeTopSite: Waiting for $waitingTime ms until the \"Remove\" menu button does not exist") composeTestRule.waitUntilDoesNotExist(hasTestTag(TopSitesTestTag.remove), waitingTime) - Log.i(TAG, "removeTopSite: Waited for \"Remove\" menu button to not exist") + Log.i(TAG, "removeTopSite: Waited for $waitingTime ms until the \"Remove\" menu button does not exist") ComposeTopSitesRobot(composeTestRule).interact() return Transition(composeTestRule)