All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.app.cash.redwood.layout.testing.RedwoodLayoutTester.kt Maven / Gradle / Ivy

There is a newer version: 0.14.0
Show newest version
@file:Suppress("DEPRECATION", "OVERRIDE_DEPRECATION")

package app.cash.redwood.layout.testing

import app.cash.redwood.RedwoodCodegenApi
import app.cash.redwood.layout.widget.RedwoodLayoutWidgetSystem
import app.cash.redwood.testing.NoOpOnBackPressedDispatcher
import app.cash.redwood.testing.TestRedwoodComposition
import app.cash.redwood.testing.TestSavedState
import app.cash.redwood.testing.WidgetValue
import app.cash.redwood.ui.OnBackPressedDispatcher
import app.cash.redwood.ui.UiConfiguration
import app.cash.redwood.widget.MutableListChildren
import kotlin.OptIn
import kotlin.Suppress
import kotlin.collections.List
import kotlinx.coroutines.coroutineScope

@OptIn(RedwoodCodegenApi::class)
public suspend fun  RedwoodLayoutTester(
  onBackPressedDispatcher: OnBackPressedDispatcher = NoOpOnBackPressedDispatcher,
  savedState: TestSavedState? = null,
  uiConfiguration: UiConfiguration = UiConfiguration(),
  body: suspend TestRedwoodComposition>.() -> R,
): R = coroutineScope {
  val widgetSystem = RedwoodLayoutWidgetSystem(
    RedwoodLayout = RedwoodLayoutTestingWidgetFactory(),
  )
  val container = MutableListChildren()
  val tester = TestRedwoodComposition(this, widgetSystem, container, onBackPressedDispatcher,
      savedState, uiConfiguration) {
    container.map { it.value }
  }
  try {
    tester.body()
  } finally {
    tester.cancel()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy