Bug 1884903 - Remove redundant assertion functions from SettingsSubMenuAboutRobot

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

@ -47,51 +47,13 @@ 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 {
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() {
val context = InstrumentationRegistry.getInstrumentation().targetContext val context = InstrumentationRegistry.getInstrumentation().targetContext
val packageInfo = context.packageManager.getPackageInfoCompat(context.packageName, 0) val packageInfo = context.packageManager.getPackageInfoCompat(context.packageName, 0)
@ -107,12 +69,12 @@ private fun assertVersionNumber() {
.check(matches(withText(containsString(asVersion)))) .check(matches(withText(containsString(asVersion))))
} }
private fun assertProductCompany() { fun verifyProductCompany() {
onView(withId(R.id.about_content)) onView(withId(R.id.about_content))
.check(matches(withText(containsString("$appName is produced by Mozilla.")))) .check(matches(withText(containsString("$appName is produced by Mozilla."))))
} }
private fun assertCurrentTimestamp() { fun verifyCurrentTimestamp() {
onView(withId(R.id.build_date)) onView(withId(R.id.build_date))
// Currently UI tests run against debug builds, which display a hard-coded string 'debug build' // 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 // 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()) // .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) aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
val firefox = TestHelper.appContext.getString(R.string.firefox) val firefox = TestHelper.appContext.getString(R.string.firefox)
@ -129,8 +99,7 @@ private fun assertWhatIsNewInFirefoxPreview() {
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
.perform(click()) .perform(click())
} }
fun verifySupport() {
private fun assertSupport() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Support")) onView(withText("Support"))
@ -144,7 +113,7 @@ private fun assertSupport() {
) )
} }
private fun assertCrashes() { fun verifyCrashesLink() {
navigationToolbar { navigationToolbar {
}.openThreeDotMenu { }.openThreeDotMenu {
}.openSettings { }.openSettings {
@ -163,7 +132,7 @@ private fun assertCrashes() {
} }
} }
private fun assertPrivacyNotice() { fun verifyPrivacyNoticeLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Privacy notice")) onView(withText("Privacy notice"))
@ -177,7 +146,7 @@ private fun assertPrivacyNotice() {
) )
} }
private fun assertKnowYourRights() { fun verifyKnowYourRightsLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Know your rights")) onView(withText("Know your rights"))
@ -191,7 +160,7 @@ private fun assertKnowYourRights() {
) )
} }
private fun assertLicensingInformation() { fun verifyLicensingInformationLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Licensing information")) onView(withText("Licensing information"))
@ -205,7 +174,7 @@ private fun assertLicensingInformation() {
) )
} }
private fun assertLibrariesUsed() { fun verifyLibrariesUsedLink() {
aboutMenuList.scrollToEnd(LISTS_MAXSWIPES) aboutMenuList.scrollToEnd(LISTS_MAXSWIPES)
onView(withText("Libraries that we use")) onView(withText("Libraries that we use"))
@ -216,6 +185,40 @@ private fun assertLibrariesUsed() {
Espresso.pressBack() 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 val aboutMenuList = UiScrollable(UiSelector().resourceId("$packageName:id/about_layout"))
private fun goBackButton() = private fun goBackButton() =

Loading…
Cancel
Save