Skip to content

Commit 528cae6

Browse files
authored
Fix muted ScrollableTest for iOS target (JetBrains#2711)
Fixes https://youtrack.jetbrains.com/issue/CMP-8401/Fix-ScrollableTest-fling-tests ## Release Notes N/A
1 parent 8a1f7cd commit 528cae6

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

  • compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/copyPasteAndroidTests

compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/copyPasteAndroidTests/ScrollableTest.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import androidx.compose.runtime.currentComposer
8181
import androidx.compose.runtime.getValue
8282
import androidx.compose.runtime.mutableFloatStateOf
8383
import androidx.compose.runtime.mutableStateOf
84+
import androidx.compose.runtime.remember
8485
import androidx.compose.runtime.rememberCoroutineScope
8586
import androidx.compose.runtime.setValue
8687
import androidx.compose.ui.Alignment
@@ -1490,7 +1491,6 @@ class ScrollableTest {
14901491
}
14911492

14921493
@Test
1493-
@IgnoreIosTarget // https://youtrack.jetbrains.com/issue/CMP-8401
14941494
fun scrollable_nestedFling() = runComposeUiTest {
14951495
var innerDrag = 0f
14961496
var outerDrag = 0f
@@ -2413,7 +2413,6 @@ class ScrollableTest {
24132413
}
24142414

24152415
@Test
2416-
@IgnoreIosTarget // https://youtrack.jetbrains.com/issue/CMP-8401
24172416
fun scrollable_flingBehaviourCalled() = runComposeUiTest {
24182417
var total = 0f
24192418
val controller =
@@ -2448,7 +2447,6 @@ class ScrollableTest {
24482447
}
24492448

24502449
@Test
2451-
@IgnoreIosTarget // https://youtrack.jetbrains.com/issue/CMP-8401
24522450
fun scrollable_flingBehaviourCalled_reversed() = runComposeUiTest {
24532451
var total = 0f
24542452
val controller =
@@ -3154,13 +3152,12 @@ class ScrollableTest {
31543152
}
31553153

31563154
@Test
3157-
@IgnoreIosTarget // https://youtrack.jetbrains.com/issue/CMP-8401
31583155
fun disableSystemAnimations_defaultFlingBehaviorShouldContinueToWork() = runComposeUiTest {
31593156

31603157
val controller = ScrollableState { 0f }
31613158
var defaultFlingBehavior: DefaultFlingBehavior? = null
31623159
setScrollableContent {
3163-
defaultFlingBehavior = ScrollableDefaults.flingBehavior() as? DefaultFlingBehavior
3160+
defaultFlingBehavior = rememberDefaultFlingBehavior()
31643161
Modifier.scrollable(
31653162
state = controller,
31663163
orientation = Orientation.Horizontal,
@@ -3410,7 +3407,7 @@ class ScrollableTest {
34103407
}
34113408

34123409
@Test
3413-
@IgnoreIosTarget // https://youtrack.jetbrains.com/issue/CMP-8401
3410+
@IgnoreIosTarget // Fling behavior on iOS does not use screen density
34143411
fun onDensityChange_shouldUpdateFlingBehavior() = runComposeUiTest {
34153412
var density by mutableStateOf(density)
34163413
var flingDelta = 0f
@@ -3543,6 +3540,14 @@ class ScrollableTest {
35433540
runOnIdle { assertThat(focusRequester.requestFocus()).isTrue() }
35443541
}
35453542
}
3543+
3544+
@Composable
3545+
private fun rememberDefaultFlingBehavior(): DefaultFlingBehavior {
3546+
val flingSpec = rememberSplineBasedDecay<Float>()
3547+
return remember(flingSpec) {
3548+
DefaultFlingBehavior(flingSpec)
3549+
}
3550+
}
35463551
}
35473552

35483553
// Very low tolerance on the difference

0 commit comments

Comments
 (0)