diff --git a/redwood-layout-uiview/RedwoodLayoutUIViewTests/SnapshotTestingCallback.swift b/redwood-layout-uiview/RedwoodLayoutUIViewTests/SnapshotTestingCallback.swift index 9dd400b5d2..0e2ea66e4f 100644 --- a/redwood-layout-uiview/RedwoodLayoutUIViewTests/SnapshotTestingCallback.swift +++ b/redwood-layout-uiview/RedwoodLayoutUIViewTests/SnapshotTestingCallback.swift @@ -14,6 +14,6 @@ final class SnapshotTestingCallback : Redwood_snapshot_testingUIViewSnapshotCall func verifySnapshot(view: UIView, name: String?, delay: TimeInterval = 0.0) { // 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: .wait(for: delay, on: .image), named: name, record: false, file: fileName, testName: testName) + assertSnapshot(of: view, as: .wait(for: delay, on: .image), named: name, record: true, file: fileName, testName: testName) } } diff --git a/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ComposeUiTestWidgetFactory.kt b/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ComposeUiTestWidgetFactory.kt index 8cec622921..9a49ea3282 100644 --- a/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ComposeUiTestWidgetFactory.kt +++ b/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ComposeUiTestWidgetFactory.kt @@ -15,6 +15,9 @@ */ package app.cash.redwood.snapshot.testing +import androidx.compose.ui.unit.Dp as ComposeDp +import app.cash.redwood.Modifier as RedwoodModifier +import app.cash.redwood.snapshot.testing.Color as ColorWidget import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -32,11 +35,8 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.unit.Dp as ComposeDp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import app.cash.redwood.Modifier as RedwoodModifier -import app.cash.redwood.snapshot.testing.Color as ColorWidget import app.cash.redwood.ui.Dp import app.cash.redwood.ui.toPlatformDp @@ -113,6 +113,7 @@ class ComposeUiColumn : SimpleColumn<@Composable () -> Unit> { override var modifier: RedwoodModifier = RedwoodModifier override val value = @Composable { + // We'd like to pass Modifier.fillMaxWidth() to all children. Column { for (child in children) { child() diff --git a/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ViewTestWidgetFactory.kt b/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ViewTestWidgetFactory.kt index e74ee63c43..fcdcc8da22 100644 --- a/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ViewTestWidgetFactory.kt +++ b/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ViewTestWidgetFactory.kt @@ -18,6 +18,7 @@ package app.cash.redwood.snapshot.testing import android.content.Context import android.view.Gravity import android.view.View +import android.view.ViewGroup import android.widget.LinearLayout import android.widget.ScrollView import android.widget.TextView @@ -67,7 +68,17 @@ class ViewColor(context: Context) : Color { private val density = Density(context.resources) override val value = object : View(context) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { - setMeasuredDimension(minimumWidth, minimumHeight) + val width = when (MeasureSpec.getMode(widthMeasureSpec)) { + MeasureSpec.EXACTLY -> MeasureSpec.getSize(widthMeasureSpec) + MeasureSpec.AT_MOST -> minimumWidth.coerceAtMost(MeasureSpec.getSize(widthMeasureSpec)) + else -> minimumWidth + } + val height = when (MeasureSpec.getMode(heightMeasureSpec)) { + MeasureSpec.EXACTLY -> MeasureSpec.getSize(heightMeasureSpec) + MeasureSpec.AT_MOST -> minimumHeight.coerceAtMost(MeasureSpec.getSize(heightMeasureSpec)) + else -> minimumHeight + } + setMeasuredDimension(width, height) } } override var modifier: Modifier = Modifier @@ -97,7 +108,13 @@ class ViewSimpleColumn(context: Context) : SimpleColumn { override var modifier: Modifier = Modifier override fun add(child: View) { - value.addView(child) + value.addView( + child, + ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT, + ), + ) } } diff --git a/redwood-snapshot-testing/src/iosMain/kotlin/app/cash/redwood/snapshot/testing/UIViewTestWidgetFactory.kt b/redwood-snapshot-testing/src/iosMain/kotlin/app/cash/redwood/snapshot/testing/UIViewTestWidgetFactory.kt index 634b0020ef..ab542c5cbb 100644 --- a/redwood-snapshot-testing/src/iosMain/kotlin/app/cash/redwood/snapshot/testing/UIViewTestWidgetFactory.kt +++ b/redwood-snapshot-testing/src/iosMain/kotlin/app/cash/redwood/snapshot/testing/UIViewTestWidgetFactory.kt @@ -32,8 +32,8 @@ import platform.UIKit.UILabel import platform.UIKit.UILayoutConstraintAxisVertical import platform.UIKit.UIScrollView import platform.UIKit.UIStackView -import platform.UIKit.UIStackViewAlignmentLeading -import platform.UIKit.UIStackViewDistributionFill +import platform.UIKit.UIStackViewAlignmentFill +import platform.UIKit.UIStackViewDistributionEqualSpacing import platform.UIKit.UIView object UIViewTestWidgetFactory : TestWidgetFactory { @@ -120,8 +120,8 @@ class UIViewSimpleColumn : SimpleColumn { override val value = UIStackView(CGRectZero.readValue()).apply { this.axis = UILayoutConstraintAxisVertical - this.alignment = UIStackViewAlignmentLeading - this.distribution = UIStackViewDistributionFill + this.alignment = UIStackViewAlignmentFill + this.distribution = UIStackViewDistributionEqualSpacing } override fun add(child: UIView) { @@ -144,8 +144,8 @@ class UIViewScrollWrapper : ScrollWrapper { scrollView.addSubview(value) value.translatesAutoresizingMaskIntoConstraints = false value.leadingAnchor.constraintEqualToAnchor(scrollView.leadingAnchor).active = true + value.widthAnchor.constraintEqualToAnchor(scrollView.widthAnchor).active = true value.topAnchor.constraintEqualToAnchor(scrollView.topAnchor).active = true - value.trailingAnchor.constraintEqualToAnchor(scrollView.trailingAnchor).active = true value.bottomAnchor.constraintEqualToAnchor(scrollView.bottomAnchor).active = true } } diff --git a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/SnapshotTestingCallback.swift b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/SnapshotTestingCallback.swift index 879e557d77..19d1f4f276 100644 --- a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/SnapshotTestingCallback.swift +++ b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/SnapshotTestingCallback.swift @@ -14,6 +14,6 @@ final class SnapshotTestingCallback : Redwood_snapshot_testingUIViewSnapshotCall func verifySnapshot(view: UIView, name: String?, delay: TimeInterval = 0.0) { // 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: .wait(for: delay, on: .image), named: name, record: false, file: fileName, testName: testName) + assertSnapshot(of: view, as: .wait(for: delay, on: .image), named: name, record: true, file: fileName, testName: testName) } } diff --git a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize.1.png b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize.1.png index c559091c5c..16b689c88d 100644 --- a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize.1.png +++ b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0d9d64df4e24b76af287489cfd2f1d506bd26f5005d366480efab49d6a73ea22 -size 71420 +oid sha256:a9b7b952dc41d9b2fae998cda7338ef3441e4633deab1160abf14ad02a225e0e +size 68141 diff --git a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._1.png b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._1.png index 5eb11fb06c..fe11d5ec68 100644 --- a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._1.png +++ b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8edfed83820c4070200271fe23953c773c433fb61d76682872a6daf3fa1d8409 -size 73100 +oid sha256:f7eca4381bcd9fc30536eb2bcb57d7465e6501218c423141d36adc41e029f59e +size 68807 diff --git a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._2.png b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._2.png index c166a99317..c4c8281bd9 100644 --- a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._2.png +++ b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eea2bb3446b525db632a2c2f5c27b06175b6fef1a3e98e495cde25e3d85ae970 -size 71108 +oid sha256:2023a9195d38536a1dc09c7e8e0b1a8d6dfd09c8bfc6376edfd2394570790d86 +size 68598 diff --git a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testWrapped.1.png b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testWrapped.1.png index 051c936bd4..00d27a6498 100644 --- a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testWrapped.1.png +++ b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testWrapped.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b1c5d640a7c2d60a1e730cd042fbd6e82982923e8a37bb4d14ad51acceb27dd -size 62199 +oid sha256:b11eca15f92c14f0c3220914b92e217eca89c9b53c0043e40ea5ef0cb7436ce0 +size 59948 diff --git a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize.png b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize.png index 82834e7360..033d89e27c 100644 --- a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize.png +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f54ab5877144719d3310aa5f24fee3b1022dbad589ca1e00f5e5dfa5470b236f -size 6460 +oid sha256:587e1a65cdc6fca5ad9b005bceb387e64cb0cc6f94b2ac54ec3a391e38e861f0 +size 4173 diff --git a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize__1.png b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize__1.png index 0b843ffed4..582dfd7d9c 100644 --- a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize__1.png +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize__1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4833fa2383690045a88971f57c431aa510e97d1f599c71d63c9a36827510f73d -size 6370 +oid sha256:ef8757ddfcce879456bdc1a28e09f7db329e7935eef1432502cbdfb7a4d0c757 +size 3944 diff --git a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize__2.png b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize__2.png index 3ce4008575..38d39f0ff1 100644 --- a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize__2.png +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize__2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0b332e7f7d1041a05ac7ef236c5aa9eae89fff66211ab9c9418893a7fd5e172c -size 6435 +oid sha256:e8aa02564fee06822e2b3e4a8af0fe8adf7b54c9e8f4f637fe8c646df3f757a9 +size 4181 diff --git a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testWrapped.png b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testWrapped.png index 2a5266a17b..0000047723 100644 --- a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testWrapped.png +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testWrapped.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d99576bc950f42850702f4e43af52ffd2f2c2bd5629c46d6b363bdf4d4571271 -size 4811 +oid sha256:06d141323fd0858da1246cfa0d4e097685aed8eb5803e5f44494db3026d4d83a +size 4192 diff --git a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize.png b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize.png index 2a3ca996b7..6e84a0a4ea 100644 --- a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize.png +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:525fc7a9b088a11d1aef7266c64f23e2ef5f9260b5da6c3abbda9fa18e2be59a -size 6148 +oid sha256:dc60862740838f50ade2ba3113dfd938c68a959b1bfe126f681f2bcbc7c5abcf +size 4178 diff --git a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize__1.png b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize__1.png index 7ebad69d4c..046444f9ea 100644 --- a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize__1.png +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize__1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58c3fa683afb55bfbc4c9e3306bebcfc525119606efc5e0f9438e5b71f2561a4 -size 6097 +oid sha256:c996281c406946c4d16150e0dcdef25fb9b24a779a4fc4366f43fd01628c72bb +size 3945 diff --git a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize__2.png b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize__2.png index ae118a15d7..54991b7be0 100644 --- a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize__2.png +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize__2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:146ec24fcd9deae813ebc5cd33b9995021e9c915435b35a3548c0088447fe39f -size 6149 +oid sha256:f27e15b984683ae6e92d92e400471500b259594e61461d484ca9e59dbb54bc12 +size 4178 diff --git a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testWrapped.png b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testWrapped.png index 87834285b3..0000047723 100644 --- a/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testWrapped.png +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testWrapped.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:624e2fd35536f878ac4f7156f8525ec1361ac7668c83380a33165acf4d34c610 -size 4789 +oid sha256:06d141323fd0858da1246cfa0d4e097685aed8eb5803e5f44494db3026d4d83a +size 4192