From 69879ff874161253b255de4e5c7bdf5fb024f228 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Fri, 19 May 2023 12:28:01 +0100 Subject: [PATCH] Grant permission only if TIRAMISU or above --- .../apps/nowinandroid/feature/foryou/ForYouScreenTest.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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()