Skip to content

Commit 116f362

Browse files
committed
Register the Skiko UI implementation at Compose entry points
Wire registerSkikoComposeImplementation() into the Skiko-backed Compose entry points so the ui-graphics/ui-text registries are populated before any scene is created: desktop ComposePanel/ComposeWindowPanel, macOS ComposeWindow, iOS ComposeUIViewController, web ComposeWindowInternal, ImageComposeScene, and the ui-test rules. Adds the :compose:ui:ui-skiko dependency to the modules that rely on the Skiko backend transitively (ui, ui-test, ui-test-junit4, foundation) and registers in the affected test harnesses.
1 parent 9b25724 commit 116f362

36 files changed

Lines changed: 290 additions & 14 deletions

File tree

compose/foundation/foundation/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ androidXMultiplatform {
124124
dependencies {
125125
// TODO(https://youtrack.jetbrains.com/issue/CMP-219) Remove API
126126
api(libs.skiko)
127+
// TODO(https://youtrack.jetbrains.com/issue/CMP-10338): Remove direct dependency
128+
implementation(project(":compose:ui:ui-skiko"))
129+
127130
implementation(libs.atomicFu)
128131
}
129132
}

compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/OnClickTest.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ import androidx.compose.ui.input.pointer.pointerInput
3333
import androidx.compose.ui.platform.FrameRecomposer
3434
import androidx.compose.ui.platform.LocalViewConfiguration
3535
import androidx.compose.ui.platform.ViewConfiguration
36+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
3637
import androidx.compose.ui.scene.CanvasLayersComposeScene
3738
import androidx.compose.ui.test.ExperimentalTestApi
3839
import androidx.compose.ui.test.runSkikoComposeUiTest
3940
import androidx.compose.ui.unit.Density
4041
import androidx.compose.ui.unit.IntSize
4142
import androidx.compose.ui.unit.dp
4243
import androidx.compose.ui.use
44+
import kotlin.test.BeforeTest
4345
import kotlin.test.Test
4446
import kotlinx.coroutines.ExperimentalCoroutinesApi
4547
import kotlinx.coroutines.test.runTest
@@ -48,6 +50,19 @@ import kotlinx.coroutines.test.runTest
4850
@OptIn(ExperimentalFoundationApi::class, InternalComposeUiApi::class)
4951
class OnClickTest {
5052

53+
@BeforeTest
54+
fun registerSkikoBackend() {
55+
registerSkikoComposeImplementation()
56+
}
57+
58+
// TODO: re-enable per-test cleanup once tests that register the backend asynchronously
59+
// (e.g. AWT ComposePanel/ComposeWindow via ComposeContainer on the EDT) no longer rely on
60+
// the registration persisting across tests.
61+
// @AfterTest
62+
// fun clearSkikoBackend() {
63+
// clearSkikoComposeImplementation()
64+
// }
65+
5166
private fun testClick(
5267
pointerMatcher: PointerMatcher,
5368
button: PointerButton

compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/copyPasteAndroidTests/text/TextDelegateIntegrationTest.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import androidx.compose.foundation.isEqualTo
2121
import androidx.compose.foundation.isTrue
2222
import androidx.compose.foundation.text.InternalFoundationTextApi
2323
import androidx.compose.foundation.text.TextDelegate
24+
import androidx.compose.ui.InternalComposeUiApi
25+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
2426
import androidx.compose.ui.text.AnnotatedString
2527
import androidx.compose.ui.text.SpanStyle
2628
import androidx.compose.ui.text.TextStyle
@@ -32,12 +34,26 @@ import androidx.compose.ui.unit.Density
3234
import androidx.compose.ui.unit.LayoutDirection
3335
import androidx.compose.ui.unit.sp
3436
import kotlin.math.roundToInt
37+
import kotlin.test.BeforeTest
3538
import kotlin.test.Ignore
3639
import kotlin.test.Test
3740

38-
@OptIn(InternalFoundationTextApi::class)
41+
@OptIn(InternalFoundationTextApi::class, InternalComposeUiApi::class)
3942
class TextDelegateIntegrationTest {
4043

44+
@BeforeTest
45+
fun registerSkikoBackend() {
46+
registerSkikoComposeImplementation()
47+
}
48+
49+
// TODO: re-enable per-test cleanup once tests that register the backend asynchronously
50+
// (e.g. AWT ComposePanel/ComposeWindow via ComposeContainer on the EDT) no longer rely on
51+
// the registration persisting across tests.
52+
// @AfterTest
53+
// fun clearSkikoBackend() {
54+
// clearSkikoComposeImplementation()
55+
// }
56+
4157
@Test
4258
@Ignore // TODO: test is failing
4359
fun minIntrinsicWidth_getter() = with(Density(1f, 1f)) {

compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/shape/AbsoluteCutCornerShapeTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package androidx.compose.foundation.shape
1818

19+
import androidx.compose.ui.InternalComposeUiApi
20+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
21+
import kotlin.test.BeforeTest
1922
import androidx.compose.foundation.assertThat
2023
import androidx.compose.foundation.isEqualTo
2124
import androidx.compose.foundation.isFalse
@@ -31,8 +34,22 @@ import androidx.compose.ui.unit.dp
3134
import kotlin.test.Test
3235
import kotlin.test.assertEquals
3336

37+
@OptIn(InternalComposeUiApi::class)
3438
class AbsoluteCutCornerShapeTest {
3539

40+
@BeforeTest
41+
fun registerSkikoBackend() {
42+
registerSkikoComposeImplementation()
43+
}
44+
45+
// TODO: re-enable per-test cleanup once tests that register the backend asynchronously
46+
// (e.g. AWT ComposePanel/ComposeWindow via ComposeContainer on the EDT) no longer rely on
47+
// the registration persisting across tests.
48+
// @AfterTest
49+
// fun clearSkikoBackend() {
50+
// clearSkikoComposeImplementation()
51+
// }
52+
3653
private var layoutDirection: LayoutDirection? = null
3754

3855
private val testParameters = arrayOf(

compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/shape/AbsoluteRoundedCornerShapeTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package androidx.compose.foundation.shape
1818

19+
import androidx.compose.ui.InternalComposeUiApi
20+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
21+
import kotlin.test.BeforeTest
1922
import androidx.compose.foundation.assertThat
2023
import androidx.compose.foundation.isEqualTo
2124
import androidx.compose.foundation.isFalse
@@ -32,8 +35,22 @@ import androidx.compose.ui.unit.dp
3235
import kotlin.test.Test
3336
import kotlin.test.assertEquals
3437

38+
@OptIn(InternalComposeUiApi::class)
3539
class AbsoluteRoundedCornerShapeTest {
3640

41+
@BeforeTest
42+
fun registerSkikoBackend() {
43+
registerSkikoComposeImplementation()
44+
}
45+
46+
// TODO: re-enable per-test cleanup once tests that register the backend asynchronously
47+
// (e.g. AWT ComposePanel/ComposeWindow via ComposeContainer on the EDT) no longer rely on
48+
// the registration persisting across tests.
49+
// @AfterTest
50+
// fun clearSkikoBackend() {
51+
// clearSkikoComposeImplementation()
52+
// }
53+
3754
private var layoutDirection: LayoutDirection? = null
3855

3956
private val testParameters = arrayOf(

compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/shape/CutCornerShapeTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package androidx.compose.foundation.shape
1818

19+
import androidx.compose.ui.InternalComposeUiApi
20+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
21+
import kotlin.test.BeforeTest
1922
import androidx.compose.foundation.assertThat
2023
import androidx.compose.foundation.isEqualTo
2124
import androidx.compose.foundation.isFalse
@@ -33,8 +36,22 @@ import kotlin.test.Test
3336
import kotlin.test.assertEquals
3437
import kotlin.test.assertTrue
3538

39+
@OptIn(InternalComposeUiApi::class)
3640
class CutCornerShapeTest {
3741

42+
@BeforeTest
43+
fun registerSkikoBackend() {
44+
registerSkikoComposeImplementation()
45+
}
46+
47+
// TODO: re-enable per-test cleanup once tests that register the backend asynchronously
48+
// (e.g. AWT ComposePanel/ComposeWindow via ComposeContainer on the EDT) no longer rely on
49+
// the registration persisting across tests.
50+
// @AfterTest
51+
// fun clearSkikoBackend() {
52+
// clearSkikoComposeImplementation()
53+
// }
54+
3855
private val density = Density(2f)
3956
private val size = Size(100.0f, 150.0f)
4057

compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/shape/RoundedCornerShapeTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package androidx.compose.foundation.shape
1818

19+
import androidx.compose.ui.InternalComposeUiApi
20+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
21+
import kotlin.test.BeforeTest
1922
import androidx.compose.foundation.assertThat
2023
import androidx.compose.foundation.isEqualTo
2124
import androidx.compose.foundation.isFalse
@@ -32,8 +35,22 @@ import androidx.compose.ui.unit.dp
3235
import kotlin.test.Test
3336
import kotlin.test.assertEquals
3437

38+
@OptIn(InternalComposeUiApi::class)
3539
class RoundedCornerShapeTest {
3640

41+
@BeforeTest
42+
fun registerSkikoBackend() {
43+
registerSkikoComposeImplementation()
44+
}
45+
46+
// TODO: re-enable per-test cleanup once tests that register the backend asynchronously
47+
// (e.g. AWT ComposePanel/ComposeWindow via ComposeContainer on the EDT) no longer rely on
48+
// the registration persisting across tests.
49+
// @AfterTest
50+
// fun clearSkikoBackend() {
51+
// clearSkikoComposeImplementation()
52+
// }
53+
3754
private val density = Density(2f)
3855
private val size = Size(100.0f, 150.0f)
3956

compose/foundation/foundation/src/skikoTest/kotlin/androidx/compose/foundation/text/CupertinoTextFieldDelegateTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package androidx.compose.foundation.text
1818

19+
import androidx.compose.ui.InternalComposeUiApi
20+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
21+
import kotlin.test.BeforeTest
1922
import androidx.compose.ui.text.AnnotatedString
2023
import androidx.compose.ui.text.MultiParagraph
2124
import androidx.compose.ui.text.TextLayoutInput
@@ -34,7 +37,21 @@ import kotlin.test.Test
3437
import kotlin.test.assertEquals
3538
import kotlinx.test.IgnoreWasmTarget
3639

40+
@OptIn(InternalComposeUiApi::class)
3741
class CupertinoTextFieldDelegateTest {
42+
43+
@BeforeTest
44+
fun registerSkikoBackend() {
45+
registerSkikoComposeImplementation()
46+
}
47+
48+
// TODO: re-enable per-test cleanup once tests that register the backend asynchronously
49+
// (e.g. AWT ComposePanel/ComposeWindow via ComposeContainer on the EDT) no longer rely on
50+
// the registration persisting across tests.
51+
// @AfterTest
52+
// fun clearSkikoBackend() {
53+
// clearSkikoComposeImplementation()
54+
// }
3855
private val sampleText =
3956
"aaaa bbb cccc dd e fffffffff?????????!!!!!!! ...\n" + "ggggggg tttt\n" +
4057
"Family emoji: \uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66\uD83D\uDC68\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC66, and some text at the end\n" +

compose/mpp/demo/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ kotlin {
136136
implementation(project(":compose:ui:ui-graphics"))
137137
implementation(project(":compose:ui:ui-text"))
138138
implementation(project(":compose:ui:ui-backhandler"))
139+
implementation(project(":compose:ui:ui-skiko"))
139140
implementation(project(":lifecycle:lifecycle-common"))
140141
implementation(project(":lifecycle:lifecycle-runtime"))
141142
implementation(project(":lifecycle:lifecycle-runtime-compose"))

compose/ui/ui-skiko/src/desktopTest/kotlin/androidx/compose/ui/text/DesktopParagraphIntegrationLineHeightStyleTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ class DesktopParagraphIntegrationLineHeightStyleTest {
4949
registerSkikoComposeImplementation()
5050
}
5151

52+
// TODO: re-enable per-test cleanup once async-registration tests (AWT) no longer rely on the
53+
// backend registration persisting across tests.
54+
// @After
55+
// fun cleanup() {
56+
// clearSkikoComposeImplementation()
57+
// }
58+
5259
// Lazy so the registry is populated by [setup] before the resolver is created.
5360
private val fontFamilyResolver by lazy { createFontFamilyResolver() }
5461
private val fontFamilyMeasureFont =

0 commit comments

Comments
 (0)