Skip to content

Commit

Permalink
Fix testRecursiveLayoutIsIncremental in UIViewLazyList (#2298)
Browse files Browse the repository at this point in the history
* Fix testRecursiveLayoutIsIncremental in UIViewLazyList

The test was incorrectly nesting a UITableView inside a UITableView
instead of nesting a Row inside a UITableView.

See: #2289

* More fixed snapshots
  • Loading branch information
squarejesse authored Sep 11, 2024
1 parent a2fcabc commit bebfbd0
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ abstract class AbstractFlexContainerTest<T : Any> {
backgroundColor: Int = argb(51, 0, 0, 255),
): TestFlexContainer<T>

/** Returns a non-lazy flex container row, even if the test is for a LazyList. */
abstract fun row(): Row<T>

/** Returns a non-lazy flex container column, even if the test is for a LazyList. */
abstract fun column(): Column<T>

abstract fun text(): Text<T>
Expand Down Expand Up @@ -691,33 +693,33 @@ abstract class AbstractFlexContainerTest<T : Any> {
container.height(Constraint.Fill)
container.crossAxisAlignment(CrossAxisAlignment.Start)

val rowA = flexContainer(FlexDirection.Row)
val rowA = row()
.apply {
width(Constraint.Fill)
height(Constraint.Wrap)
}
.also { container.add(it) }
val rowB = flexContainer(FlexDirection.Row)
val rowB = row()
.apply {
width(Constraint.Fill)
height(Constraint.Wrap)
}
.also { container.add(it) }
val rowC = flexContainer(FlexDirection.Row)
val rowC = row()
.apply {
width(Constraint.Fill)
height(Constraint.Wrap)
}
.also { container.add(it) }
val a = text("A")
.apply { modifier = HeightImpl(100.dp) }
.also { rowA.add(it) }
.also { rowA.children.insert(0, it) }
val b = text("B")
.apply { modifier = HeightImpl(100.dp) }
.also { rowB.add(it) }
.also { rowB.children.insert(0, it) }
val c = text("C")
.apply { modifier = HeightImpl(100.dp) }
.also { rowC.add(it) }
.also { rowC.children.insert(0, it) }
container.onEndChanges()
verifySnapshot(container.value, "v1")
val aMeasureCountV1 = a.measureCount
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import app.cash.redwood.lazylayout.toUIColor
import app.cash.redwood.lazylayout.widget.LazyList
import app.cash.redwood.ui.Px
import app.cash.redwood.widget.ChangeListener
import app.cash.redwood.widget.ResizableWidget
import app.cash.redwood.widget.Widget
import app.cash.redwood.yoga.FlexDirection
import kotlin.time.Duration.Companion.milliseconds
Expand All @@ -48,16 +49,18 @@ class UIViewLazyListAsFlexContainerTest(

override fun column() = UIViewRedwoodLayoutWidgetFactory().Column()

override fun text() = object : Text<UIView> {
override fun text(): Text<UIView> = object : Text<UIView>, ResizableWidget<UIView> {
override val value = UILabel().apply {
numberOfLines = 0
textColor = platform.UIKit.UIColor.blackColor
}
override var modifier: Modifier = Modifier
override val measureCount = 0
override var sizeListener: ResizableWidget.SizeListener? = null

override fun text(text: String) {
value.text = text
sizeListener?.invalidateSize()
}

override fun bgColor(color: Int) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bebfbd0

Please sign in to comment.