diff options
| author | 2024-02-20 12:47:06 +0100 | |
|---|---|---|
| committer | 2024-02-20 13:12:36 +0100 | |
| commit | 08e50b87d92951466a4673d21c5f47e28a6564ae (patch) | |
| tree | 937195d389d0e90f2d93aa8473e35e00107cedb9 | |
| parent | 4f7007cfcf87b54d853ea8a446d8400ce02d5cb5 (diff) | |
Re-enable ElementTest#elementIsReusedBetweenScenes
This CL removes invalid assumptions made in
elementIsReusedInSameSceneAndBetweenScenes and renames it to
elementIsReusedBetweenScenes. See b/325120420 for details.
Bug: 326021461
Test: atest ElementTest
Flag: N/A
Change-Id: I7540b3265d501c086cd39e7e6f57309fb702abfb
| -rw-r--r-- | packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt | 45 |
1 files changed, 2 insertions, 43 deletions
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt index c9b5b75d6c49..33be1dc83dc8 100644 --- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt +++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt @@ -44,7 +44,6 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import kotlinx.coroutines.test.runTest import org.junit.Assert.assertThrows -import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith @@ -248,11 +247,9 @@ class ElementTest { } @Test - @Ignore - 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 @@ -270,19 +267,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 */ } @@ -315,35 +299,10 @@ class ElementTest { assertThat(layoutImpl.elements.getValue(key)).isSameInstanceAs(element) assertThat(element.sceneStates.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.sceneStates.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.sceneStates.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.sceneStates.keys).containsExactly(TestScenes.SceneD) - - // Scene D, state 2: the element is removed from the map. - sceneDState = 2 - rule.waitForIdle() - assertThat(element.sceneStates).isEmpty() assertThat(layoutImpl.elements).isEmpty() } |