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)
@ -107,12 +69,12 @@ private fun assertVersionNumber() {
.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
@ -121,7 +83,15 @@ private fun assertCurrentTimestamp() {
// .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)
@ -129,8 +99,7 @@ private fun assertWhatIsNewInFirefoxPreview() {
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
.perform(click())
}
private fun assertSupport() {
fun verifySupport() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Support"))
@ -144,7 +113,7 @@ private fun assertSupport() {
)
}
private fun assertCrashes() {
fun verifyCrashesLink() {
navigationToolbar {
}.openThreeDotMenu {
}.openSettings {
@ -163,7 +132,7 @@ private fun assertCrashes() {
}
}
private fun assertPrivacyNotice() {
fun verifyPrivacyNoticeLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Privacy notice"))
@ -177,7 +146,7 @@ private fun assertPrivacyNotice() {
)
}
private fun assertKnowYourRights() {
fun verifyKnowYourRightsLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Know your rights"))
@ -191,7 +160,7 @@ private fun assertKnowYourRights() {
)
}
private fun assertLicensingInformation() {
fun verifyLicensingInformationLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Licensing information"))
@ -205,7 +174,7 @@ private fun assertLicensingInformation() {
)
}
private fun assertLibrariesUsed() {
fun verifyLibrariesUsedLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Libraries that we use"))
@ -216,6 +185,40 @@ private fun assertLibrariesUsed() {
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"))
private fun goBackButton() =

Loading…
Cancel
Save