Bug 1879072 - Convert private variables to functions so they don't get initialized

fenix/124.1.0
AndiAJ 4 months ago committed by mergify[bot]
parent ab4a64f380
commit fa93a4ba3a

@ -79,19 +79,20 @@ import org.mozilla.fenix.tabstray.TabsTrayTestTag
* Implementation of Robot Pattern for the home screen menu. * Implementation of Robot Pattern for the home screen menu.
*/ */
class HomeScreenRobot { class HomeScreenRobot {
val privateSessionMessage =
"$appName clears your search and browsing history from private tabs when you close them" +
" or quit the app. While this doesnt make you anonymous to websites or your internet" +
" service provider, it makes it easier to keep what you do online private from anyone" +
" else who uses this device."
fun verifyNavigationToolbar() = assertUIObjectExists(navigationToolbar()) fun verifyNavigationToolbar() = assertUIObjectExists(navigationToolbar())
fun verifyHomeScreen() = assertUIObjectExists(homeScreen()) fun verifyHomeScreen() = assertUIObjectExists(homeScreen())
fun verifyPrivateBrowsingHomeScreenItems() { fun verifyPrivateBrowsingHomeScreenItems() {
verifyHomeScreenAppBarItems() verifyHomeScreenAppBarItems()
assertUIObjectExists(itemContainingText(privateSessionMessage)) assertUIObjectExists(
itemContainingText(
"$appName clears your search and browsing history from private tabs when you close them" +
" or quit the app. While this doesnt make you anonymous to websites or your internet" +
" service provider, it makes it easier to keep what you do online private from anyone" +
" else who uses this device.",
),
)
verifyCommonMythsLink() verifyCommonMythsLink()
} }
@ -99,7 +100,7 @@ class HomeScreenRobot {
assertUIObjectExists(homeScreen(), privateBrowsingButton(), homepageWordmark()) assertUIObjectExists(homeScreen(), privateBrowsingButton(), homepageWordmark())
fun verifyHomePrivateBrowsingButton() = assertUIObjectExists(privateBrowsingButton()) fun verifyHomePrivateBrowsingButton() = assertUIObjectExists(privateBrowsingButton())
fun verifyHomeMenuButton() = assertUIObjectExists(menuButton) fun verifyHomeMenuButton() = assertUIObjectExists(menuButton())
fun verifyTabButton() = fun verifyTabButton() =
onView(allOf(withId(R.id.tab_button), isDisplayed())).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) onView(allOf(withId(R.id.tab_button), isDisplayed())).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
fun verifyCollectionsHeader() = fun verifyCollectionsHeader() =
@ -365,8 +366,7 @@ class HomeScreenRobot {
fun verifyPocketRecommendedStoriesItems() { fun verifyPocketRecommendedStoriesItems() {
for (position in 0..8) { for (position in 0..8) {
pocketStoriesList pocketStoriesList().scrollIntoView(UiSelector().index(position))
.scrollIntoView(UiSelector().index(position))
assertUIObjectExists(itemWithIndex(position)) assertUIObjectExists(itemWithIndex(position))
} }
} }
@ -387,8 +387,7 @@ class HomeScreenRobot {
// } // }
fun verifyDiscoverMoreStoriesButton() { fun verifyDiscoverMoreStoriesButton() {
pocketStoriesList pocketStoriesList().scrollIntoView(UiSelector().text("Discover more"))
.scrollIntoView(UiSelector().text("Discover more"))
assertUIObjectExists(itemWithText("Discover more")) assertUIObjectExists(itemWithText("Discover more"))
} }
@ -661,7 +660,7 @@ class HomeScreenRobot {
mDevice.findObject( mDevice.findObject(
UiSelector().resourceId("$packageName:id/simple_text"), UiSelector().resourceId("$packageName:id/simple_text"),
).waitForExists(waitingTime) ).waitForExists(waitingTime)
deleteFromHistory.click() deleteFromHistory().click()
HomeScreenRobot().interact() HomeScreenRobot().interact()
return Transition() return Transition()
@ -677,18 +676,18 @@ class HomeScreenRobot {
} }
fun clickSponsorsAndPrivacyButton(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun clickSponsorsAndPrivacyButton(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
sponsorsAndPrivacyButton.waitForExists(waitingTime) sponsorsAndPrivacyButton().waitForExists(waitingTime)
sponsorsAndPrivacyButton.clickAndWaitForNewWindow(waitingTime) sponsorsAndPrivacyButton().clickAndWaitForNewWindow(waitingTime)
BrowserRobot().interact() BrowserRobot().interact()
return BrowserRobot.Transition() return BrowserRobot.Transition()
} }
fun clickSponsoredShortcutsSettingsButton(interact: SettingsSubMenuHomepageRobot.() -> Unit): SettingsSubMenuHomepageRobot.Transition { fun clickSponsoredShortcutsSettingsButton(interact: SettingsSubMenuHomepageRobot.() -> Unit): SettingsSubMenuHomepageRobot.Transition {
Log.i(TAG, "clickSponsoredShortcutsSettingsButton: Looking for: ${sponsoredShortcutsSettingsButton.selector}") Log.i(TAG, "clickSponsoredShortcutsSettingsButton: Looking for: ${sponsoredShortcutsSettingsButton().selector}")
sponsoredShortcutsSettingsButton.waitForExists(waitingTime) sponsoredShortcutsSettingsButton().waitForExists(waitingTime)
sponsoredShortcutsSettingsButton.clickAndWaitForNewWindow(waitingTime) sponsoredShortcutsSettingsButton().clickAndWaitForNewWindow(waitingTime)
Log.i(TAG, "clickSponsoredShortcutsSettingsButton: Clicked ${sponsoredShortcutsSettingsButton.selector} and waiting for $waitingTime for a new window") Log.i(TAG, "clickSponsoredShortcutsSettingsButton: Clicked ${sponsoredShortcutsSettingsButton().selector} and waiting for $waitingTime for a new window")
SettingsSubMenuHomepageRobot().interact() SettingsSubMenuHomepageRobot().interact()
return SettingsSubMenuHomepageRobot.Transition() return SettingsSubMenuHomepageRobot.Transition()
@ -793,7 +792,7 @@ class HomeScreenRobot {
} }
fun clickPocketDiscoverMoreButton(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun clickPocketDiscoverMoreButton(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
pocketStoriesList pocketStoriesList()
.scrollIntoView(UiSelector().text("Discover more")) .scrollIntoView(UiSelector().text("Discover more"))
mDevice.findObject(UiSelector().text("Discover more")).also { mDevice.findObject(UiSelector().text("Discover more")).also {
@ -888,12 +887,12 @@ private fun homepageWordmark() =
private fun navigationToolbar() = private fun navigationToolbar() =
itemWithResId("$packageName:id/toolbar") itemWithResId("$packageName:id/toolbar")
private val menuButton = private fun menuButton() =
itemWithResId("$packageName:id/menuButton") itemWithResId("$packageName:id/menuButton")
private fun tabCounter(numberOfOpenTabs: String) = private fun tabCounter(numberOfOpenTabs: String) =
itemWithResIdAndText("$packageName:id/counter_text", numberOfOpenTabs) itemWithResIdAndText("$packageName:id/counter_text", numberOfOpenTabs)
val deleteFromHistory = fun deleteFromHistory() =
onView( onView(
allOf( allOf(
withId(R.id.simple_text), withId(R.id.simple_text),
@ -901,7 +900,7 @@ val deleteFromHistory =
), ),
).inRoot(RootMatchers.isPlatformPopup()) ).inRoot(RootMatchers.isPlatformPopup())
private val sponsoredShortcutsSettingsButton = private fun sponsoredShortcutsSettingsButton() =
mDevice mDevice
.findObject( .findObject(
UiSelector() UiSelector()
@ -909,7 +908,7 @@ private val sponsoredShortcutsSettingsButton =
.resourceId("$packageName:id/simple_text"), .resourceId("$packageName:id/simple_text"),
) )
private val sponsorsAndPrivacyButton = private fun sponsorsAndPrivacyButton() =
mDevice mDevice
.findObject( .findObject(
UiSelector() UiSelector()
@ -917,5 +916,5 @@ private val sponsorsAndPrivacyButton =
.resourceId("$packageName:id/simple_text"), .resourceId("$packageName:id/simple_text"),
) )
private val pocketStoriesList = private fun pocketStoriesList() =
UiScrollable(UiSelector().resourceId("pocket.stories")).setAsHorizontalList() UiScrollable(UiSelector().resourceId("pocket.stories")).setAsHorizontalList()

Loading…
Cancel
Save