aboutsummaryrefslogtreecommitdiff
path: root/tools/tests/test_make_icon.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/tests/test_make_icon.py')
-rw-r--r--tools/tests/test_make_icon.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/tests/test_make_icon.py b/tools/tests/test_make_icon.py
new file mode 100644
index 0000000..66128c5
--- /dev/null
+++ b/tools/tests/test_make_icon.py
@@ -0,0 +1,25 @@
+"""Tests for tools/make_icon.py (launcher icon generator)."""
+
+from __future__ import annotations
+
+import make_icon
+from PIL import Image
+
+
+def rgba(img: Image.Image, xy: tuple[int, int]) -> tuple[int, ...]:
+ """One RGBA pixel as a tuple (Pillow's getpixel returns a wider union type)."""
+ value = img.getpixel(xy)
+ assert isinstance(value, tuple)
+ return value
+
+
+def test_icon_size_transparency_and_colours() -> None:
+ img = make_icon.draw_icon(60)
+ assert img.size == (60, 60)
+ assert img.mode == "RGBA"
+ # Corners are outside the disc, so fully transparent.
+ assert rgba(img, (0, 0))[3] == 0
+ # The disc edge is teal, the lock body in the middle is white.
+ r, g, b, a = rgba(img, (30, 4))
+ assert a > 200 and g > r and b > r
+ assert rgba(img, (22, 40))[:3] == (255, 255, 255)