mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-12 23:30:52 +01:00
Every Flutter app still shipped the stock Flutter "beach" launcher icon, and none had an adaptive-icon descriptor at all. Rather than hand-drawing five one-off icons, define the family once and let each app contribute only an accent colour and a glyph. The family: a charcoal #1B1D21 field carrying one glyph in that app's own theme seed colour, at a single stroke weight. Glyphs are optically centred automatically - render.centre_offset rasterises a glyph alone, measures its ink box, and translates (never scales) the fragment, so a row of icons lines up while every icon keeps the exact family stroke weight. safe_box_overflow warns when a glyph exceeds the 560px adaptive-icon safe box; it caught three real overflows that a launcher mask would have clipped. The registry points dufs_client at ~/dufs-cloud/app: ~/dufs_client was a stale, remote-less checkout with an identical package name, since deleted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
"""Tests for the app registry, glyph library and family style invariants."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from python_pkg.app_icons import apps, glyphs, style
|
|
|
|
|
|
class TestGlyphLookup:
|
|
def test_known_glyph(self) -> None:
|
|
assert glyphs.get_glyph("barbell").name == "barbell"
|
|
|
|
def test_unknown_glyph_lists_alternatives(self) -> None:
|
|
with pytest.raises(KeyError, match="barbell"):
|
|
glyphs.get_glyph("nope")
|
|
|
|
|
|
class TestAppLookup:
|
|
def test_known_app(self) -> None:
|
|
assert apps.get_app("todo").glyph == "checklist"
|
|
|
|
def test_unknown_app_lists_alternatives(self) -> None:
|
|
with pytest.raises(KeyError, match="todo"):
|
|
apps.get_app("nope")
|
|
|
|
def test_asset_dir_is_under_repo(self) -> None:
|
|
app = apps.get_app("todo")
|
|
assert app.asset_dir == app.repo / "assets" / "icon"
|
|
|
|
|
|
class TestFamilyInvariants:
|
|
def test_every_app_references_a_real_glyph(self) -> None:
|
|
for app in apps.APPS.values():
|
|
assert app.glyph in glyphs.GLYPHS
|
|
|
|
def test_accents_are_unique(self) -> None:
|
|
accents = [app.accent for app in apps.APPS.values()]
|
|
assert len(set(accents)) == len(accents)
|
|
|
|
def test_accents_are_hex_triplets(self) -> None:
|
|
for app in apps.APPS.values():
|
|
assert app.accent.startswith("#")
|
|
assert len(app.accent) == 7
|
|
int(app.accent[1:], 16)
|
|
|
|
def test_safe_box_fits_inside_canvas(self) -> None:
|
|
assert style.SAFE_BOX < style.CANVAS
|
|
assert style.MIN_NEGATIVE_SPACE == style.STROKE_WIDTH / 2
|