Bug 1884903 - Remove redundant assertion functions from SettingsSubMenuAboutRobot

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

@ -47,51 +47,13 @@ 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())
SettingsRobot().interact()
return SettingsRobot.Transition()
}
}
}
private fun navigateBackToAboutPage(itemToInteract: () -> Unit) {
navigationToolbar {
}.openThreeDotMenu {
}.openSettings {
}.openAboutFirefoxPreview {
itemToInteract()
}
}
private fun verifyTheLinksList() {
assertAboutToolbar()
assertWhatIsNewInFirefoxPreview()
navigateBackToAboutPage(::assertSupport)
assertCrashes()
navigateBackToAboutPage(::assertPrivacyNotice)
navigateBackToAboutPage(::assertKnowYourRights)
navigateBackToAboutPage(::assertLicensingInformation)
navigateBackToAboutPage(::assertLibrariesUsed)
}
private fun assertAboutToolbar() =
onView(
allOf(
withId(R.id.navigationToolbar),
hasDescendant(withText("About $appName")),
),
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertVersionNumber() {
fun verifyVersionNumber() {
val context = InstrumentationRegistry.getInstrumentation().targetContext
val packageInfo = context.packageManager.getPackageInfoCompat(context.packageName, 0)
@ -105,32 +67,39 @@ private fun assertVersionNumber() {
.check(matches(withText(containsString(buildNVersion))))
.check(matches(withText(containsString(geckoVersion))))
.check(matches(withText(containsString(asVersion))))
}
}
private fun assertProductCompany() {
fun verifyProductCompany() {
onView(withId(R.id.about_content))
.check(matches(withText(containsString("$appName is produced by Mozilla."))))
}
}
private fun assertCurrentTimestamp() {
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 assertWhatIsNewInFirefoxPreview() {
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("Whats new in $firefox"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
.perform(click())
}
private fun assertSupport() {
}
fun verifySupport() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Support"))
@ -142,9 +111,9 @@ private fun assertSupport() {
"org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view",
R.id.mozac_browser_toolbar_url_view,
)
}
}
private fun assertCrashes() {
fun verifyCrashesLink() {
navigationToolbar {
}.openThreeDotMenu {
}.openSettings {
@ -161,9 +130,9 @@ private fun assertCrashes() {
for (i in 1..3) {
Espresso.pressBack()
}
}
}
private fun assertPrivacyNotice() {
fun verifyPrivacyNoticeLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Privacy notice"))
@ -175,9 +144,9 @@ private fun assertPrivacyNotice() {
"org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view",
R.id.mozac_browser_toolbar_url_view,
)
}
}
private fun assertKnowYourRights() {
fun verifyKnowYourRightsLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Know your rights"))
@ -189,9 +158,9 @@ private fun assertKnowYourRights() {
"org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view",
R.id.mozac_browser_toolbar_url_view,
)
}
}
private fun assertLicensingInformation() {
fun verifyLicensingInformationLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Licensing information"))
@ -203,9 +172,9 @@ private fun assertLicensingInformation() {
"org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view",
R.id.mozac_browser_toolbar_url_view,
)
}
}
private fun assertLibrariesUsed() {
fun verifyLibrariesUsedLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Libraries that we use"))
@ -214,6 +183,40 @@ private fun assertLibrariesUsed() {
onView(withId(R.id.navigationToolbar)).check(matches(hasDescendant(withText(containsString("$appName | OSS Libraries")))))
Espresso.pressBack()
}
fun verifyTheLinksList() {
verifyAboutToolbar()
verifyWhatIsNewInFirefoxLink()
navigateBackToAboutPage()
verifySupport()
verifyCrashesLink()
navigateBackToAboutPage()
verifyPrivacyNoticeLink()
navigateBackToAboutPage()
verifyKnowYourRightsLink()
navigateBackToAboutPage()
verifyLicensingInformationLink()
navigateBackToAboutPage()
verifyLibrariesUsedLink()
}
class Transition {
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
goBackButton().perform(click())
SettingsRobot().interact()
return SettingsRobot.Transition()
}
}
}
private fun navigateBackToAboutPage() {
navigationToolbar {
}.openThreeDotMenu {
}.openSettings {
}.openAboutFirefoxPreview {
}
}
private val aboutMenuList = UiScrollable(UiSelector().resourceId("$packageName:id/about_layout"))

Loading…
Cancel
Save