-
Notifications
You must be signed in to change notification settings - Fork 74
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 scrolling of LazyList
#1485
Conversation
Integrates `WindowedLazyList` in the test, so any change to `WindowedLazyList#updateViewport` will be tested here.
private suspend fun <R> TestSchemaTester( | ||
factories: TestSchemaWidgetFactories<WidgetValue> = TestSchemaWidgetFactories( | ||
TestSchema = TestSchemaTestingWidgetFactory(), | ||
RedwoodLayout = RedwoodLayoutTestingWidgetFactory(), | ||
RedwoodLazyLayout = RedwoodLazyLayoutTestingWidgetFactory(), | ||
), | ||
body: suspend TestRedwoodComposition<List<WidgetValue>>.() -> R, | ||
): R = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this supposed to be generated for the testing code automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented on this but I forgot to press submit 🤦 This is what I originally wrote about it:
This is a copy-paste of the generated
TestSchemaTester
, with the only change being that factories is now a parameter, thus can be changed. Would such an API change make sense within the generated code?
For reference, this is what the generated one looks like:
@OptIn(RedwoodCodegenApi::class)
public suspend fun <R>
TestSchemaTester(body: suspend TestRedwoodComposition<List<WidgetValue>>.() -> R): R =
coroutineScope {
val factories = TestSchemaWidgetFactories(
TestSchema = TestSchemaTestingWidgetFactory(),
RedwoodLayout = RedwoodLayoutTestingWidgetFactory(),
RedwoodLazyLayout = RedwoodLazyLayoutTestingWidgetFactory(),
)
val container = MutableListChildren<WidgetValue>()
val tester = TestRedwoodComposition(this, factories, container,
MutableStateFlow(UiConfiguration())) {
container.map { it.value }
}
try {
tester.body()
} finally {
tester.cancel()
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I'll think about this tomorrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna merge this for now. I'm happy to create a follow-up PR that updates the generation of TestSchemaTester
such that this custom TestSchemaTester
can be deleted, either by updating it as it is here, or in a different way that'd allow custom factory implementations to be passed in.
Integrates
WindowedLazyList
in the test, so any change toWindowedLazyList#updateViewport
will be tested here.