Simplify and organize settings pages
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
package se.ajpanton.notificationlog.settings
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotSame
|
||||
import org.junit.Test
|
||||
|
||||
class LoggingRuleCopyTest {
|
||||
@Test fun `copy retains every rule field and owns its selected-package set`() {
|
||||
val source = LoggingRule(false, AppRuleMode.WHITELIST, setOf("example.app"), true, false, false)
|
||||
val target = source.copyForTarget()
|
||||
|
||||
assertEquals(source, target)
|
||||
assertNotSame(source.selectedPackages, target.selectedPackages)
|
||||
}
|
||||
}
|
||||
+3
-6
@@ -6,22 +6,19 @@ import org.junit.Test
|
||||
|
||||
class NotificationRuleEvaluatorTest {
|
||||
@Test fun `default blacklist allows every app`() {
|
||||
assertTrue(NotificationRuleEvaluator.allows(LoggingRule(), "example.app"))
|
||||
assertTrue(NotificationRuleEvaluator.allows(AppFilterSettings(), "example.app"))
|
||||
}
|
||||
|
||||
@Test fun `blacklist excludes selected app`() {
|
||||
val rule = LoggingRule(selectedPackages = setOf("example.app"))
|
||||
val rule = AppFilterSettings(selectedPackages = setOf("example.app"))
|
||||
assertFalse(NotificationRuleEvaluator.allows(rule, "example.app"))
|
||||
assertTrue(NotificationRuleEvaluator.allows(rule, "other.app"))
|
||||
}
|
||||
|
||||
@Test fun `whitelist accepts only selected app`() {
|
||||
val rule = LoggingRule(appRuleMode = AppRuleMode.WHITELIST, selectedPackages = setOf("example.app"))
|
||||
val rule = AppFilterSettings(mode = AppRuleMode.WHITELIST, selectedPackages = setOf("example.app"))
|
||||
assertTrue(NotificationRuleEvaluator.allows(rule, "example.app"))
|
||||
assertFalse(NotificationRuleEvaluator.allows(rule, "other.app"))
|
||||
}
|
||||
|
||||
@Test fun `disabled rule rejects selected app`() {
|
||||
assertFalse(NotificationRuleEvaluator.allows(LoggingRule(enabled = false), "example.app"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user