Skip to content

Commit a03307e

Browse files
authored
Merge pull request #738 from SimonMarquis/patch-5
Grant `POST_NOTIFICATIONS` permission in instrumented tests
2 parents f87e769 + a93cce9 commit a03307e

File tree

1 file changed

+14
-0
lines changed
  • feature/foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou

1 file changed

+14
-0
lines changed

feature/foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package com.google.samples.apps.nowinandroid.feature.foryou
1818

19+
import android.Manifest
20+
import android.os.Build.VERSION.SDK_INT
21+
import android.os.Build.VERSION_CODES.TIRAMISU
1922
import androidx.activity.ComponentActivity
2023
import androidx.compose.foundation.layout.BoxWithConstraints
2124
import androidx.compose.ui.test.assertHasClickAction
@@ -28,13 +31,24 @@ import androidx.compose.ui.test.onFirst
2831
import androidx.compose.ui.test.onNodeWithContentDescription
2932
import androidx.compose.ui.test.onNodeWithText
3033
import androidx.compose.ui.test.performScrollToNode
34+
import androidx.test.rule.GrantPermissionRule
35+
import androidx.test.rule.GrantPermissionRule.grant
3136
import com.google.samples.apps.nowinandroid.core.testing.data.followableTopicTestData
3237
import com.google.samples.apps.nowinandroid.core.testing.data.userNewsResourcesTestData
3338
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
3439
import org.junit.Rule
3540
import org.junit.Test
3641

3742
class ForYouScreenTest {
43+
44+
@get:Rule
45+
val permissionTestRule: GrantPermissionRule =
46+
if (SDK_INT >= TIRAMISU) {
47+
grant(Manifest.permission.POST_NOTIFICATIONS)
48+
} else {
49+
grant()
50+
}
51+
3852
@get:Rule
3953
val composeTestRule = createAndroidComposeRule<ComponentActivity>()
4054

0 commit comments

Comments
 (0)