From 59a660046d17ddb7242753be214b56f982016bd2 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Fri, 17 Nov 2023 11:57:24 -0800 Subject: [PATCH] Test layout content changes (#1687) * Test layout content changes We were missing tests for items being removed from Column, etc. * Add iOS snapshots for the new test * Spotless --- .../composeui/ComposeUiFlexContainerTest.kt | 12 +++++++++- ...t_testDynamicElementUpdates[LTR]_abcde.png | 3 +++ ...st_testDynamicElementUpdates[LTR]_abde.png | 3 +++ ...st_testDynamicElementUpdates[LTR]_bcde.png | 3 +++ ...t_testDynamicElementUpdates[RTL]_abcde.png | 3 +++ ...st_testDynamicElementUpdates[RTL]_abde.png | 3 +++ ...st_testDynamicElementUpdates[RTL]_bcde.png | 3 +++ .../layout/AbstractFlexContainerTest.kt | 24 +++++++++++++++++++ .../SnapshotTestingCallback.swift | 4 +++- .../testDynamicElementUpdates.ABCDE.png | 3 +++ .../testDynamicElementUpdates.ABDE.png | 3 +++ .../testDynamicElementUpdates.BCDE.png | 3 +++ .../layout/uiview/UIViewFlexContainerTest.kt | 12 +++++++++- .../layout/view/ViewFlexContainerTest.kt | 12 +++++++++- ...t_testDynamicElementUpdates[LTR]_abcde.png | 3 +++ ...st_testDynamicElementUpdates[LTR]_abde.png | 3 +++ ...st_testDynamicElementUpdates[LTR]_bcde.png | 3 +++ ...t_testDynamicElementUpdates[RTL]_abcde.png | 3 +++ ...st_testDynamicElementUpdates[RTL]_abde.png | 3 +++ ...st_testDynamicElementUpdates[RTL]_bcde.png | 3 +++ .../layout/composeui/ComposeUiLazyListTest.kt | 12 +++++++++- ...t_testDynamicElementUpdates[LTR]_abcde.png | 3 +++ ...st_testDynamicElementUpdates[LTR]_abde.png | 3 +++ ...st_testDynamicElementUpdates[LTR]_bcde.png | 3 +++ ...t_testDynamicElementUpdates[RTL]_abcde.png | 3 +++ ...st_testDynamicElementUpdates[RTL]_abde.png | 3 +++ ...st_testDynamicElementUpdates[RTL]_bcde.png | 3 +++ .../lazylayout/view/ViewLazyListTest.kt | 12 +++++++++- ...t_testDynamicElementUpdates[LTR]_abcde.png | 3 +++ ...st_testDynamicElementUpdates[LTR]_abde.png | 3 +++ ...st_testDynamicElementUpdates[LTR]_bcde.png | 3 +++ ...t_testDynamicElementUpdates[RTL]_abcde.png | 3 +++ ...st_testDynamicElementUpdates[RTL]_abde.png | 3 +++ ...st_testDynamicElementUpdates[RTL]_bcde.png | 3 +++ 34 files changed, 163 insertions(+), 6 deletions(-) create mode 100644 redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_abcde.png create mode 100644 redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_abde.png create mode 100644 redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_bcde.png create mode 100644 redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_abcde.png create mode 100644 redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_abde.png create mode 100644 redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_bcde.png create mode 100644 redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.ABCDE.png create mode 100644 redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.ABDE.png create mode 100644 redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.BCDE.png create mode 100644 redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_abcde.png create mode 100644 redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_abde.png create mode 100644 redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_bcde.png create mode 100644 redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_abcde.png create mode 100644 redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_abde.png create mode 100644 redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_bcde.png create mode 100644 redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_abcde.png create mode 100644 redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_abde.png create mode 100644 redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_bcde.png create mode 100644 redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_abcde.png create mode 100644 redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_abde.png create mode 100644 redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_bcde.png create mode 100644 redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_abcde.png create mode 100644 redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_abde.png create mode 100644 redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_bcde.png create mode 100644 redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_abcde.png create mode 100644 redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_abde.png create mode 100644 redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_bcde.png diff --git a/redwood-layout-composeui/src/androidUnitTest/kotlin/app/cash/redwood/layout/composeui/ComposeUiFlexContainerTest.kt b/redwood-layout-composeui/src/androidUnitTest/kotlin/app/cash/redwood/layout/composeui/ComposeUiFlexContainerTest.kt index 12640184b4..f0d7c643b3 100644 --- a/redwood-layout-composeui/src/androidUnitTest/kotlin/app/cash/redwood/layout/composeui/ComposeUiFlexContainerTest.kt +++ b/redwood-layout-composeui/src/androidUnitTest/kotlin/app/cash/redwood/layout/composeui/ComposeUiFlexContainerTest.kt @@ -90,7 +90,17 @@ class ComposeUiFlexContainerTest( ) override fun add(widget: Widget<@Composable () -> Unit>) { - delegate.children.insert(childCount++, widget) + addAt(childCount, widget) + } + + override fun addAt(index: Int, widget: Widget<() -> Unit>) { + delegate.children.insert(index, widget) + childCount++ + } + + override fun removeAt(index: Int) { + delegate.children.remove(index = index, count = 1) + childCount-- } override fun onEndChanges() { diff --git a/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_abcde.png b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_abcde.png new file mode 100644 index 0000000000..fa9eee49e8 --- /dev/null +++ b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_abcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84c70ea7306c335b4f5ef372d5e49b4ce71e4800660f3a9e40613681ff572948 +size 5307 diff --git a/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_abde.png b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_abde.png new file mode 100644 index 0000000000..67f0d8af8f --- /dev/null +++ b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_abde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3def4c79fa6ff36bc428a00d2d866425f067426a3ede81a39ba986cfbdc17524 +size 4970 diff --git a/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_bcde.png b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_bcde.png new file mode 100644 index 0000000000..08b4d43983 --- /dev/null +++ b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[LTR]_bcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:647993ec7eacd77063d68f106b7eae9750146c1838bcbb5507566548c04d0c99 +size 4976 diff --git a/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_abcde.png b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_abcde.png new file mode 100644 index 0000000000..91497717ff --- /dev/null +++ b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_abcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:25dfe344b7703b0cf63b37f29b03cddb2d781072935776702ec4ceb0e558b9c5 +size 5333 diff --git a/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_abde.png b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_abde.png new file mode 100644 index 0000000000..e48f4b9b31 --- /dev/null +++ b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_abde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d783dfafea012c945fd2d9eacbf4495235fce067e8024226c26332854a065163 +size 5013 diff --git a/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_bcde.png b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_bcde.png new file mode 100644 index 0000000000..b6fd97cb95 --- /dev/null +++ b/redwood-layout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiFlexContainerTest_testDynamicElementUpdates[RTL]_bcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bcb08a179e8e6210300536fb791f496fc2b89d14230b6110b92a72f23c54b74c +size 5037 diff --git a/redwood-layout-shared-test/src/commonMain/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt b/redwood-layout-shared-test/src/commonMain/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt index 0012f8e9a7..03fbd0ba1d 100644 --- a/redwood-layout-shared-test/src/commonMain/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt +++ b/redwood-layout-shared-test/src/commonMain/kotlin/app/cash/redwood/layout/AbstractFlexContainerTest.kt @@ -415,6 +415,28 @@ abstract class AbstractFlexContainerTest { verifySnapshot(column) } + @Test + fun testDynamicElementUpdates() { + val container = flexContainer(FlexDirection.Column) + container.width(Constraint.Fill) + container.height(Constraint.Fill) + container.add(widget("A")) + container.add(widget("B")) + container.add(widget("D")) + container.add(widget("E")) + + container.onEndChanges() + verifySnapshot(container, "ABDE") + + container.addAt(index = 2, widget = widget("C")) + container.onEndChanges() + verifySnapshot(container, "ABCDE") + + container.removeAt(index = 0) + container.onEndChanges() + verifySnapshot(container, "BCDE") + } + /** We don't have assume() on kotlin.test. Tests that fail here should be skipped instead. */ private fun assumeTrue(b: Boolean) { assertTrue(b) @@ -429,6 +451,8 @@ interface TestFlexContainer : Widget, ChangeListener { fun mainAxisAlignment(mainAxisAlignment: MainAxisAlignment) fun margin(margin: Margin) fun add(widget: Widget) + fun addAt(index: Int, widget: Widget) + fun removeAt(index: Int) } interface Text : Widget { diff --git a/redwood-layout-uiview/RedwoodLayoutUIViewTests/SnapshotTestingCallback.swift b/redwood-layout-uiview/RedwoodLayoutUIViewTests/SnapshotTestingCallback.swift index ebde35122f..41ab23050e 100644 --- a/redwood-layout-uiview/RedwoodLayoutUIViewTests/SnapshotTestingCallback.swift +++ b/redwood-layout-uiview/RedwoodLayoutUIViewTests/SnapshotTestingCallback.swift @@ -12,6 +12,8 @@ final class SnapshotTestingCallback : UIViewSnapshotCallback { } func verifySnapshot(view: UIView, name: String?) { - assertSnapshot(of: view, as: .image, named: name, file: fileName, testName: testName) + // Set `record` to true to generate new snapshots. Be sure to revert that before committing! + // Note that tests always fail when `record` is true. + assertSnapshot(of: view, as: .image, named: name, record: false, file: fileName, testName: testName) } } diff --git a/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.ABCDE.png b/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.ABCDE.png new file mode 100644 index 0000000000..3f2ea20b8c --- /dev/null +++ b/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.ABCDE.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d7d2a342b6c121e44d48e64175f4cc6853f6acdccbea0631969fdb76a917fd2 +size 68997 diff --git a/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.ABDE.png b/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.ABDE.png new file mode 100644 index 0000000000..e97e191375 --- /dev/null +++ b/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.ABDE.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2162a6fccffb3d28208bc0127f25ac225914a8e5d933605df1c6a144d48935f3 +size 68142 diff --git a/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.BCDE.png b/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.BCDE.png new file mode 100644 index 0000000000..98d4e47139 --- /dev/null +++ b/redwood-layout-uiview/RedwoodLayoutUIViewTests/__Snapshots__/UIViewFlexContainerTestHost/testDynamicElementUpdates.BCDE.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5e090f271547a8ee7a8ac8cca2365c0eb987d5b3d1dc2f5a6c010fcca21d1e4 +size 68213 diff --git a/redwood-layout-uiview/src/commonTest/kotlin/app/cash/redwood/layout/uiview/UIViewFlexContainerTest.kt b/redwood-layout-uiview/src/commonTest/kotlin/app/cash/redwood/layout/uiview/UIViewFlexContainerTest.kt index 8ed33a6762..e5a76a3591 100644 --- a/redwood-layout-uiview/src/commonTest/kotlin/app/cash/redwood/layout/uiview/UIViewFlexContainerTest.kt +++ b/redwood-layout-uiview/src/commonTest/kotlin/app/cash/redwood/layout/uiview/UIViewFlexContainerTest.kt @@ -61,7 +61,17 @@ class UIViewFlexContainerTest( } override fun add(widget: Widget) { - delegate.children.insert(childCount++, widget) + addAt(childCount, widget) + } + + override fun addAt(index: Int, widget: Widget) { + delegate.children.insert(index, widget) + childCount++ + } + + override fun removeAt(index: Int) { + delegate.children.remove(index = index, count = 1) + childCount-- } } diff --git a/redwood-layout-view/src/test/kotlin/app/cash/redwood/layout/view/ViewFlexContainerTest.kt b/redwood-layout-view/src/test/kotlin/app/cash/redwood/layout/view/ViewFlexContainerTest.kt index a778b4dc8f..67033ca52d 100644 --- a/redwood-layout-view/src/test/kotlin/app/cash/redwood/layout/view/ViewFlexContainerTest.kt +++ b/redwood-layout-view/src/test/kotlin/app/cash/redwood/layout/view/ViewFlexContainerTest.kt @@ -83,7 +83,17 @@ class ViewFlexContainerTest( ) override fun add(widget: Widget) { - delegate.children.insert(childCount++, widget) + addAt(childCount, widget) + } + + override fun addAt(index: Int, widget: Widget) { + delegate.children.insert(index, widget) + childCount++ + } + + override fun removeAt(index: Int) { + delegate.children.remove(index = index, count = 1) + childCount-- } } } diff --git a/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_abcde.png b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_abcde.png new file mode 100644 index 0000000000..fa9eee49e8 --- /dev/null +++ b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_abcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:84c70ea7306c335b4f5ef372d5e49b4ce71e4800660f3a9e40613681ff572948 +size 5307 diff --git a/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_abde.png b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_abde.png new file mode 100644 index 0000000000..67f0d8af8f --- /dev/null +++ b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_abde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3def4c79fa6ff36bc428a00d2d866425f067426a3ede81a39ba986cfbdc17524 +size 4970 diff --git a/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_bcde.png b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_bcde.png new file mode 100644 index 0000000000..08b4d43983 --- /dev/null +++ b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[LTR]_bcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:647993ec7eacd77063d68f106b7eae9750146c1838bcbb5507566548c04d0c99 +size 4976 diff --git a/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_abcde.png b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_abcde.png new file mode 100644 index 0000000000..91497717ff --- /dev/null +++ b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_abcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:25dfe344b7703b0cf63b37f29b03cddb2d781072935776702ec4ceb0e558b9c5 +size 5333 diff --git a/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_abde.png b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_abde.png new file mode 100644 index 0000000000..e48f4b9b31 --- /dev/null +++ b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_abde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d783dfafea012c945fd2d9eacbf4495235fce067e8024226c26332854a065163 +size 5013 diff --git a/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_bcde.png b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_bcde.png new file mode 100644 index 0000000000..b6fd97cb95 --- /dev/null +++ b/redwood-layout-view/src/test/snapshots/images/app.cash.redwood.layout.view_ViewFlexContainerTest_testDynamicElementUpdates[RTL]_bcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bcb08a179e8e6210300536fb791f496fc2b89d14230b6110b92a72f23c54b74c +size 5037 diff --git a/redwood-lazylayout-composeui/src/androidUnitTest/kotlin/app/cash/redwood/layout/composeui/ComposeUiLazyListTest.kt b/redwood-lazylayout-composeui/src/androidUnitTest/kotlin/app/cash/redwood/layout/composeui/ComposeUiLazyListTest.kt index d02c8d6678..b1dee1383d 100644 --- a/redwood-lazylayout-composeui/src/androidUnitTest/kotlin/app/cash/redwood/layout/composeui/ComposeUiLazyListTest.kt +++ b/redwood-lazylayout-composeui/src/androidUnitTest/kotlin/app/cash/redwood/layout/composeui/ComposeUiLazyListTest.kt @@ -96,7 +96,17 @@ class ComposeUiLazyListTest( } override fun add(widget: Widget<@Composable () -> Unit>) { - delegate.items.insert(childCount++, widget) + addAt(childCount, widget) + } + + override fun addAt(index: Int, widget: Widget<() -> Unit>) { + delegate.items.insert(index, widget) + childCount++ + } + + override fun removeAt(index: Int) { + delegate.items.remove(index = index, count = 1) + childCount-- } override fun onEndChanges() { diff --git a/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_abcde.png b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_abcde.png new file mode 100644 index 0000000000..c34ed55a5d --- /dev/null +++ b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_abcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:447b60563e10b2a9447bcbb12063cf3e64ef565801072685f46b27bc5a69b2ed +size 5112 diff --git a/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_abde.png b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_abde.png new file mode 100644 index 0000000000..053b9d62bf --- /dev/null +++ b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_abde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bad1bb41743071c9468d065da2e06d1e36e1c08f2ddfdd5ce7f379d7942580db +size 4805 diff --git a/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_bcde.png b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_bcde.png new file mode 100644 index 0000000000..2ab047ce56 --- /dev/null +++ b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[LTR]_bcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aeb31084a2a8a4cfe5c650451e294f5bc2211455470a400e96fbe8dba943dd27 +size 4817 diff --git a/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_abcde.png b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_abcde.png new file mode 100644 index 0000000000..2e529eea4e --- /dev/null +++ b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_abcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:165f80e674d1354b42612c3e335548b1ba714752c7e2b5204c6ca44e6816bc68 +size 5208 diff --git a/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_abde.png b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_abde.png new file mode 100644 index 0000000000..792b6e2f5e --- /dev/null +++ b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_abde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04416c3b64a1e6e1543be3a65785ebf4a4891ae9523ff01ee9444e7af38efbf5 +size 4905 diff --git a/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_bcde.png b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_bcde.png new file mode 100644 index 0000000000..382803840d --- /dev/null +++ b/redwood-lazylayout-composeui/src/test/snapshots/images/app.cash.redwood.layout.composeui_ComposeUiLazyListTest_testDynamicElementUpdates[RTL]_bcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b9086943c97c3353418a09124b4231700cd3adf9a2d8ddc7e316df22c69fca4 +size 4897 diff --git a/redwood-lazylayout-view/src/test/kotlin/app/cash/redwood/lazylayout/view/ViewLazyListTest.kt b/redwood-lazylayout-view/src/test/kotlin/app/cash/redwood/lazylayout/view/ViewLazyListTest.kt index 03ef65f729..c032a67234 100644 --- a/redwood-lazylayout-view/src/test/kotlin/app/cash/redwood/lazylayout/view/ViewLazyListTest.kt +++ b/redwood-lazylayout-view/src/test/kotlin/app/cash/redwood/lazylayout/view/ViewLazyListTest.kt @@ -85,7 +85,17 @@ class ViewLazyListTest( } override fun add(widget: Widget) { - delegate.items.insert(childCount++, widget) + addAt(childCount, widget) + } + + override fun addAt(index: Int, widget: Widget) { + delegate.items.insert(index, widget) + childCount++ + } + + override fun removeAt(index: Int) { + delegate.items.remove(index = index, count = 1) + childCount-- } } } diff --git a/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_abcde.png b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_abcde.png new file mode 100644 index 0000000000..c34ed55a5d --- /dev/null +++ b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_abcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:447b60563e10b2a9447bcbb12063cf3e64ef565801072685f46b27bc5a69b2ed +size 5112 diff --git a/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_abde.png b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_abde.png new file mode 100644 index 0000000000..053b9d62bf --- /dev/null +++ b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_abde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bad1bb41743071c9468d065da2e06d1e36e1c08f2ddfdd5ce7f379d7942580db +size 4805 diff --git a/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_bcde.png b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_bcde.png new file mode 100644 index 0000000000..2ab047ce56 --- /dev/null +++ b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[LTR]_bcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aeb31084a2a8a4cfe5c650451e294f5bc2211455470a400e96fbe8dba943dd27 +size 4817 diff --git a/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_abcde.png b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_abcde.png new file mode 100644 index 0000000000..2e529eea4e --- /dev/null +++ b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_abcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:165f80e674d1354b42612c3e335548b1ba714752c7e2b5204c6ca44e6816bc68 +size 5208 diff --git a/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_abde.png b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_abde.png new file mode 100644 index 0000000000..792b6e2f5e --- /dev/null +++ b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_abde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04416c3b64a1e6e1543be3a65785ebf4a4891ae9523ff01ee9444e7af38efbf5 +size 4905 diff --git a/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_bcde.png b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_bcde.png new file mode 100644 index 0000000000..382803840d --- /dev/null +++ b/redwood-lazylayout-view/src/test/snapshots/images/app.cash.redwood.lazylayout.view_ViewLazyListTest_testDynamicElementUpdates[RTL]_bcde.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3b9086943c97c3353418a09124b4231700cd3adf9a2d8ddc7e316df22c69fca4 +size 4897