-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
142 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
mosaic-runtime/src/commonTest/kotlin/com/jakewharton/mosaic/snapshotStrategies.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.jakewharton.mosaic | ||
|
||
import com.jakewharton.mosaic.layout.MosaicNode | ||
import com.jakewharton.mosaic.testing.SnapshotStrategy | ||
|
||
internal object DumpSnapshots : SnapshotStrategy<String> { | ||
override fun create(mosaic: Mosaic): String { | ||
return mosaic.dump() | ||
} | ||
} | ||
|
||
internal object NodeSnapshots : SnapshotStrategy<MosaicNode> { | ||
override fun create(mosaic: Mosaic): MosaicNode { | ||
return (mosaic as MosaicComposition).rootNode | ||
} | ||
} | ||
|
||
internal class RenderingSnapshots( | ||
private val rendering: Rendering, | ||
) : SnapshotStrategy<String> { | ||
override fun create(mosaic: Mosaic): String { | ||
return rendering.render(mosaic).toString() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
public abstract interface class com/jakewharton/mosaic/testing/SnapshotStrategy { | ||
public abstract fun create (Lcom/jakewharton/mosaic/Mosaic;)Ljava/lang/Object; | ||
} | ||
|
||
public abstract interface class com/jakewharton/mosaic/testing/TestMosaic : com/jakewharton/mosaic/Mosaic { | ||
public abstract fun awaitSnapshot-VtjQ1oo (JLkotlin/coroutines/Continuation;)Ljava/lang/Object; | ||
public static synthetic fun awaitSnapshot-VtjQ1oo$default (Lcom/jakewharton/mosaic/testing/TestMosaic;JLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; | ||
} | ||
|
||
public final class com/jakewharton/mosaic/testing/TestMosaicKt { | ||
public static final fun runMosaicTest (Lcom/jakewharton/mosaic/testing/SnapshotStrategy;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; | ||
public static final fun runMosaicTest (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Klib ABI Dump | ||
// Targets: [linuxArm64, linuxX64, macosArm64, macosX64, mingwX64] | ||
// Rendering settings: | ||
// - Signature version: 2 | ||
// - Show manifest properties: true | ||
// - Show declarations: true | ||
|
||
// Library unique name: <com.jakewharton.mosaic:mosaic-testing> | ||
abstract fun interface <#A: kotlin/Any?> com.jakewharton.mosaic.testing/SnapshotStrategy { // com.jakewharton.mosaic.testing/SnapshotStrategy|null[0] | ||
abstract fun create(com.jakewharton.mosaic/Mosaic): #A // com.jakewharton.mosaic.testing/SnapshotStrategy.create|create(com.jakewharton.mosaic.Mosaic){}[0] | ||
} | ||
|
||
abstract interface <#A: kotlin/Any?> com.jakewharton.mosaic.testing/TestMosaic : com.jakewharton.mosaic/Mosaic { // com.jakewharton.mosaic.testing/TestMosaic|null[0] | ||
abstract suspend fun awaitSnapshot(kotlin.time/Duration = ...): #A // com.jakewharton.mosaic.testing/TestMosaic.awaitSnapshot|awaitSnapshot(kotlin.time.Duration){}[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_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 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apply plugin: 'org.jetbrains.kotlin.multiplatform' | ||
apply plugin: 'org.jetbrains.kotlin.plugin.compose' | ||
apply from: "$rootDir/addAllTargets.gradle" | ||
apply from: "$rootDir/publish.gradle" | ||
apply plugin: 'dev.drewhamilton.poko' | ||
|
||
kotlin { | ||
explicitApi() | ||
|
||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
api projects.mosaicRuntime | ||
api libs.kotlinx.coroutines.core | ||
implementation libs.compose.collection | ||
} | ||
} | ||
} | ||
|
||
compilerOptions.freeCompilerArgs.add('-Xexpect-actual-classes') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
POM_ARTIFACT_ID=mosaic-testing | ||
POM_NAME=Mosaic testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
samples/counter/src/commonTest/kotlin/example/CounterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package example | ||
|
||
import assertk.assertThat | ||
import assertk.assertions.isEqualTo | ||
import com.jakewharton.mosaic.testing.runMosaicTest | ||
import kotlin.test.Test | ||
import kotlinx.coroutines.test.runTest | ||
|
||
class CounterTest { | ||
@Test | ||
fun counter() = runTest { | ||
runMosaicTest { | ||
setContent { | ||
Counter() | ||
} | ||
for (count in 0..20) { | ||
assertThat(awaitSnapshot()).isEqualTo("The count is: $count") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters