Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92efbbfc authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Don't implicitly add test tags to all elements and scenes (1/2)

Bug: 393516240
Test: atest PlatformComposeSceneTransitionLayoutTests
Flag: com.android.systemui.scene_container
Change-Id: I1bf8f90ecbc32e185f18479b3409f9ba01e5ed1f
parent e018f198
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import com.android.compose.animation.scene.ContentScope
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.UserAction
@@ -102,6 +103,8 @@ private fun ContentScope.BouncerScene(
            viewModel,
            dialogFactory,
            Modifier.element(Bouncer.Elements.Content)
                // TODO(b/393516240): Use the same sysuiResTag() as views instead.
                .testTag(Bouncer.Elements.Content.testTag)
                .overscroll(verticalOverscrollEffect)
                .sysuiResTag(Bouncer.TestTags.Root)
                .fillMaxSize(),
+6 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.composable
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import com.android.compose.animation.scene.ContentScope
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
@@ -55,7 +56,11 @@ constructor(

    @Composable
    override fun ContentScope.Content(modifier: Modifier) {
        LockscreenScene(lockscreenContent = lockscreenContent, modifier = modifier)
        LockscreenScene(
            lockscreenContent = lockscreenContent,
            // TODO(b/393516240): Use the same sysuiResTag() as views instead.
            modifier = modifier.testTag(key.rootElementKey.testTag),
        )
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ internal fun Modifier.element(
            Modifier.maybeElevateInContent(layoutImpl, content, key, currentTransitionStates)
        }
        .then(ElementModifier(layoutImpl, currentTransitionStates, content, key))
        .testTag(key.testTag)
        .thenIf(layoutImpl.implicitTestTags) { Modifier.testTag(key.testTag) }
}

/**
+7 −4
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ fun SceneTransitionLayout(
    swipeSourceDetector: SwipeSourceDetector = DefaultEdgeDetector,
    swipeDetector: SwipeDetector = DefaultSwipeDetector,
    @FloatRange(from = 0.0, to = 0.5) transitionInterceptionThreshold: Float = 0.05f,
    // TODO(b/240432457) Remove this once test utils can access the internal STLForTesting().
    implicitTestTags: Boolean = false,
    builder: SceneTransitionLayoutScope<ContentScope>.() -> Unit,
) {
    SceneTransitionLayoutForTesting(
@@ -73,6 +75,7 @@ fun SceneTransitionLayout(
        swipeSourceDetector,
        swipeDetector,
        transitionInterceptionThreshold,
        implicitTestTags = implicitTestTags,
        onLayoutImpl = null,
        builder = builder,
    )
@@ -725,10 +728,8 @@ class FixedDistance(private val distance: Dp) : UserActionDistance {
}

/**
 * An internal version of [SceneTransitionLayout] to be used for tests.
 *
 * Important: You should use this only in tests and if you need to access the underlying
 * [SceneTransitionLayoutImpl]. In other cases, you should use [SceneTransitionLayout].
 * An internal version of [SceneTransitionLayout] to be used for tests, that provides access to the
 * internal [SceneTransitionLayoutImpl] and implicitly tags all scenes and elements.
 */
@Composable
internal fun SceneTransitionLayoutForTesting(
@@ -741,6 +742,7 @@ internal fun SceneTransitionLayoutForTesting(
    sharedElementMap: MutableMap<ElementKey, Element> = remember { mutableMapOf() },
    ancestors: List<Ancestor> = remember { emptyList() },
    lookaheadScope: LookaheadScope? = null,
    implicitTestTags: Boolean = true,
    builder: SceneTransitionLayoutScope<InternalContentScope>.() -> Unit,
) {
    val density = LocalDensity.current
@@ -765,6 +767,7 @@ internal fun SceneTransitionLayoutForTesting(
                directionChangeSlop = directionChangeSlop,
                defaultEffectFactory = defaultEffectFactory,
                decayAnimationSpec = decayAnimationSpec,
                implicitTestTags = implicitTestTags,
            )
            .also { onLayoutImpl?.invoke(it) }
    }
+3 −0
Original line number Diff line number Diff line
@@ -122,6 +122,9 @@ internal class SceneTransitionLayoutImpl(
     * This is used to enable transformations and shared elements across NestedSTLs.
     */
    internal val ancestors: List<Ancestor> = emptyList(),

    /** Whether elements and scene should be tagged using `Modifier.testTag`. */
    internal val implicitTestTags: Boolean = false,
    lookaheadScope: LookaheadScope? = null,
    defaultEffectFactory: OverscrollFactory,
) {
Loading