Avoid inactive listener work and eager image encoding
This commit is contained in:
@@ -13,7 +13,6 @@ class GroupSummaryPolicyTest {
|
||||
hasImage = false,
|
||||
isGroupSummary = isGroupSummary,
|
||||
isRoutine = false,
|
||||
imageBytes = null,
|
||||
)
|
||||
|
||||
@Test fun `enabled group-summary logging retains summaries`() {
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.junit.Test
|
||||
class NotificationChangeClassifierTest {
|
||||
private fun snapshot(text: String, routine: Boolean = false) = NotificationSnapshot(
|
||||
key = "key", packageName = "example.app", textContents = text, hasImage = false,
|
||||
isGroupSummary = false, isRoutine = routine, imageBytes = null,
|
||||
isGroupSummary = false, isRoutine = routine,
|
||||
)
|
||||
|
||||
@Test fun `text change is an edit`() {
|
||||
|
||||
+12
-4
@@ -5,20 +5,28 @@ import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class NotificationListenerPolicyTest {
|
||||
@Test fun `listener runs when any logging type is enabled`() {
|
||||
assertTrue(NotificationListenerPolicy.shouldRun(listOf(LoggingRule(enabled = false), LoggingRule(enabled = true))))
|
||||
@Test fun `listener runs when any event logging type is enabled`() {
|
||||
assertTrue(NotificationListenerPolicy.shouldRun(rules(LoggingType.EDITS to true)))
|
||||
}
|
||||
|
||||
@Test fun `listener stays off when every logging type is disabled`() {
|
||||
assertFalse(NotificationListenerPolicy.shouldRun(LoggingType.entries.map { LoggingRule(enabled = false) }))
|
||||
assertFalse(NotificationListenerPolicy.shouldRun(rules()))
|
||||
}
|
||||
|
||||
@Test fun `content settings alone do not keep the listener active`() {
|
||||
assertFalse(NotificationListenerPolicy.shouldRun(rules(LoggingType.TEXT_CONTENT to true, LoggingType.IMAGE_CONTENT to true)))
|
||||
}
|
||||
|
||||
@Test fun `listener runs for an enabled per-app event override`() {
|
||||
assertTrue(
|
||||
NotificationListenerPolicy.shouldRun(
|
||||
LoggingType.entries.map { LoggingRule(enabled = false) },
|
||||
rules(),
|
||||
hasEnabledEventOverride = true,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun rules(vararg enabled: Pair<LoggingType, Boolean>) = LoggingType.entries.associateWith { type ->
|
||||
LoggingRule(enabled = enabled.firstOrNull { it.first == type }?.second ?: false)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user