diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAboutRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAboutRobot.kt index a7c569874..51156d089 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAboutRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAboutRobot.kt @@ -47,173 +47,176 @@ import java.util.Date */ class SettingsSubMenuAboutRobot { fun verifyAboutFirefoxPreviewInfo() { - assertVersionNumber() - assertProductCompany() - assertCurrentTimestamp() + verifyVersionNumber() + verifyProductCompany() + verifyCurrentTimestamp() verifyTheLinksList() } - class Transition { - fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { - goBackButton().perform(click()) + fun verifyVersionNumber() { + val context = InstrumentationRegistry.getInstrumentation().targetContext - SettingsRobot().interact() - return SettingsRobot.Transition() - } + val packageInfo = context.packageManager.getPackageInfoCompat(context.packageName, 0) + val versionCode = PackageInfoCompat.getLongVersionCode(packageInfo).toString() + val buildNVersion = "${packageInfo.versionName} (Build #$versionCode)\n" + val geckoVersion = + org.mozilla.geckoview.BuildConfig.MOZ_APP_VERSION + "-" + org.mozilla.geckoview.BuildConfig.MOZ_APP_BUILDID + val asVersion = mozilla.components.Build.applicationServicesVersion + + onView(withId(R.id.about_text)) + .check(matches(withText(containsString(buildNVersion)))) + .check(matches(withText(containsString(geckoVersion)))) + .check(matches(withText(containsString(asVersion)))) } -} -private fun navigateBackToAboutPage(itemToInteract: () -> Unit) { - navigationToolbar { - }.openThreeDotMenu { - }.openSettings { - }.openAboutFirefoxPreview { - itemToInteract() + fun verifyProductCompany() { + onView(withId(R.id.about_content)) + .check(matches(withText(containsString("$appName is produced by Mozilla.")))) } -} -private fun verifyTheLinksList() { - assertAboutToolbar() - assertWhatIsNewInFirefoxPreview() - navigateBackToAboutPage(::assertSupport) - assertCrashes() - navigateBackToAboutPage(::assertPrivacyNotice) - navigateBackToAboutPage(::assertKnowYourRights) - navigateBackToAboutPage(::assertLicensingInformation) - navigateBackToAboutPage(::assertLibrariesUsed) -} + fun verifyCurrentTimestamp() { + onView(withId(R.id.build_date)) + // Currently UI tests run against debug builds, which display a hard-coded string 'debug build' + // instead of the date. See https://github.com/mozilla-mobile/fenix/pull/10812#issuecomment-633746833 + .check(matches(withText(containsString("debug build")))) + // This assertion should be valid for non-debug build types. + // .check(BuildDateAssertion.isDisplayedDateAccurate()) + } -private fun assertAboutToolbar() = - onView( - allOf( - withId(R.id.navigationToolbar), - hasDescendant(withText("About $appName")), - ), - ).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - -private fun assertVersionNumber() { - val context = InstrumentationRegistry.getInstrumentation().targetContext - - val packageInfo = context.packageManager.getPackageInfoCompat(context.packageName, 0) - val versionCode = PackageInfoCompat.getLongVersionCode(packageInfo).toString() - val buildNVersion = "${packageInfo.versionName} (Build #$versionCode)\n" - val geckoVersion = - org.mozilla.geckoview.BuildConfig.MOZ_APP_VERSION + "-" + org.mozilla.geckoview.BuildConfig.MOZ_APP_BUILDID - val asVersion = mozilla.components.Build.applicationServicesVersion - - onView(withId(R.id.about_text)) - .check(matches(withText(containsString(buildNVersion)))) - .check(matches(withText(containsString(geckoVersion)))) - .check(matches(withText(containsString(asVersion)))) -} + fun verifyAboutToolbar() = + onView( + allOf( + withId(R.id.navigationToolbar), + hasDescendant(withText("About $appName")), + ), + ).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + + fun verifyWhatIsNewInFirefoxLink() { + aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) + + val firefox = TestHelper.appContext.getString(R.string.firefox) + onView(withText("What’s new in $firefox")) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .perform(click()) + } + fun verifySupport() { + aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) + + onView(withText("Support")) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .perform(click()) + + TestHelper.verifyUrl( + "support.mozilla.org", + "org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view", + R.id.mozac_browser_toolbar_url_view, + ) + } -private fun assertProductCompany() { - onView(withId(R.id.about_content)) - .check(matches(withText(containsString("$appName is produced by Mozilla.")))) -} + fun verifyCrashesLink() { + navigationToolbar { + }.openThreeDotMenu { + }.openSettings { + }.openAboutFirefoxPreview {} -private fun assertCurrentTimestamp() { - onView(withId(R.id.build_date)) - // Currently UI tests run against debug builds, which display a hard-coded string 'debug build' - // instead of the date. See https://github.com/mozilla-mobile/fenix/pull/10812#issuecomment-633746833 - .check(matches(withText(containsString("debug build")))) - // This assertion should be valid for non-debug build types. - // .check(BuildDateAssertion.isDisplayedDateAccurate()) -} + aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) -private fun assertWhatIsNewInFirefoxPreview() { - aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) + onView(withText("Crashes")) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .perform(click()) - val firefox = TestHelper.appContext.getString(R.string.firefox) - onView(withText("What’s new in $firefox")) - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - .perform(click()) -} + assertUIObjectExists(itemContainingText("No crash reports have been submitted.")) -private fun assertSupport() { - aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) + for (i in 1..3) { + Espresso.pressBack() + } + } - onView(withText("Support")) - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - .perform(click()) + fun verifyPrivacyNoticeLink() { + aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) - TestHelper.verifyUrl( - "support.mozilla.org", - "org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view", - R.id.mozac_browser_toolbar_url_view, - ) -} + onView(withText("Privacy notice")) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .perform(click()) -private fun assertCrashes() { - navigationToolbar { - }.openThreeDotMenu { - }.openSettings { - }.openAboutFirefoxPreview {} - - aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) + TestHelper.verifyUrl( + "/privacy/firefox", + "org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view", + R.id.mozac_browser_toolbar_url_view, + ) + } - onView(withText("Crashes")) - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - .perform(click()) + fun verifyKnowYourRightsLink() { + aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) - assertUIObjectExists(itemContainingText("No crash reports have been submitted.")) + onView(withText("Know your rights")) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .perform(click()) - for (i in 1..3) { - Espresso.pressBack() + TestHelper.verifyUrl( + SupportUtils.SumoTopic.YOUR_RIGHTS.topicStr, + "org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view", + R.id.mozac_browser_toolbar_url_view, + ) } -} -private fun assertPrivacyNotice() { - aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) + fun verifyLicensingInformationLink() { + aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) - onView(withText("Privacy notice")) - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - .perform(click()) + onView(withText("Licensing information")) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .perform(click()) - TestHelper.verifyUrl( - "/privacy/firefox", - "org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view", - R.id.mozac_browser_toolbar_url_view, - ) -} + TestHelper.verifyUrl( + "about:license", + "org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view", + R.id.mozac_browser_toolbar_url_view, + ) + } -private fun assertKnowYourRights() { - aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) + fun verifyLibrariesUsedLink() { + aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) - onView(withText("Know your rights")) - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - .perform(click()) + onView(withText("Libraries that we use")) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .perform(click()) - TestHelper.verifyUrl( - SupportUtils.SumoTopic.YOUR_RIGHTS.topicStr, - "org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view", - R.id.mozac_browser_toolbar_url_view, - ) -} + onView(withId(R.id.navigationToolbar)).check(matches(hasDescendant(withText(containsString("$appName | OSS Libraries"))))) + Espresso.pressBack() + } -private fun assertLicensingInformation() { - aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) + fun verifyTheLinksList() { + verifyAboutToolbar() + verifyWhatIsNewInFirefoxLink() + navigateBackToAboutPage() + verifySupport() + verifyCrashesLink() + navigateBackToAboutPage() + verifyPrivacyNoticeLink() + navigateBackToAboutPage() + verifyKnowYourRightsLink() + navigateBackToAboutPage() + verifyLicensingInformationLink() + navigateBackToAboutPage() + verifyLibrariesUsedLink() + } - onView(withText("Licensing information")) - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - .perform(click()) + class Transition { + fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { + goBackButton().perform(click()) - TestHelper.verifyUrl( - "about:license", - "org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view", - R.id.mozac_browser_toolbar_url_view, - ) + SettingsRobot().interact() + return SettingsRobot.Transition() + } + } } -private fun assertLibrariesUsed() { - aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) - - onView(withText("Libraries that we use")) - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - .perform(click()) - - onView(withId(R.id.navigationToolbar)).check(matches(hasDescendant(withText(containsString("$appName | OSS Libraries"))))) - Espresso.pressBack() +private fun navigateBackToAboutPage() { + navigationToolbar { + }.openThreeDotMenu { + }.openSettings { + }.openAboutFirefoxPreview { + } } private val aboutMenuList = UiScrollable(UiSelector().resourceId("$packageName:id/about_layout"))