summaryrefslogtreecommitdiff
path: root/android/app/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'android/app/src/test/java')
-rw-r--r--android/app/src/test/java/org/terst/doot/widget/ui/WidgetTextSizeTest.kt42
1 files changed, 42 insertions, 0 deletions
diff --git a/android/app/src/test/java/org/terst/doot/widget/ui/WidgetTextSizeTest.kt b/android/app/src/test/java/org/terst/doot/widget/ui/WidgetTextSizeTest.kt
new file mode 100644
index 0000000..b0826b5
--- /dev/null
+++ b/android/app/src/test/java/org/terst/doot/widget/ui/WidgetTextSizeTest.kt
@@ -0,0 +1,42 @@
+package org.terst.doot.widget.ui
+
+import androidx.glance.text.FontWeight
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+class WidgetTextSizeTest {
+
+ @Test
+ fun `SMALL reproduces base size and weight unchanged`() {
+ assertEquals(14f, WidgetTextSize.SMALL.scaledContentSize(14).value, 0.001f)
+ assertEquals(FontWeight.Normal, WidgetTextSize.SMALL.scaledContentWeight(FontWeight.Normal))
+ assertEquals(FontWeight.Bold, WidgetTextSize.SMALL.scaledHeaderWeight(FontWeight.Bold))
+ }
+
+ @Test
+ fun `NORMAL scales size by 1_15x and bumps weight one step`() {
+ assertEquals(16.1f, WidgetTextSize.NORMAL.scaledContentSize(14).value, 0.001f)
+ assertEquals(FontWeight.Medium, WidgetTextSize.NORMAL.scaledContentWeight(FontWeight.Normal))
+ assertEquals(FontWeight.Bold, WidgetTextSize.NORMAL.scaledHeaderWeight(FontWeight.Medium))
+ }
+
+ @Test
+ fun `LARGE scales size by 1_3x and bumps weight two steps`() {
+ assertEquals(18.2f, WidgetTextSize.LARGE.scaledContentSize(14).value, 0.001f)
+ assertEquals(FontWeight.Bold, WidgetTextSize.LARGE.scaledContentWeight(FontWeight.Normal))
+ }
+
+ @Test
+ fun `weight bump caps at Bold instead of overflowing`() {
+ assertEquals(FontWeight.Bold, WidgetTextSize.LARGE.scaledContentWeight(FontWeight.Bold))
+ assertEquals(FontWeight.Bold, WidgetTextSize.LARGE.scaledHeaderWeight(FontWeight.Medium))
+ }
+
+ @Test
+ fun `fromPref falls back to NORMAL for missing or invalid values, else parses by name`() {
+ assertEquals(WidgetTextSize.NORMAL, WidgetTextSize.fromPref(null))
+ assertEquals(WidgetTextSize.NORMAL, WidgetTextSize.fromPref("bogus"))
+ assertEquals(WidgetTextSize.SMALL, WidgetTextSize.fromPref("SMALL"))
+ assertEquals(WidgetTextSize.LARGE, WidgetTextSize.fromPref("LARGE"))
+ }
+}