From fe778867938775e3be72931d3d20379d5110a194 Mon Sep 17 00:00:00 2001 From: Oleksandr Karpovich Date: Mon, 26 Feb 2024 16:45:12 +0100 Subject: [PATCH] Add k/wasm target to composable-test-cases (#4371) --- .../buildSrc/src/main/kotlin/TargetsConfiguration.kt | 3 +++ .../composable-test-cases/common/build.gradle.kts | 1 - .../src/commonMain/kotlin/com/example/common/Applier.kt | 8 +++++--- .../integrations/composable-test-cases/gradle.properties | 8 ++++---- .../lib/src/wasmJsMain/kotlin/Dependencies.wasmJs.kt | 2 ++ 5 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 compose/integrations/composable-test-cases/testcases/expectActual/lib/src/wasmJsMain/kotlin/Dependencies.wasmJs.kt diff --git a/compose/integrations/composable-test-cases/buildSrc/src/main/kotlin/TargetsConfiguration.kt b/compose/integrations/composable-test-cases/buildSrc/src/main/kotlin/TargetsConfiguration.kt index 7d2ba91d2d1..faddff2ffbc 100644 --- a/compose/integrations/composable-test-cases/buildSrc/src/main/kotlin/TargetsConfiguration.kt +++ b/compose/integrations/composable-test-cases/buildSrc/src/main/kotlin/TargetsConfiguration.kt @@ -26,6 +26,9 @@ val Project.isMingwX64Enabled: Boolean fun KotlinMultiplatformExtension.configureTargets() { jvm("desktop") configureJsTargets() + wasmJs { + browser() + } ios() iosArm64() iosSimulatorArm64() diff --git a/compose/integrations/composable-test-cases/common/build.gradle.kts b/compose/integrations/composable-test-cases/common/build.gradle.kts index 399f2724bdf..ee3511e6c95 100644 --- a/compose/integrations/composable-test-cases/common/build.gradle.kts +++ b/compose/integrations/composable-test-cases/common/build.gradle.kts @@ -13,7 +13,6 @@ kotlin { val commonMain by getting { dependencies { implementation(compose.runtime) - implementation(libs.kotlinx.datetime) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") } } diff --git a/compose/integrations/composable-test-cases/common/src/commonMain/kotlin/com/example/common/Applier.kt b/compose/integrations/composable-test-cases/common/src/commonMain/kotlin/com/example/common/Applier.kt index ec2c725d579..6d62358584a 100644 --- a/compose/integrations/composable-test-cases/common/src/commonMain/kotlin/com/example/common/Applier.kt +++ b/compose/integrations/composable-test-cases/common/src/commonMain/kotlin/com/example/common/Applier.kt @@ -9,7 +9,6 @@ import androidx.compose.runtime.* import androidx.compose.runtime.snapshots.ObserverHandle import androidx.compose.runtime.snapshots.Snapshot import kotlinx.coroutines.* -import kotlinx.datetime.Clock import kotlin.coroutines.CoroutineContext import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine @@ -76,11 +75,14 @@ private object GlobalSnapshotManager { private class MonotonicClockImpl : MonotonicFrameClock { private val NANOS_PER_MILLI = 1_000_000 + + private var i = 0L + override suspend fun withFrameNanos( onFrame: (Long) -> R ): R = suspendCoroutine { continuation -> - val now = Clock.System.now() - val currentNanos = now.toEpochMilliseconds() * NANOS_PER_MILLI + now.nanosecondsOfSecond + val now = ++i + val currentNanos = now * NANOS_PER_MILLI val result = onFrame(currentNanos) continuation.resume(result) } diff --git a/compose/integrations/composable-test-cases/gradle.properties b/compose/integrations/composable-test-cases/gradle.properties index 0adfe994f73..b27b770e0b6 100644 --- a/compose/integrations/composable-test-cases/gradle.properties +++ b/compose/integrations/composable-test-cases/gradle.properties @@ -1,15 +1,15 @@ -org.gradle.jvmargs=-Xmx2048M -XX:MaxMetaspaceSize=512m +org.gradle.jvmargs=-Xmx4096M -XX:MaxMetaspaceSize=512m kotlin.code.style=official android.useAndroidX=true kotlin.version=1.9.22 agp.version=7.3.0 -compose.version=1.6.0-dev1357 +compose.version=1.6.0-rc03 -kotlinx.coroutines.version=1.8.0-RC +kotlinx.coroutines.version=1.8.0 #empty by default - a default version will be used #compose.kotlinCompilerPluginVersion=23.12.18 -compose.kotlinCompilerPluginVersion=1.5.8-beta01 +compose.kotlinCompilerPluginVersion=1.5.8.1 # default|failingJs - see enum class CasesToRun tests.casesToRun=default diff --git a/compose/integrations/composable-test-cases/testcases/expectActual/lib/src/wasmJsMain/kotlin/Dependencies.wasmJs.kt b/compose/integrations/composable-test-cases/testcases/expectActual/lib/src/wasmJsMain/kotlin/Dependencies.wasmJs.kt new file mode 100644 index 00000000000..399cfccc662 --- /dev/null +++ b/compose/integrations/composable-test-cases/testcases/expectActual/lib/src/wasmJsMain/kotlin/Dependencies.wasmJs.kt @@ -0,0 +1,2 @@ +actual val Abc.composableIntVal: Int + get() = 100 \ No newline at end of file