From 60b8cfa9169b3d3ed39f1a54c751acaa66f55e0b Mon Sep 17 00:00:00 2001 From: Oana Horvath Date: Fri, 28 May 2021 15:47:21 +0300 Subject: [PATCH] [fenix] No issue: Add more smoke tests coverage --- .../java/org/mozilla/fenix/ui/SmokeTest.kt | 23 +++++++++++++++++-- .../mozilla/fenix/ui/robots/SettingsRobot.kt | 10 ++------ .../SettingsSubMenuAddonsManagerRobot.kt | 7 +++--- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt index f8209ba8c6..1a8de40810 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt @@ -26,7 +26,7 @@ import org.mozilla.fenix.R import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.settings import org.mozilla.fenix.helpers.AndroidAssetDispatcher -import org.mozilla.fenix.helpers.HomeActivityTestRule +import org.mozilla.fenix.helpers.HomeActivityIntentTestRule import org.mozilla.fenix.helpers.RecyclerViewIdlingResource import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestHelper @@ -45,6 +45,7 @@ import org.mozilla.fenix.ui.robots.enhancedTrackingProtection import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.navigationToolbar import org.mozilla.fenix.ui.robots.notificationShade +import org.mozilla.fenix.ui.robots.searchScreen import org.mozilla.fenix.ui.robots.tabDrawer import org.mozilla.fenix.ui.util.STRING_ONBOARDING_TRACKING_PROTECTION_HEADER @@ -76,7 +77,7 @@ class SmokeTest { } @get:Rule - val activityTestRule = HomeActivityTestRule() + val activityTestRule = HomeActivityIntentTestRule() private lateinit var browserStore: BrowserStore @get: Rule @@ -1134,6 +1135,11 @@ class SmokeTest { clickAddPrivateBrowsingShortcutButton() clickAddAutomaticallyButton() }.openHomeScreenShortcut("Private $appName") {} + searchScreen { + verifySearchView() + }.dismissSearchBar { + verifyPrivateSessionMessage() + } } @Test @@ -1320,4 +1326,17 @@ class SmokeTest { assertPlaybackState(browserStore, MediaSession.PlaybackState.PAUSED) } } + + @Test + // For API>23 + // Verifies the default browser switch opens the system default apps menu. + fun changeDefaultBrowserSetting() { + homeScreen { + }.openThreeDotMenu { + }.openSettings { + verifyDefaultBrowserIsDisaled() + clickDefaultBrowserSwitch() + verifyAndroidDefaultAppsMenuAppears() + } + } } 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 7557c5096c..fc02dd5baa 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 @@ -311,14 +311,8 @@ private fun assertDefaultBrowserIsDisabled() { } private fun toggleDefaultBrowserSwitch() { - scrollToElementByText("Set as default browser") - onView( - CoreMatchers.allOf( - ViewMatchers.withParent(CoreMatchers.not(withId(R.id.navigationToolbar))), - withText("Set as default browser") - ) - ) - .perform(ViewActions.click()) + scrollToElementByText("Privacy and security") + onView(withText("Set as default browser")).perform(ViewActions.click()) } private fun assertAndroidDefaultAppsMenuAppears() { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerRobot.kt index c370b3c8a8..8c048afea1 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerRobot.kt @@ -15,14 +15,15 @@ import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withParent import androidx.test.espresso.matcher.ViewMatchers.withText +import androidx.test.rule.ActivityTestRule import androidx.test.uiautomator.By import androidx.test.uiautomator.Until import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.containsString import org.hamcrest.CoreMatchers.instanceOf import org.hamcrest.CoreMatchers.not +import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.R -import org.mozilla.fenix.helpers.HomeActivityTestRule import org.mozilla.fenix.helpers.IdlingResourceHelper.registerAddonInstallingIdlingResource import org.mozilla.fenix.helpers.IdlingResourceHelper.unregisterAddonInstallingIdlingResource import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime @@ -38,7 +39,7 @@ import org.mozilla.fenix.helpers.ext.waitNotNull class SettingsSubMenuAddonsManagerRobot { fun verifyAddonPrompt(addonName: String) = assertAddonPrompt(addonName) fun clickInstallAddon(addonName: String) = selectInstallAddon(addonName) - fun verifyDownloadAddonPrompt(addonName: String, activityTestRule: HomeActivityTestRule) = + fun verifyDownloadAddonPrompt(addonName: String, activityTestRule: ActivityTestRule) = assertDownloadingAddonPrompt(addonName, activityTestRule) fun cancelInstallAddon() = cancelInstall() @@ -125,7 +126,7 @@ class SettingsSubMenuAddonsManagerRobot { private fun assertDownloadingAddonPrompt( addonName: String, - activityTestRule: HomeActivityTestRule + activityTestRule: ActivityTestRule ) { registerAddonInstallingIdlingResource(activityTestRule)