From d02db131f04c5ab70eaeeb58dd1f31198e25cb60 Mon Sep 17 00:00:00 2001 From: Mugurell Date: Mon, 24 May 2021 19:49:11 +0300 Subject: [PATCH] For #19620 - Have MenuScreenShotTest screenshot DefaultBrowser setting again As a regression from #19590 which added a new setting above the existing "Set as default browser" setting the settingsTest() needed to be updated to allow clicking and screenshot of what happens after clicking on the "Set as default browser" setting which can now be pushed offscreen. --- .../fenix/screenshots/MenuScreenShotTest.kt | 53 ++++++++----------- .../mozilla/fenix/ui/robots/SettingsRobot.kt | 18 +++++++ .../ui/robots/SettingsSubMenuLanguageRobot.kt | 29 ++++++++++ .../SettingsSubMenuSetDefaultBrowserRobot.kt | 25 +++++++++ .../ui/robots/SettingsTurnOnSyncRobot.kt | 4 +- 5 files changed, 96 insertions(+), 33 deletions(-) create mode 100644 app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuLanguageRobot.kt create mode 100644 app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuSetDefaultBrowserRobot.kt diff --git a/app/src/androidTest/java/org/mozilla/fenix/screenshots/MenuScreenShotTest.kt b/app/src/androidTest/java/org/mozilla/fenix/screenshots/MenuScreenShotTest.kt index d058bc8c7e..ab2465a79e 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/screenshots/MenuScreenShotTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/screenshots/MenuScreenShotTest.kt @@ -68,47 +68,38 @@ class MenuScreenShotTest : ScreenshotTest() { }.openThreeDotMenu { }.openSettings { Screengrab.screenshot("SettingsRobot_settings-menu") - settingsAccountPreferences() + }.openTurnOnSyncMenu { Screengrab.screenshot("AccountSettingsRobot_settings-account") - mDevice.pressBack() - - settingsSearch() + }.goBack { + }.openSearchSubMenu { Screengrab.screenshot("SettingsSubMenuSearchRobot_settings-search") - mDevice.pressBack() - - settingsTheme() + }.goBack { + }.openCustomizeSubMenu { Screengrab.screenshot("SettingsSubMenuThemeRobot_settings-theme") - mDevice.pressBack() - - settingsAccessibility() + }.goBack { + }.openAccessibilitySubMenu { Screengrab.screenshot("SettingsSubMenuAccessibilityRobot_settings-accessibility") - mDevice.pressBack() - - settingsLanguage() + }.goBack { + }.openLanguageSubMenu { Screengrab.screenshot("SettingsSubMenuAccessibilityRobot_settings-language") - mDevice.pressBack() - - settingDefaultBrowser() + }.goBack { + // From about here we need to scroll up to ensure all settings options are visible. + }.openSetDefaultBrowserSubMenu { Screengrab.screenshot("SettingsSubMenuDefaultBrowserRobot_settings-default-browser") - mDevice.pressBack() - - // Disabled for Pixel 2 - // settingsTP() - // Screengrab.screenshot("settings-enhanced-tp") - // mDevice.pressBack() - - loginsAndPassword() + }.goBack { + // Disabled for Pixel 2 + // }.openEnhancedTrackingProtectionSubMenu { + // Screengrab.screenshot("settings-enhanced-tp") + // }.goBack { + }.openLoginsAndPasswordSubMenu { Screengrab.screenshot("SettingsSubMenuLoginsAndPasswords-settings-logins-passwords") - mDevice.pressBack() - + }.goBack { swipeToBottom() Screengrab.screenshot("SettingsRobot_settings-scroll-to-bottom") - - settingsTelemetry() + }.openSettingsSubMenuDataCollection { Screengrab.screenshot("settings-telemetry") - mDevice.pressBack() - - addOns() + }.goBack { + }.openAddonsManagerMenu { Screengrab.screenshot("settings-addons") } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt index d585e75d7e..c0d8f33bf8 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt @@ -155,6 +155,24 @@ class SettingsRobot { return SettingsSubMenuAccessibilityRobot.Transition() } + fun openLanguageSubMenu(interact: SettingsSubMenuLanguageRobot.() -> Unit): SettingsSubMenuLanguageRobot.Transition { + + fun languageButton() = onView(withText("Language")) + languageButton().click() + + SettingsSubMenuLanguageRobot().interact() + return SettingsSubMenuLanguageRobot.Transition() + } + + fun openSetDefaultBrowserSubMenu(interact: SettingsSubMenuSetDefaultBrowserRobot.() -> Unit): SettingsSubMenuSetDefaultBrowserRobot.Transition { + scrollToElementByText("Set as default browser") + fun setDefaultBrowserButton() = onView(withText("Set as default browser")) + setDefaultBrowserButton().click() + + SettingsSubMenuSetDefaultBrowserRobot().interact() + return SettingsSubMenuSetDefaultBrowserRobot.Transition() + } + fun openEnhancedTrackingProtectionSubMenu(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionRobot.Transition { scrollToElementByText("Enhanced Tracking Protection") fun enhancedTrackingProtectionButton() = diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuLanguageRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuLanguageRobot.kt new file mode 100644 index 0000000000..1dd28b2a70 --- /dev/null +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuLanguageRobot.kt @@ -0,0 +1,29 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.ui.robots + +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.action.ViewActions +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice +import org.hamcrest.CoreMatchers + +class SettingsSubMenuLanguageRobot { + class Transition { + val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) + + fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { + mDevice.waitForIdle() + goBackButton().perform(ViewActions.click()) + + SettingsRobot().interact() + return SettingsRobot.Transition() + } + } +} + +private fun goBackButton() = + onView(CoreMatchers.allOf(ViewMatchers.withContentDescription("Navigate up"))) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuSetDefaultBrowserRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuSetDefaultBrowserRobot.kt new file mode 100644 index 0000000000..7b7d3bd2cd --- /dev/null +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuSetDefaultBrowserRobot.kt @@ -0,0 +1,25 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.ui.robots + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.UiDevice + +class SettingsSubMenuSetDefaultBrowserRobot { + class Transition { + val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) + + fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { + mDevice.waitForIdle() + + // We are now in system settings / showing a default browser dialog. + // Really want to go back to the app. Not interested in up navigation like in other robots. + mDevice.pressBack() + + SettingsRobot().interact() + return SettingsRobot.Transition() + } + } +} diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsTurnOnSyncRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsTurnOnSyncRobot.kt index 156815761f..5faa2840be 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsTurnOnSyncRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsTurnOnSyncRobot.kt @@ -36,11 +36,11 @@ class SettingsTurnOnSyncRobot { class Transition { val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) - fun goBack(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsSubMenuLoginsAndPasswordRobot.Transition { + fun goBack(interact: SettingsSubMenuLoginsAndPasswordRobot.() -> Unit): SettingsRobot.Transition { goBackButton().perform(ViewActions.click()) SettingsSubMenuLoginsAndPasswordRobot().interact() - return SettingsSubMenuLoginsAndPasswordRobot.Transition() + return SettingsRobot.Transition() } } }