aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/udt-accent35
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")