Suppress matched native notification alerts
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
||||
package se.ajpanton.notificationsmaster.module
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import se.ajpanton.notificationsmaster.alerts.AlertConfiguration
|
||||
import se.ajpanton.notificationsmaster.alerts.AlertOutcome
|
||||
import se.ajpanton.notificationsmaster.alerts.AlertProfile
|
||||
import se.ajpanton.notificationsmaster.alerts.AlertRule
|
||||
import se.ajpanton.notificationsmaster.alerts.AlertSource
|
||||
import se.ajpanton.notificationsmaster.alerts.AlertTextMatcher
|
||||
import se.ajpanton.notificationsmaster.alerts.AlertConfigurationStore
|
||||
|
||||
/** Installs a predictable helper policy for the AOSP LSPosed smoke test. */
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class AlertPolicySyncDeviceTest {
|
||||
@Test
|
||||
fun savesMatchingHelperPolicy() {
|
||||
val profile = AlertProfile("module-test", "Module test", vibrationPattern = listOf(0, 200))
|
||||
val configuration = AlertConfiguration(
|
||||
profiles = listOf(profile),
|
||||
rules = listOf(
|
||||
AlertRule(
|
||||
id = "module-helper-post",
|
||||
packageName = HELPER_PACKAGE,
|
||||
order = 0,
|
||||
sources = setOf(AlertSource.NOTIFICATION_POST),
|
||||
matcher = AlertTextMatcher(),
|
||||
outcome = AlertOutcome.PLAY_PROFILE,
|
||||
profileId = profile.id,
|
||||
),
|
||||
),
|
||||
)
|
||||
val store = AlertConfigurationStore(InstrumentationRegistry.getInstrumentation().targetContext)
|
||||
store.save(configuration)
|
||||
assertEquals(configuration, store.load())
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val HELPER_PACKAGE = "se.ajpanton.notificationsmaster.helper"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user