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

Commit 8a8f6cd2 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Revert "Revert "Don't implicitly add test tags to all elements a..."

Revert submission 31794863-stl-test-tags

Reason for revert: b/397580627

Reverted changes: /q/submissionid:31794863-stl-test-tags

Change-Id: I74d572a1433d589393cfbc03633e575082c825ba
parent a8c157b4
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.BouncerOverlay(
            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
@@ -66,6 +66,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(
@@ -74,6 +76,7 @@ fun SceneTransitionLayout(
        swipeSourceDetector,
        swipeDetector,
        transitionInterceptionThreshold,
        implicitTestTags = implicitTestTags,
        onLayoutImpl = null,
        builder = builder,
    )
@@ -727,10 +730,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(
@@ -743,6 +744,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
@@ -767,6 +769,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