Loading packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt +2 −41 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 */ } Loading Loading @@ -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() } Loading Loading
packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt +2 −41 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 */ } Loading Loading @@ -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() } Loading