diff --git a/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ComposeSnapshotter.kt b/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ComposeSnapshotter.kt index f8a9600462..b51430956f 100644 --- a/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ComposeSnapshotter.kt +++ b/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ComposeSnapshotter.kt @@ -22,7 +22,7 @@ class ComposeSnapshotter( private val paparazzi: Paparazzi, private val widget: @Composable () -> Unit, ) : Snapshotter { - override fun snapshot(name: String?) { + override fun snapshot(name: String?, scrolling: Boolean) { paparazzi.snapshot(name, widget) } } 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 4715949dfe..8cec622921 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 @@ -17,11 +17,15 @@ package app.cash.redwood.snapshot.testing import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.size +import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.BasicText +import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment @@ -40,6 +44,10 @@ object ComposeUiTestWidgetFactory : TestWidgetFactory<@Composable () -> Unit> { override fun color(): ColorWidget<@Composable () -> Unit> = ComposeUiColor() override fun text(): Text<@Composable () -> Unit> = ComposeUiText() + + override fun column(): SimpleColumn<@Composable () -> Unit> = ComposeUiColumn() + + override fun scrollWrapper(): ScrollWrapper<@Composable () -> Unit> = ComposeUiScrollWrapper() } class ComposeUiText : Text<@Composable () -> Unit> { @@ -98,3 +106,36 @@ class ComposeUiColor : ColorWidget<@Composable () -> Unit> { internal fun Dp.toDp(): ComposeDp { return ComposeDp(toPlatformDp().toFloat()) } + +class ComposeUiColumn : SimpleColumn<@Composable () -> Unit> { + private val children = mutableStateListOf<@Composable () -> Unit>() + + override var modifier: RedwoodModifier = RedwoodModifier + + override val value = @Composable { + Column { + for (child in children) { + child() + } + } + } + + override fun add(child: @Composable () -> Unit) { + children.add(child) + } +} + +class ComposeUiScrollWrapper : ScrollWrapper<@Composable () -> Unit> { + override var content: (@Composable () -> Unit)? = null + + override var modifier: RedwoodModifier = RedwoodModifier + + override val value = @Composable { + val state = rememberScrollState() + Column( + modifier = Modifier.verticalScroll(state), + ) { + content?.invoke() + } + } +} diff --git a/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ViewSnapshotter.kt b/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ViewSnapshotter.kt index 840fce0b88..65e80d24f9 100644 --- a/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ViewSnapshotter.kt +++ b/redwood-snapshot-testing/src/androidMain/kotlin/app/cash/redwood/snapshot/testing/ViewSnapshotter.kt @@ -22,7 +22,22 @@ class ViewSnapshotter( private val paparazzi: Paparazzi, private val view: View, ) : Snapshotter { - override fun snapshot(name: String?) { + override fun snapshot(name: String?, scrolling: Boolean) { paparazzi.snapshot(view = view, name = name) + + if (scrolling) { + var scrollCount = 0 + while (view.canScrollVertically(1)) { + view.scrollBy(0, view.height) + scrollCount++ + + check(scrollCount < 15) { + "This view has been scrolled 15 times! Bad input?" + } + + paparazzi.snapshot(view = view, name = "${name.orEmpty()}_$scrollCount") + } + view.scrollTo(0, 0) + } } } 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 5d2788498b..e74ee63c43 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,8 @@ package app.cash.redwood.snapshot.testing import android.content.Context import android.view.Gravity import android.view.View +import android.widget.LinearLayout +import android.widget.ScrollView import android.widget.TextView import app.cash.redwood.Modifier import app.cash.redwood.ui.Density @@ -29,6 +31,10 @@ class ViewTestWidgetFactory( override fun color() = ViewColor(context) override fun text() = ViewText(context) + + override fun column() = ViewSimpleColumn(context) + + override fun scrollWrapper() = ViewScrollWrapper(context) } class ViewText(context: Context) : Text { @@ -82,3 +88,33 @@ class ViewColor(context: Context) : Color { value.setBackgroundColor(color) } } + +class ViewSimpleColumn(context: Context) : SimpleColumn { + override val value = LinearLayout(context).apply { + orientation = LinearLayout.VERTICAL + } + + override var modifier: Modifier = Modifier + + override fun add(child: View) { + value.addView(child) + } +} + +class ViewScrollWrapper(context: Context) : ScrollWrapper { + override val value = ScrollView(context) + + override var modifier: Modifier = Modifier + + override var content: View? + get() = when (value.childCount) { + 1 -> value.getChildAt(0) + else -> null + } + set(value) { + this@ViewScrollWrapper.value.removeAllViews() + if (value != null) { + this@ViewScrollWrapper.value.addView(value) + } + } +} diff --git a/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Color.kt b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Color.kt index 17ef5d1f02..c9da9eaf66 100644 --- a/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Color.kt +++ b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Color.kt @@ -18,7 +18,7 @@ package app.cash.redwood.snapshot.testing import app.cash.redwood.ui.Dp import app.cash.redwood.widget.Widget -interface Color : Widget { +interface Color : Widget { fun width(width: Dp) fun height(height: Dp) fun color(color: Int) diff --git a/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/ScrollWrapper.kt b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/ScrollWrapper.kt new file mode 100644 index 0000000000..3adf5aa9ba --- /dev/null +++ b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/ScrollWrapper.kt @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package app.cash.redwood.snapshot.testing + +import app.cash.redwood.widget.Widget + +/** + * Wraps a widget in a container that scrolls vertically. + */ +interface ScrollWrapper : Widget { + var content: W? +} diff --git a/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/SimpleColumn.kt b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/SimpleColumn.kt new file mode 100644 index 0000000000..97047f0e9c --- /dev/null +++ b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/SimpleColumn.kt @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 Square, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package app.cash.redwood.snapshot.testing + +import app.cash.redwood.widget.Widget + +/** + * Delegates to the host platform's column-like layout without any other capabilities. + */ +interface SimpleColumn : Widget { + fun add(child: W) +} diff --git a/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Snapshotter.kt b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Snapshotter.kt index 35b9764aa2..23d8787a2f 100644 --- a/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Snapshotter.kt +++ b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Snapshotter.kt @@ -23,5 +23,8 @@ package app.cash.redwood.snapshot.testing * changes. */ interface Snapshotter { - fun snapshot(name: String? = null) + fun snapshot( + name: String? = null, + scrolling: Boolean = false, + ) } diff --git a/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/TestWidgetFactory.kt b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/TestWidgetFactory.kt index db2f1eb40a..97b8d55e9d 100644 --- a/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/TestWidgetFactory.kt +++ b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/TestWidgetFactory.kt @@ -21,6 +21,8 @@ import app.cash.redwood.ui.Dp interface TestWidgetFactory { fun color(): Color fun text(): Text + fun column(): SimpleColumn + fun scrollWrapper(): ScrollWrapper } fun TestWidgetFactory.text( diff --git a/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Text.kt b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Text.kt index f8911dd0e1..8b10d6239f 100644 --- a/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Text.kt +++ b/redwood-snapshot-testing/src/commonMain/kotlin/app/cash/redwood/snapshot/testing/Text.kt @@ -24,7 +24,7 @@ import app.cash.redwood.widget.Widget * * The text is centered vertically. */ -interface Text : Widget { +interface Text : Widget { val measureCount: Int fun text(text: String) fun bgColor(color: Int) diff --git a/redwood-snapshot-testing/src/iosMain/kotlin/app/cash/redwood/snapshot/testing/UIViewSnapshotter.kt b/redwood-snapshot-testing/src/iosMain/kotlin/app/cash/redwood/snapshot/testing/UIViewSnapshotter.kt index 1b5cb816db..cac6ded021 100644 --- a/redwood-snapshot-testing/src/iosMain/kotlin/app/cash/redwood/snapshot/testing/UIViewSnapshotter.kt +++ b/redwood-snapshot-testing/src/iosMain/kotlin/app/cash/redwood/snapshot/testing/UIViewSnapshotter.kt @@ -17,8 +17,11 @@ package app.cash.redwood.snapshot.testing import kotlin.time.Duration.Companion.milliseconds import kotlin.time.DurationUnit +import kotlinx.cinterop.useContents +import platform.CoreGraphics.CGPointMake import platform.CoreGraphics.CGRectMake import platform.UIKit.UIColor +import platform.UIKit.UIScrollView import platform.UIKit.UIView /** Snapshot the subject on a white background. */ @@ -27,12 +30,46 @@ class UIViewSnapshotter( private val subject: UIView, ) : Snapshotter { - override fun snapshot(name: String?) { + override fun snapshot(name: String?, scrolling: Boolean) { layoutSubject() // Unfortunately even with animations forced off, UITableView's animation system breaks // synchronous snapshots. The simplest workaround is to delay snapshots one frame. callback.verifySnapshot(subject, name, delay = 1.milliseconds.toDouble(DurationUnit.SECONDS)) + + if (scrolling) { + var scrollCount = 0 + val scrollView = findScrollView(subject) ?: return + val contentHeight = scrollView.contentSize.useContents { height } + val frameHeight = scrollView.frame.useContents { size.height } + var offset = 0.0 + while (offset + frameHeight < contentHeight) { + offset = minOf(offset + frameHeight, contentHeight - frameHeight) + scrollView.setContentOffset(CGPointMake(0.0, offset), false) + scrollCount++ + + check(scrollCount < 15) { + "This view has been scrolled 15 times! Bad input?" + } + + callback.verifySnapshot( + view = subject, + name = "${name.orEmpty()}_$scrollCount", + delay = 1.milliseconds.toDouble(DurationUnit.SECONDS), + ) + } + scrollView.setContentOffset(CGPointMake(0.0, 0.0), false) + } + } + + private fun findScrollView(view: UIView): UIScrollView? { + if (view is UIScrollView) return view + + for (subview in view.subviews) { + return findScrollView(subview as UIView) ?: continue + } + + return null } /** Do layout without taking a snapshot. */ 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 df1fe83d87..634b0020ef 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 @@ -29,12 +29,21 @@ import platform.CoreGraphics.CGSize import platform.CoreGraphics.CGSizeMake import platform.UIKit.UIColor 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.UIView object UIViewTestWidgetFactory : TestWidgetFactory { override fun color() = UIViewColor() override fun text() = UIViewText() + + override fun column() = UIViewSimpleColumn() + + override fun scrollWrapper() = UIViewScrollWrapper() } fun Int.toUIColor(): UIColor { @@ -105,3 +114,38 @@ class UIViewColor : Color { value.invalidateIntrinsicContentSize() } } + +class UIViewSimpleColumn : SimpleColumn { + override var modifier: Modifier = Modifier + + override val value = UIStackView(CGRectZero.readValue()).apply { + this.axis = UILayoutConstraintAxisVertical + this.alignment = UIStackViewAlignmentLeading + this.distribution = UIStackViewDistributionFill + } + + override fun add(child: UIView) { + value.addArrangedSubview(child) + } +} + +class UIViewScrollWrapper : ScrollWrapper { + override var modifier: Modifier = Modifier + + override val value = UIScrollView(CGRectZero.readValue()) + + override var content: UIView? + get() = value.subviews().firstOrNull() as UIView? + set(value) { + val scrollView = this@UIViewScrollWrapper.value + (scrollView.subviews.firstOrNull() as UIView?)?.removeFromSuperview() + if (value == null) return + + scrollView.addSubview(value) + value.translatesAutoresizingMaskIntoConstraints = false + value.leadingAnchor.constraintEqualToAnchor(scrollView.leadingAnchor).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-shared-test/src/commonMain/kotlin/app/cash/redwood/widget/AbstractRedwoodViewTest.kt b/redwood-widget-shared-test/src/commonMain/kotlin/app/cash/redwood/widget/AbstractRedwoodViewTest.kt index 2aee8fe1ee..fe201174a8 100644 --- a/redwood-widget-shared-test/src/commonMain/kotlin/app/cash/redwood/widget/AbstractRedwoodViewTest.kt +++ b/redwood-widget-shared-test/src/commonMain/kotlin/app/cash/redwood/widget/AbstractRedwoodViewTest.kt @@ -15,9 +15,14 @@ */ package app.cash.redwood.widget +import app.cash.redwood.snapshot.testing.Blue +import app.cash.redwood.snapshot.testing.Green +import app.cash.redwood.snapshot.testing.Red import app.cash.redwood.snapshot.testing.Snapshotter import app.cash.redwood.snapshot.testing.TestWidgetFactory +import app.cash.redwood.snapshot.testing.color import app.cash.redwood.snapshot.testing.text +import app.cash.redwood.ui.dp import kotlin.test.Test abstract class AbstractRedwoodViewTest> { @@ -28,6 +33,8 @@ abstract class AbstractRedwoodViewTest> { abstract fun snapshotter(redwoodView: R): Snapshotter + abstract fun snapshotter(widget: Widget): Snapshotter + /** * This test uses a string that wraps to confirm the root view's dimensions aren't unbounded. * https://github.com/cashapp/redwood/issues/2128 @@ -38,4 +45,47 @@ abstract class AbstractRedwoodViewTest> { redwoodView.children.insert(0, widgetFactory.text("Hello ".repeat(50))) snapshotter(redwoodView).snapshot() } + + /** RedwoodView is measured by its content. */ + @Test + fun testWrapped() { + // Green, Blue, Green. + val rootColumn = widgetFactory.column() + rootColumn.add(widgetFactory.color(Green, 100.dp, 100.dp).value) + rootColumn.add( + redwoodView().apply { + children.insert(0, widgetFactory.color(Blue, 100.dp, 100.dp)) + }.value, + ) + rootColumn.add(widgetFactory.color(Green, 100.dp, 100.dp).value) + + val scrollWrapper = widgetFactory.scrollWrapper() + scrollWrapper.content = rootColumn.value + + snapshotter(scrollWrapper).snapshot(scrolling = true) + } + + /** RedwoodView's height can exceed the height of the screen. */ + @Test + fun testExceedsScreenSize() { + // Green, Blue, Red, Blue, Red, ... Blue, Red, Green. + val rootColumn = widgetFactory.column() + rootColumn.add(widgetFactory.color(Green, 100.dp, 100.dp).value) + rootColumn.add( + redwoodView().apply { + val column = widgetFactory.column() + for (i in 0 until 10) { + column.add(widgetFactory.color(Blue, 100.dp, 100.dp).value) + column.add(widgetFactory.color(Red, 100.dp, 100.dp).value) + } + children.insert(0, column) + }.value, + ) + rootColumn.add(widgetFactory.color(Green, 100.dp, 100.dp).value) + + val scrollWrapper = widgetFactory.scrollWrapper() + scrollWrapper.content = rootColumn.value + + snapshotter(scrollWrapper).snapshot(scrolling = true) + } } diff --git a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize.1.png b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize.1.png new file mode 100644 index 0000000000..c559091c5c --- /dev/null +++ b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize.1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d9d64df4e24b76af287489cfd2f1d506bd26f5005d366480efab49d6a73ea22 +size 71420 diff --git a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._1.png b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._1.png new file mode 100644 index 0000000000..5eb11fb06c --- /dev/null +++ b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8edfed83820c4070200271fe23953c773c433fb61d76682872a6daf3fa1d8409 +size 73100 diff --git a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._2.png b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._2.png new file mode 100644 index 0000000000..c166a99317 --- /dev/null +++ b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testExceedsScreenSize._2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eea2bb3446b525db632a2c2f5c27b06175b6fef1a3e98e495cde25e3d85ae970 +size 71108 diff --git a/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testWrapped.1.png b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testWrapped.1.png new file mode 100644 index 0000000000..051c936bd4 --- /dev/null +++ b/redwood-widget-uiview-test/RedwoodWidgetUIViewTests/__Snapshots__/UIViewRedwoodViewTestHost/testWrapped.1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b1c5d640a7c2d60a1e730cd042fbd6e82982923e8a37bb4d14ad51acceb27dd +size 62199 diff --git a/redwood-widget-uiview-test/src/commonTest/kotlin/app/cash/redwood/widget/uiview/UIViewRedwoodViewTest.kt b/redwood-widget-uiview-test/src/commonTest/kotlin/app/cash/redwood/widget/uiview/UIViewRedwoodViewTest.kt index e2676f1d9c..278717b212 100644 --- a/redwood-widget-uiview-test/src/commonTest/kotlin/app/cash/redwood/widget/uiview/UIViewRedwoodViewTest.kt +++ b/redwood-widget-uiview-test/src/commonTest/kotlin/app/cash/redwood/widget/uiview/UIViewRedwoodViewTest.kt @@ -20,6 +20,7 @@ import app.cash.redwood.snapshot.testing.UIViewSnapshotter import app.cash.redwood.snapshot.testing.UIViewTestWidgetFactory import app.cash.redwood.widget.AbstractRedwoodViewTest import app.cash.redwood.widget.RedwoodUIView +import app.cash.redwood.widget.Widget import platform.UIKit.UIView class UIViewRedwoodViewTest( @@ -31,4 +32,7 @@ class UIViewRedwoodViewTest( override fun snapshotter(redwoodView: RedwoodUIView) = UIViewSnapshotter.framed(callback, redwoodView.value) + + override fun snapshotter(widget: Widget) = + UIViewSnapshotter.framed(callback, widget.value) } diff --git a/redwood-widget-view-test/src/test/kotlin/app/cash/redwood/widget/view/ViewRedwoodViewTest.kt b/redwood-widget-view-test/src/test/kotlin/app/cash/redwood/widget/view/ViewRedwoodViewTest.kt index 103eb059f3..a2fd3d7f99 100644 --- a/redwood-widget-view-test/src/test/kotlin/app/cash/redwood/widget/view/ViewRedwoodViewTest.kt +++ b/redwood-widget-view-test/src/test/kotlin/app/cash/redwood/widget/view/ViewRedwoodViewTest.kt @@ -25,6 +25,7 @@ import app.cash.redwood.snapshot.testing.ViewSnapshotter import app.cash.redwood.snapshot.testing.ViewTestWidgetFactory import app.cash.redwood.widget.AbstractRedwoodViewTest import app.cash.redwood.widget.RedwoodLayout +import app.cash.redwood.widget.Widget import com.android.resources.LayoutDirection import org.junit.Rule @@ -45,4 +46,6 @@ class ViewRedwoodViewTest( override fun redwoodView() = RedwoodLayout(paparazzi.context, OnBackPressedDispatcher()) override fun snapshotter(redwoodView: RedwoodLayout) = ViewSnapshotter(paparazzi, redwoodView) + + override fun snapshotter(widget: Widget) = ViewSnapshotter(paparazzi, widget.value) } 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 new file mode 100644 index 0000000000..82834e7360 --- /dev/null +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f54ab5877144719d3310aa5f24fee3b1022dbad589ca1e00f5e5dfa5470b236f +size 6460 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 new file mode 100644 index 0000000000..0b843ffed4 --- /dev/null +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize__1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4833fa2383690045a88971f57c431aa510e97d1f599c71d63c9a36827510f73d +size 6370 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 new file mode 100644 index 0000000000..3ce4008575 --- /dev/null +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testExceedsScreenSize__2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b332e7f7d1041a05ac7ef236c5aa9eae89fff66211ab9c9418893a7fd5e172c +size 6435 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 new file mode 100644 index 0000000000..2a5266a17b --- /dev/null +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_RTL_testWrapped.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d99576bc950f42850702f4e43af52ffd2f2c2bd5629c46d6b363bdf4d4571271 +size 4811 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 new file mode 100644 index 0000000000..2a3ca996b7 --- /dev/null +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:525fc7a9b088a11d1aef7266c64f23e2ef5f9260b5da6c3abbda9fa18e2be59a +size 6148 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 new file mode 100644 index 0000000000..7ebad69d4c --- /dev/null +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize__1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58c3fa683afb55bfbc4c9e3306bebcfc525119606efc5e0f9438e5b71f2561a4 +size 6097 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 new file mode 100644 index 0000000000..ae118a15d7 --- /dev/null +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testExceedsScreenSize__2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:146ec24fcd9deae813ebc5cd33b9995021e9c915435b35a3548c0088447fe39f +size 6149 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 new file mode 100644 index 0000000000..87834285b3 --- /dev/null +++ b/redwood-widget-view-test/src/test/snapshots/images/app.cash.redwood.widget.view_ViewRedwoodViewTest_testWrapped.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:624e2fd35536f878ac4f7156f8525ec1361ac7668c83380a33165acf4d34c610 +size 4789