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

Commit cdd45525 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Android (Google) Code Review
Browse files

Merge "Re-enable ElementTest#elementIsReusedBetweenScenes" into aosp-main-future

parents ca6f28e8 f46e3037
Loading
Loading
Loading
Loading
+2 −41
Original line number Diff line number Diff line
@@ -227,10 +227,9 @@ class ElementTest {
    }

    @Test
    fun elementIsReusedInSameSceneAndBetweenScenes() {
    fun elementIsReusedBetweenScenes() {
        var currentScene by mutableStateOf(TestScenes.SceneA)
        var sceneCState by mutableStateOf(0)
        var sceneDState by mutableStateOf(0)
        val key = TestElements.Foo
        var nullableLayoutImpl: SceneTransitionLayoutImpl? = null

@@ -250,19 +249,6 @@ class ElementTest {
                scene(TestScenes.SceneC) {
                    when (sceneCState) {
                        0 -> Row(Modifier.element(key)) {}
                        1 -> Column(Modifier.element(key)) {}
                        else -> {
                            /* Nothing */
                        }
                    }
                }
                scene(TestScenes.SceneD) {
                    // We should be able to extract the modifier before assigning it to different
                    // nodes.
                    val childModifier = Modifier.element(key)
                    when (sceneDState) {
                        0 -> Row(childModifier) {}
                        1 -> Column(childModifier) {}
                        else -> {
                            /* Nothing */
                        }
@@ -295,35 +281,10 @@ class ElementTest {
        assertThat(layoutImpl.elements.getValue(key)).isSameInstanceAs(element)
        assertThat(element.sceneValues.keys).containsExactly(TestScenes.SceneC)

        // Scene C, state 1: the same element is reused.
        // Scene C, state 1: the element is removed from the map.
        sceneCState = 1
        rule.waitForIdle()

        assertThat(layoutImpl.elements.keys).containsExactly(key)
        assertThat(layoutImpl.elements.getValue(key)).isSameInstanceAs(element)
        assertThat(element.sceneValues.keys).containsExactly(TestScenes.SceneC)

        // Scene D, state 0: the same element is reused.
        currentScene = TestScenes.SceneD
        sceneDState = 0
        rule.waitForIdle()

        assertThat(layoutImpl.elements.keys).containsExactly(key)
        assertThat(layoutImpl.elements.getValue(key)).isSameInstanceAs(element)
        assertThat(element.sceneValues.keys).containsExactly(TestScenes.SceneD)

        // Scene D, state 1: the same element is reused.
        sceneDState = 1
        rule.waitForIdle()

        assertThat(layoutImpl.elements.keys).containsExactly(key)
        assertThat(layoutImpl.elements.getValue(key)).isSameInstanceAs(element)
        assertThat(element.sceneValues.keys).containsExactly(TestScenes.SceneD)

        // Scene D, state 2: the element is removed from the map.
        sceneDState = 2
        rule.waitForIdle()

        assertThat(element.sceneValues).isEmpty()
        assertThat(layoutImpl.elements).isEmpty()
    }