-
Notifications
You must be signed in to change notification settings - Fork 5
feat(core): serial-timeline waveform pipeline (overlap, fall-ramp, handle lifecycle) #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ba3ed7e
build: run JUnit4 Robolectric tests via the vintage engine
l2hyunwoo dc66e2b
feat(core): add serial-timeline merge and fall-ramp primitives for ov…
l2hyunwoo 9007991
fix(android): serialize overlapping events and soften amplitude drops…
l2hyunwoo cb84684
fix(android): await the full waveform length including compat segments
l2hyunwoo 9700e78
test(android): cover await length and sub-threshold gap handling
l2hyunwoo e8d6160
fix(android): skip vibration for zero-duration or all-gap patterns
l2hyunwoo 9725488
test(android): cover zero-duration no-op and overlap await duration
l2hyunwoo f7996dc
test(core): property-test fall-ramp duration conservation across gap …
l2hyunwoo bd7860d
docs: write detail process of `HapticPattern.toWaveform()`
l2hyunwoo a4a0647
fix(core): expire HapticHandle.isActive when the estimated playback ends
l2hyunwoo b347741
test(core): cover HapticHandle expiry and natural-completion deactiva…
l2hyunwoo 13e8386
refactor(core): split executor helpers into one declaration per file
l2hyunwoo 34c376e
test(android): assert no waveform reaches the vibrator for silent pat…
l2hyunwoo c23df09
docs: document max-intensity resolution for overlapping included patt…
l2hyunwoo 812098d
docs: clarify fall-ramp scope and Samsung primer placement rationale
l2hyunwoo fbe49c2
refactor(core): extract playbackDurationMs to unify duration derivati…
l2hyunwoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...androidHostTest/kotlin/io/github/compose/jindong/core/executor/AndroidHapticHandleTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /* | ||
| * Copyright (C) 2026 compose-jindong | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.github.compose.jindong.core.executor | ||
|
|
||
| import android.content.Context | ||
| import android.os.Build | ||
| import android.os.Vibrator | ||
| import androidx.test.core.app.ApplicationProvider | ||
| import io.kotest.matchers.shouldBe | ||
| import org.junit.Before | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
| import org.robolectric.RobolectricTestRunner | ||
| import org.robolectric.annotation.Config | ||
| import kotlin.time.Duration.Companion.milliseconds | ||
| import kotlin.time.TestTimeSource | ||
|
|
||
| /** | ||
| * Time-based expiry behaviour of [AndroidHapticHandle], the bug this change fixes: before, `isActive` | ||
| * was decided once at construction (vibrator != null) and never noticed natural completion, so it | ||
| * stayed `true` until [AndroidHapticHandle.cancel]. A [TestTimeSource] drives expiry deterministically. | ||
| */ | ||
| @RunWith(RobolectricTestRunner::class) | ||
| @Config(sdk = [Build.VERSION_CODES.O]) | ||
| class AndroidHapticHandleTest { | ||
|
|
||
| private lateinit var vibrator: Vibrator | ||
|
|
||
| @Before | ||
| fun setup() { | ||
| val context: Context = ApplicationProvider.getApplicationContext() | ||
| vibrator = context.getSystemService(Vibrator::class.java) | ||
| } | ||
|
|
||
| @Test | ||
| fun `isActive is true right after creation`() { | ||
| val time = TestTimeSource() | ||
| val handle = AndroidHapticHandle(vibrator, totalDurationMs = 100L, timeSource = time) | ||
|
|
||
| handle.isActive shouldBe true | ||
| } | ||
|
|
||
| @Test | ||
| fun `isActive stays true before the duration elapses`() { | ||
| val time = TestTimeSource() | ||
| val handle = AndroidHapticHandle(vibrator, totalDurationMs = 100L, timeSource = time) | ||
|
|
||
| time += 99.milliseconds | ||
|
|
||
| handle.isActive shouldBe true | ||
| } | ||
|
|
||
| // Regression guard: the false positive the previous handle could never detect. | ||
| @Test | ||
| fun `isActive becomes false once the duration elapses without cancel`() { | ||
| val time = TestTimeSource() | ||
| val handle = AndroidHapticHandle(vibrator, totalDurationMs = 100L, timeSource = time) | ||
|
|
||
| time += 100.milliseconds | ||
|
|
||
| handle.isActive shouldBe false | ||
| } | ||
|
|
||
| @Test | ||
| fun `isActive is false after cancel regardless of time`() { | ||
| val time = TestTimeSource() | ||
| val handle = AndroidHapticHandle(vibrator, totalDurationMs = 100L, timeSource = time) | ||
|
|
||
| handle.cancel() | ||
|
|
||
| handle.isActive shouldBe false | ||
| } | ||
|
|
||
| @Test | ||
| fun `a silent pattern handle is inactive from the start`() { | ||
| val time = TestTimeSource() | ||
| val handle = AndroidHapticHandle(vibrator = null, totalDurationMs = 0L, timeSource = time) | ||
|
|
||
| handle.isActive shouldBe false | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.