Skip to content

Commit 0fdfdd3

Browse files
committed
Use included lib modules in CI and clean interaction tests
1 parent 8e16183 commit 0fdfdd3

File tree

4 files changed

+157
-27
lines changed

4 files changed

+157
-27
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ jobs:
4747
if: steps.changes.outputs.should_run == 'true'
4848
run: |
4949
set -euo pipefail
50-
cd lib
51-
./gradlew publishRecorderModulesToMavenLocal \
52-
-x signMavenPublication \
53-
-x signPluginMavenPublication \
54-
-x signComposeGifRecorderPluginMarkerMavenPublication \
55-
--info
56-
cd ..
5750
./gradlew appTest --info
5851
cd lib
5952
./gradlew recorderTest --info

lib/recorder-annotations/src/main/kotlin/io/github/hdcodedev/composegif/annotations/RecordGif.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ public annotation class GifInteraction(
5656
val type: GifInteractionType = GifInteractionType.PAUSE,
5757
val frames: Int = 0,
5858
val framesAfter: Int = 0,
59+
/**
60+
* Target lane for the interaction.
61+
*
62+
* For taps, this is the tap point.
63+
*
64+
* For swipes, this selects the lane perpendicular to the swipe direction:
65+
* - horizontal swipes (`LEFT_TO_RIGHT`, `RIGHT_TO_LEFT`) use `TOP`/`BOTTOM` for Y lane,
66+
* - vertical swipes (`TOP_TO_BOTTOM`, `BOTTOM_TO_TOP`) use `LEFT`/`RIGHT` for X lane,
67+
* - other values fall back to center lane.
68+
*/
5969
val target: GifInteractionTarget = GifInteractionTarget.CENTER,
6070
val direction: GifSwipeDirection = GifSwipeDirection.LEFT_TO_RIGHT,
6171
val distance: GifSwipeDistance = GifSwipeDistance.MEDIUM,

lib/recorder-ksp/src/test/kotlin/io/github/hdcodedev/composegif/ksp/InteractionGestureExpanderTest.kt

Lines changed: 134 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package io.github.hdcodedev.composegif.ksp
22

3+
import io.github.hdcodedev.composegif.annotations.GifGestureType
4+
import io.github.hdcodedev.composegif.annotations.GifInteractionTarget
5+
import io.github.hdcodedev.composegif.annotations.GifInteractionType
6+
import io.github.hdcodedev.composegif.annotations.GifSwipeDirection
7+
import io.github.hdcodedev.composegif.annotations.GifSwipeDistance
38
import kotlin.test.Test
49
import kotlin.test.assertEquals
510
import kotlin.test.assertTrue
@@ -10,13 +15,13 @@ class InteractionGestureExpanderTest {
1015
val gestures =
1116
InteractionGestureExpander.expand(
1217
InteractionSpec(
13-
type = "PAUSE",
18+
type = GifInteractionType.PAUSE.name,
1419
frames = 12,
1520
),
1621
)
1722

1823
assertEquals(1, gestures.size)
19-
assertEquals("PAUSE", gestures.single().type)
24+
assertEquals(GifGestureType.PAUSE.name, gestures.single().type)
2025
assertEquals(12, gestures.single().frames)
2126
}
2227

@@ -25,15 +30,15 @@ class InteractionGestureExpanderTest {
2530
val gestures =
2631
InteractionGestureExpander.expand(
2732
InteractionSpec(
28-
type = "TAP",
29-
target = "RIGHT",
33+
type = GifInteractionType.TAP.name,
34+
target = GifInteractionTarget.RIGHT.name,
3035
frames = 7,
3136
framesAfter = 0,
3237
),
3338
)
3439

3540
val tap = gestures.single()
36-
assertEquals("TAP", tap.type)
41+
assertEquals(GifGestureType.TAP.name, tap.type)
3742
assertEquals(0.70f, tap.xFraction)
3843
assertEquals(0.5f, tap.yFraction)
3944
assertEquals(7, tap.framesAfter)
@@ -44,10 +49,10 @@ class InteractionGestureExpanderTest {
4449
val gestures =
4550
InteractionGestureExpander.expand(
4651
InteractionSpec(
47-
type = "SWIPE",
48-
target = "TOP",
49-
direction = "RIGHT_TO_LEFT",
50-
distance = "LONG",
52+
type = GifInteractionType.SWIPE.name,
53+
target = GifInteractionTarget.TOP.name,
54+
direction = GifSwipeDirection.RIGHT_TO_LEFT.name,
55+
distance = GifSwipeDistance.LONG.name,
5156
travelFrames = 9,
5257
holdStartFrames = 4,
5358
releaseFrames = 3,
@@ -57,14 +62,14 @@ class InteractionGestureExpanderTest {
5762

5863
assertEquals(2, gestures.size)
5964
val drag = gestures[0]
60-
assertEquals("DRAG_PATH", drag.type)
65+
assertEquals(GifGestureType.DRAG_PATH.name, drag.type)
6166
assertEquals(4, drag.holdStartFrames)
6267
assertEquals(9, drag.framesPerWaypoint)
6368
assertEquals(3, drag.releaseFrames)
6469
assertEquals(2, drag.points.size)
6570
assertTrue(drag.points[0].x > drag.points[1].x)
6671
assertEquals(0.30f, drag.points[0].y)
67-
assertEquals("PAUSE", gestures[1].type)
72+
assertEquals(GifGestureType.PAUSE.name, gestures[1].type)
6873
assertEquals(5, gestures[1].frames)
6974
}
7075

@@ -73,22 +78,34 @@ class InteractionGestureExpanderTest {
7378
val leftToRight =
7479
InteractionGestureExpander
7580
.expand(
76-
InteractionSpec(type = "SWIPE", direction = "LEFT_TO_RIGHT"),
81+
InteractionSpec(
82+
type = GifInteractionType.SWIPE.name,
83+
direction = GifSwipeDirection.LEFT_TO_RIGHT.name,
84+
),
7785
).first()
7886
val rightToLeft =
7987
InteractionGestureExpander
8088
.expand(
81-
InteractionSpec(type = "SWIPE", direction = "RIGHT_TO_LEFT"),
89+
InteractionSpec(
90+
type = GifInteractionType.SWIPE.name,
91+
direction = GifSwipeDirection.RIGHT_TO_LEFT.name,
92+
),
8293
).first()
8394
val topToBottom =
8495
InteractionGestureExpander
8596
.expand(
86-
InteractionSpec(type = "SWIPE", direction = "TOP_TO_BOTTOM"),
97+
InteractionSpec(
98+
type = GifInteractionType.SWIPE.name,
99+
direction = GifSwipeDirection.TOP_TO_BOTTOM.name,
100+
),
87101
).first()
88102
val bottomToTop =
89103
InteractionGestureExpander
90104
.expand(
91-
InteractionSpec(type = "SWIPE", direction = "BOTTOM_TO_TOP"),
105+
InteractionSpec(
106+
type = GifInteractionType.SWIPE.name,
107+
direction = GifSwipeDirection.BOTTOM_TO_TOP.name,
108+
),
92109
).first()
93110

94111
assertTrue(leftToRight.points.first().x < leftToRight.points.last().x)
@@ -102,17 +119,26 @@ class InteractionGestureExpanderTest {
102119
val shortSwipe =
103120
InteractionGestureExpander
104121
.expand(
105-
InteractionSpec(type = "SWIPE", distance = "SHORT"),
122+
InteractionSpec(
123+
type = GifInteractionType.SWIPE.name,
124+
distance = GifSwipeDistance.SHORT.name,
125+
),
106126
).first()
107127
val mediumSwipe =
108128
InteractionGestureExpander
109129
.expand(
110-
InteractionSpec(type = "SWIPE", distance = "MEDIUM"),
130+
InteractionSpec(
131+
type = GifInteractionType.SWIPE.name,
132+
distance = GifSwipeDistance.MEDIUM.name,
133+
),
111134
).first()
112135
val longSwipe =
113136
InteractionGestureExpander
114137
.expand(
115-
InteractionSpec(type = "SWIPE", distance = "LONG"),
138+
InteractionSpec(
139+
type = GifInteractionType.SWIPE.name,
140+
distance = GifSwipeDistance.LONG.name,
141+
),
116142
).first()
117143

118144
val shortDelta = shortSwipe.points.last().x - shortSwipe.points.first().x
@@ -123,6 +149,96 @@ class InteractionGestureExpanderTest {
123149
assertTrue(mediumDelta < longDelta)
124150
}
125151

152+
@Test
153+
fun horizontalSwipeUsesTopBottomTargetLaneAndIgnoresLeftRightTarget() {
154+
val topLane =
155+
InteractionGestureExpander
156+
.expand(
157+
InteractionSpec(
158+
type = GifInteractionType.SWIPE.name,
159+
direction = GifSwipeDirection.LEFT_TO_RIGHT.name,
160+
target = GifInteractionTarget.TOP.name,
161+
),
162+
).first()
163+
val bottomLane =
164+
InteractionGestureExpander
165+
.expand(
166+
InteractionSpec(
167+
type = GifInteractionType.SWIPE.name,
168+
direction = GifSwipeDirection.LEFT_TO_RIGHT.name,
169+
target = GifInteractionTarget.BOTTOM.name,
170+
),
171+
).first()
172+
val leftTarget =
173+
InteractionGestureExpander
174+
.expand(
175+
InteractionSpec(
176+
type = GifInteractionType.SWIPE.name,
177+
direction = GifSwipeDirection.LEFT_TO_RIGHT.name,
178+
target = GifInteractionTarget.LEFT.name,
179+
),
180+
).first()
181+
val rightTarget =
182+
InteractionGestureExpander
183+
.expand(
184+
InteractionSpec(
185+
type = GifInteractionType.SWIPE.name,
186+
direction = GifSwipeDirection.LEFT_TO_RIGHT.name,
187+
target = GifInteractionTarget.RIGHT.name,
188+
),
189+
).first()
190+
191+
assertEquals(0.30f, topLane.points.first().y)
192+
assertEquals(0.70f, bottomLane.points.first().y)
193+
assertEquals(0.5f, leftTarget.points.first().y)
194+
assertEquals(0.5f, rightTarget.points.first().y)
195+
}
196+
197+
@Test
198+
fun verticalSwipeUsesLeftRightTargetLaneAndIgnoresTopBottomTarget() {
199+
val leftLane =
200+
InteractionGestureExpander
201+
.expand(
202+
InteractionSpec(
203+
type = GifInteractionType.SWIPE.name,
204+
direction = GifSwipeDirection.TOP_TO_BOTTOM.name,
205+
target = GifInteractionTarget.LEFT.name,
206+
),
207+
).first()
208+
val rightLane =
209+
InteractionGestureExpander
210+
.expand(
211+
InteractionSpec(
212+
type = GifInteractionType.SWIPE.name,
213+
direction = GifSwipeDirection.TOP_TO_BOTTOM.name,
214+
target = GifInteractionTarget.RIGHT.name,
215+
),
216+
).first()
217+
val topTarget =
218+
InteractionGestureExpander
219+
.expand(
220+
InteractionSpec(
221+
type = GifInteractionType.SWIPE.name,
222+
direction = GifSwipeDirection.TOP_TO_BOTTOM.name,
223+
target = GifInteractionTarget.TOP.name,
224+
),
225+
).first()
226+
val bottomTarget =
227+
InteractionGestureExpander
228+
.expand(
229+
InteractionSpec(
230+
type = GifInteractionType.SWIPE.name,
231+
direction = GifSwipeDirection.TOP_TO_BOTTOM.name,
232+
target = GifInteractionTarget.BOTTOM.name,
233+
),
234+
).first()
235+
236+
assertEquals(0.30f, leftLane.points.first().x)
237+
assertEquals(0.70f, rightLane.points.first().x)
238+
assertEquals(0.5f, topTarget.points.first().x)
239+
assertEquals(0.5f, bottomTarget.points.first().x)
240+
}
241+
126242
@Test
127243
fun unknownInteractionTypeProducesNoGestures() {
128244
val gestures =

settings.gradle.kts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pluginManagement {
22
repositories {
3-
mavenLocal()
43
google {
54
content {
65
includeGroupByRegex("com\\.android.*")
@@ -18,11 +17,23 @@ plugins {
1817
dependencyResolutionManagement {
1918
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
2019
repositories {
21-
mavenLocal()
2220
google()
2321
mavenCentral()
2422
}
2523
}
2624

25+
includeBuild("lib") {
26+
dependencySubstitution {
27+
substitute(module("io.github.hdcodedev:compose-gif-recorder-annotations"))
28+
.using(project(":recorder-annotations"))
29+
substitute(module("io.github.hdcodedev:compose-gif-recorder-core"))
30+
.using(project(":recorder-core"))
31+
substitute(module("io.github.hdcodedev:compose-gif-recorder-ksp"))
32+
.using(project(":recorder-ksp"))
33+
substitute(module("io.github.hdcodedev:compose-gif-recorder-android"))
34+
.using(project(":recorder-android"))
35+
}
36+
}
37+
2738
rootProject.name = "demo"
2839
include(":app")

0 commit comments

Comments
 (0)