mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-10-09 21:21:18 +11:00
Automate WinUtil title screen generation (#4965)
* feat: add title screen generation tooling Add local automation for capturing WinUtil in Light and Dark themes and generating the composite title-screen image. * ci: automate title screen updates Add a manual Windows workflow that compiles WinUtil, generates the Light and Dark composite, and opens an image-only pull request. * docs: update AGENTS.md and SPEC.md with title-screen generation details * fix: address review comments Tested image is correct, SHA-256 hash is identical to the previously verified output. * fix: deselect bitmap before reading capture pixels
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
"""Smoke tests for the WinUtil title-screen compositor."""
|
||||
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
from create_composite import BORDER_COLOR, create_composite
|
||||
|
||||
|
||||
class CreateCompositeTests(unittest.TestCase):
|
||||
def test_creates_only_requested_composite(self):
|
||||
with tempfile.TemporaryDirectory(prefix="winutil-composite-test-") as temp_dir:
|
||||
work_dir = Path(temp_dir)
|
||||
dark_path = work_dir / "dark.png"
|
||||
light_path = work_dir / "light.png"
|
||||
output_path = work_dir / "title-screen.png"
|
||||
|
||||
self._create_capture(dark_path, (32, 34, 36, 255))
|
||||
self._create_capture(light_path, (235, 237, 239, 255))
|
||||
|
||||
result = create_composite(dark_path, light_path, output_path)
|
||||
|
||||
self.assertEqual(result, output_path)
|
||||
self.assertEqual(
|
||||
{path.name for path in work_dir.glob("*.png")},
|
||||
{"dark.png", "light.png", "title-screen.png"},
|
||||
)
|
||||
with Image.open(output_path) as composite:
|
||||
self.assertEqual(composite.size, (64, 40))
|
||||
self.assertEqual(composite.getpixel((0, 0)), BORDER_COLOR)
|
||||
self.assertEqual(composite.getpixel((5, 20)), (235, 237, 239, 255))
|
||||
self.assertEqual(composite.getpixel((58, 20)), (32, 34, 36, 255))
|
||||
|
||||
@staticmethod
|
||||
def _create_capture(path: Path, content_color: tuple[int, int, int, int]):
|
||||
image = Image.new("RGBA", (70, 46), (0, 0, 0, 255))
|
||||
draw = ImageDraw.Draw(image)
|
||||
draw.rectangle((3, 3, 66, 42), fill=content_color)
|
||||
image.save(path, "PNG")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user