Route notification alerts through playback
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
package se.ajpanton.notificationsmaster.alerts
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.pm.PackageManager
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import se.ajpanton.notificationsmaster.capture.NotificationCaptureService
|
||||
import se.ajpanton.notificationsmaster.settings.LoggingRule
|
||||
import se.ajpanton.notificationsmaster.settings.LoggingRuleStore
|
||||
import se.ajpanton.notificationsmaster.settings.LoggingType
|
||||
|
||||
class AlertListenerPolicyDeviceTest {
|
||||
private val context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
private val component = ComponentName(context, NotificationCaptureService::class.java)
|
||||
|
||||
@After
|
||||
fun restoreDefaults() {
|
||||
LoggingType.entries.forEach { LoggingRuleStore(context).save(it, LoggingRule()) }
|
||||
AlertConfigurationStore(context).save(AlertConfiguration())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun alertRuleKeepsListenerEnabledWithoutLogging() {
|
||||
LoggingType.entries.forEach { LoggingRuleStore(context).save(it, LoggingRule(enabled = false)) }
|
||||
val profile = AlertProfile("profile", "Profile", vibrationPattern = listOf(0, 10))
|
||||
val configuration = AlertConfiguration(
|
||||
profiles = listOf(profile),
|
||||
rules = listOf(
|
||||
AlertRule(
|
||||
"rule", "example.app", 0, setOf(AlertSource.NOTIFICATION_POST),
|
||||
outcome = AlertOutcome.PLAY_PROFILE, profileId = profile.id,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
AlertConfigurationStore(context).save(configuration)
|
||||
assertEquals(
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||
context.packageManager.getComponentEnabledSetting(component),
|
||||
)
|
||||
|
||||
AlertConfigurationStore(context).save(AlertConfiguration())
|
||||
assertEquals(
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
context.packageManager.getComponentEnabledSetting(component),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user