diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-13 09:55:32 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-16 02:39:57 +0000 |
| commit | 2c041a9d1e370f14fffd15e9f4a6113002f05b1b (patch) | |
| tree | b6b0070d8e3866834c787755bd6a8cdb65d3d35f /android/app/src/test/java/org/terst/doot/widget | |
| parent | b3176c0ba3acdeb5de973dfef7712bdc9dfab785 (diff) | |
feat(widget): add WidgetTextSize enum with independent header/content scaling
Diffstat (limited to 'android/app/src/test/java/org/terst/doot/widget')
| -rw-r--r-- | android/app/src/test/java/org/terst/doot/widget/ui/WidgetTextSizeTest.kt | 42 |
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")) + } +} |
