address review: keep the notification tap when the activity is recreated

This commit is contained in:
austinried
2026-10-04 00:30:07 +00:00
parent b3cad97869
commit 0cd6f30c88
6 changed files with 63 additions and 50 deletions
@@ -1,37 +0,0 @@
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))
}
}
@@ -0,0 +1,36 @@
package com.subtracks
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class NowPlayingLaunchViewModelTest {
@Test
fun aFreshLaunchFromTheNotificationIsClaimed() {
assertTrue(NowPlayingLaunchViewModel().claimLaunch(MainActivity.ACTION_OPEN_NOW_PLAYING))
}
@Test
fun recreatingTheActivityDoesNotReClaimTheLaunch() {
val viewModel = NowPlayingLaunchViewModel()
assertTrue(viewModel.claimLaunch(MainActivity.ACTION_OPEN_NOW_PLAYING))
assertFalse(viewModel.claimLaunch(MainActivity.ACTION_OPEN_NOW_PLAYING))
}
@Test
fun aWarmTapMarksTheLaunchHandled() {
val viewModel = NowPlayingLaunchViewModel()
viewModel.markHandled()
assertFalse(viewModel.claimLaunch(MainActivity.ACTION_OPEN_NOW_PLAYING))
}
@Test
fun aNormalLaunchIsNotClaimed() {
assertFalse(NowPlayingLaunchViewModel().claimLaunch("android.intent.action.MAIN"))
}
@Test
fun aLaunchWithoutAnActionIsNotClaimed() {
assertFalse(NowPlayingLaunchViewModel().claimLaunch(null))
}
}