Skip to content

Commit a83e18d

Browse files
committed
test: separate RecordingHapticExecutor from test code
1 parent c388375 commit a83e18d

2 files changed

Lines changed: 44 additions & 25 deletions

File tree

jindong-compose/src/commonTest/kotlin/io/github/compose/jindong/JindongReactiveTest.kt

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,14 @@ import androidx.compose.runtime.getValue
2222
import androidx.compose.runtime.mutableStateOf
2323
import androidx.compose.ui.test.ExperimentalTestApi
2424
import androidx.compose.ui.test.runComposeUiTest
25-
import io.github.compose.jindong.core.executor.HapticExecutor
26-
import io.github.compose.jindong.core.executor.HapticHandle
27-
import io.github.compose.jindong.core.model.HapticPattern
2825
import io.github.compose.jindong.core.ms
2926
import io.github.compose.jindong.dsl.Haptic
3027
import io.github.compose.jindong.dsl.RepeatWithIndex
3128
import io.github.compose.jindong.executor.LocalHapticExecutor
29+
import io.github.compose.jindong.executor.RecordingHapticExecutor
3230
import io.kotest.core.spec.style.FunSpec
3331
import io.kotest.matchers.shouldBe
3432

35-
/**
36-
* Records executed patterns so a test can inspect what [Jindong] played for a given key.
37-
*/
38-
private class RecordingHapticExecutor : HapticExecutor {
39-
override val isSupported: Boolean = true
40-
41-
val executedPatterns = mutableListOf<HapticPattern>()
42-
43-
override suspend fun execute(pattern: HapticPattern) {
44-
executedPatterns += pattern
45-
}
46-
47-
override fun executeAsync(pattern: HapticPattern): HapticHandle = NoopHapticHandle
48-
49-
override fun release() = Unit
50-
51-
private object NoopHapticHandle : HapticHandle {
52-
override val isActive: Boolean = false
53-
override fun cancel() = Unit
54-
}
55-
}
56-
5733
class JindongReactiveTest :
5834
FunSpec({
5935
test("Jindong recompiles its pattern when the key changes") {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2026 compose-jindong
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.github.compose.jindong.executor
17+
18+
import io.github.compose.jindong.Jindong
19+
import io.github.compose.jindong.core.executor.HapticExecutor
20+
import io.github.compose.jindong.core.executor.HapticHandle
21+
import io.github.compose.jindong.core.model.HapticPattern
22+
23+
/**
24+
* Records executed patterns so a test can inspect what [Jindong] played for a given key.
25+
*/
26+
internal class RecordingHapticExecutor : HapticExecutor {
27+
override val isSupported: Boolean = true
28+
29+
val executedPatterns = mutableListOf<HapticPattern>()
30+
31+
override suspend fun execute(pattern: HapticPattern) {
32+
executedPatterns += pattern
33+
}
34+
35+
override fun executeAsync(pattern: HapticPattern): HapticHandle = NoopHapticHandle
36+
37+
override fun release() = Unit
38+
39+
internal object NoopHapticHandle : HapticHandle {
40+
override val isActive: Boolean = false
41+
override fun cancel() = Unit
42+
}
43+
}

0 commit comments

Comments
 (0)