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 scrolling of LazyList #1485

Merged
merged 1 commit into from
Sep 18, 2023
Merged

Test scrolling of LazyList #1485

merged 1 commit into from
Sep 18, 2023

Conversation

veyndan
Copy link
Contributor

@veyndan veyndan commented Sep 14, 2023

Integrates WindowedLazyList in the test, so any change to WindowedLazyList#updateViewport will be tested here.

Integrates `WindowedLazyList` in the test, so any change to `WindowedLazyList#updateViewport` will be tested here.
@veyndan veyndan requested a review from JakeWharton September 14, 2023 08:42
Comment on lines +137 to +144
private suspend fun <R> TestSchemaTester(
factories: TestSchemaWidgetFactories<WidgetValue> = TestSchemaWidgetFactories(
TestSchema = TestSchemaTestingWidgetFactory(),
RedwoodLayout = RedwoodLayoutTestingWidgetFactory(),
RedwoodLazyLayout = RedwoodLazyLayoutTestingWidgetFactory(),
),
body: suspend TestRedwoodComposition<List<WidgetValue>>.() -> R,
): R =
Copy link
Collaborator

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?

Copy link
Contributor Author

@veyndan veyndan Sep 14, 2023

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()
  }
}

Copy link
Collaborator

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

Copy link
Contributor Author

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.

@veyndan veyndan merged commit 8b9c315 into trunk Sep 18, 2023
8 checks passed
@veyndan veyndan deleted the veyndan/2023-09-14/test-scroll branch September 18, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants