@momo-kits/native-kits 0.169.13-beta.3-debug → 0.169.13-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/ios/native-kits.podspec +1 -1
  2. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  3. package/package.json +1 -1
  4. package/build.gradle.kts +0 -11
  5. package/compose/build.gradle.kts +0 -202
  6. package/compose/compose.podspec +0 -47
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  14. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiActionsTest.kt +0 -647
  15. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiExprTest.kt +0 -1411
  16. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiHostTest.kt +0 -130
  17. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitArgsTest.kt +0 -524
  18. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitNodesTest.kt +0 -559
  19. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderPlanTest.kt +0 -741
  20. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderReuseTest.kt +0 -221
  21. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRendererPropsTest.kt +0 -270
  22. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStylePlanTest.kt +0 -849
  23. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStyleTest.kt +0 -212
  24. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiTrackingTest.kt +0 -239
  25. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiViewTest.kt +0 -252
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -61
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -268
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -354
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -130
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -137
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -262
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -237
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -342
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -362
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -304
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -308
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -218
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -456
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -175
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -208
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -291
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -71
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -315
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -54
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -206
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -421
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -750
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -152
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -242
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -398
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -103
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -93
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -208
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -133
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -400
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -7
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -21
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiActions.kt +0 -154
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiExpr.kt +0 -1038
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiKitNodes.kt +0 -848
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiLog.kt +0 -47
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiModel.kt +0 -39
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiPropsRenderer.kt +0 -463
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiRenderer.kt +0 -1146
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiStyle.kt +0 -667
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiTracking.kt +0 -240
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiValidate.kt +0 -185
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiView.kt +0 -200
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  147. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  148. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  149. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -117
  150. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  151. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  152. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  153. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  154. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -65
  155. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  156. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  157. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -143
  158. package/gradle/libs.versions.toml +0 -69
  159. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  160. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  161. package/gradle.properties +0 -24
  162. package/gradlew +0 -252
  163. package/gradlew.bat +0 -94
  164. package/ios-demo/README.md +0 -120
  165. package/scripts/sdui-visual/README.md +0 -64
  166. package/settings.gradle.kts +0 -64
