11package org.schabi.newpipe.ui.components.menu
22
3+ import android.os.Build
34import androidx.activity.ComponentActivity
45import androidx.compose.runtime.getValue
56import androidx.compose.runtime.mutableStateOf
@@ -37,13 +38,16 @@ import androidx.test.espresso.device.sizeclass.WidthSizeClass
3738import androidx.test.espresso.matcher.ViewMatchers.withId
3839import androidx.test.espresso.matcher.ViewMatchers.withText
3940import androidx.test.ext.junit.runners.AndroidJUnit4
41+ import androidx.test.filters.SdkSuppress
4042import java.time.OffsetDateTime
4143import java.time.temporal.ChronoUnit
4244import kotlinx.coroutines.delay
4345import org.junit.Assert.assertEquals
4446import org.junit.Assert.assertNotEquals
4547import org.junit.Rule
4648import org.junit.Test
49+ import org.junit.rules.RuleChain
50+ import org.junit.rules.TestRule
4751import org.junit.runner.RunWith
4852import org.schabi.newpipe.R
4953import org.schabi.newpipe.assertInRange
@@ -69,7 +73,12 @@ class LongPressMenuTest {
6973 // Test rule for restoring device to its starting display size when a test case finishes.
7074 // See https://developer.android.com/training/testing/different-screens/tools#resize-displays.
7175 @get:Rule(order = 2 )
72- val displaySizeRule: DisplaySizeRule = DisplaySizeRule ()
76+ val displaySizeRule: TestRule =
77+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
78+ DisplaySizeRule ()
79+ } else {
80+ RuleChain .emptyRuleChain()
81+ }
7382
7483 private fun getLongPressable (
7584 title : String = "title",
@@ -382,6 +391,7 @@ class LongPressMenuTest {
382391 }
383392
384393 @Test
394+ @SdkSuppress(minSdkVersion = Build .VERSION_CODES .N )
385395 fun testHeaderSpansAllWidthIfSmallScreen () {
386396 onDevice().setDisplaySize(
387397 widthSizeClass = WidthSizeClass .COMPACT ,
@@ -401,6 +411,7 @@ class LongPressMenuTest {
401411 }
402412
403413 @Test
414+ @SdkSuppress(minSdkVersion = Build .VERSION_CODES .N )
404415 fun testHeaderIsNotFullWidthIfLargeScreen () {
405416 onDevice().setDisplaySize(
406417 widthSizeClass = WidthSizeClass .EXPANDED ,
@@ -549,6 +560,7 @@ class LongPressMenuTest {
549560 }
550561
551562 @Test
563+ @SdkSuppress(minSdkVersion = Build .VERSION_CODES .N )
552564 fun testAllActionsOnSmallScreenAreScrollable () {
553565 onDevice().setDisplaySize(
554566 widthSizeClass = WidthSizeClass .COMPACT ,
0 commit comments