From 75f28748c81190f534fde1706a245ef7bdb70c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=20V=C3=A1zquez?= <rafa.vazsan@gmail.com> Date: Thu, 27 May 2021 14:32:08 +0200 Subject: [PATCH] Add test to cover the new method --- .../spain/barista/sample/PermissionGranterTest.kt | 13 +++++++++++++ sample/src/main/AndroidManifest.xml | 1 + 2 files changed, 14 insertions(+) diff --git a/sample/src/androidTest/java/com/schibsted/spain/barista/sample/PermissionGranterTest.kt b/sample/src/androidTest/java/com/schibsted/spain/barista/sample/PermissionGranterTest.kt index 0b9b530c5..198a267f8 100644 --- a/sample/src/androidTest/java/com/schibsted/spain/barista/sample/PermissionGranterTest.kt +++ b/sample/src/androidTest/java/com/schibsted/spain/barista/sample/PermissionGranterTest.kt @@ -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) { diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 82ad66428..44706ef6f 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -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