Browse Source

Add more tests for expect Composables (#3851)

pull/3883/head v1.5.10-dev1243
Oleksandr Karpovich 1 year ago committed by GitHub
parent
commit
d777238d51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      compose/integrations/composable-test-cases/gradle.properties
  2. 2
      compose/integrations/composable-test-cases/settings.gradle.kts
  3. 10
      compose/integrations/composable-test-cases/testcases/expectActual/lib/src/commonMain/kotlin/Dependencies.kt
  4. 20
      compose/integrations/composable-test-cases/testcases/expectActual/main/src/commonTest/kotlin/Tests.kt
  5. 20
      compose/integrations/composable-test-cases/testcases/rememberAnonymousObj/lib/build.gradle.kts
  6. 20
      compose/integrations/composable-test-cases/testcases/rememberAnonymousObj/main/build.gradle.kts

12
compose/integrations/composable-test-cases/gradle.properties

@ -1,15 +1,17 @@
org.gradle.jvmargs=-Xmx2048M -XX:MaxMetaspaceSize=512m
kotlin.code.style=official
kotlin.native.enableDependencyPropagation=false
android.useAndroidX=true
kotlin.version=1.9.10
kotlin.version=1.9.20-RC
agp.version=7.3.0
compose.version=1.5.1
compose.version=1.5.10-rc01
#empty by default - a default version will be used
compose.kotlinCompilerPluginVersion=1.5.2
compose.kotlinCompilerPluginVersion=1.5.2.1-rc01
# default|failingJs - see enum class CasesToRun
tests.casesToRun=default
# comma separated names of test cases known to fail (either compilation or while running) with k/js.
tests.failing.kjs=rememberAnonymousObj
#tests.failing.kjs=rememberAnonymousObj
# TODO: we should test with both K2 and K1
#kotlin.experimental.tryK2=true

2
compose/integrations/composable-test-cases/settings.gradle.kts

@ -38,7 +38,7 @@ val casesToRun = CasesToRun.values().firstOrNull {
} ?: CasesToRun.Default
val listOfFailingJsCases = (extra["tests.failing.kjs"] as String).split(",")
val listOfFailingJsCases = (extra.properties.getOrDefault("tests.failing.kjs", "") as String).split(",")
val failingJsSuffix = "failingJs"
fun getFailingSuffix(testCaseName: String): String? {

10
compose/integrations/composable-test-cases/testcases/expectActual/lib/src/commonMain/kotlin/Dependencies.kt

@ -8,3 +8,13 @@ val Abc.commonIntVal: Int
expect val Abc.composableIntVal: Int
@Composable get
@Composable
fun GetIntVal(): Int {
return Abc().composableIntVal
}
@Composable
fun GetIntValWithDefault(def: Int = Abc().composableIntVal): Int {
return def
}

20
compose/integrations/composable-test-cases/testcases/expectActual/main/src/commonTest/kotlin/Tests.kt

@ -19,6 +19,26 @@ class Tests {
assertEquals("root:{100}", root.dump())
}
@Test
fun composableImplicitExpectActualValGetter() = runTest {
val root = composeText {
val v = GetIntVal()
TextLeafNode("$v")
}
assertEquals("root:{100}", root.dump())
}
@Test
fun composableImplicitExpectActualValGetterWithDefault() = runTest {
val root = composeText {
val v = GetIntValWithDefault()
TextLeafNode("$v")
}
assertEquals("root:{100}", root.dump())
}
@Test
fun commonComposableValGetter() = runTest {
val root = composeText {

20
compose/integrations/composable-test-cases/testcases/rememberAnonymousObj/lib/build.gradle.kts

@ -3,26 +3,8 @@ plugins {
id("org.jetbrains.compose")
}
@OptIn(org.jetbrains.kotlin.gradle.kpm.external.ExternalVariantApi::class)
fun org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.configureDefaultTargets() {
jvm("desktop")
ios()
iosArm64()
iosSimulatorArm64()
iosX64()
macosX64()
macosArm64()
// We use linux agents on CI. So it doesn't run the tests, but it builds the klib anyway which is time consuming.
if (project.isInIdea) mingwX64()
linuxX64()
}
kotlin {
if (project.isFailingJsCase) {
configureJsTargets()
} else {
configureDefaultTargets()
}
configureTargets()
sourceSets {
val commonMain by getting {

20
compose/integrations/composable-test-cases/testcases/rememberAnonymousObj/main/build.gradle.kts

@ -3,26 +3,8 @@ plugins {
id("org.jetbrains.compose")
}
@OptIn(org.jetbrains.kotlin.gradle.kpm.external.ExternalVariantApi::class)
fun org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.configureDefaultTargets() {
jvm("desktop")
ios()
iosArm64()
iosSimulatorArm64()
iosX64()
macosX64()
macosArm64()
// We use linux agents on CI. So it doesn't run the tests, but it builds the klib anyway which is time consuming.
if (project.isInIdea) mingwX64()
linuxX64()
}
kotlin {
if (project.isFailingJsCase) {
configureJsTargets()
} else {
configureDefaultTargets()
}
configureTargets()
sourceSets {
val commonMain by getting {

Loading…
Cancel
Save