Skip to content

A fully functional Android app built entirely with Kotlin and Jetpack Compose

Grant permission only if TIRAMISU or above

Simon Marquis69879ff87416
diff --git a/feature/foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt b/feature/foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt
index 404ad55b9..7a750a13d 100644
--- a/feature/foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt
+++ b/feature/foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt
@@ -17,6 +17,8 @@
package com.google.samples.apps.nowinandroid.feature.foryou
import android.Manifest
+import android.os.Build.VERSION.SDK_INT
+import android.os.Build.VERSION_CODES.TIRAMISU
import androidx.activity.ComponentActivity
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.ui.test.assertHasClickAction
@@ -40,7 +42,9 @@ import org.junit.Test
class ForYouScreenTest {
@get:Rule
- val permissionTestRule: GrantPermissionRule = grant(Manifest.permission.POST_NOTIFICATIONS)
+ val permissionTestRule: GrantPermissionRule =
+ if (SDK_INT < TIRAMISU) grant()
+ else grant(Manifest.permission.POST_NOTIFICATIONS)
@get:Rule
val composeTestRule = createAndroidComposeRule<ComponentActivity>()