Bug 1880445 - Add logs to SettingsRobot

fenix/124.1.0
AndiAJ 4 months ago committed by mergify[bot]
parent d4a5b09f11
commit 183188b3db

@ -178,11 +178,12 @@ object AppAndSystemHelper {
} }
fun isPackageInstalled(packageName: String): Boolean { fun isPackageInstalled(packageName: String): Boolean {
Log.i(TAG, "isPackageInstalled: Trying to verify that $packageName is installed")
return try { return try {
val packageManager = InstrumentationRegistry.getInstrumentation().context.packageManager val packageManager = InstrumentationRegistry.getInstrumentation().context.packageManager
packageManager.getApplicationInfo(packageName, 0).enabled packageManager.getApplicationInfo(packageName, 0).enabled
} catch (e: PackageManager.NameNotFoundException) { } catch (e: PackageManager.NameNotFoundException) {
Log.i(TAG, "isPackageInstalled: Catch block - ${e.message}") Log.i(TAG, "isPackageInstalled: $packageName is not installed - ${e.message}")
false false
} }
} }

@ -17,7 +17,6 @@ import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.intent.Intents.intended import androidx.test.espresso.intent.Intents.intended
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
import androidx.test.espresso.intent.matcher.IntentMatchers.hasData import androidx.test.espresso.intent.matcher.IntentMatchers.hasData
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.hasSibling import androidx.test.espresso.matcher.ViewMatchers.hasSibling
@ -26,6 +25,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isNotChecked import androidx.test.espresso.matcher.ViewMatchers.isNotChecked
import androidx.test.espresso.matcher.ViewMatchers.withClassName import androidx.test.espresso.matcher.ViewMatchers.withClassName
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.matcher.ViewMatchers.withText
@ -69,43 +69,62 @@ class SettingsRobot {
// BASICS SECTION // BASICS SECTION
fun verifyGeneralHeading() { fun verifyGeneralHeading() {
scrollToElementByText("General") scrollToElementByText("General")
Log.i(TAG, "verifyGeneralHeading: Trying to verify that the \"General\" heading is visible")
onView(withText("General")) onView(withText("General"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyGeneralHeading: Verified that the \"General\" heading is visible")
} }
fun verifySearchButton() { fun verifySearchButton() {
Log.i(TAG, "verifySearchButton: Waiting for $waitingTime ms until finding the \"Search\" button")
mDevice.wait(Until.findObject(By.text("Search")), waitingTime) mDevice.wait(Until.findObject(By.text("Search")), waitingTime)
Log.i(TAG, "verifySearchButton: Waited for $waitingTime ms until the \"Search\" button was found")
Log.i(TAG, "verifySearchButton: Trying to verify that the \"Search\" button is visible")
onView(withText(R.string.preferences_search)) onView(withText(R.string.preferences_search))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifySearchButton: Verified that the \"Search\" button is visible")
} }
fun verifyCustomizeButton() { fun verifyCustomizeButton() {
Log.i(TAG, "verifyCustomizeButton: Trying to verify that the \"Customize\" button is visible")
onView(withText("Customize")) onView(withText("Customize"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyCustomizeButton: Verified that the \"Customize\" button is visible")
} }
fun verifyAccessibilityButton() { fun verifyAccessibilityButton() {
Log.i(TAG, "verifyAccessibilityButton: Trying to verify that the \"Accessibility\" button is visible")
onView(withText("Accessibility")) onView(withText("Accessibility"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyAccessibilityButton: Verified that the \"Accessibility\" button is visible")
} }
fun verifySetAsDefaultBrowserButton() { fun verifySetAsDefaultBrowserButton() {
scrollToElementByText("Set as default browser") scrollToElementByText("Set as default browser")
Log.i(TAG, "verifySetAsDefaultBrowserButton: Trying to verify that the \"Set as default browser\" button is visible")
onView(withText("Set as default browser")) onView(withText("Set as default browser"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifySetAsDefaultBrowserButton: Verified that the \"Set as default browser\" button is visible")
} }
fun verifyTabsButton() = fun verifyTabsButton() =
assertUIObjectExists(itemContainingText(getStringResource(R.string.preferences_tabs))) assertUIObjectExists(itemContainingText(getStringResource(R.string.preferences_tabs)))
fun verifyHomepageButton() { fun verifyHomepageButton() {
Log.i(TAG, "verifyHomepageButton: Trying to verify that the \"Homepage\" button is visible")
onView(withText(R.string.preferences_home_2)).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) onView(withText(R.string.preferences_home_2)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyHomepageButton: Verified that the \"Homepage\" button is visible")
} }
fun verifyAutofillButton() { fun verifyAutofillButton() {
Log.i(TAG, "verifyAutofillButton: Trying to verify that the \"Autofill\" button is visible")
onView(withText(R.string.preferences_autofill)).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) onView(withText(R.string.preferences_autofill)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyAutofillButton: Verified that the \"Autofill\" button is visible")
} }
fun verifyLanguageButton() { fun verifyLanguageButton() {
scrollToElementByText(getStringResource(R.string.preferences_language)) scrollToElementByText(getStringResource(R.string.preferences_language))
Log.i(TAG, "verifyLanguageButton: Trying to verify that the \"Language\" button is visible")
onView(withText(R.string.preferences_language)).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) onView(withText(R.string.preferences_language)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyLanguageButton: Verified that the \"Language\" button is visible")
} }
fun verifyDefaultBrowserToggle(isEnabled: Boolean) { fun verifyDefaultBrowserToggle(isEnabled: Boolean) {
scrollToElementByText(getStringResource(R.string.preferences_set_as_default_browser)) scrollToElementByText(getStringResource(R.string.preferences_set_as_default_browser))
Log.i(TAG, "verifyDefaultBrowserToggle: Trying to verify that the \"Set as default browser\" toggle is enabled: $isEnabled")
onView(withText(R.string.preferences_set_as_default_browser)) onView(withText(R.string.preferences_set_as_default_browser))
.check( .check(
matches( matches(
@ -121,28 +140,36 @@ class SettingsRobot {
), ),
), ),
) )
Log.i(TAG, "verifyDefaultBrowserToggle: Verified that the \"Set as default browser\" toggle is enabled: $isEnabled")
} }
fun clickDefaultBrowserSwitch() = toggleDefaultBrowserSwitch() fun clickDefaultBrowserSwitch() = toggleDefaultBrowserSwitch()
fun verifyAndroidDefaultAppsMenuAppears() { fun verifyAndroidDefaultAppsMenuAppears() {
Log.i(TAG, "verifyAndroidDefaultAppsMenuAppears: Trying to verify that default browser apps dialog appears")
intended(hasAction(DEFAULT_APPS_SETTINGS_ACTION)) intended(hasAction(DEFAULT_APPS_SETTINGS_ACTION))
Log.i(TAG, "verifyAndroidDefaultAppsMenuAppears: Verified that the default browser apps dialog appears")
} }
// PRIVACY SECTION // PRIVACY SECTION
fun verifyPrivacyHeading() { fun verifyPrivacyHeading() {
scrollToElementByText("Privacy and security") scrollToElementByText("Privacy and security")
Log.i(TAG, "verifyPrivacyHeading: Trying to verify that the \"Privacy and security\" heading is visible")
onView(withText("Privacy and security")) onView(withText("Privacy and security"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyPrivacyHeading: Verified that the \"Privacy and security\" heading is visible")
} }
fun verifyHTTPSOnlyModeButton() { fun verifyHTTPSOnlyModeButton() {
scrollToElementByText(getStringResource(R.string.preferences_https_only_title)) scrollToElementByText(getStringResource(R.string.preferences_https_only_title))
Log.i(TAG, "verifyHTTPSOnlyModeButton: Trying to verify that the \"HTTPS-Only Mode\" button is visible")
onView( onView(
withText(R.string.preferences_https_only_title), withText(R.string.preferences_https_only_title),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) ).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyHTTPSOnlyModeButton: Verified that the \"HTTPS-Only Mode\" button is visible")
} }
fun verifyCookieBannerBlockerButton(enabled: Boolean) { fun verifyCookieBannerBlockerButton(enabled: Boolean) {
scrollToElementByText(getStringResource(R.string.preferences_cookie_banner_reduction_private_mode)) scrollToElementByText(getStringResource(R.string.preferences_cookie_banner_reduction_private_mode))
Log.i(TAG, "verifyCookieBannerBlockerButton: Trying to verify that the \"Cookie Banner Blocker in private browsing\" toggle is enabled: $enabled")
onView(withText(R.string.preferences_cookie_banner_reduction_private_mode)) onView(withText(R.string.preferences_cookie_banner_reduction_private_mode))
.check( .check(
matches( matches(
@ -158,114 +185,167 @@ class SettingsRobot {
), ),
), ),
) )
Log.i(TAG, "verifyCookieBannerBlockerButton: Verified if cookie banner blocker toggle is enabled: $enabled") Log.i(TAG, "verifyCookieBannerBlockerButton: Verified that the \"Cookie Banner Blocker in private browsing\" toggle is enabled: $enabled")
} }
fun verifyEnhancedTrackingProtectionButton() { fun verifyEnhancedTrackingProtectionButton() {
Log.i(TAG, "verifyEnhancedTrackingProtectionButton: Waiting for $waitingTime ms until finding the \"Privacy and Security\" heading")
mDevice.wait(Until.findObject(By.text("Privacy and Security")), waitingTime) mDevice.wait(Until.findObject(By.text("Privacy and Security")), waitingTime)
Log.i(TAG, "verifyEnhancedTrackingProtectionButton: Waited for $waitingTime ms until the \"Privacy and Security\" heading was found")
Log.i(TAG, "verifyEnhancedTrackingProtectionButton: Trying to verify that the \"Enhanced Tracking Protection\" button is visible")
onView(withId(R.id.recycler_view)).perform( onView(withId(R.id.recycler_view)).perform(
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>( RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
hasDescendant(withText("Enhanced Tracking Protection")), hasDescendant(withText("Enhanced Tracking Protection")),
), ),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) ).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyEnhancedTrackingProtectionButton: Verified that the \"Enhanced Tracking Protection\" button is visible")
} }
fun verifyLoginsAndPasswordsButton() { fun verifyLoginsAndPasswordsButton() {
scrollToElementByText("Logins and passwords") scrollToElementByText("Logins and passwords")
Log.i(TAG, "verifyLoginsAndPasswordsButton: Trying to verify that the \"Logins and passwords\" button is visible")
onView(withText(R.string.preferences_passwords_logins_and_passwords)) onView(withText(R.string.preferences_passwords_logins_and_passwords))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyLoginsAndPasswordsButton: Verified that the \"Logins and passwords\" button is visible")
} }
fun verifyPrivateBrowsingButton() { fun verifyPrivateBrowsingButton() {
scrollToElementByText("Private browsing") scrollToElementByText("Private browsing")
Log.i(TAG, "verifyPrivateBrowsingButton: Waiting for $waitingTime ms until finding the \"Private browsing\" button")
mDevice.wait(Until.findObject(By.text("Private browsing")), waitingTime) mDevice.wait(Until.findObject(By.text("Private browsing")), waitingTime)
Log.i(TAG, "verifyPrivateBrowsingButton: Waited for $waitingTime ms until the \"Private browsing\" button was found")
Log.i(TAG, "verifyPrivateBrowsingButton: Trying to verify that the \"Private browsing\" button is visible")
onView(withText("Private browsing")) onView(withText("Private browsing"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyPrivateBrowsingButton: Verified that the \"Private browsing\" button is visible")
} }
fun verifySitePermissionsButton() { fun verifySitePermissionsButton() {
scrollToElementByText("Site permissions") scrollToElementByText("Site permissions")
Log.i(TAG, "verifySitePermissionsButton: Trying to verify that the \"Site permissions\" button is visible")
onView(withText("Site permissions")) onView(withText("Site permissions"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifySitePermissionsButton: Verified that the \"Site permissions\" button is visible")
} }
fun verifyDeleteBrowsingDataButton() { fun verifyDeleteBrowsingDataButton() {
scrollToElementByText("Delete browsing data") scrollToElementByText("Delete browsing data")
Log.i(TAG, "verifyDeleteBrowsingDataButton: Trying to verify that the \"Delete browsing data\" button is visible")
onView(withText("Delete browsing data")) onView(withText("Delete browsing data"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyDeleteBrowsingDataButton: Verified that the \"Delete browsing data\" button is visible")
} }
fun verifyDeleteBrowsingDataOnQuitButton() { fun verifyDeleteBrowsingDataOnQuitButton() {
scrollToElementByText("Delete browsing data on quit") scrollToElementByText("Delete browsing data on quit")
Log.i(TAG, "verifyDeleteBrowsingDataOnQuitButton: Trying to verify that the \"Delete browsing data on quit\" button is visible")
onView(withText("Delete browsing data on quit")) onView(withText("Delete browsing data on quit"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyDeleteBrowsingDataOnQuitButton: Verified that the \"Delete browsing data on quit\" button is visible")
} }
fun verifyNotificationsButton() { fun verifyNotificationsButton() {
scrollToElementByText("Notifications") scrollToElementByText("Notifications")
Log.i(TAG, "verifyNotificationsButton: Trying to verify that the \"Notifications\" button is visible")
onView(withText("Notifications")) onView(withText("Notifications"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyNotificationsButton: Verified that the \"Notifications\" button is visible")
} }
fun verifyDataCollectionButton() { fun verifyDataCollectionButton() {
scrollToElementByText("Data collection") scrollToElementByText("Data collection")
Log.i(TAG, "verifyDataCollectionButton: Trying to verify that the \"Data collection\" button is visible")
onView(withText("Data collection")) onView(withText("Data collection"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyDataCollectionButton: Verified that the \"Data collection\" button is visible")
} }
fun verifyOpenLinksInAppsButton() { fun verifyOpenLinksInAppsButton() {
scrollToElementByText("Open links in apps") scrollToElementByText("Open links in apps")
Log.i(TAG, "verifyOpenLinksInAppsButton: Trying to verify that the \"Open links in apps\" button is visible")
openLinksInAppsButton() openLinksInAppsButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "clickOpenLinksInAppsGoToSettingsCFRButton: Verified \"Open links in apps\" setting option") Log.i(TAG, "verifyOpenLinksInAppsButton: Verified that the \"Open links in apps\" button is visible")
} }
fun verifySettingsView() { fun verifySettingsView() {
scrollToElementByText("General") scrollToElementByText("General")
Log.i(TAG, "verifySettingsView: Trying to verify that the \"General\" heading is visible")
onView(withText("General")) onView(withText("General"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifySettingsView: Verified that the \"General\" heading is visible")
scrollToElementByText("Privacy and security") scrollToElementByText("Privacy and security")
Log.i(TAG, "verifySettingsView: Trying to verify that the \"Privacy and security\" heading is visible")
onView(withText("Privacy and security")) onView(withText("Privacy and security"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifySettingsView: Verified that the \"Privacy and security\" heading is visible")
Log.i(TAG, "verifySettingsView: Trying to perform scroll to the \"Add-ons\" button")
onView(withId(R.id.recycler_view)).perform( onView(withId(R.id.recycler_view)).perform(
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>( RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
hasDescendant(withText("Add-ons")), hasDescendant(withText("Add-ons")),
), ),
) )
Log.i(TAG, "verifySettingsView: Performed scroll to the \"Add-ons\" button")
Log.i(TAG, "verifySettingsView: Trying to verify that the \"Add-ons\" button is completely displayed")
onView(withText("Add-ons")) onView(withText("Add-ons"))
.check(matches(isCompletelyDisplayed())) .check(matches(isCompletelyDisplayed()))
Log.i(TAG, "verifySettingsView: Verified that the \"Add-ons\" button is completely displayed")
Log.i(TAG, "verifySettingsView: Trying to perform ${LISTS_MAXSWIPES}x a scroll action to the end of the settings list")
settingsList().scrollToEnd(LISTS_MAXSWIPES) settingsList().scrollToEnd(LISTS_MAXSWIPES)
Log.i(TAG, "verifySettingsView: Performed ${LISTS_MAXSWIPES}x a scroll action to the end of the settings list")
Log.i(TAG, "verifySettingsView: Trying to verify that the \"About\" heading is visible")
onView(withText("About")) onView(withText("About"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifySettingsView: Verified that the \"About\" heading is visible")
} }
fun verifySettingsToolbar() = fun verifySettingsToolbar() {
Log.i(TAG, "verifySettingsToolbar: Trying to verify that the navigate up button is visible")
onView( onView(
CoreMatchers.allOf( allOf(
withId(R.id.navigationToolbar),
hasDescendant(withContentDescription(R.string.action_bar_up_description)),
),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifySettingsToolbar: Verified that the navigate up button is visible")
Log.i(TAG, "verifySettingsToolbar: Trying to verify that the \"Settings\" toolbar title is visible")
onView(
allOf(
withId(R.id.navigationToolbar), withId(R.id.navigationToolbar),
hasDescendant(ViewMatchers.withContentDescription(R.string.action_bar_up_description)),
hasDescendant(withText(R.string.settings)), hasDescendant(withText(R.string.settings)),
), ),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) ).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifySettingsToolbar: Verified that the \"Settings\" toolbar title is visible")
}
// ADVANCED SECTION // ADVANCED SECTION
fun verifyAdvancedHeading() { fun verifyAdvancedHeading() {
Log.i(TAG, "verifyAdvancedHeading: Trying to perform scroll to the \"Add-ons\" button")
onView(withId(R.id.recycler_view)).perform( onView(withId(R.id.recycler_view)).perform(
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>( RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
hasDescendant(withText("Add-ons")), hasDescendant(withText("Add-ons")),
), ),
) )
Log.i(TAG, "verifyAdvancedHeading: Performed scroll to the \"Add-ons\" button")
Log.i(TAG, "verifyAdvancedHeading: Trying to verify that the \"Add-ons\" button is completely displayed")
onView(withText("Add-ons")) onView(withText("Add-ons"))
.check(matches(isCompletelyDisplayed())) .check(matches(isCompletelyDisplayed()))
Log.i(TAG, "verifyAdvancedHeading: Verified that the \"Add-ons\" button is completely displayed")
} }
fun verifyAddons() { fun verifyAddons() {
Log.i(TAG, "verifyAddons: Trying to perform scroll to the \"Add-ons\" button")
onView(withId(R.id.recycler_view)).perform( onView(withId(R.id.recycler_view)).perform(
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>( RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
hasDescendant(withText("Add-ons")), hasDescendant(withText("Add-ons")),
), ),
) )
Log.i(TAG, "verifyAddons: Performed scroll to the \"Add-ons\" button")
Log.i(TAG, "verifyAddons: Trying to verify that the \"Add-ons\" button is completely displayed")
addonsManagerButton() addonsManagerButton()
.check(matches(isCompletelyDisplayed())) .check(matches(isCompletelyDisplayed()))
Log.i(TAG, "verifyAddons: Verified that the \"Add-ons\" button is completely displayed")
} }
fun verifyExternalDownloadManagerButton() = fun verifyExternalDownloadManagerButton() {
Log.i(TAG, "verifyExternalDownloadManagerButton: Trying to verify that the \"External download manager\" button is visible")
onView( onView(
withText(R.string.preferences_external_download_manager), withText(R.string.preferences_external_download_manager),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) ).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyExternalDownloadManagerButton: Verified that the \"External download manager\" button is visible")
}
fun verifyExternalDownloadManagerToggle(enabled: Boolean) = fun verifyExternalDownloadManagerToggle(enabled: Boolean) {
Log.i(TAG, "verifyExternalDownloadManagerToggle: Trying to verify that the \"External download manager\" toggle is enabled: $enabled")
onView(withText(R.string.preferences_external_download_manager)) onView(withText(R.string.preferences_external_download_manager))
.check( .check(
matches( matches(
@ -281,8 +361,11 @@ class SettingsRobot {
), ),
), ),
) )
Log.i(TAG, "verifyExternalDownloadManagerToggle: Verified that the \"External download manager\" toggle is enabled: $enabled")
}
fun verifyLeakCanaryToggle(enabled: Boolean) = fun verifyLeakCanaryToggle(enabled: Boolean) {
Log.i(TAG, "verifyLeakCanaryToggle: Trying to verify that the \"LeakCanary\" toggle is enabled: $enabled")
onView(withText(R.string.preference_leakcanary)) onView(withText(R.string.preference_leakcanary))
.check( .check(
matches( matches(
@ -298,8 +381,11 @@ class SettingsRobot {
), ),
), ),
) )
Log.i(TAG, "verifyLeakCanaryToggle: Verified that the \"LeakCanary\" toggle is enabled: $enabled")
}
fun verifyRemoteDebuggingToggle(enabled: Boolean) = fun verifyRemoteDebuggingToggle(enabled: Boolean) {
Log.i(TAG, "verifyRemoteDebuggingToggle: Trying to verify that the \"Remote debugging via USB\" toggle is enabled: $enabled")
onView(withText(R.string.preferences_remote_debugging)) onView(withText(R.string.preferences_remote_debugging))
.check( .check(
matches( matches(
@ -315,38 +401,52 @@ class SettingsRobot {
), ),
), ),
) )
Log.i(TAG, "verifyRemoteDebuggingToggle: Verified that the \"Remote debugging via USB\" toggle is enabled: $enabled")
}
// DEVELOPER TOOLS SECTION // DEVELOPER TOOLS SECTION
fun verifyRemoteDebuggingButton() { fun verifyRemoteDebuggingButton() {
scrollToElementByText("Remote debugging via USB") scrollToElementByText("Remote debugging via USB")
Log.i(TAG, "verifyRemoteDebuggingButton: Trying to verify that the \"Remote debugging via USB\" button is visible")
onView(withText("Remote debugging via USB")) onView(withText("Remote debugging via USB"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyRemoteDebuggingButton: Verified that the \"Remote debugging via USB\" button is visible")
} }
fun verifyLeakCanaryButton() { fun verifyLeakCanaryButton() {
scrollToElementByText("LeakCanary") scrollToElementByText("LeakCanary")
Log.i(TAG, "verifyLeakCanaryButton: Trying to verify that the \"LeakCanary\" button is visible")
onView(withText("LeakCanary")) onView(withText("LeakCanary"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyLeakCanaryButton: Verified that the \"LeakCanary\" button is visible")
} }
// ABOUT SECTION // ABOUT SECTION
fun verifyAboutHeading() { fun verifyAboutHeading() {
Log.i(TAG, "verifyAboutHeading: Trying to perform ${LISTS_MAXSWIPES}x a scroll action to the end of the settings list")
settingsList().scrollToEnd(LISTS_MAXSWIPES) settingsList().scrollToEnd(LISTS_MAXSWIPES)
Log.i(TAG, "verifyAboutHeading: Performed ${LISTS_MAXSWIPES}x a scroll action to the end of the settings list")
Log.i(TAG, "verifyAboutHeading: Trying to verify that the \"About\" heading is visible")
onView(withText("About")) onView(withText("About"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyAboutHeading: Verified that the \"About\" heading is visible")
} }
fun verifyRateOnGooglePlay() = assertUIObjectExists(rateOnGooglePlayHeading()) fun verifyRateOnGooglePlay() = assertUIObjectExists(rateOnGooglePlayHeading())
fun verifyAboutFirefoxPreview() = assertUIObjectExists(aboutFirefoxHeading()) fun verifyAboutFirefoxPreview() = assertUIObjectExists(aboutFirefoxHeading())
fun verifyGooglePlayRedirect() { fun verifyGooglePlayRedirect() {
if (isPackageInstalled(GOOGLE_PLAY_SERVICES)) { if (isPackageInstalled(GOOGLE_PLAY_SERVICES)) {
Log.i(TAG, "verifyGooglePlayRedirect: $GOOGLE_PLAY_SERVICES is installed")
try { try {
Log.i(TAG, "verifyGooglePlayRedirect: Trying to verify intent to: $GOOGLE_PLAY_SERVICES")
intended( intended(
allOf( allOf(
hasAction(Intent.ACTION_VIEW), hasAction(Intent.ACTION_VIEW),
hasData(Uri.parse(SupportUtils.RATE_APP_URL)), hasData(Uri.parse(SupportUtils.RATE_APP_URL)),
), ),
) )
Log.i(TAG, "verifyGooglePlayRedirect: Verified intent to: $GOOGLE_PLAY_SERVICES")
} catch (e: AssertionFailedError) { } catch (e: AssertionFailedError) {
Log.i(TAG, "verifyGooglePlayRedirect: AssertionFailedError caught, executing fallback methods")
BrowserRobot().verifyRateOnGooglePlayURL() BrowserRobot().verifyRateOnGooglePlayURL()
} }
} else { } else {
@ -356,39 +456,51 @@ class SettingsRobot {
fun verifySettingsOptionSummary(setting: String, summary: String) { fun verifySettingsOptionSummary(setting: String, summary: String) {
scrollToElementByText(setting) scrollToElementByText(setting)
Log.i(TAG, "verifySettingsOptionSummary: Trying to verify that setting: $setting with summary:$summary is visible")
onView( onView(
allOf( allOf(
withText(setting), withText(setting),
hasSibling(withText(summary)), hasSibling(withText(summary)),
), ),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) ).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifySettingsOptionSummary: Verified that setting: $setting with summary:$summary is visible")
} }
class Transition { class Transition {
fun goBack(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { fun goBack(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
Log.i(TAG, "goBack: Trying to click the navigate up button")
goBackButton().click() goBackButton().click()
Log.i(TAG, "goBack: Clicked the navigate up button")
HomeScreenRobot().interact() HomeScreenRobot().interact()
return HomeScreenRobot.Transition() return HomeScreenRobot.Transition()
} }
fun goBackToOnboardingScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { fun goBackToOnboardingScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
Log.i(TAG, "goBackToOnboardingScreen: Trying to click device back button")
mDevice.pressBack() mDevice.pressBack()
Log.i(TAG, "goBackToOnboardingScreen: Clicked device back button")
Log.i(TAG, "goBackToOnboardingScreen: Waiting for device to be idle for $waitingTimeShort ms")
mDevice.waitForIdle(waitingTimeShort) mDevice.waitForIdle(waitingTimeShort)
Log.i(TAG, "goBackToOnboardingScreen: Device was idle for $waitingTimeShort ms")
HomeScreenRobot().interact() HomeScreenRobot().interact()
return HomeScreenRobot.Transition() return HomeScreenRobot.Transition()
} }
fun goBackToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun goBackToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
Log.i(TAG, "goBackToBrowser: Trying to click the navigate up button")
goBackButton().click() goBackButton().click()
Log.i(TAG, "goBackToBrowser: Clicked the navigate up button")
BrowserRobot().interact() BrowserRobot().interact()
return BrowserRobot.Transition() return BrowserRobot.Transition()
} }
fun openAboutFirefoxPreview(interact: SettingsSubMenuAboutRobot.() -> Unit): SettingsSubMenuAboutRobot.Transition { fun openAboutFirefoxPreview(interact: SettingsSubMenuAboutRobot.() -> Unit): SettingsSubMenuAboutRobot.Transition {
Log.i(TAG, "openAboutFirefoxPreview: Trying to click the \"About Firefox\" button")
aboutFirefoxHeading().click() aboutFirefoxHeading().click()
Log.i(TAG, "openAboutFirefoxPreview: Clicked the \"About Firefox\" button")
SettingsSubMenuAboutRobot().interact() SettingsSubMenuAboutRobot().interact()
return SettingsSubMenuAboutRobot.Transition() return SettingsSubMenuAboutRobot.Transition()
} }
@ -396,8 +508,12 @@ class SettingsRobot {
fun openSearchSubMenu(interact: SettingsSubMenuSearchRobot.() -> Unit): SettingsSubMenuSearchRobot.Transition { fun openSearchSubMenu(interact: SettingsSubMenuSearchRobot.() -> Unit): SettingsSubMenuSearchRobot.Transition {
itemWithText(getStringResource(R.string.preferences_search)) itemWithText(getStringResource(R.string.preferences_search))
.also { .also {
Log.i(TAG, "openSearchSubMenu: Waiting for $waitingTimeShort ms for the \"Search\" button to exist")
it.waitForExists(waitingTimeShort) it.waitForExists(waitingTimeShort)
Log.i(TAG, "openSearchSubMenu: Waited for $waitingTimeShort ms for the \"Search\" button to exist")
Log.i(TAG, "openSearchSubMenu: Trying to click the \"Search\" button")
it.click() it.click()
Log.i(TAG, "openSearchSubMenu: Clicked the \"Search\" button")
} }
SettingsSubMenuSearchRobot().interact() SettingsSubMenuSearchRobot().interact()
@ -405,8 +521,9 @@ class SettingsRobot {
} }
fun openCustomizeSubMenu(interact: SettingsSubMenuCustomizeRobot.() -> Unit): SettingsSubMenuCustomizeRobot.Transition { fun openCustomizeSubMenu(interact: SettingsSubMenuCustomizeRobot.() -> Unit): SettingsSubMenuCustomizeRobot.Transition {
fun customizeButton() = onView(withText("Customize")) Log.i(TAG, "openCustomizeSubMenu: Trying to click the \"Customize\" button")
customizeButton().click() onView(withText("Customize")).click()
Log.i(TAG, "openCustomizeSubMenu: Clicked the \"Customize\" button")
SettingsSubMenuCustomizeRobot().interact() SettingsSubMenuCustomizeRobot().interact()
return SettingsSubMenuCustomizeRobot.Transition() return SettingsSubMenuCustomizeRobot.Transition()
@ -415,8 +532,12 @@ class SettingsRobot {
fun openTabsSubMenu(interact: SettingsSubMenuTabsRobot.() -> Unit): SettingsSubMenuTabsRobot.Transition { fun openTabsSubMenu(interact: SettingsSubMenuTabsRobot.() -> Unit): SettingsSubMenuTabsRobot.Transition {
itemWithText(getStringResource(R.string.preferences_tabs)) itemWithText(getStringResource(R.string.preferences_tabs))
.also { .also {
Log.i(TAG, "openTabsSubMenu: Waiting for $waitingTime ms for the \"Tabs\" button to exist")
it.waitForExists(waitingTime) it.waitForExists(waitingTime)
Log.i(TAG, "openTabsSubMenu: Waited for $waitingTime ms for the \"Tabs\" button to exist")
Log.i(TAG, "openTabsSubMenu: Trying to click the \"Tabs\" button and wait for $waitingTimeShort ms for a new window")
it.clickAndWaitForNewWindow(waitingTimeShort) it.clickAndWaitForNewWindow(waitingTimeShort)
Log.i(TAG, "openTabsSubMenu: Clicked the \"Tabs\" button and wait for $waitingTimeShort ms for a new window")
} }
SettingsSubMenuTabsRobot().interact() SettingsSubMenuTabsRobot().interact()
@ -424,8 +545,12 @@ class SettingsRobot {
} }
fun openHomepageSubMenu(interact: SettingsSubMenuHomepageRobot.() -> Unit): SettingsSubMenuHomepageRobot.Transition { fun openHomepageSubMenu(interact: SettingsSubMenuHomepageRobot.() -> Unit): SettingsSubMenuHomepageRobot.Transition {
Log.i(TAG, "openHomepageSubMenu: Waiting for $waitingTime ms for the \"Homepage\" button to exist")
mDevice.findObject(UiSelector().textContains("Homepage")).waitForExists(waitingTime) mDevice.findObject(UiSelector().textContains("Homepage")).waitForExists(waitingTime)
Log.i(TAG, "openHomepageSubMenu: Waited for $waitingTime ms for the \"Homepage\" button to exist")
Log.i(TAG, "openHomepageSubMenu: Trying to click the \"Homepage\" button")
onView(withText(R.string.preferences_home_2)).click() onView(withText(R.string.preferences_home_2)).click()
Log.i(TAG, "openHomepageSubMenu: Clicked the \"Homepage\" button")
SettingsSubMenuHomepageRobot().interact() SettingsSubMenuHomepageRobot().interact()
return SettingsSubMenuHomepageRobot.Transition() return SettingsSubMenuHomepageRobot.Transition()
@ -434,10 +559,12 @@ class SettingsRobot {
fun openAutofillSubMenu(interact: SettingsSubMenuAutofillRobot.() -> Unit): SettingsSubMenuAutofillRobot.Transition { fun openAutofillSubMenu(interact: SettingsSubMenuAutofillRobot.() -> Unit): SettingsSubMenuAutofillRobot.Transition {
mDevice.findObject(UiSelector().textContains(getStringResource(R.string.preferences_autofill))) mDevice.findObject(UiSelector().textContains(getStringResource(R.string.preferences_autofill)))
.also { .also {
Log.i(TAG, "openAutofillSubMenu: Looking for \"Autofill\" settings button") Log.i(TAG, "openAutofillSubMenu: Waiting for $waitingTime ms for the \"Autofill\" button to exist")
it.waitForExists(waitingTime) it.waitForExists(waitingTime)
Log.i(TAG, "openAutofillSubMenu: Waited for $waitingTime ms for the \"Autofill\" button to exist")
Log.i(TAG, "openAutofillSubMenu: Trying to click the \"Autofill\" button")
it.click() it.click()
Log.i(TAG, "openAutofillSubMenu: Clicked \"Autofill\" settings button") Log.i(TAG, "openAutofillSubMenu: Clicked the \"Autofill\" button")
} }
SettingsSubMenuAutofillRobot().interact() SettingsSubMenuAutofillRobot().interact()
@ -446,11 +573,12 @@ class SettingsRobot {
fun openAccessibilitySubMenu(interact: SettingsSubMenuAccessibilityRobot.() -> Unit): SettingsSubMenuAccessibilityRobot.Transition { fun openAccessibilitySubMenu(interact: SettingsSubMenuAccessibilityRobot.() -> Unit): SettingsSubMenuAccessibilityRobot.Transition {
scrollToElementByText("Accessibility") scrollToElementByText("Accessibility")
Log.i(TAG, "openAccessibilitySubMenu: Trying to verify that the \"Accessibility\" button is displayed")
fun accessibilityButton() = onView(withText("Accessibility")) onView(withText("Accessibility")).check(matches(isDisplayed()))
accessibilityButton() Log.i(TAG, "openAccessibilitySubMenu: Verified that the \"Accessibility\" button is displayed")
.check(matches(isDisplayed())) Log.i(TAG, "openAccessibilitySubMenu: Trying to click the \"Accessibility\" button")
.click() onView(withText("Accessibility")).click()
Log.i(TAG, "openAccessibilitySubMenu: Clicked the \"Accessibility\" button")
SettingsSubMenuAccessibilityRobot().interact() SettingsSubMenuAccessibilityRobot().interact()
return SettingsSubMenuAccessibilityRobot.Transition() return SettingsSubMenuAccessibilityRobot.Transition()
@ -460,6 +588,7 @@ class SettingsRobot {
localizedText: String = getStringResource(R.string.preferences_language), localizedText: String = getStringResource(R.string.preferences_language),
interact: SettingsSubMenuLanguageRobot.() -> Unit, interact: SettingsSubMenuLanguageRobot.() -> Unit,
): SettingsSubMenuLanguageRobot.Transition { ): SettingsSubMenuLanguageRobot.Transition {
Log.i(TAG, "openLanguageSubMenu: Trying to click the $localizedText button")
onView(withId(R.id.recycler_view)) onView(withId(R.id.recycler_view))
.perform( .perform(
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>( RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
@ -469,6 +598,7 @@ class SettingsRobot {
ViewActions.click(), ViewActions.click(),
), ),
) )
Log.i(TAG, "openLanguageSubMenu: Clicked the $localizedText button")
SettingsSubMenuLanguageRobot().interact() SettingsSubMenuLanguageRobot().interact()
return SettingsSubMenuLanguageRobot.Transition() return SettingsSubMenuLanguageRobot.Transition()
@ -476,8 +606,9 @@ class SettingsRobot {
fun openSetDefaultBrowserSubMenu(interact: SettingsSubMenuSetDefaultBrowserRobot.() -> Unit): SettingsSubMenuSetDefaultBrowserRobot.Transition { fun openSetDefaultBrowserSubMenu(interact: SettingsSubMenuSetDefaultBrowserRobot.() -> Unit): SettingsSubMenuSetDefaultBrowserRobot.Transition {
scrollToElementByText("Set as default browser") scrollToElementByText("Set as default browser")
fun setDefaultBrowserButton() = onView(withText("Set as default browser")) Log.i(TAG, "openSetDefaultBrowserSubMenu: Trying to click the \"Set as default browser\" button")
setDefaultBrowserButton().click() onView(withText("Set as default browser")).click()
Log.i(TAG, "openSetDefaultBrowserSubMenu: Clicked the \"Set as default browser\" button")
SettingsSubMenuSetDefaultBrowserRobot().interact() SettingsSubMenuSetDefaultBrowserRobot().interact()
return SettingsSubMenuSetDefaultBrowserRobot.Transition() return SettingsSubMenuSetDefaultBrowserRobot.Transition()
@ -485,9 +616,9 @@ class SettingsRobot {
fun openEnhancedTrackingProtectionSubMenu(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionRobot.Transition { fun openEnhancedTrackingProtectionSubMenu(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionRobot.Transition {
scrollToElementByText("Enhanced Tracking Protection") scrollToElementByText("Enhanced Tracking Protection")
fun enhancedTrackingProtectionButton() = Log.i(TAG, "openEnhancedTrackingProtectionSubMenu: Trying to click the \"Enhanced Tracking Protection\" button")
onView(withText("Enhanced Tracking Protection")) onView(withText("Enhanced Tracking Protection")).click()
enhancedTrackingProtectionButton().click() Log.i(TAG, "openEnhancedTrackingProtectionSubMenu: Clicked the \"Enhanced Tracking Protection\" button")
SettingsSubMenuEnhancedTrackingProtectionRobot().interact() SettingsSubMenuEnhancedTrackingProtectionRobot().interact()
return SettingsSubMenuEnhancedTrackingProtectionRobot.Transition() return SettingsSubMenuEnhancedTrackingProtectionRobot.Transition()
@ -495,16 +626,18 @@ class SettingsRobot {
fun openLoginsAndPasswordSubMenu(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition { fun openLoginsAndPasswordSubMenu(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition {
scrollToElementByText("Logins and passwords") scrollToElementByText("Logins and passwords")
fun loginsAndPasswordsButton() = onView(withText("Logins and passwords")) Log.i(TAG, "openLoginsAndPasswordSubMenu: Trying to click the \"Logins and passwords\" button")
loginsAndPasswordsButton().click() onView(withText("Logins and passwords")).click()
Log.i(TAG, "openLoginsAndPasswordSubMenu: Clicked the \"Logins and passwords\" button")
SettingsSubMenuLoginsAndPasswordRobot().interact() SettingsSubMenuLoginsAndPasswordRobot().interact()
return SettingsSubMenuLoginsAndPasswordRobot.Transition() return SettingsSubMenuLoginsAndPasswordRobot.Transition()
} }
fun openTurnOnSyncMenu(interact: SettingsTurnOnSyncRobot.() -> Unit): SettingsTurnOnSyncRobot.Transition { fun openTurnOnSyncMenu(interact: SettingsTurnOnSyncRobot.() -> Unit): SettingsTurnOnSyncRobot.Transition {
fun turnOnSyncButton() = onView(withText("Sync and save your data")) Log.i(TAG, "openTurnOnSyncMenu: Trying to click the \"Sync and save your data\" button")
turnOnSyncButton().click() onView(withText("Sync and save your data")).click()
Log.i(TAG, "openTurnOnSyncMenu: Clicked the \"Sync and save your data\" button")
SettingsTurnOnSyncRobot().interact() SettingsTurnOnSyncRobot().interact()
return SettingsTurnOnSyncRobot.Transition() return SettingsTurnOnSyncRobot.Transition()
@ -512,8 +645,9 @@ class SettingsRobot {
fun openPrivateBrowsingSubMenu(interact: SettingsSubMenuPrivateBrowsingRobot.() -> Unit): SettingsSubMenuPrivateBrowsingRobot.Transition { fun openPrivateBrowsingSubMenu(interact: SettingsSubMenuPrivateBrowsingRobot.() -> Unit): SettingsSubMenuPrivateBrowsingRobot.Transition {
scrollToElementByText("Private browsing") scrollToElementByText("Private browsing")
fun privateBrowsingButton() = mDevice.findObject(textContains("Private browsing")) Log.i(TAG, "openPrivateBrowsingSubMenu: Trying to click the \"Private browsing\" button")
privateBrowsingButton().click() mDevice.findObject(textContains("Private browsing")).click()
Log.i(TAG, "openPrivateBrowsingSubMenu: Clicked the \"Private browsing\" button")
SettingsSubMenuPrivateBrowsingRobot().interact() SettingsSubMenuPrivateBrowsingRobot().interact()
return SettingsSubMenuPrivateBrowsingRobot.Transition() return SettingsSubMenuPrivateBrowsingRobot.Transition()
@ -521,8 +655,9 @@ class SettingsRobot {
fun openSettingsSubMenuSitePermissions(interact: SettingsSubMenuSitePermissionsRobot.() -> Unit): SettingsSubMenuSitePermissionsRobot.Transition { fun openSettingsSubMenuSitePermissions(interact: SettingsSubMenuSitePermissionsRobot.() -> Unit): SettingsSubMenuSitePermissionsRobot.Transition {
scrollToElementByText("Site permissions") scrollToElementByText("Site permissions")
fun sitePermissionButton() = mDevice.findObject(textContains("Site permissions")) Log.i(TAG, "openSettingsSubMenuSitePermissions: Trying to click the \"Site permissions\" button")
sitePermissionButton().click() mDevice.findObject(textContains("Site permissions")).click()
Log.i(TAG, "openSettingsSubMenuSitePermissions: Clicked the \"Site permissions\" button")
SettingsSubMenuSitePermissionsRobot().interact() SettingsSubMenuSitePermissionsRobot().interact()
return SettingsSubMenuSitePermissionsRobot.Transition() return SettingsSubMenuSitePermissionsRobot.Transition()
@ -530,8 +665,9 @@ class SettingsRobot {
fun openSettingsSubMenuDeleteBrowsingData(interact: SettingsSubMenuDeleteBrowsingDataRobot.() -> Unit): SettingsSubMenuDeleteBrowsingDataRobot.Transition { fun openSettingsSubMenuDeleteBrowsingData(interact: SettingsSubMenuDeleteBrowsingDataRobot.() -> Unit): SettingsSubMenuDeleteBrowsingDataRobot.Transition {
scrollToElementByText("Delete browsing data") scrollToElementByText("Delete browsing data")
fun deleteBrowsingDataButton() = mDevice.findObject(textContains("Delete browsing data")) Log.i(TAG, "openSettingsSubMenuDeleteBrowsingData: Trying to click the \"Delete browsing data\" button")
deleteBrowsingDataButton().click() mDevice.findObject(textContains("Delete browsing data")).click()
Log.i(TAG, "openSettingsSubMenuDeleteBrowsingData: Clicked the \"Delete browsing data\" button")
SettingsSubMenuDeleteBrowsingDataRobot().interact() SettingsSubMenuDeleteBrowsingDataRobot().interact()
return SettingsSubMenuDeleteBrowsingDataRobot.Transition() return SettingsSubMenuDeleteBrowsingDataRobot.Transition()
@ -539,8 +675,9 @@ class SettingsRobot {
fun openSettingsSubMenuDeleteBrowsingDataOnQuit(interact: SettingsSubMenuDeleteBrowsingDataOnQuitRobot.() -> Unit): SettingsSubMenuDeleteBrowsingDataOnQuitRobot.Transition { fun openSettingsSubMenuDeleteBrowsingDataOnQuit(interact: SettingsSubMenuDeleteBrowsingDataOnQuitRobot.() -> Unit): SettingsSubMenuDeleteBrowsingDataOnQuitRobot.Transition {
scrollToElementByText("Delete browsing data on quit") scrollToElementByText("Delete browsing data on quit")
fun deleteBrowsingDataOnQuitButton() = mDevice.findObject(textContains("Delete browsing data on quit")) Log.i(TAG, "openSettingsSubMenuDeleteBrowsingDataOnQuit: Trying to click the \"Delete browsing data on quit\" button")
deleteBrowsingDataOnQuitButton().click() mDevice.findObject(textContains("Delete browsing data on quit")).click()
Log.i(TAG, "openSettingsSubMenuDeleteBrowsingDataOnQuit: Clicked the \"Delete browsing data on quit\" button")
SettingsSubMenuDeleteBrowsingDataOnQuitRobot().interact() SettingsSubMenuDeleteBrowsingDataOnQuitRobot().interact()
return SettingsSubMenuDeleteBrowsingDataOnQuitRobot.Transition() return SettingsSubMenuDeleteBrowsingDataOnQuitRobot.Transition()
@ -548,8 +685,9 @@ class SettingsRobot {
fun openSettingsSubMenuNotifications(interact: SystemSettingsRobot.() -> Unit): SystemSettingsRobot.Transition { fun openSettingsSubMenuNotifications(interact: SystemSettingsRobot.() -> Unit): SystemSettingsRobot.Transition {
scrollToElementByText("Notifications") scrollToElementByText("Notifications")
fun notificationsButton() = mDevice.findObject(textContains("Notifications")) Log.i(TAG, "openSettingsSubMenuNotifications: Trying to click the \"Notifications\" button")
notificationsButton().click() mDevice.findObject(textContains("Notifications")).click()
Log.i(TAG, "openSettingsSubMenuNotifications: Clicked the \"Notifications\" button")
SystemSettingsRobot().interact() SystemSettingsRobot().interact()
return SystemSettingsRobot.Transition() return SystemSettingsRobot.Transition()
@ -557,22 +695,27 @@ class SettingsRobot {
fun openSettingsSubMenuDataCollection(interact: SettingsSubMenuDataCollectionRobot.() -> Unit): SettingsSubMenuDataCollectionRobot.Transition { fun openSettingsSubMenuDataCollection(interact: SettingsSubMenuDataCollectionRobot.() -> Unit): SettingsSubMenuDataCollectionRobot.Transition {
scrollToElementByText("Data collection") scrollToElementByText("Data collection")
fun dataCollectionButton() = mDevice.findObject(textContains("Data collection")) Log.i(TAG, "openSettingsSubMenuDataCollection: Trying to click the \"Data collection\" button")
dataCollectionButton().click() mDevice.findObject(textContains("Data collection")).click()
Log.i(TAG, "openSettingsSubMenuDataCollection: Clicked the \"Data collection\" button")
SettingsSubMenuDataCollectionRobot().interact() SettingsSubMenuDataCollectionRobot().interact()
return SettingsSubMenuDataCollectionRobot.Transition() return SettingsSubMenuDataCollectionRobot.Transition()
} }
fun openAddonsManagerMenu(interact: SettingsSubMenuAddonsManagerRobot.() -> Unit): SettingsSubMenuAddonsManagerRobot.Transition { fun openAddonsManagerMenu(interact: SettingsSubMenuAddonsManagerRobot.() -> Unit): SettingsSubMenuAddonsManagerRobot.Transition {
Log.i(TAG, "openAddonsManagerMenu: Trying to click the \"Add-ons\" button")
addonsManagerButton().click() addonsManagerButton().click()
Log.i(TAG, "openAddonsManagerMenu: Clicked the \"Add-ons\" button")
SettingsSubMenuAddonsManagerRobot().interact() SettingsSubMenuAddonsManagerRobot().interact()
return SettingsSubMenuAddonsManagerRobot.Transition() return SettingsSubMenuAddonsManagerRobot.Transition()
} }
fun openOpenLinksInAppsMenu(interact: SettingsSubMenuOpenLinksInAppsRobot.() -> Unit): SettingsSubMenuOpenLinksInAppsRobot.Transition { fun openOpenLinksInAppsMenu(interact: SettingsSubMenuOpenLinksInAppsRobot.() -> Unit): SettingsSubMenuOpenLinksInAppsRobot.Transition {
Log.i(TAG, "openOpenLinksInAppsMenu: Trying to click the \"Open links in apps\" button")
openLinksInAppsButton().click() openLinksInAppsButton().click()
Log.i(TAG, "openOpenLinksInAppsMenu: Clicked the \"Open links in apps\" button")
SettingsSubMenuOpenLinksInAppsRobot().interact() SettingsSubMenuOpenLinksInAppsRobot().interact()
return SettingsSubMenuOpenLinksInAppsRobot.Transition() return SettingsSubMenuOpenLinksInAppsRobot.Transition()
@ -580,7 +723,9 @@ class SettingsRobot {
fun openHttpsOnlyModeMenu(interact: SettingsSubMenuHttpsOnlyModeRobot.() -> Unit): SettingsSubMenuHttpsOnlyModeRobot.Transition { fun openHttpsOnlyModeMenu(interact: SettingsSubMenuHttpsOnlyModeRobot.() -> Unit): SettingsSubMenuHttpsOnlyModeRobot.Transition {
scrollToElementByText("HTTPS-Only Mode") scrollToElementByText("HTTPS-Only Mode")
Log.i(TAG, "openHttpsOnlyModeMenu: Trying to click the \"HTTPS-Only Mode\" button")
onView(withText(getStringResource(R.string.preferences_https_only_title))).click() onView(withText(getStringResource(R.string.preferences_https_only_title))).click()
Log.i(TAG, "openHttpsOnlyModeMenu: Clicked the \"HTTPS-Only Mode\" button")
mDevice.waitNotNull( mDevice.waitNotNull(
Until.findObjects(By.res("$packageName:id/https_only_switch")), Until.findObjects(By.res("$packageName:id/https_only_switch")),
waitingTime, waitingTime,
@ -611,7 +756,9 @@ fun settingsScreen(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition
private fun toggleDefaultBrowserSwitch() { private fun toggleDefaultBrowserSwitch() {
scrollToElementByText("Privacy and security") scrollToElementByText("Privacy and security")
Log.i(TAG, "toggleDefaultBrowserSwitch: Trying to click the \"Set as default browser\" button")
onView(withText("Set as default browser")).perform(ViewActions.click()) onView(withText("Set as default browser")).perform(ViewActions.click())
Log.i(TAG, "toggleDefaultBrowserSwitch: Clicked the \"Set as default browser\" button")
} }
private fun openLinksInAppsButton() = onView(withText(R.string.preferences_open_links_in_apps)) private fun openLinksInAppsButton() = onView(withText(R.string.preferences_open_links_in_apps))
@ -649,7 +796,7 @@ fun clickRateButtonGooglePlay() {
private fun addonsManagerButton() = onView(withText(R.string.preferences_addons)) private fun addonsManagerButton() = onView(withText(R.string.preferences_addons))
private fun goBackButton() = private fun goBackButton() =
onView(CoreMatchers.allOf(ViewMatchers.withContentDescription("Navigate up"))) onView(CoreMatchers.allOf(withContentDescription("Navigate up")))
private fun settingsList() = private fun settingsList() =
UiScrollable(UiSelector().resourceId("$packageName:id/recycler_view")) UiScrollable(UiSelector().resourceId("$packageName:id/recycler_view"))

Loading…
Cancel
Save