Recompile STL sources when building tests
This CL works around b/240432457 by recompiling the sources of
PlatformComposeSceneTransitionLayout when compiling the associated tests
so that we can access internal members without polluting the public API.
Bug: 240432457
Test: atest PlatformComposeSceneTransitionLayoutTests
Flag: NA
Change-Id: I4ffceda155e836e360a2d8f562e2e3c43da8bbf0
diff --git a/packages/SystemUI/compose/scene/Android.bp b/packages/SystemUI/compose/scene/Android.bp
index 050d1d5..3424085 100644
--- a/packages/SystemUI/compose/scene/Android.bp
+++ b/packages/SystemUI/compose/scene/Android.bp
@@ -21,12 +21,19 @@
default_applicable_licenses: ["frameworks_base_packages_SystemUI_license"],
}
+filegroup {
+ name: "PlatformComposeSceneTransitionLayout-srcs",
+ srcs: [
+ "src/**/*.kt",
+ ],
+}
+
android_library {
name: "PlatformComposeSceneTransitionLayout",
manifest: "AndroidManifest.xml",
srcs: [
- "src/**/*.kt",
+ ":PlatformComposeSceneTransitionLayout-srcs",
],
static_libs: [
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt
index bc015ee..5b752eb 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt
@@ -43,7 +43,10 @@
name: String,
identity: Any = Object(),
) : Key(name, identity) {
- @VisibleForTesting val testTag: String = "scene:$name"
+ @VisibleForTesting
+ // TODO(b/240432457): Make internal once PlatformComposeSceneTransitionLayoutTestsUtils can
+ // access internal members.
+ val testTag: String = "scene:$name"
/** The unique [ElementKey] identifying this scene's root element. */
val rootElementKey = ElementKey(name, identity)
@@ -64,7 +67,10 @@
*/
val isBackground: Boolean = false,
) : Key(name, identity), ElementMatcher {
- @VisibleForTesting val testTag: String = "element:$name"
+ @VisibleForTesting
+ // TODO(b/240432457): Make internal once PlatformComposeSceneTransitionLayoutTestsUtils can
+ // access internal members.
+ val testTag: String = "element:$name"
override fun matches(key: ElementKey, scene: SceneKey): Boolean {
return key == this
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
index 838cb3b..c51287a 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneGestureHandler.kt
@@ -17,7 +17,6 @@
package com.android.compose.animation.scene
import android.util.Log
-import androidx.annotation.VisibleForTesting
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
@@ -37,8 +36,7 @@
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
-@VisibleForTesting
-class SceneGestureHandler(
+internal class SceneGestureHandler(
internal val layoutImpl: SceneTransitionLayoutImpl,
internal val orientation: Orientation,
private val coroutineScope: CoroutineScope,
@@ -63,12 +61,10 @@
internal val currentScene: Scene
get() = layoutImpl.scene(transitionState.currentScene)
- @VisibleForTesting
- val isDrivingTransition
+ internal val isDrivingTransition
get() = transitionState == swipeTransition
- @VisibleForTesting
- var isAnimatingOffset
+ internal var isAnimatingOffset
get() = swipeTransition.isAnimatingOffset
private set(value) {
swipeTransition.isAnimatingOffset = value
@@ -81,7 +77,7 @@
* The velocity threshold at which the intent of the user is to swipe up or down. It is the same
* as SwipeableV2Defaults.VelocityThreshold.
*/
- @VisibleForTesting val velocityThreshold = with(layoutImpl.density) { 125.dp.toPx() }
+ internal val velocityThreshold = with(layoutImpl.density) { 125.dp.toPx() }
/**
* The positional threshold at which the intent of the user is to swipe to the next scene. It is
@@ -533,8 +529,7 @@
}
}
-@VisibleForTesting
-class SceneNestedScrollHandler(
+internal class SceneNestedScrollHandler(
private val gestureHandler: SceneGestureHandler,
private val startBehavior: NestedScrollBehavior,
private val endBehavior: NestedScrollBehavior,
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
index 94f2737..60f385a 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
@@ -17,7 +17,6 @@
package com.android.compose.animation.scene
import androidx.activity.compose.BackHandler
-import androidx.annotation.VisibleForTesting
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
@@ -42,8 +41,7 @@
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.Channel
-@VisibleForTesting
-class SceneTransitionLayoutImpl(
+internal class SceneTransitionLayoutImpl(
onChangeScene: (SceneKey) -> Unit,
builder: SceneTransitionLayoutScope.() -> Unit,
transitions: SceneTransitions,
@@ -260,8 +258,7 @@
internal fun isSceneReady(scene: SceneKey): Boolean = readyScenes.containsKey(scene)
- @VisibleForTesting
- fun setScenesTargetSizeForTest(size: IntSize) {
+ internal fun setScenesTargetSizeForTest(size: IntSize) {
scenes.values.forEach { it.targetSize = size }
}
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt
index 72a2d61..2172ed3 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt
@@ -16,7 +16,6 @@
package com.android.compose.animation.scene
-import androidx.annotation.VisibleForTesting
import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.snap
import androidx.compose.ui.geometry.Offset
@@ -38,12 +37,11 @@
/** The transitions configuration of a [SceneTransitionLayout]. */
class SceneTransitions(
- @get:VisibleForTesting val transitionSpecs: List<TransitionSpec>,
+ internal val transitionSpecs: List<TransitionSpec>,
) {
private val cache = mutableMapOf<SceneKey, MutableMap<SceneKey, TransitionSpec>>()
- @VisibleForTesting
- fun transitionSpec(from: SceneKey, to: SceneKey): TransitionSpec {
+ internal fun transitionSpec(from: SceneKey, to: SceneKey): TransitionSpec {
return cache.getOrPut(from) { mutableMapOf() }.getOrPut(to) { findSpec(from, to) }
}
diff --git a/packages/SystemUI/compose/scene/tests/Android.bp b/packages/SystemUI/compose/scene/tests/Android.bp
index 6de7550..13df35b 100644
--- a/packages/SystemUI/compose/scene/tests/Android.bp
+++ b/packages/SystemUI/compose/scene/tests/Android.bp
@@ -30,10 +30,13 @@
srcs: [
"src/**/*.kt",
+
+ // TODO(b/240432457): Depend on PlatformComposeSceneTransitionLayout
+ // directly once Kotlin tests can access internal declarations.
+ ":PlatformComposeSceneTransitionLayout-srcs",
],
static_libs: [
- "PlatformComposeSceneTransitionLayout",
"PlatformComposeSceneTransitionLayoutTestsUtils",
"androidx.test.runner",