Skip to content

Replace Calculator placeholder with tests against real radioplayer types#7

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/create-testing-subproject
Draft

Replace Calculator placeholder with tests against real radioplayer types#7
Copilot wants to merge 3 commits intomainfrom
copilot/create-testing-subproject

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

The :tests subproject existed purely as a structural demo with an unrelated Calculator class. It now imports :radioplayer and tests the actual public API.

Constraint

PlatformMediaPlayer is an expect class with actual implementations only for Android and iOS. Adding a JVM target to :tests would fail to compile without a JVM actual.

Changes

  • radioplayer — adds jvm() target + a JVM stub actual class PlatformMediaPlayer that fires subscribeState/subscribeProgress callbacks synchronously and exposes currentState and emitProgress() for test assertions
  • tests/build.gradle.kts — adds projects.radioplayer as a commonTest dependency
  • tests/commonTest — replaces CalculatorTest with four focused test classes:
    • ProgressTest — data class equality, copy, elapsed/duration ratio
    • PlaybackStateTest — all 5 enum values, names, count
    • MediaPlayerItemTest — live station and on-demand track implementations
    • PlatformMediaPlayerTest — state transitions via subscribeState (common API only)
  • tests/jvmTestPlatformMediaPlayerJvmTest exercises JVM-stub extras (currentState, emitProgress)
// commonTest — uses only the expect class surface
@Test
fun testStopTransitionsToStoppedState() {
    val player = PlatformMediaPlayer()
    val states = mutableListOf<PlaybackState>()
    player.subscribeState { states += it }
    player.play()
    player.stop()
    assertEquals(listOf(PlaybackState.PLAYING, PlaybackState.STOPPED), states)
}

// jvmTest — uses the stub's extra helpers
@Test
fun testSubscribeProgressReceivesEmittedUpdates() {
    val player = PlatformMediaPlayer()
    val received = mutableListOf<Progress>()
    player.subscribeProgress { received += it }
    player.emitProgress(Progress(elapsed = 10.0, duration = 180.0))
    assertEquals(10.0, received[0].elapsed)
}

Run with ./gradlew :tests:jvmTest.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Add new subproject for testing KMP functionality Add :tests subproject demonstrating KMP multiplatform testing without swiftklib Mar 25, 2026
Copilot AI requested a review from markst March 25, 2026 10:39
Copilot AI changed the title Add :tests subproject demonstrating KMP multiplatform testing without swiftklib Replace Calculator placeholder with tests against real radioplayer types Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants