mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 22:47:02 +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>
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""Tests for app_icons.preview."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from python_pkg.app_icons import preview
|
|
|
|
if TYPE_CHECKING:
|
|
from pathlib import Path
|
|
|
|
MOD = "python_pkg.app_icons.preview"
|
|
|
|
|
|
class TestBuildContactSheet:
|
|
@patch(f"{MOD}.subprocess.run")
|
|
@patch(f"{MOD}.render.rasterise")
|
|
@patch(f"{MOD}.render.centre_offset", return_value=(0.0, 0.0))
|
|
@patch(f"{MOD}.render.resolve_tool", return_value="/usr/bin/magick")
|
|
def test_renders_one_tile_per_app_and_three_rows(
|
|
self,
|
|
mock_tool: MagicMock,
|
|
mock_offset: MagicMock,
|
|
raster: MagicMock,
|
|
run: MagicMock,
|
|
tmp_path: Path,
|
|
) -> None:
|
|
destination = tmp_path / "out" / "sheet.png"
|
|
assert preview.build_contact_sheet(["todo", "workout_app"], destination) == (
|
|
destination
|
|
)
|
|
assert raster.call_count == 2
|
|
# per app: circle mask + downscale; then 3 row montages + 1 append.
|
|
assert run.call_count == 2 * 2 + 3 + 1
|
|
assert destination.parent.is_dir()
|
|
|
|
@patch(f"{MOD}.subprocess.run")
|
|
@patch(f"{MOD}.render.rasterise")
|
|
@patch(f"{MOD}.render.centre_offset", return_value=(0.0, 0.0))
|
|
@patch(f"{MOD}.render.resolve_tool", return_value="/usr/bin/magick")
|
|
def test_final_append_is_vertical(
|
|
self,
|
|
mock_tool: MagicMock,
|
|
mock_offset: MagicMock,
|
|
mock_raster: MagicMock,
|
|
run: MagicMock,
|
|
tmp_path: Path,
|
|
) -> None:
|
|
preview.build_contact_sheet(["todo"], tmp_path / "sheet.png")
|
|
assert "-append" in run.call_args.args[0]
|