Bug 1881228 - Add logs to SettingsSubMenuHomepageRobot

fenix/125.0
AndiAJ 4 months ago committed by mergify[bot]
parent 260cff62bf
commit 878676dd98

@ -22,7 +22,7 @@ import org.hamcrest.CoreMatchers
import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.Matchers import org.hamcrest.Matchers
import org.mozilla.fenix.R 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.TestAssetHelper.waitingTimeShort
import org.mozilla.fenix.helpers.TestHelper import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.TestHelper.mDevice import org.mozilla.fenix.helpers.TestHelper.mDevice
@ -43,9 +43,11 @@ class SettingsSubMenuHomepageRobot {
pocketSwitchEnabled: Boolean = true, pocketSwitchEnabled: Boolean = true,
sponsoredStoriesCheckBox: Boolean = true, sponsoredStoriesCheckBox: Boolean = true,
) { ) {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Shortcuts\" option is visible")
shortcutsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE))) shortcutsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyHomePageView: Verified that the \"Shortcuts\" option is visible")
if (shortcutsSwitchEnabled) { if (shortcutsSwitchEnabled) {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Shortcuts\" toggle is checked")
shortcutsButton() shortcutsButton()
.check( .check(
matches( matches(
@ -57,7 +59,9 @@ class SettingsSubMenuHomepageRobot {
), ),
), ),
) )
Log.i(TAG, "verifyHomePageView: Verified that the \"Shortcuts\" toggle is checked")
} else { } else {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Shortcuts\" toggle is not checked")
shortcutsButton() shortcutsButton()
.check( .check(
matches( 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))) sponsoredShortcutsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyHomePageView: Verified that the \"Sponsored shortcuts\" option is visible")
if (sponsoredShortcutsCheckBox) { if (sponsoredShortcutsCheckBox) {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Sponsored shortcuts\" check box is checked")
sponsoredShortcutsButton() sponsoredShortcutsButton()
.check( .check(
matches( matches(
@ -87,7 +93,9 @@ class SettingsSubMenuHomepageRobot {
), ),
), ),
) )
Log.i(TAG, "verifyHomePageView: Verified that the \"Sponsored shortcuts\" check box is checked")
} else { } else {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Sponsored shortcuts\" check box is not checked")
sponsoredShortcutsButton() sponsoredShortcutsButton()
.check( .check(
matches( 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))) jumpBackInButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyHomePageView: Verified that the \"Jump back in\" option is visible")
if (jumpBackInSwitchEnabled) { if (jumpBackInSwitchEnabled) {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Jump back in\" toggle is checked")
jumpBackInButton() jumpBackInButton()
.check( .check(
matches( matches(
@ -117,7 +127,9 @@ class SettingsSubMenuHomepageRobot {
), ),
), ),
) )
Log.i(TAG, "verifyHomePageView: Verified that the \"Jump back in\" toggle is checked")
} else { } else {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Jump back in\" toggle is not checked")
jumpBackInButton() jumpBackInButton()
.check( .check(
matches( 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))) recentBookmarksButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyHomePageView: Verified that the \"Recent bookmarks\" option is visible")
if (recentBookmarksSwitchEnabled) { if (recentBookmarksSwitchEnabled) {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Recent bookmarks\" toggle is checked")
recentBookmarksButton() recentBookmarksButton()
.check( .check(
matches( matches(
@ -145,7 +159,9 @@ class SettingsSubMenuHomepageRobot {
), ),
), ),
) )
Log.i(TAG, "verifyHomePageView: Verified that the \"Recent bookmarks\" toggle is checked")
} else { } else {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Recent bookmarks\" toggle is not checked")
recentBookmarksButton() recentBookmarksButton()
.check( .check(
matches( 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))) recentlyVisitedButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyHomePageView: Verified that the \"Recently visited\" option is visible")
if (recentlyVisitedSwitchEnabled) { if (recentlyVisitedSwitchEnabled) {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Recently visited\" toggle is checked")
recentlyVisitedButton() recentlyVisitedButton()
.check( .check(
matches( matches(
@ -173,7 +191,9 @@ class SettingsSubMenuHomepageRobot {
), ),
), ),
) )
Log.i(TAG, "verifyHomePageView: Verified that the \"Recently visited\" toggle is checked")
} else { } else {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Recently visited\" toggle is not checked")
recentlyVisitedButton() recentlyVisitedButton()
.check( .check(
matches( 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))) pocketButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyHomePageView: Verified that the \"Thought-provoking stories\" option is visible")
if (pocketSwitchEnabled) { if (pocketSwitchEnabled) {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Thought-provoking stories\" toggle is checked")
pocketButton() pocketButton()
.check( .check(
matches( matches(
@ -201,7 +223,9 @@ class SettingsSubMenuHomepageRobot {
), ),
), ),
) )
Log.i(TAG, "verifyHomePageView: Verified that the \"Thought-provoking stories\" toggle is checked")
} else { } else {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Thought-provoking stories\" toggle is not checked")
pocketButton() pocketButton()
.check( .check(
matches( 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))) sponsoredStoriesButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyHomePageView: Verified that the \"Sponsored stories\" option is visible")
if (sponsoredStoriesCheckBox) { if (sponsoredStoriesCheckBox) {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Sponsored stories\" check box is checked")
sponsoredStoriesButton() sponsoredStoriesButton()
.check( .check(
matches( matches(
@ -231,7 +257,9 @@ class SettingsSubMenuHomepageRobot {
), ),
), ),
) )
Log.i(TAG, "verifyHomePageView: Verified that the \"Sponsored stories\" check box is checked")
} else { } else {
Log.i(TAG, "verifyHomePageView: Trying to verify that the \"Sponsored stories\" check box is not checked")
sponsoredStoriesButton() sponsoredStoriesButton()
.check( .check(
matches( 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))) 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))) 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))) 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))) homepageAfterFourHoursButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyHomePageView: Verified that the \"Homepage after four hours of inactivity\" option is visible")
Log.i(Constants.TAG, "verifyHomePageView: Verified the home page elements")
} }
fun verifySelectedOpeningScreenOption(openingScreenOption: String) = fun verifySelectedOpeningScreenOption(openingScreenOption: String) {
Log.i(TAG, "verifySelectedOpeningScreenOption: Trying to verify that the \"Opening screen\" option $openingScreenOption is checked")
onView( onView(
allOf( allOf(
withId(R.id.radio_button), withId(R.id.radio_button),
hasSibling(withText(openingScreenOption)), hasSibling(withText(openingScreenOption)),
), ),
).check(matches(isChecked(true))) ).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) { fun clickOpeningScreenOption(openingScreenOption: String) {
Log.i(TAG, "clickOpeningScreenOption: Trying to click \"Opening screen\" option: $openingScreenOption")
when (openingScreenOption) { when (openingScreenOption) {
"Homepage" -> homepageButton().click() "Homepage" -> homepageButton().click()
"Last tab" -> lastTabButton().click() "Last tab" -> lastTabButton().click()
"Homepage after four hours of inactivity" -> homepageAfterFourHoursButton().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() mDevice.findObject(UiSelector().description(wallpaperName)).click()
Log.i(TAG, "selectWallpaper: Clicked wallpaper: $wallpaperName")
}
fun verifySponsoredShortcutsCheckBox(checked: Boolean) { fun verifySponsoredShortcutsCheckBox(checked: Boolean) {
if (checked) { if (checked) {
Log.i(TAG, "verifySponsoredShortcutsCheckBox: Trying to verify that the \"Sponsored shortcuts\" check box is checked")
sponsoredShortcutsButton() sponsoredShortcutsButton()
.check( .check(
matches( matches(
@ -308,7 +380,9 @@ class SettingsSubMenuHomepageRobot {
), ),
), ),
) )
Log.i(TAG, "verifySponsoredShortcutsCheckBox: Verified that the \"Sponsored shortcuts\" check box is checked")
} else { } else {
Log.i(TAG, "verifySponsoredShortcutsCheckBox: Trying to verify that the \"Sponsored shortcuts\" check box is not checked")
sponsoredShortcutsButton() sponsoredShortcutsButton()
.check( .check(
matches( matches(
@ -322,29 +396,37 @@ class SettingsSubMenuHomepageRobot {
), ),
), ),
) )
Log.i(TAG, "verifySponsoredShortcutsCheckBox: Verified that the \"Sponsored shortcuts\" check box is not checked")
} }
} }
class Transition { class Transition {
fun goBackToHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { fun goBackToHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
Log.i(TAG, "goBackToHomeScreen: Trying to click the navigate up toolbar button")
goBackButton().click() goBackButton().click()
Log.i(TAG, "goBackToHomeScreen: Clicked the navigate up toolbar button")
HomeScreenRobot().interact() HomeScreenRobot().interact()
return HomeScreenRobot.Transition() return HomeScreenRobot.Transition()
} }
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
Log.i(TAG, "goBack: Trying to click the navigate up toolbar button")
goBackButton().click() goBackButton().click()
Log.i(TAG, "goBack: Clicked the navigate up toolbar button")
SettingsRobot().interact() SettingsRobot().interact()
return SettingsRobot.Transition() return SettingsRobot.Transition()
} }
fun clickSnackBarViewButton(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { fun clickSnackBarViewButton(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
val snackBarButton = mDevice.findObject(UiSelector().text("VIEW")) Log.i(TAG, "clickSnackBarViewButton: Waiting for $waitingTimeShort ms for \"VIEW\" snackbar button to exist")
snackBarButton.waitForExists(waitingTimeShort) mDevice.findObject(UiSelector().text("VIEW")).waitForExists(waitingTimeShort)
snackBarButton.click() 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() HomeScreenRobot().interact()
return HomeScreenRobot.Transition() return HomeScreenRobot.Transition()

Loading…
Cancel
Save