Bug 1884903 - Remove redundant assertion functions from SettingsSubMenuAboutRobot

fenix/125.0
AndiAJ 2 months ago committed by mergify[bot]
parent 03949df932
commit bbb3c0dfe6

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

Loading…
Cancel
Save