Skip to content

Commit

Permalink
Add test to cover the new method
Browse files Browse the repository at this point in the history
  • Loading branch information
Sloy committed May 27, 2021
1 parent 8afe081 commit 75f2874
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,25 @@ class PermissionGranterTest {
}
}

@Test
fun denies_simple_permission() {
launchActivity {
verifyPermissionNotGranted(PERMISSION_3_CALLS)
requestPermission(PERMISSION_3_CALLS)

PermissionGranter.denyPermissions(PERMISSION_3_CALLS)

verifyPermissionNotGranted(PERMISSION_3_CALLS)
}
}


}

// We can't reuse permission from one test to another, because they stay granted after each test
private const val PERMISSION_1_CONTACTS = Manifest.permission.READ_CONTACTS
private const val PERMISSION_2_CAMERA = Manifest.permission.CAMERA
private const val PERMISSION_3_CALLS = Manifest.permission.ANSWER_PHONE_CALLS
private const val LOCATION_PERMISSION = Manifest.permission.ACCESS_FINE_LOCATION

private fun ActivityScenario<*>.requestPermission(permission: String) {
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application
Expand Down

0 comments on commit 75f2874

Please sign in to comment.