Skip to content

Commit 3899898

Browse files
committed
DisplaySizeRule is only supported on API>=24
1 parent ad68d03 commit 3899898

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

app/src/androidTest/java/org/schabi/newpipe/ui/components/menu/LongPressMenuTest.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.schabi.newpipe.ui.components.menu
22

3+
import android.os.Build
34
import androidx.activity.ComponentActivity
45
import androidx.compose.runtime.getValue
56
import androidx.compose.runtime.mutableStateOf
@@ -44,6 +45,8 @@ import org.junit.Assert.assertEquals
4445
import org.junit.Assert.assertNotEquals
4546
import org.junit.Rule
4647
import org.junit.Test
48+
import org.junit.rules.RuleChain
49+
import org.junit.rules.TestRule
4750
import org.junit.runner.RunWith
4851
import org.schabi.newpipe.R
4952
import org.schabi.newpipe.assertInRange
@@ -69,7 +72,12 @@ class LongPressMenuTest {
6972
// Test rule for restoring device to its starting display size when a test case finishes.
7073
// See https://developer.android.com/training/testing/different-screens/tools#resize-displays.
7174
@get:Rule(order = 2)
72-
val displaySizeRule: DisplaySizeRule = DisplaySizeRule()
75+
val displaySizeRule: TestRule =
76+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
77+
DisplaySizeRule()
78+
} else {
79+
RuleChain.emptyRuleChain()
80+
}
7381

7482
private fun getLongPressable(
7583
title: String = "title",

0 commit comments

Comments
 (0)