address review: keep notification taps working after recreation

This commit is contained in:
austinried
2026-10-04 00:30:07 +00:00
parent 46ab8f66c4
commit fd3b1ce298
4 changed files with 50 additions and 42 deletions
@@ -0,0 +1,37 @@
package com.subtracks
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class NowPlayingLaunchTest {
@Test
fun aFreshLaunchFromTheNotificationIsRecorded() {
assertTrue(
shouldRecordNowPlayingLaunch(
action = MainActivity.ACTION_OPEN_NOW_PLAYING,
restoringState = false,
),
)
}
@Test
fun recreatingTheActivityDoesNotReRecordTheLaunch() {
assertFalse(
shouldRecordNowPlayingLaunch(
action = MainActivity.ACTION_OPEN_NOW_PLAYING,
restoringState = true,
),
)
}
@Test
fun aNormalLaunchIsNotRecorded() {
assertFalse(shouldRecordNowPlayingLaunch(action = "android.intent.action.MAIN", restoringState = false))
}
@Test
fun aLaunchWithoutAnActionIsNotRecorded() {
assertFalse(shouldRecordNowPlayingLaunch(action = null, restoringState = false))
}
}
@@ -1,33 +0,0 @@
package com.subtracks.ui
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class NowPlayingRequestTest {
@Test
fun aNotificationWithNothingPlayingDoesNotOpen() {
assertFalse(shouldOpenNowPlaying(request = 1, handled = 0, playerVisible = false))
}
@Test
fun aNotificationWithSomethingPlayingOpens() {
assertTrue(shouldOpenNowPlaying(request = 1, handled = 0, playerVisible = true))
}
@Test
fun anAlreadyHandledRequestDoesNotReopen() {
assertFalse(shouldOpenNowPlaying(request = 1, handled = 1, playerVisible = true))
}
@Test
fun aNewerRequestOpensAgain() {
assertTrue(shouldOpenNowPlaying(request = 2, handled = 1, playerVisible = true))
}
@Test
fun anOldRequestWaitsUntilSomethingIsPlaying() {
assertFalse(shouldOpenNowPlaying(request = 1, handled = 0, playerVisible = false))
assertTrue(shouldOpenNowPlaying(request = 1, handled = 0, playerVisible = true))
}
}