mirror of
https://github.com/JakeWharton/mosaic.git
synced 2025-10-30 02:06:19 +08:00
Two quick helpers for testing statics (#634)
Not great, but better than we have.
This commit is contained in:
@ -4,6 +4,7 @@ public abstract interface class com/jakewharton/mosaic/Mosaic {
|
|||||||
public abstract fun dump ()Ljava/lang/String;
|
public abstract fun dump ()Ljava/lang/String;
|
||||||
public abstract fun getTerminalState ()Landroidx/compose/runtime/MutableState;
|
public abstract fun getTerminalState ()Landroidx/compose/runtime/MutableState;
|
||||||
public abstract fun paint ()Lcom/jakewharton/mosaic/TextCanvas;
|
public abstract fun paint ()Lcom/jakewharton/mosaic/TextCanvas;
|
||||||
|
public fun paintStatics ()Ljava/util/List;
|
||||||
public abstract fun paintStaticsTo (Landroidx/collection/MutableObjectList;)V
|
public abstract fun paintStaticsTo (Landroidx/collection/MutableObjectList;)V
|
||||||
public abstract fun sendKeyEvent (Lcom/jakewharton/mosaic/layout/KeyEvent;)V
|
public abstract fun sendKeyEvent (Lcom/jakewharton/mosaic/layout/KeyEvent;)V
|
||||||
public abstract fun setContent (Lkotlin/jvm/functions/Function2;)V
|
public abstract fun setContent (Lkotlin/jvm/functions/Function2;)V
|
||||||
|
|||||||
@ -207,6 +207,7 @@ abstract interface com.jakewharton.mosaic/Mosaic { // com.jakewharton.mosaic/Mos
|
|||||||
abstract fun sendKeyEvent(com.jakewharton.mosaic.layout/KeyEvent) // com.jakewharton.mosaic/Mosaic.sendKeyEvent|sendKeyEvent(com.jakewharton.mosaic.layout.KeyEvent){}[0]
|
abstract fun sendKeyEvent(com.jakewharton.mosaic.layout/KeyEvent) // com.jakewharton.mosaic/Mosaic.sendKeyEvent|sendKeyEvent(com.jakewharton.mosaic.layout.KeyEvent){}[0]
|
||||||
abstract fun setContent(kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>) // com.jakewharton.mosaic/Mosaic.setContent|setContent(kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>){}[0]
|
abstract fun setContent(kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>) // com.jakewharton.mosaic/Mosaic.setContent|setContent(kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>){}[0]
|
||||||
abstract suspend fun awaitComplete() // com.jakewharton.mosaic/Mosaic.awaitComplete|awaitComplete(){}[0]
|
abstract suspend fun awaitComplete() // com.jakewharton.mosaic/Mosaic.awaitComplete|awaitComplete(){}[0]
|
||||||
|
open fun paintStatics(): kotlin.collections/List<com.jakewharton.mosaic/TextCanvas> // com.jakewharton.mosaic/Mosaic.paintStatics|paintStatics(){}[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract interface com.jakewharton.mosaic/TextCanvas { // com.jakewharton.mosaic/TextCanvas|null[0]
|
abstract interface com.jakewharton.mosaic/TextCanvas { // com.jakewharton.mosaic/TextCanvas|null[0]
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.jakewharton.mosaic
|
package com.jakewharton.mosaic
|
||||||
|
|
||||||
import androidx.collection.MutableObjectList
|
import androidx.collection.MutableObjectList
|
||||||
|
import androidx.collection.mutableObjectListOf
|
||||||
import androidx.collection.mutableScatterSetOf
|
import androidx.collection.mutableScatterSetOf
|
||||||
import androidx.compose.runtime.AbstractApplier
|
import androidx.compose.runtime.AbstractApplier
|
||||||
import androidx.compose.runtime.BroadcastFrameClock
|
import androidx.compose.runtime.BroadcastFrameClock
|
||||||
@ -163,6 +164,12 @@ public interface Mosaic {
|
|||||||
|
|
||||||
public fun paint(): TextCanvas
|
public fun paint(): TextCanvas
|
||||||
public fun paintStaticsTo(list: MutableObjectList<TextCanvas>)
|
public fun paintStaticsTo(list: MutableObjectList<TextCanvas>)
|
||||||
|
public fun paintStatics(): List<TextCanvas> {
|
||||||
|
return mutableObjectListOf<TextCanvas>()
|
||||||
|
.apply(::paintStaticsTo)
|
||||||
|
.asList()
|
||||||
|
}
|
||||||
|
|
||||||
public fun dump(): String
|
public fun dump(): String
|
||||||
|
|
||||||
public suspend fun awaitComplete()
|
public suspend fun awaitComplete()
|
||||||
|
|||||||
@ -1,3 +1,10 @@
|
|||||||
|
public final class com/jakewharton/mosaic/testing/MosaicSnapshots : com/jakewharton/mosaic/testing/SnapshotStrategy {
|
||||||
|
public static final field $stable I
|
||||||
|
public static final field INSTANCE Lcom/jakewharton/mosaic/testing/MosaicSnapshots;
|
||||||
|
public fun create (Lcom/jakewharton/mosaic/Mosaic;)Lcom/jakewharton/mosaic/Mosaic;
|
||||||
|
public synthetic fun create (Lcom/jakewharton/mosaic/Mosaic;)Ljava/lang/Object;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract interface class com/jakewharton/mosaic/testing/SnapshotStrategy {
|
public abstract interface class com/jakewharton/mosaic/testing/SnapshotStrategy {
|
||||||
public abstract fun create (Lcom/jakewharton/mosaic/Mosaic;)Ljava/lang/Object;
|
public abstract fun create (Lcom/jakewharton/mosaic/Mosaic;)Ljava/lang/Object;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,14 @@ abstract interface <#A: kotlin/Any?> com.jakewharton.mosaic.testing/TestMosaic :
|
|||||||
abstract suspend fun awaitSnapshot(kotlin.time/Duration = ...): #A // com.jakewharton.mosaic.testing/TestMosaic.awaitSnapshot|awaitSnapshot(kotlin.time.Duration){}[0]
|
abstract suspend fun awaitSnapshot(kotlin.time/Duration = ...): #A // com.jakewharton.mosaic.testing/TestMosaic.awaitSnapshot|awaitSnapshot(kotlin.time.Duration){}[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final object com.jakewharton.mosaic.testing/MosaicSnapshots : com.jakewharton.mosaic.testing/SnapshotStrategy<com.jakewharton.mosaic/Mosaic> { // com.jakewharton.mosaic.testing/MosaicSnapshots|null[0]
|
||||||
|
final fun create(com.jakewharton.mosaic/Mosaic): com.jakewharton.mosaic/Mosaic // com.jakewharton.mosaic.testing/MosaicSnapshots.create|create(com.jakewharton.mosaic.Mosaic){}[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
final val com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_MosaicSnapshots$stableprop // com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_MosaicSnapshots$stableprop|#static{}com_jakewharton_mosaic_testing_MosaicSnapshots$stableprop[0]
|
||||||
final val com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop // com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop|#static{}com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop[0]
|
final val com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop // com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop|#static{}com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop[0]
|
||||||
|
|
||||||
|
final fun com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_MosaicSnapshots$stableprop_getter(): kotlin/Int // com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_MosaicSnapshots$stableprop_getter|com_jakewharton_mosaic_testing_MosaicSnapshots$stableprop_getter(){}[0]
|
||||||
final fun com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop_getter(): kotlin/Int // com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop_getter|com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop_getter(){}[0]
|
final fun com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop_getter(): kotlin/Int // com.jakewharton.mosaic.testing/com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop_getter|com_jakewharton_mosaic_testing_PlainTextSnapshots$stableprop_getter(){}[0]
|
||||||
final suspend fun <#A: kotlin/Any?, #B: kotlin/Any?> com.jakewharton.mosaic.testing/runMosaicTest(com.jakewharton.mosaic.testing/SnapshotStrategy<#A>, kotlin.coroutines/SuspendFunction1<com.jakewharton.mosaic.testing/TestMosaic<#A>, #B>): #B // com.jakewharton.mosaic.testing/runMosaicTest|runMosaicTest(com.jakewharton.mosaic.testing.SnapshotStrategy<0:0>;kotlin.coroutines.SuspendFunction1<com.jakewharton.mosaic.testing.TestMosaic<0:0>,0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0]
|
final suspend fun <#A: kotlin/Any?, #B: kotlin/Any?> com.jakewharton.mosaic.testing/runMosaicTest(com.jakewharton.mosaic.testing/SnapshotStrategy<#A>, kotlin.coroutines/SuspendFunction1<com.jakewharton.mosaic.testing/TestMosaic<#A>, #B>): #B // com.jakewharton.mosaic.testing/runMosaicTest|runMosaicTest(com.jakewharton.mosaic.testing.SnapshotStrategy<0:0>;kotlin.coroutines.SuspendFunction1<com.jakewharton.mosaic.testing.TestMosaic<0:0>,0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}[0]
|
||||||
final suspend fun com.jakewharton.mosaic.testing/runMosaicTest(kotlin.coroutines/SuspendFunction1<com.jakewharton.mosaic.testing/TestMosaic<kotlin/String>, kotlin/Unit>) // com.jakewharton.mosaic.testing/runMosaicTest|runMosaicTest(kotlin.coroutines.SuspendFunction1<com.jakewharton.mosaic.testing.TestMosaic<kotlin.String>,kotlin.Unit>){}[0]
|
final suspend fun com.jakewharton.mosaic.testing/runMosaicTest(kotlin.coroutines/SuspendFunction1<com.jakewharton.mosaic.testing/TestMosaic<kotlin/String>, kotlin/Unit>) // com.jakewharton.mosaic.testing/runMosaicTest|runMosaicTest(kotlin.coroutines.SuspendFunction1<com.jakewharton.mosaic.testing.TestMosaic<kotlin.String>,kotlin.Unit>){}[0]
|
||||||
|
|||||||
@ -14,12 +14,16 @@ import kotlinx.coroutines.currentCoroutineContext
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.withTimeout
|
import kotlinx.coroutines.withTimeout
|
||||||
|
|
||||||
|
public suspend fun runMosaicTest(block: suspend TestMosaic<String>.() -> Unit) {
|
||||||
|
runMosaicTest(PlainTextSnapshots, block)
|
||||||
|
}
|
||||||
|
|
||||||
public fun interface SnapshotStrategy<T> {
|
public fun interface SnapshotStrategy<T> {
|
||||||
public fun create(mosaic: Mosaic): T
|
public fun create(mosaic: Mosaic): T
|
||||||
}
|
}
|
||||||
|
|
||||||
public suspend fun runMosaicTest(block: suspend TestMosaic<String>.() -> Unit) {
|
public object MosaicSnapshots : SnapshotStrategy<Mosaic> {
|
||||||
runMosaicTest(PlainTextSnapshots, block)
|
override fun create(mosaic: Mosaic): Mosaic = mosaic
|
||||||
}
|
}
|
||||||
|
|
||||||
public suspend fun <T, R> runMosaicTest(
|
public suspend fun <T, R> runMosaicTest(
|
||||||
|
|||||||
Reference in New Issue
Block a user