Skip to content

Commit

Permalink
Upgrade permissions tests to work on API30+
Browse files Browse the repository at this point in the history
  • Loading branch information
bentrengrove committed Aug 26, 2022
1 parent 3397a90 commit 25a1d45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Expand Up @@ -87,7 +87,6 @@ class RequestMultiplePermissionsTest {
composeTestRule.onNodeWithText("No permission").assertIsDisplayed()
}

@OptIn(ExperimentalCoroutinesApi::class)
@Test
fun permissionTest_grantInTheBackground() {
composeTestRule.onNodeWithText("No permission").assertIsDisplayed()
Expand Down
Expand Up @@ -78,20 +78,21 @@ internal fun grantPermissionInDialog(
internal fun denyPermissionInDialog(
instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
) {
UiDevice.getInstance(instrumentation).findPermissionButton(
when (Build.VERSION.SDK_INT) {
in 24..28 -> "DENY"
else -> "Deny"
}
).clickForPermission(instrumentation)
val text = when (Build.VERSION.SDK_INT) {
in 24..28 -> "DENY"
in 29..30 -> "Deny"
else -> "Don’t allow"
}
val permissionButton = UiDevice.getInstance(instrumentation).findPermissionButton(text)
assert(permissionButton.clickForPermission(instrumentation)) { "Could not deny permission" }
}

internal fun doNotAskAgainPermissionInDialog(
instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
) {
val uiDevice = UiDevice.getInstance(instrumentation)
when {
Build.VERSION.SDK_INT == 30 -> {
Build.VERSION.SDK_INT >= 30 -> {
denyPermissionInDialog(instrumentation)
}
Build.VERSION.SDK_INT > 28 -> {
Expand Down

0 comments on commit 25a1d45

Please sign in to comment.