For #16615: UI smoke test redirectToAppPermissionsSystemSettingsTest

upstream-sync
Oana Horvath 4 years ago
parent 233018df84
commit f24c6e1316

@ -459,4 +459,35 @@ class SmokeTest {
verifyPasswordSaved("test")
}
}
@Test
fun redirectToAppPermissionsSystemSettingsTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
}.openSettingsSubMenuSitePermissions {
}.openCamera {
verifyBlockedByAndroid()
}.goBack {
}.openLocation {
verifyBlockedByAndroid()
}.goBack {
}.openMicrophone {
verifyBlockedByAndroid()
clickGoToSettingsButton()
openAppSystemPermissionsSettings()
switchAppPermissionSystemSetting("Camera")
switchAppPermissionSystemSetting("Location")
switchAppPermissionSystemSetting("Microphone")
mDevice.pressBack()
mDevice.pressBack()
verifyUnblockedByAndroid()
}.goBack {
}.openLocation {
verifyUnblockedByAndroid()
}.goBack {
}.openCamera {
verifyUnblockedByAndroid()
}
}
}

@ -7,14 +7,18 @@ package org.mozilla.fenix.ui.robots
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.Matchers.not
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.assertIsChecked
import org.mozilla.fenix.helpers.click
@ -41,6 +45,8 @@ class SettingsSubMenuSitePermissionsCommonRobot {
fun verifyBlockedByAndroid() = assertBlockedByAndroid()
fun verifyUnblockedByAndroid() = assertUnblockedByAndroid()
fun verifyToAllowIt() = assertToAllowIt()
fun verifyGotoAndroidSettings() = assertGotoAndroidSettings()
@ -81,6 +87,22 @@ class SettingsSubMenuSitePermissionsCommonRobot {
verifyCheckCommonRadioButtonDefault()
}
fun clickGoToSettingsButton() {
goToSettingsButton().click()
mDevice.findObject(UiSelector().resourceId("com.android.settings:id/list"))
.waitForExists(waitingTime)
}
fun openAppSystemPermissionsSettings() {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mDevice.findObject(UiSelector().textContains("Permissions")).click()
}
fun switchAppPermissionSystemSetting(permissionCategory: String) {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mDevice.findObject(UiSelector().textContains(permissionCategory)).click()
}
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
@ -131,6 +153,9 @@ private fun assertCheckCommonRadioButtonDefault() {
private fun assertBlockedByAndroid() = onView(withText(R.string.phone_feature_blocked_by_android))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertUnblockedByAndroid() = onView(withText(R.string.phone_feature_blocked_by_android))
.check(matches(not(isDisplayed())))
private fun assertToAllowIt() = onView(withText(R.string.phone_feature_blocked_intro))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
@ -143,8 +168,10 @@ private fun assertTapPermissions() = onView(withText("2. Tap Permissions"))
private fun assertToggleNameToON(name: String) = onView(withText(name))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertGoToSettingsButton() = onView(withId(R.id.settings_button))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertGoToSettingsButton() =
goToSettingsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun goBackButton() =
onView(allOf(withContentDescription("Navigate up")))
private fun goToSettingsButton() = onView(withId(R.id.settings_button))

Loading…
Cancel
Save