From 878676dd987d24a57a9876e6e31c6ac1cba7d39d Mon Sep 17 00:00:00 2001 From: AndiAJ Date: Tue, 20 Feb 2024 16:21:41 +0200 Subject: [PATCH] Bug 1881228 - Add logs to SettingsSubMenuHomepageRobot --- .../ui/robots/SettingsSubMenuHomepageRobot.kt | 148 ++++++++++++++---- 1 file changed, 115 insertions(+), 33 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuHomepageRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuHomepageRobot.kt index b04ca8a30a..9d1c919a37 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuHomepageRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuHomepageRobot.kt @@ -22,7 +22,7 @@ import org.hamcrest.CoreMatchers import org.hamcrest.CoreMatchers.allOf import org.hamcrest.Matchers import org.mozilla.fenix.R -import org.mozilla.fenix.helpers.Constants +import org.mozilla.fenix.helpers.Constants.TAG import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeShort import org.mozilla.fenix.helpers.TestHelper import org.mozilla.fenix.helpers.TestHelper.mDevice @@ -43,9 +43,11 @@ class SettingsSubMenuHomepageRobot { pocketSwitchEnabled: Boolean = true, sponsoredStoriesCheckBox: Boolean = true, ) { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Shortcuts\" option is visible") shortcutsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - + Log.i(TAG, "verifyHomePageView: Verified that the \"Shortcuts\" option is visible") if (shortcutsSwitchEnabled) { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Shortcuts\" toggle is checked") shortcutsButton() .check( matches( @@ -57,7 +59,9 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Shortcuts\" toggle is checked") } else { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Shortcuts\" toggle is not checked") shortcutsButton() .check( matches( @@ -69,11 +73,13 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Shortcuts\" toggle is not checked") } - + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Sponsored shortcuts\" option is visible") sponsoredShortcutsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - + Log.i(TAG, "verifyHomePageView: Verified that the \"Sponsored shortcuts\" option is visible") if (sponsoredShortcutsCheckBox) { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Sponsored shortcuts\" check box is checked") sponsoredShortcutsButton() .check( matches( @@ -87,7 +93,9 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Sponsored shortcuts\" check box is checked") } else { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Sponsored shortcuts\" check box is not checked") sponsoredShortcutsButton() .check( matches( @@ -101,11 +109,13 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Sponsored shortcuts\" check box is not checked") } - + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Jump back in\" option is visible") jumpBackInButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - + Log.i(TAG, "verifyHomePageView: Verified that the \"Jump back in\" option is visible") if (jumpBackInSwitchEnabled) { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Jump back in\" toggle is checked") jumpBackInButton() .check( matches( @@ -117,7 +127,9 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Jump back in\" toggle is checked") } else { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Jump back in\" toggle is not checked") jumpBackInButton() .check( matches( @@ -129,11 +141,13 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Jump back in\" toggle is not checked") } - + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Recent bookmarks\" option is visible") recentBookmarksButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - + Log.i(TAG, "verifyHomePageView: Verified that the \"Recent bookmarks\" option is visible") if (recentBookmarksSwitchEnabled) { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Recent bookmarks\" toggle is checked") recentBookmarksButton() .check( matches( @@ -145,7 +159,9 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Recent bookmarks\" toggle is checked") } else { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Recent bookmarks\" toggle is not checked") recentBookmarksButton() .check( matches( @@ -157,11 +173,13 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Recent bookmarks\" toggle is not checked") } - + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Recently visited\" option is visible") recentlyVisitedButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - + Log.i(TAG, "verifyHomePageView: Verified that the \"Recently visited\" option is visible") if (recentlyVisitedSwitchEnabled) { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Recently visited\" toggle is checked") recentlyVisitedButton() .check( matches( @@ -173,7 +191,9 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Recently visited\" toggle is checked") } else { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Recently visited\" toggle is not checked") recentlyVisitedButton() .check( matches( @@ -185,11 +205,13 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Recently visited\" toggle is not checked") } - + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Thought-provoking stories\" option is visible") pocketButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - + Log.i(TAG, "verifyHomePageView: Verified that the \"Thought-provoking stories\" option is visible") if (pocketSwitchEnabled) { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Thought-provoking stories\" toggle is checked") pocketButton() .check( matches( @@ -201,7 +223,9 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Thought-provoking stories\" toggle is checked") } else { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Thought-provoking stories\" toggle is not checked") pocketButton() .check( matches( @@ -213,11 +237,13 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Thought-provoking stories\" toggle is not checked") } - + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Sponsored stories\" option is visible") sponsoredStoriesButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - + Log.i(TAG, "verifyHomePageView: Verified that the \"Sponsored stories\" option is visible") if (sponsoredStoriesCheckBox) { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Sponsored stories\" check box is checked") sponsoredStoriesButton() .check( matches( @@ -231,7 +257,9 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Sponsored stories\" check box is checked") } else { + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Sponsored stories\" check box is not checked") sponsoredStoriesButton() .check( matches( @@ -245,56 +273,100 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifyHomePageView: Verified that the \"Sponsored stories\" check box is not checked") } - + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Opening screen\" heading is visible") openingScreenHeading().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - + Log.i(TAG, "verifyHomePageView: Verified that the \"Opening screen\" heading is visible") + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Homepage\" option is visible") homepageButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - + Log.i(TAG, "verifyHomePageView: Verified that the \"Homepage\" option is visible") + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Last tab\" option is visible") lastTabButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - + Log.i(TAG, "verifyHomePageView: Verified that the \"Last tab\" option is visible") + Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Homepage after four hours of inactivity\" option is visible") homepageAfterFourHoursButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - - Log.i(Constants.TAG, "verifyHomePageView: Verified the home page elements") + Log.i(TAG, "verifyHomePageView: Verified that the \"Homepage after four hours of inactivity\" option is visible") } - fun verifySelectedOpeningScreenOption(openingScreenOption: String) = + fun verifySelectedOpeningScreenOption(openingScreenOption: String) { + Log.i(TAG, "verifySelectedOpeningScreenOption: Trying to verify that the \"Opening screen\" option $openingScreenOption is checked") onView( allOf( withId(R.id.radio_button), hasSibling(withText(openingScreenOption)), ), ).check(matches(isChecked(true))) + Log.i(TAG, "verifySelectedOpeningScreenOption: Verified that the \"Opening screen\" option $openingScreenOption is checked") + } - fun clickShortcutsButton() = shortcutsButton().click() + fun clickShortcutsButton() { + Log.i(TAG, "clickShortcutsButton: Trying to click the \"Shortcuts\" option") + shortcutsButton().click() + Log.i(TAG, "clickShortcutsButton: Clicked the \"Shortcuts\" option") + } - fun clickSponsoredShortcuts() = sponsoredShortcutsButton().click() + fun clickSponsoredShortcuts() { + Log.i(TAG, "clickSponsoredShortcuts: Trying to click the \"Sponsored shortcuts\" option") + sponsoredShortcutsButton().click() + Log.i(TAG, "clickSponsoredShortcuts: Clicked the \"Sponsored shortcuts\" option") + } - fun clickJumpBackInButton() = jumpBackInButton().click() + fun clickJumpBackInButton() { + Log.i(TAG, "clickJumpBackInButton: Trying to click the \"Jump back in\" option") + jumpBackInButton().click() + Log.i(TAG, "clickJumpBackInButton: Clicked the \"Jump back in\" option") + } - fun clickRecentlyVisited() = recentlyVisitedButton().click() + fun clickRecentlyVisited() { + Log.i(TAG, "clickRecentlyVisited: Trying to click the \"Recently visited\" option") + recentlyVisitedButton().click() + Log.i(TAG, "clickRecentlyVisited: Clicked the \"Recently visited\" option") + } - fun clickRecentBookmarksButton() = recentBookmarksButton().click() + fun clickRecentBookmarksButton() { + Log.i(TAG, "clickRecentBookmarksButton: Trying to click the \"Recent bookmarks\" option") + recentBookmarksButton().click() + Log.i(TAG, "clickRecentBookmarksButton: Clicked the \"Recent bookmarks\" option") + } - fun clickRecentSearchesButton() = recentlyVisitedButton().click() + fun clickRecentSearchesButton() { + Log.i(TAG, "clickRecentSearchesButton: Trying to click the \"Recently visited\" option") + recentlyVisitedButton().click() + Log.i(TAG, "clickRecentSearchesButton: Clicked the \"Recently visited\" option") + } - fun clickPocketButton() = pocketButton().click() + fun clickPocketButton() { + Log.i(TAG, "clickPocketButton: Trying to click the \"Thought-provoking stories\" option") + pocketButton().click() + Log.i(TAG, "clickPocketButton: Clicked the \"Thought-provoking stories\" option") + } fun clickOpeningScreenOption(openingScreenOption: String) { + Log.i(TAG, "clickOpeningScreenOption: Trying to click \"Opening screen\" option: $openingScreenOption") when (openingScreenOption) { "Homepage" -> homepageButton().click() "Last tab" -> lastTabButton().click() "Homepage after four hours of inactivity" -> homepageAfterFourHoursButton().click() } + Log.i(TAG, "clickOpeningScreenOption: Clicked \"Opening screen\" option: $openingScreenOption") } - fun openWallpapersMenu() = wallpapersMenuButton().click() + fun openWallpapersMenu() { + Log.i(TAG, "openWallpapersMenu: Trying to click the \"Wallpapers\" option") + wallpapersMenuButton().click() + Log.i(TAG, "openWallpapersMenu: Clicked the \"Wallpapers\" option") + } - fun selectWallpaper(wallpaperName: String) = + fun selectWallpaper(wallpaperName: String) { + Log.i(TAG, "selectWallpaper: Trying to click wallpaper: $wallpaperName") mDevice.findObject(UiSelector().description(wallpaperName)).click() + Log.i(TAG, "selectWallpaper: Clicked wallpaper: $wallpaperName") + } fun verifySponsoredShortcutsCheckBox(checked: Boolean) { if (checked) { + Log.i(TAG, "verifySponsoredShortcutsCheckBox: Trying to verify that the \"Sponsored shortcuts\" check box is checked") sponsoredShortcutsButton() .check( matches( @@ -308,7 +380,9 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifySponsoredShortcutsCheckBox: Verified that the \"Sponsored shortcuts\" check box is checked") } else { + Log.i(TAG, "verifySponsoredShortcutsCheckBox: Trying to verify that the \"Sponsored shortcuts\" check box is not checked") sponsoredShortcutsButton() .check( matches( @@ -322,29 +396,37 @@ class SettingsSubMenuHomepageRobot { ), ), ) + Log.i(TAG, "verifySponsoredShortcutsCheckBox: Verified that the \"Sponsored shortcuts\" check box is not checked") } } class Transition { fun goBackToHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { + Log.i(TAG, "goBackToHomeScreen: Trying to click the navigate up toolbar button") goBackButton().click() + Log.i(TAG, "goBackToHomeScreen: Clicked the navigate up toolbar button") HomeScreenRobot().interact() return HomeScreenRobot.Transition() } fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { + Log.i(TAG, "goBack: Trying to click the navigate up toolbar button") goBackButton().click() + Log.i(TAG, "goBack: Clicked the navigate up toolbar button") SettingsRobot().interact() return SettingsRobot.Transition() } fun clickSnackBarViewButton(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { - val snackBarButton = mDevice.findObject(UiSelector().text("VIEW")) - snackBarButton.waitForExists(waitingTimeShort) - snackBarButton.click() + Log.i(TAG, "clickSnackBarViewButton: Waiting for $waitingTimeShort ms for \"VIEW\" snackbar button to exist") + mDevice.findObject(UiSelector().text("VIEW")).waitForExists(waitingTimeShort) + Log.i(TAG, "clickSnackBarViewButton: Waited for $waitingTimeShort ms for \"VIEW\" snackbar button to exist") + Log.i(TAG, "clickSnackBarViewButton: Trying to click the \"VIEW\" snackbar button") + mDevice.findObject(UiSelector().text("VIEW")).click() + Log.i(TAG, "clickSnackBarViewButton: Clicked the \"VIEW\" snackbar button") HomeScreenRobot().interact() return HomeScreenRobot.Transition()