[fenix] For https://github.com/mozilla-mobile/fenix/issues/16615: UI smoke test redirectToAppPermissionsSystemSettingsTest

pull/600/head
Oana Horvath 4 years ago
parent f7430161e5
commit f2f33944df

@ -459,4 +459,35 @@ class SmokeTest {
verifyPasswordSaved("test") 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.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.Visibility 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.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.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.allOf import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.Matchers.not
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.assertIsChecked import org.mozilla.fenix.helpers.assertIsChecked
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
@ -41,6 +45,8 @@ class SettingsSubMenuSitePermissionsCommonRobot {
fun verifyBlockedByAndroid() = assertBlockedByAndroid() fun verifyBlockedByAndroid() = assertBlockedByAndroid()
fun verifyUnblockedByAndroid() = assertUnblockedByAndroid()
fun verifyToAllowIt() = assertToAllowIt() fun verifyToAllowIt() = assertToAllowIt()
fun verifyGotoAndroidSettings() = assertGotoAndroidSettings() fun verifyGotoAndroidSettings() = assertGotoAndroidSettings()
@ -81,6 +87,22 @@ class SettingsSubMenuSitePermissionsCommonRobot {
verifyCheckCommonRadioButtonDefault() 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 { class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!! 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)) private fun assertBlockedByAndroid() = onView(withText(R.string.phone_feature_blocked_by_android))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .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)) private fun assertToAllowIt() = onView(withText(R.string.phone_feature_blocked_intro))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .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)) private fun assertToggleNameToON(name: String) = onView(withText(name))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertGoToSettingsButton() = onView(withId(R.id.settings_button)) private fun assertGoToSettingsButton() =
.check(matches(withEffectiveVisibility(Visibility.VISIBLE))) goToSettingsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun goBackButton() = private fun goBackButton() =
onView(allOf(withContentDescription("Navigate up"))) onView(allOf(withContentDescription("Navigate up")))
private fun goToSettingsButton() = onView(withId(R.id.settings_button))

Loading…
Cancel
Save