From 2c041a9d1e370f14fffd15e9f4a6113002f05b1b Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 13 Jul 2026 09:55:32 +0000 Subject: feat(widget): add WidgetTextSize enum with independent header/content scaling --- .../org/terst/doot/widget/ui/WidgetTextSizeTest.kt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 android/app/src/test/java/org/terst/doot/widget/ui/WidgetTextSizeTest.kt (limited to 'android/app/src/test/java/org/terst/doot/widget') 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")) + } +} -- cgit v1.2.3