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

Commit 3411977a authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Elements overscrolling on other scene should not affect interruption

Bug: 290930950
Test: ElementTest
Flag: com.android.systemui.scene_container
Change-Id: I7907ba3c0202bbf0dddd4f2f3f3819312c84596f
parent edc181e0
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -294,10 +294,9 @@ internal class ElementNode(
        val isNotPartOfAnyOngoingTransitions = transitions.isNotEmpty() && transition == null
        if (isNotPartOfAnyOngoingTransitions || isOtherSceneOverscrolling) {
            recursivelyClearPlacementValues()
            sceneState.lastSize = Element.SizeUnspecified

            val placeable = measurable.measure(constraints)
            sceneState.lastSize = placeable.size()

            return layout(placeable.width, placeable.height) { /* Do not place */ }
        }

+37 −0
Original line number Diff line number Diff line
@@ -1900,4 +1900,41 @@ class ElementTest {
        }
        rule.onNode(isElement(TestElements.Foo, SceneB)).assertPositionInRootIsEqualTo(20.dp, 20.dp)
    }

    @Test
    fun lastSizeIsUnspecifiedWhenOverscrollingOtherScene() = runTest {
        val state =
            rule.runOnIdle {
                MutableSceneTransitionLayoutStateImpl(
                    SceneA,
                    transitions { overscroll(SceneA, Orientation.Horizontal) }
                )
            }

        @Composable
        fun SceneScope.Foo() {
            Box(Modifier.element(TestElements.Foo).size(10.dp))
        }

        lateinit var layoutImpl: SceneTransitionLayoutImpl
        rule.setContent {
            SceneTransitionLayoutForTesting(state, onLayoutImpl = { layoutImpl = it }) {
                scene(SceneA) { Foo() }
                scene(SceneB) { Foo() }
            }
        }

        // Overscroll A => B on A.
        rule.runOnUiThread {
            state.startTransition(
                transition(from = SceneA, to = SceneB, progress = { -1f }, onFinish = neverFinish())
            )
        }
        rule.waitForIdle()

        assertThat(
                layoutImpl.elements.getValue(TestElements.Foo).sceneStates.getValue(SceneB).lastSize
            )
            .isEqualTo(Element.SizeUnspecified)
    }
}