Simplify and organize settings pages

This commit is contained in:
ajp_anton
2026-07-27 12:59:26 +00:00
parent 3dc87b417a
commit cad73e33a0
21 changed files with 293 additions and 426 deletions
@@ -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)
}
}
@@ -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"))
}
}