mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
address review: keep the notification tap when the activity is recreated
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user