@@ -1,221 +0,0 @@
1
- // File: compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderReuseTest.kt
2
- // Created At: 2026-11-10 10:00:00 +07:00
3
- // Created By: AI
4
- // AI Agent: Claude Code
5
- // Model: claude-opus-5-5
6
-
7
- package vn.momo.kits.sdui
8
-
9
- import androidx.compose.runtime.mutableStateMapOf
10
- import org.junit.Assert.assertEquals
11
- import org.junit.Assert.assertFalse
12
- import org.junit.Assert.assertNotEquals
13
- import org.junit.Assert.assertNotSame
14
- import org.junit.Assert.assertSame
15
- import org.junit.Assert.assertTrue
16
- import org.junit.Test
17
- import vn.momo.kits.const.defaultTheme
18
-
19
- // AI-GENERATED START: unit tests for resolving a child's styles once and for stable repeat-row scopes
20
- class SduiRenderReuseTest {
21
- private val state = mutableStateMapOf<String, Any?>()
22
- private val sink = object : TrackSink {
23
- override val id = "rec"
24
- val records = mutableListOf<TrackRecord>()
25
- override fun write(record: TrackRecord) { records += record }
26
- }
27
- private val session = Tracker(listOf(sink), "sess").begin(SessionCtx("sdui:view:t"))
28
- private fun nodeErrors() = sink.records.filter { it.event.step == "sdui_node_error" }.map { it.event.fields }
29
- private fun scopeOf(data: Map<String, Any?> = emptyMap()) = SduiScope(data, state, nodeErrors = NodeErrorSink { session })
30
- private val ctx = SduiCtx(defaultTheme, state, { _, _, _, _, _, _, _ -> }, session = session)
31
-
32
- // ---- styles resolved once per child ---------------------------------------------------------------------------
33
- @Test fun layChildrenResolvesEachChildExactlyOnceAndSplitsAbsoluteOnes() {
34
- val sc = scopeOf()
35
- val kids = listOf(
36
- mapOf("type" to "Text", "styles" to mapOf("flex" to 1L)),
37
- mapOf("type" to "View", "styles" to mapOf("position" to "absolute", "top" to 4L)),
38
- mapOf("type" to "Text"),
39
- )
40
- val all = expand(kids, sc, defaultTheme, null)
41
- val calls = mutableListOf<Expanded>()
42
- val (flow, abs) = layChildren(all) { calls += it; preStyOf(it.node, it.scope, ctx) }
43
- assertEquals(all, calls) // once each, in order
44
- assertEquals(listOf(0, 2), flow.map { it.e.index })
45
- assertEquals(listOf(1), abs.map { it.e.index })
46
- assertTrue(flow[0].pre.sty.isFlexOne)
47
- }
48
-
49
- @Test fun aPreResolvedStyleReportsNothingUntilTheChildUsesItThenOnceOnItsOwnPath() {
50
- val sc = scopeOf()
51
- val child = mapOf("type" to "Text", "id" to "t", "styles" to mapOf("backgroundColor" to "Colors.nope", "flex" to "{((}"))
52
- val pre = preStyOf(child, sc, ctx)
53
- assertTrue(nodeErrors().isEmpty())
54
- assertEquals(setOf("unknown_token", "expr_failed"), pre.errors)
55
- val sty = styOf(child, sc, ctx, "body.children.2", pre)
56
- assertEquals(styOf(child, scopeOf(), ctx, null), sty) // same value as the child resolving it itself
57
- assertEquals(listOf("body.children.2", "body.children.2"), nodeErrors().map { it["nodePath"] })
58
- assertEquals(listOf("unknown_token", "expr_failed"), nodeErrors().map { it["code"] })
59
- assertTrue(nodeErrors().all { it["nodeId"] == "t" && it["nodeType"] == "Text" })
60
- }
61
-
62
- @Test fun aPreResolvedStyleReportsLikeTheChildsOwnResolution() {
63
- val node = mapOf("type" to "View", "styles" to mapOf("padding" to "Spacing.ZZZ"))
64
- styOf(node, scopeOf(), ctx, "body.children.0")
65
- val own = nodeErrors()
66
- sink.records.clear()
67
- // another path: the session reports a path / code / reason once
68
- styOf(node, scopeOf(), ctx, "body.children.1", preStyOf(node, scopeOf(), ctx))
69
- assertEquals(1, own.size)
70
- assertEquals(own.map { it + ("nodePath" to "body.children.1") }, nodeErrors())
71
- }
72
-
73
- // ---- styles that are accepted but ignored (text keys, alignSelf) ------------------------------------------------
74
- @Test fun anIgnoredStyleKeyReportsOnceOnTheNodesOwnPathAndLeavesThePlanAlone() {
75
- val lines = mutableListOf<String>()
76
- val c = SduiCtx(defaultTheme, state, { _, _, _, _, _, _, _ -> }, session = session, log = capturingLog(lines))
77
- val node = mapOf("type" to "View", "id" to "v", "styles" to mapOf("fontWeight" to "bold", "padding" to 4L))
78
- val sc = scopeOf()
79
- val sty = styOf(node, sc, c, "body.children.1")
80
- repeat(3) { styOf(node, sc, c, "body.children.1") } // recompositions
81
- styOf(node, sc, c, "body.children.1", preStyOf(node, sc, c)) // a parent that resolved it for layout
82
- assertEquals(
83
- listOf(mapOf("step" to "sdui_node_error", "code" to "unsupported_style", "reason" to "fontWeight", "nodePath" to "body.children.1",
84
- "nodeId" to "v", "nodeType" to "View")),
85
- nodeErrors(),
86
- )
87
- assertEquals(1, lines.size)
88
- assertTrue(lines[0], lines[0].endsWith("body.children.1: styles.fontWeight is ignored; use props.typography/props.color"))
89
- assertFalse(lines[0].contains("bold")) // the value never reaches the log
90
- // still drawn: the plan is exactly the one without the key
91
- assertEquals(stylePlanOf(Sty(mapOf("padding" to 4L)), stretch = true), stylePlanOf(sty, stretch = true))
92
- }
93
-
94
- @Test fun eachIgnoredKeyReportsItsOwnReasonAndAlignSelfItsOwnHint() {
95
- val lines = mutableListOf<String>()
96
- val c = SduiCtx(defaultTheme, state, { _, _, _, _, _, _, _ -> }, session = session, log = capturingLog(lines))
97
- val node = mapOf("type" to "Text", "styles" to mapOf("color" to "#fff", "fontSize" to 14L, "alignSelf" to "center", "margin" to 2L))
98
- styOf(node, scopeOf(), c, "body")
99
- assertEquals(listOf("fontSize", "color", "alignSelf"), nodeErrors().map { it["reason"] })
100
- assertTrue(nodeErrors().all { it["code"] == "unsupported_style" && it["nodePath"] == "body" })
101
- assertTrue(lines.any { it.endsWith("body: styles.alignSelf is ignored; use the parent's alignItems") })
102
- assertEquals(3, lines.size)
103
- }
104
-
105
- @Test fun anIgnoredStyleIsNotReportedByAQuietProbeNorByAParentResolvingIt() {
106
- val node = mapOf("type" to "Text", "styles" to mapOf("lineHeight" to 20L))
107
- styOf(node, scopeOf(), ctx, null)
108
- preStyOf(node, scopeOf(), ctx)
109
- assertTrue(nodeErrors().isEmpty())
110
- // a whole-binding styles map is checked once resolved
111
- val bound = mapOf("type" to "View", "styles" to "{s}")
112
- styOf(bound, scopeOf(mapOf("s" to mapOf("letterSpacing" to 1L))), ctx, "body.children.0")
113
- assertEquals(listOf("letterSpacing"), nodeErrors().map { it["reason"] })
114
- }
115
-
116
- @Test fun eachRepeatCopyGetsTheStylesOfItsOwnScope() {
117
- val sc = scopeOf(mapOf("rows" to listOf(mapOf("w" to 10L), mapOf("w" to 20L))))
118
- val node = mapOf("type" to "View", "repeat" to mapOf("source" to "rows", "as" to "r"), "styles" to mapOf("width" to "{r.w}"))
119
- val (flow, _) = layChildren(expand(listOf(node), sc, defaultTheme, null)) { preStyOf(it.node, it.scope, ctx) }
120
- assertEquals(listOf(10L, 20L), flow.map { it.pre.sty.m["width"] })
121
- flow.forEach { assertEquals(styOf(it.e.node, it.e.scope, ctx, null), it.pre.sty) }
122
- }
123
-
124
- @Test fun styAndPreStyCompareByValue() {
125
- assertEquals(Sty(mapOf("a" to 1L)), Sty(mapOf("a" to 1L)))
126
- assertNotEquals(Sty(mapOf("a" to 1L)), Sty(mapOf("a" to 2L)))
127
- assertEquals(PreSty(Sty(mapOf("a" to 1L)), setOf("x")), PreSty(Sty(mapOf("a" to 1L)), setOf("x")))
128
- }
129
-
130
- // ---- stable repeat-row scopes --------------------------------------------------------------------------------
131
- private val row = mapOf("type" to "Text", "repeat" to mapOf("source" to "{state.rows}", "as" to "r", "index" to "i"), "props" to mapOf("children" to "{r.t}"))
132
- private fun rows(vararg t: String) = t.map { mapOf("t" to it) }
133
-
134
- @Test fun unchangedRowsKeepTheirScopeAndTheListIsReused() {
135
- state["rows"] = rows("a", "b", "c")
136
- val sc = scopeOf(); val cache = ExpandCache(); val nodes = listOf(row, mapOf("type" to "Text"))
137
- val first = expand(nodes, sc, defaultTheme, null, cache)
138
- val second = expand(nodes, sc, defaultTheme, null, cache)
139
- assertSame(first, second)
140
- assertEquals(4, second.size)
141
- }
142
-
143
- @Test fun anEqualItemThatIsANewInstanceKeepsTheScope() {
144
- state["rows"] = rows("a", "b")
145
- val sc = scopeOf(); val cache = ExpandCache()
146
- val first = expand(listOf(row), sc, defaultTheme, null, cache)
147
- state["rows"] = rows("a", "b") // e.g. a filter / map expression re-run
148
- val second = expand(listOf(row), sc, defaultTheme, null, cache)
149
- assertSame(first[0].scope, second[0].scope); assertSame(first[1].scope, second[1].scope)
150
- }
151
-
152
- @Test fun aChangedItemGetsANewScopeOthersKeepTheirs() {
153
- state["rows"] = rows("a", "b", "c")
154
- val sc = scopeOf(); val cache = ExpandCache()
155
- val first = expand(listOf(row), sc, defaultTheme, null, cache)
156
- state["rows"] = rows("a", "B", "c")
157
- val second = expand(listOf(row), sc, defaultTheme, null, cache)
158
- assertSame(first[0].scope, second[0].scope); assertSame(first[2].scope, second[2].scope)
159
- assertNotSame(first[1].scope, second[1].scope)
160
- assertEquals("B", evalExpr("r.t", second[1].scope))
161
- assertEquals(1L, evalExpr("i", second[1].scope))
162
- }
163
-
164
- @Test fun anInsertedRowShiftsTheItemsSoShiftedRowsGetNewScopesWithTheirNewIndex() {
165
- state["rows"] = rows("a", "b")
166
- val sc = scopeOf(); val cache = ExpandCache()
167
- expand(listOf(row), sc, defaultTheme, null, cache)
168
- state["rows"] = rows("z", "a", "b")
169
- val second = expand(listOf(row), sc, defaultTheme, null, cache)
170
- assertEquals(listOf("z", "a", "b"), second.map { evalExpr("r.t", it.scope) })
171
- assertEquals(listOf(0L, 1L, 2L), second.map { evalExpr("i", it.scope) })
172
- }
173
-
174
- @Test fun aNewParentScopeOrSpecNodeGivesNewRows() {
175
- state["rows"] = rows("a")
176
- val cache = ExpandCache(); val sc = scopeOf()
177
- val first = expand(listOf(row), sc, defaultTheme, null, cache)
178
- val otherParent = expand(listOf(row), sc.with("x", 1L), defaultTheme, null, cache)
179
- assertNotSame(first[0].scope, otherParent[0].scope)
180
- assertEquals(1L, evalExpr("x", otherParent[0].scope))
181
- val otherNode = expand(listOf(row + ("id" to "n2")), sc, defaultTheme, null, cache)
182
- assertNotSame(otherParent[0].scope, otherNode[0].scope)
183
- assertEquals("n2", otherNode[0].node["id"])
184
- }
185
-
186
- @Test fun visibleIsStillEvaluatedEveryTimeAndAHiddenRowComesBackWithItsScope() {
187
- state["rows"] = rows("a", "b"); state["hide"] = ""
188
- val node = row + ("visible" to "{r.t != state.hide}")
189
- val sc = scopeOf(); val cache = ExpandCache()
190
- val first = expand(listOf(node), sc, defaultTheme, null, cache)
191
- state["hide"] = "b"
192
- assertEquals(listOf("a"), expand(listOf(node), sc, defaultTheme, null, cache).map { evalExpr("r.t", it.scope) })
193
- state["hide"] = ""
194
- val third = expand(listOf(node), sc, defaultTheme, null, cache)
195
- assertSame(first[1].scope, third[1].scope)
196
- }
197
-
198
- @Test fun cachedExpansionStillReportsBrokenVisibleOnTheChildPath() {
199
- val cache = ExpandCache(); val sc = scopeOf()
200
- val kids = listOf(mapOf("type" to "Text", "visible" to "{((}"))
201
- expand(kids, sc, defaultTheme, "body.children.3", cache)
202
- assertEquals(listOf("body.children.3.children.0"), nodeErrors().map { it["nodePath"] })
203
- }
204
-
205
- @Test fun withoutACacheEveryExpansionMakesNewScopes() {
206
- state["rows"] = rows("a")
207
- val sc = scopeOf()
208
- assertNotSame(expand(listOf(row), sc, defaultTheme, null)[0].scope, expand(listOf(row), sc, defaultTheme, null)[0].scope)
209
- }
210
-
211
- @Test fun aReusedRowScopeStillReadsLiveState() {
212
- state["rows"] = rows("a"); state["n"] = 1L
213
- val sc = scopeOf(); val cache = ExpandCache()
214
- val first = expand(listOf(row), sc, defaultTheme, null, cache)
215
- state["n"] = 2L
216
- val second = expand(listOf(row), sc, defaultTheme, null, cache)
217
- assertSame(first[0].scope, second[0].scope)
218
- assertEquals(2L, evalExpr("n", second[0].scope))
219
- }
220
- }
221
- // AI-GENERATED END: unit tests for resolving a child's styles once and for stable repeat-row scopes
@@ -1,270 +0,0 @@
1
- // File: compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRendererPropsTest.kt
2
- // Created At: 2026-11-03 10:00:00 +07:00
3
- // Created By: AI
4
- // AI Agent: Claude Code
5
- // Model: claude-sonnet-5-5
6
-
7
- package vn.momo.kits.sdui
8
-
9
- import androidx.compose.foundation.layout.Arrangement
10
- import androidx.compose.foundation.layout.PaddingValues
11
- import androidx.compose.ui.Alignment
12
- import androidx.compose.ui.graphics.Color
13
- import androidx.compose.ui.text.input.KeyboardType
14
- import androidx.compose.ui.text.style.TextDecoration
15
- import androidx.compose.ui.text.style.TextOverflow
16
- import androidx.compose.ui.unit.TextUnit
17
- import androidx.compose.ui.unit.dp
18
- import androidx.compose.ui.unit.sp
19
- import vn.momo.kits.components.ButtonSize
20
- import vn.momo.kits.components.ChipSize
21
- import vn.momo.kits.components.RibbonPosition
22
- import vn.momo.kits.components.TagColor
23
- import vn.momo.kits.components.TagSize
24
- import vn.momo.kits.components.ButtonType
25
- import vn.momo.kits.components.DotSize
26
- import vn.momo.kits.components.IconAlign
27
- import vn.momo.kits.components.ImageState
28
- import vn.momo.kits.components.InputFontWeight
29
- import vn.momo.kits.components.Size
30
- import vn.momo.kits.components.TabViewType
31
- import vn.momo.kits.components.TitleSize
32
- import org.junit.Test
33
- import org.junit.Assert.assertEquals
34
- import org.junit.Assert.assertNotNull
35
- import org.junit.Assert.assertNull
36
-
37
- class SduiRendererPropsTest {
38
- @Test fun buttonArgsDefaultsAreKitDefaults() {
39
- val a = buttonArgsOf(emptyMap())
40
- assertEquals(ButtonArgs(ButtonType.PRIMARY, Size.LARGE, "Button", "", "", false, true, true), a)
41
- }
42
-
43
- @Test fun buttonArgsSetValuesAndIconsNotSwapped() {
44
- val a = buttonArgsOf(mapOf(
45
- "type" to "danger", "size" to "small", "title" to "Pay", "iconLeft" to "L", "iconRight" to "R",
46
- "loading" to true, "useTintColor" to false, "full" to false,
47
- ))
48
- assertEquals(ButtonArgs(ButtonType.DANGER, Size.SMALL, "Pay", "L", "R", true, false, false), a)
49
- assertEquals(Size.LARGE, buttonArgsOf(mapOf("size" to "huge")).size)
50
- }
51
-
52
- @Test fun textProps() {
53
- assertEquals(TextOverflow.Ellipsis, textOverflowOf("ellipsis"))
54
- assertEquals(TextOverflow.Visible, textOverflowOf("visible"))
55
- assertEquals(TextOverflow.Clip, textOverflowOf(null))
56
- assertEquals(TextOverflow.Clip, textOverflowOf("zzz"))
57
- // numberOfLines set and no overflow -> "…" (owner-approved exception to the kit's Clip default)
58
- assertEquals(TextOverflow.Ellipsis, textOverflowOf(null, linesLimited = true))
59
- assertEquals(TextOverflow.Clip, textOverflowOf("clip", linesLimited = true))
60
- assertEquals(TextDecoration.Underline, textDecorationOf("underline"))
61
- assertEquals(TextDecoration.LineThrough, textDecorationOf("line-through"))
62
- assertEquals(TextDecoration.LineThrough, textDecorationOf("line_through"))
63
- assertEquals(TextDecoration.combine(listOf(TextDecoration.Underline, TextDecoration.LineThrough)), textDecorationOf("underline line-through"))
64
- assertNull(textDecorationOf("none")); assertNull(textDecorationOf(null))
65
- assertEquals(TextUnit.Unspecified, letterSpacingOf(null))
66
- assertEquals(1.5f.sp, letterSpacingOf(1.5))
67
- assertEquals("fam", optStr("fam")); assertNull(optStr("")); assertNull(optStr(null))
68
- assertEquals(1, intOr(null, 1)); assertEquals(3, intOr(3L, 1))
69
- }
70
-
71
- @Test fun titleProps() {
72
- assertEquals(TitleSize.Medium, titleSizeOf(null))
73
- assertEquals(TitleSize.Small, titleSizeOf("small"))
74
- assertEquals(TitleSize.Large, titleSizeOf("large"))
75
- assertEquals(TitleSize.Medium, titleSizeOf("xx"))
76
- assertEquals(IconAlign.Top, iconAlignOf(null))
77
- assertEquals(IconAlign.Center, iconAlignOf("center"))
78
- assertEquals(IconAlign.Bottom, iconAlignOf("bottom"))
79
- assertEquals(ButtonSize.Small, titleButtonSizeOf(null))
80
- assertEquals(ButtonSize.Large, titleButtonSizeOf("large"))
81
- }
82
-
83
- @Test fun imageProps() {
84
- assertEquals(Alignment.TopStart, alignmentOf(null, Alignment.TopStart))
85
- assertEquals(Alignment.BottomEnd, alignmentOf("bottom_end", Alignment.TopStart))
86
- assertEquals(Alignment.Center, alignmentOf("center", Alignment.TopStart))
87
- assertEquals(Alignment.TopStart, alignmentOf("nope", Alignment.TopStart))
88
- assertNull(colorFilterOf(null)); assertNotNull(colorFilterOf(Color.Red))
89
- assertEquals(1f, alphaOf(null)); assertEquals(0.5f, alphaOf(0.5)); assertEquals(1f, alphaOf(7))
90
- assertEquals("success", imageStateName(ImageState.Success))
91
- assertEquals("error", imageStateName(ImageState.Error))
92
- assertEquals("loading", imageStateName(ImageState.Loading))
93
- }
94
-
95
- @Test fun paddingValues() {
96
- assertNull(paddingValuesOf(null))
97
- assertEquals(PaddingValues(8.dp), paddingValuesOf(8))
98
- assertEquals(PaddingValues(start = 4.dp, top = 2.dp, end = 4.dp, bottom = 2.dp), paddingValuesOf(mapOf("horizontal" to 4, "vertical" to 2)))
99
- assertEquals(PaddingValues(start = 1.dp, top = 0.dp, end = 3.dp, bottom = 0.dp), paddingValuesOf(mapOf("left" to 1, "right" to 3)))
100
- }
101
-
102
- @Test fun tabViewProps() {
103
- assertEquals(TabViewType.DEFAULT, tabViewTypeOf(null))
104
- assertEquals(TabViewType.CARD, tabViewTypeOf("card"))
105
- assertEquals(DotSize.Small, dotSizeOf(null))
106
- assertEquals(DotSize.Large, dotSizeOf("large"))
107
- }
108
-
109
- @Test fun paginationKinds() {
110
- assertEquals(PaginationKind.DOT, paginationKindOf(null))
111
- assertEquals(PaginationKind.WHITE_DOT, paginationKindOf("white_dot"))
112
- assertEquals(PaginationKind.WHITE_DOT, paginationKindOf("white-dot"))
113
- assertEquals(PaginationKind.NUMBER, paginationKindOf("number"))
114
- assertEquals(PaginationKind.SCROLL, paginationKindOf("scroll"))
115
- assertEquals(PaginationKind.DOT, paginationKindOf("?"))
116
- }
117
-
118
- @Test fun scrollArrangements() {
119
- assertEquals(Arrangement.Start, horizontalArrangementOf(null))
120
- assertEquals(Arrangement.SpaceBetween, horizontalArrangementOf("space_between"))
121
- assertEquals(Arrangement.Top, verticalArrangementOf(null))
122
- assertEquals(Arrangement.Bottom, verticalArrangementOf("bottom"))
123
- assertEquals(Arrangement.Center, verticalArrangementOf("center"))
124
- }
125
-
126
- @Test fun inputSearchProps() {
127
- assertEquals(InputFontWeight.REGULAR, inputFontWeightOf(null, InputFontWeight.REGULAR))
128
- assertEquals(InputFontWeight.BOLD, inputFontWeightOf("bold", InputFontWeight.REGULAR))
129
- assertEquals(InputFontWeight.BOLD, inputFontWeightOf("BOLD", InputFontWeight.REGULAR))
130
- assertEquals(KeyboardType.Text, keyboardTypeOf(null))
131
- assertEquals(KeyboardType.Number, keyboardTypeOf("number"))
132
- assertEquals(KeyboardType.Number, keyboardTypeOf("number-pad"))
133
- assertEquals(KeyboardType.NumberPassword, keyboardTypeOf("number_password"))
134
- assertEquals(KeyboardType.Text, keyboardTypeOf("zzz"))
135
- }
136
-
137
- @Test fun snakeAndColours() {
138
- assertEquals("top_right", snake("top-right")); assertEquals("line_through", snake("LINE_THROUGH")); assertNull(snake(3))
139
- assertEquals(KIT_LABEL, "Label")
140
- assertEquals(Color(0xFFFF0000), parseColor("#FF0000"))
141
- }
142
-
143
- // ---- numeric strings ----
144
- @Test fun numericStringsAreAccepted() {
145
- assertEquals(6, intOr("6", 12)); assertEquals(12, intOr("abc", 12)); assertEquals(12, intOr(null, 12))
146
- assertEquals(1.5f, floatOr("1.5", 1f)); assertEquals(1f, floatOr(true, 1f))
147
- assertEquals(500L, longOr("500", 3000L)); assertEquals(3000L, longOr(listOf(1), 3000L))
148
- assertEquals(6, itemArgsOf(mapOf("widthSpan" to "6")).widthSpan)
149
- }
150
-
151
- // ---- Text lines ----
152
- @Test fun textLinesClamp() {
153
- assertEquals(Int.MAX_VALUE, maxLinesOf(null)); assertEquals(Int.MAX_VALUE, maxLinesOf(0))
154
- assertEquals(Int.MAX_VALUE, maxLinesOf(-3)); assertEquals(Int.MAX_VALUE, maxLinesOf("x"))
155
- assertEquals(2, maxLinesOf(2)); assertEquals(2, maxLinesOf("2"))
156
- assertEquals(1, minLinesOf(null, 5)); assertEquals(1, minLinesOf(0, 5)); assertEquals(1, minLinesOf(-2, 5))
157
- assertEquals(3, minLinesOf(3, 5)); assertEquals(2, minLinesOf(9, 2))
158
- assertEquals(1, minLinesOf(9, 1))
159
- }
160
-
161
- // ---- padding ----
162
- @Test fun negativePaddingClampedToZero() {
163
- assertEquals(PaddingValues(0.dp), paddingValuesOf(-5))
164
- assertEquals(PaddingValues(start = 0.dp, top = 2.dp, end = 0.dp, bottom = 2.dp),
165
- paddingValuesOf(mapOf("horizontal" to -4, "vertical" to 2)))
166
- assertEquals(PaddingValues(start = 0.dp, top = 0.dp, end = 3.dp, bottom = 0.dp), paddingValuesOf(mapOf("left" to -1, "right" to 3)))
167
- assertEquals(16.dp, PaddingValues(start = 4.dp, end = 12.dp).horizontal())
168
- }
169
-
170
- // ---- grid ----
171
- @Test fun gridSizePerSpanUsesActualCardPadding() {
172
- // default Card padding 12 -> 24 horizontal: identical to the old fixed assumption
173
- val old = (360.dp - 24.dp - 24.dp - 8.dp * 11) / 12 - (1f / 12).dp
174
- assertEquals(old.value, gridSizePerSpan(360.dp, true, true, 24.dp).value, 0.001f)
175
- // zero padding gives each span more room; a wide padding gives less
176
- assertEquals(24f / 12f, gridSizePerSpan(360.dp, true, true, 24.dp).value - gridSizePerSpan(360.dp, true, true, 48.dp).value, 0.001f)
177
- assert(gridSizePerSpan(360.dp, true, true, 0.dp) > gridSizePerSpan(360.dp, true, true, 24.dp))
178
- // Section: no card padding, gutter 12
179
- assertEquals(((360.dp - 24.dp - 12.dp * 11) / 12 - (1f / 12).dp).value, gridSizePerSpan(360.dp, true, false, 24.dp).value, 0.001f)
180
- assertEquals(0f, gridSizePerSpan(20.dp, true, true, 24.dp).value, 0f)
181
- }
182
-
183
- @Test fun itemSpans() {
184
- assertEquals(ItemArgs(12, 0), itemArgsOf(emptyMap()))
185
- assertEquals(ItemArgs(12, 0), itemArgsOf(mapOf("widthSpan" to "wide", "heightSpan" to null)))
186
- assertEquals(ItemArgs(1, 0), itemArgsOf(mapOf("widthSpan" to 0, "heightSpan" to -2)))
187
- assertEquals(ItemArgs(12, 3), itemArgsOf(mapOf("widthSpan" to 99, "heightSpan" to 3)))
188
- assertEquals(ItemArgs(6, 4), itemArgsOf(mapOf("widthSpan" to 6L, "heightSpan" to "4")))
189
- }
190
-
191
- @Test fun sectionAndCardArgs() {
192
- val s = gridArgsOf(mapOf("useMargin" to false, "backgroundImage" to "https://x/y.png", "useShadow" to true), card = false)
193
- assertEquals(false, s.useMargin); assertEquals(false, s.useShadow); assertEquals("https://x/y.png", s.backgroundImage)
194
- assertEquals(true, gridArgsOf(emptyMap(), false).useMargin)
195
- val c = gridArgsOf(mapOf("useMargin" to false, "useShadow" to true, "contentPadding" to -8), card = true)
196
- assertEquals(true, c.useMargin); assertEquals(true, c.useShadow); assertEquals(PaddingValues(0.dp), c.contentPadding)
197
- assertEquals(PaddingValues(12.dp), gridArgsOf(emptyMap(), true).contentPadding)
198
- assertEquals(false, gridArgsOf(emptyMap(), true).useShadow)
199
- assertNull(gridArgsOf(emptyMap(), true).backgroundImage)
200
- assertEquals(Color(0xFFFF0000), gridArgsOf(mapOf("backgroundColor" to "#FF0000"), true).backgroundColor)
201
- }
202
-
203
- // ---- Badge / Ribbon / Tag / Chip ----
204
- @Test fun badgeArgs() {
205
- assertEquals(BadgeArgs(KIT_LABEL, null), badgeArgsOf(emptyMap()))
206
- assertEquals(BadgeArgs("New", Color(0xFF00FF00)), badgeArgsOf(mapOf("label" to "New", "backgroundColor" to "#00FF00")))
207
- }
208
-
209
- @Test fun ribbonArgs() {
210
- assertEquals(RibbonArgs(RibbonPosition.TopRight, KIT_LABEL, false), ribbonArgsOf(emptyMap()))
211
- assertEquals(RibbonPosition.TopLeft, ribbonArgsOf(mapOf("position" to "top_left")).position)
212
- assertEquals(RibbonPosition.BottomLeft, ribbonArgsOf(mapOf("position" to "bottom-left")).position)
213
- assertEquals(RibbonPosition.BottomRight, ribbonArgsOf(mapOf("position" to "bottom_right")).position)
214
- assertEquals(RibbonPosition.TopRight, ribbonArgsOf(mapOf("position" to "nowhere")).position)
215
- assertEquals(RibbonPosition.TopRight, ribbonArgsOf(mapOf("position" to 3)).position)
216
- assertEquals(true, ribbonArgsOf(mapOf("isRound" to true, "label" to "Hot")).isRound)
217
- }
218
-
219
- @Test fun tagArgs() {
220
- assertEquals(TagArgs(KIT_LABEL, null, null, TagColor.Default, TagSize.Large), tagArgsOf(emptyMap()))
221
- val t = tagArgsOf(mapOf("label" to "A", "icon" to "ic", "color" to "green", "size" to "medium", "customColor" to "#0000FF"))
222
- assertEquals(TagArgs("A", "ic", Color(0xFF0000FF), TagColor.Green, TagSize.Medium), t)
223
- assertEquals(TagSize.Large, tagArgsOf(mapOf("size" to "huge")).size)
224
- }
225
-
226
- @Test fun chipArgsKeepIconsAndTintsApart() {
227
- assertEquals(ChipArgs(KIT_LABEL, null, null, null, null, null, false, ChipSize.LARGE, null), chipArgsOf(emptyMap()))
228
- val c = chipArgsOf(mapOf(
229
- "label" to "L", "iconLeft" to "left", "iconRight" to "right", "iconLeftTint" to "#FF0000", "iconRightTint" to "#0000FF",
230
- "backgroundColor" to "#00FF00", "selected" to true, "size" to "small", "accessibilityLabel" to "a",
231
- ))
232
- assertEquals("left", c.iconLeft); assertEquals("right", c.iconRight)
233
- assertEquals(Color(0xFFFF0000), c.iconLeftTint); assertEquals(Color(0xFF0000FF), c.iconRightTint)
234
- assertEquals(Color(0xFF00FF00), c.backgroundColor)
235
- assertEquals(true, c.selected); assertEquals(ChipSize.SMALL, c.size); assertEquals("a", c.accessibilityLabel)
236
- }
237
-
238
- // ---- Carousel ----
239
- @Test fun autoplayIntervalHasAFloor() {
240
- assertEquals(3000L, autoplayIntervalOf(null)); assertEquals(1000L, autoplayIntervalOf(0))
241
- assertEquals(1000L, autoplayIntervalOf(-50)); assertEquals(1000L, autoplayIntervalOf("10"))
242
- assertEquals(5000L, autoplayIntervalOf("5000")); assertEquals(2500L, autoplayIntervalOf(2500))
243
- }
244
-
245
- // ---- InputSearch overlay decision ----
246
- private fun searchNode(vararg actions: String, props: Map<String, Any?> = emptyMap()): Node =
247
- mapOf("type" to "InputSearch", "props" to props, "actions" to actions.map { mapOf("name" to it) })
248
-
249
- @Test fun searchOverlayOnlyForPurePressable() {
250
- assertEquals(true, searchShowsOverlay(searchNode("onPress")))
251
- assertEquals(false, searchPressOnFocus(searchNode("onPress")))
252
- // typing callback present: no overlay, onPress fires on focus
253
- for (cb in SEARCH_TYPING_CALLBACKS) {
254
- val n = searchNode("onPress", cb)
255
- assertEquals(cb, false, searchShowsOverlay(n)); assertEquals(cb, true, searchPressOnFocus(n))
256
- }
257
- // no onPress: never an overlay
258
- assertEquals(false, searchShowsOverlay(searchNode("onChangeText")))
259
- assertEquals(false, searchShowsOverlay(searchNode()))
260
- assertEquals(false, searchPressOnFocus(searchNode("onChangeText")))
261
- }
262
-
263
- @Test fun searchOverlayReadsPropFormActions() {
264
- val pressInProps = searchNode(props = mapOf("onPress" to mapOf("set" to "x")))
265
- assertEquals(true, searchShowsOverlay(pressInProps))
266
- val both = searchNode(props = mapOf("onPress" to mapOf("set" to "x"), "onChangeText" to mapOf("set" to "q")))
267
- assertEquals(false, searchShowsOverlay(both)); assertEquals(true, searchPressOnFocus(both))
268
- assertEquals(false, searchShowsOverlay(searchNode("onPress", props = mapOf("onFocus" to listOf(mapOf("set" to "x"))))))
269
- }
270
- }