Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test itemsAfter is set when item count is high #1480

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,25 @@ class LazyListTest {
}

@Test
fun populatedLazyColumn() = runTest {
fun populatedLazyColumnVariesItemsAfter_0() =
populatedLazyColumnVariesItemsAfter(10, 0, 10)

@Test
fun populatedLazyColumnVariesItemsAfter_1() =
populatedLazyColumnVariesItemsAfter(100, 85, 15)

private fun populatedLazyColumnVariesItemsAfter(
itemCount: Int,
expectedItemsAfter: Int,
expectedItemCount: Int,
) = runTest {
val snapshot = TestSchemaTester {
setContent {
LazyColumn(
state = rememberLazyListState(),
placeholder = { Text("Placeholder") },
) {
items(10) {
items(itemCount) {
Text(it.toString())
}
}
Expand All @@ -83,14 +94,14 @@ class LazyListTest {
isVertical = true,
onViewportChanged = { _, _ -> },
itemsBefore = 0,
itemsAfter = 0,
itemsAfter = expectedItemsAfter,
width = Constraint.Wrap,
height = Constraint.Wrap,
margin = Margin(0.0.dp),
crossAxisAlignment = CrossAxisAlignment.Start,
scrollItemIndex = ScrollItemIndex(0, 0),
placeholder = List(20) { TextValue(Modifier, "Placeholder") },
items = List(10) { TextValue(Modifier, it.toString()) },
items = List(expectedItemCount) { TextValue(Modifier, it.toString()) },
),
)
}
Expand Down