Improve coverage for verifyAboutFirefoxPreview

upstream-sync
AndiAJ 3 years ago committed by mergify[bot]
parent f4397cc85e
commit d4ce149c3e

@ -20,15 +20,20 @@ import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withSubstring
import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import org.hamcrest.CoreMatchers import org.hamcrest.CoreMatchers
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.containsString import org.hamcrest.CoreMatchers.containsString
import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestHelper import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.TestHelper.appName import org.mozilla.fenix.helpers.TestHelper.appName
import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.isVisibleForUser import org.mozilla.fenix.helpers.isVisibleForUser
import org.mozilla.fenix.settings.SupportUtils import org.mozilla.fenix.settings.SupportUtils
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
@ -79,14 +84,24 @@ private fun navigateBackToAboutPage(itemToInteract: () -> Unit) {
} }
private fun verifyListElements() { private fun verifyListElements() {
assertAboutToolbar()
assertWhatIsNewInFirefoxPreview() assertWhatIsNewInFirefoxPreview()
navigateBackToAboutPage(::assertSupport) navigateBackToAboutPage(::assertSupport)
assertCrashes()
navigateBackToAboutPage(::assertPrivacyNotice) navigateBackToAboutPage(::assertPrivacyNotice)
navigateBackToAboutPage(::assertKnowYourRights) navigateBackToAboutPage(::assertKnowYourRights)
navigateBackToAboutPage(::assertLicensingInformation) navigateBackToAboutPage(::assertLicensingInformation)
navigateBackToAboutPage(::assertLibrariesUsed) navigateBackToAboutPage(::assertLibrariesUsed)
} }
private fun assertAboutToolbar() =
onView(
allOf(
withId(R.id.navigationToolbar),
hasDescendant(withText("About $appName"))
)
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertVersionNumber() { private fun assertVersionNumber() {
val context = InstrumentationRegistry.getInstrumentation().targetContext val context = InstrumentationRegistry.getInstrumentation().targetContext
@ -160,6 +175,37 @@ private fun assertSupport() {
Espresso.pressBack() Espresso.pressBack()
} }
private fun assertCrashes() {
browserScreen {
}.openThreeDotMenu {
}.openSettings {
}.openAboutFirefoxPreview {
}
if (!onView(withText("Crashes")).isVisibleForUser()) {
onView(withId(R.id.about_layout)).perform(ViewActions.swipeUp())
}
onView(withText("Crashes"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
.perform(click())
onView(withSubstring("No crash reports have been submitted"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
for (i in 1..3) {
Espresso.pressBack()
}
mDevice.findObject(
UiSelector().resourceId("$packageName:id/homeLayout")
).waitForExists(waitingTime)
onView(ViewMatchers.withResourceName("homeLayout"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
}
private fun assertPrivacyNotice() { private fun assertPrivacyNotice() {
if (!onView(withText("Privacy notice")).isVisibleForUser()) { if (!onView(withText("Privacy notice")).isVisibleForUser()) {
onView(withId(R.id.about_layout)).perform(ViewActions.swipeUp()) onView(withId(R.id.about_layout)).perform(ViewActions.swipeUp())

Loading…
Cancel
Save