mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 10:32:34 +00:00
Warmup molecule only once.
This commit is contained in:
@@ -32,17 +32,22 @@ import kotlin.time.Duration.Companion.seconds
|
|||||||
* Applying this test rule ensures that the slow initialisation is not done
|
* Applying this test rule ensures that the slow initialisation is not done
|
||||||
* inside runTest which has a short default timeout.
|
* inside runTest which has a short default timeout.
|
||||||
*/
|
*/
|
||||||
class WarmUpRule: TestRule {
|
class WarmUpRule : TestRule {
|
||||||
override fun apply(base: Statement, description: Description): Statement = object: Statement() {
|
companion object {
|
||||||
override fun evaluate() {
|
init {
|
||||||
runTest(timeout = 60.seconds) {
|
warmUpMolecule()
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
}
|
||||||
// Do nothing
|
}
|
||||||
}.test {
|
|
||||||
awaitItem() // Await a Unit composition
|
override fun apply(base: Statement, description: Description): Statement = base
|
||||||
}
|
}
|
||||||
}
|
|
||||||
base.evaluate()
|
private fun warmUpMolecule() {
|
||||||
|
runTest(timeout = 60.seconds) {
|
||||||
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
// Do nothing
|
||||||
|
}.test {
|
||||||
|
awaitItem() // Await a Unit composition
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user