diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-17 13:17:18 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-17 13:17:18 +0200 |
| commit | b822cc3562b5277176f330587000ea5a556a4fed (patch) | |
| tree | eea11aadc3e407560542f4dcae17af9cf7b91bad /bin/udt-accent | |
| parent | 394eb7d1eb3e0366afa8bfbba4e579ab4cb66a46 (diff) | |
| download | unified-desktop-theme-b822cc3562b5277176f330587000ea5a556a4fed.tar.gz unified-desktop-theme-b822cc3562b5277176f330587000ea5a556a4fed.zip | |
test: make the SDDM selftest independent of SDDM_KEYS
Diffstat (limited to 'bin/udt-accent')
| -rwxr-xr-x | bin/udt-accent | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/bin/udt-accent b/bin/udt-accent index 610b04e..8d6a229 100755 --- a/bin/udt-accent +++ b/bin/udt-accent @@ -398,16 +398,31 @@ def selftest(): assert min(delta, 2 * math.pi - delta) < math.pi, (name, neighbour) # The SDDM theme reads this file through a symlink, so it has to carry every - # key the theme asks for, and a second run has to overwrite cleanly rather - # than append. - palette = {k: "#1e2030" for k in SDDM_KEYS} - probe_image = Path(tempfile.mkdtemp()) / "wall.png" - probe_image.write_bytes(b"") - text = sddm_conf(palette, FALLBACK, str(probe_image)) - for key in ["type", "background", "accent", *SDDM_KEYS]: - assert f"\n{key}=" in "\n" + text, f"sddm conf missing {key}" - assert text.count("accent=") == 1 - assert "background=" + str(probe_image) in text + # key the theme asks for. The names are spelled out here rather than read + # from SDDM_KEYS: deriving both the input and the check from the same + # constant would still pass if a key were dropped from the writer's list. + expected_keys = [ + "base", "mantle", "crust", "surface0", "surface1", "surface2", + "text", "subtext0", "subtext1", "overlay0", "overlay1", "overlay2", + "red", "yellow", "green", "teal", "blue", "lavender", + ] + with tempfile.TemporaryDirectory() as tmpdir: + probe_image = Path(tmpdir) / "wall.png" + probe_image.write_bytes(b"") + palette = {k: "#1e2030" for k in expected_keys} + text = sddm_conf(palette, FALLBACK, str(probe_image)) + for key in ["type", "background", "accent", *expected_keys]: + assert f"\n{key}=" in "\n" + text, f"sddm conf missing {key}" + assert text.count("accent=") == 1 + assert "background=" + os.path.realpath(probe_image) in text + + # A second run has to overwrite cleanly rather than append: the greeter + # rereads this file through a symlink on every login. + target = Path(tmpdir) / "sddm-theme.conf" + write_atomic(target, text) + write_atomic(target, sddm_conf(palette, FALLBACK, str(probe_image))) + assert target.read_text() == text, "second write changed the output" + assert target.read_text().count("[General]") == 1, "second write appended" print("selftest OK") |
