Files
Classroom_Desktop/tests/test-classroom-desktop-layout.sh
T
ekklesiaandClaude Opus 5 d2d30d6b0c feat: take the last of sway out of the classroom
The DVD player was the only thing still speaking a compositor the room
no longer runs. It asked sway's tree whether VLC's window had really
gone fullscreen, because VLC reports playing while its window is still
the black startup one the loading cover exists to hide.

VLC's own status was measured as a replacement and is not one: it
reports fullscreen true in the same 250ms poll as playing, because the
flag is the option it was started with and not a report about its
window. So the cover is held for a floor and capped by the deadline that
was already there, and the compositor is not asked anything.

Focus-or-launch went the same way. The session already takes an
exclusive lock, so a second one cannot start, and bringing an existing
one to the front is the panel's job.

classroom-window, classroom_sway and classroom_chrome are gone with it —
the last of them was reachable from nothing at all.

DVD also moves out of the status row, where it sat beside the clock as
though a disc were a machine reading. It is an application: it is in the
row with Wonder Ink and the browser, and classroom-provision removes it
from the layout on a machine with no optical drive, which retires
DVD_ENABLED. A computer that moves between rooms takes its drive with
it; nobody remembers to edit a file when it does.

The panel is rebuilt from the package at every login now. Plasma keeps
whatever panel it first built, so an update could change the bar in the
package and never change it in a room — measured, with an icon that
outlived the file it came from. Editing the live panel configuration was
tried instead and destroyed the panel, because the shell owns that file.
Removing it before the shell starts is safe and makes the desktop
stateless.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-10 13:00:50 -05:00

94 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
set -uo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PYTHONPATH="$ROOT/lib" python3 - "$ROOT" <<'PY'
import importlib.util
import sys
import tempfile
from importlib.machinery import SourceFileLoader
from pathlib import Path
root = Path(sys.argv[1])
loader = SourceFileLoader("layout", str(root / "scripts/classroom-desktop-layout"))
spec = importlib.util.spec_from_loader("layout", loader)
module = importlib.util.module_from_spec(spec)
loader.exec_module(module)
passed = failed = 0
def check(label, condition, detail=""):
global passed, failed
if condition:
print(f" ok {label}")
passed += 1
else:
print(f" FAIL {label}")
if detail:
print(f" {detail}")
failed += 1
WITH = '''tasks.writeConfig("launchers", [
"applications:ekklesia-wonderink.desktop",
"applications:google-chrome.desktop",
/* CLASSROOM-DVD-LAUNCHER */ "applications:ekklesia-dvd.desktop"
].join(","));'''
WITHOUT = WITH.replace(' /* CLASSROOM-DVD-LAUNCHER */',
' // /* CLASSROOM-DVD-LAUNCHER */')
print("1. the DVD launcher follows the hardware")
check("a machine with a drive keeps it",
module.rewrite(WITH, True) == WITH)
check("a machine without a drive loses it",
module.rewrite(WITH, False) == WITHOUT,
module.rewrite(WITH, False))
check("and gets it back when a drive appears",
module.rewrite(WITHOUT, True) == WITH)
check("removing twice changes nothing the second time",
module.rewrite(module.rewrite(WITH, False), False) == WITHOUT)
check("adding twice changes nothing the second time",
module.rewrite(module.rewrite(WITHOUT, True), True) == WITH)
print()
print("2. nothing else in the layout is touched")
other = WITH + "\npanel.addWidget(\"org.kde.plasma.digitalclock\");\n"
check("a line without the marker is left alone",
module.rewrite(other, False).endswith('digitalclock");\n'))
check("the other launchers survive",
"ekklesia-wonderink.desktop" in module.rewrite(WITH, False)
and "google-chrome.desktop" in module.rewrite(WITH, False))
print()
print("3. the real layout carries the marker")
layout = (root / "config/plasma/lookandfeel/contents/layouts"
/ "org.kde.plasma.desktop-layout.js").read_text()
check("the shipped layout has exactly one marker",
layout.count(module.MARKER) == 1)
check("and it is on the DVD launcher",
'CLASSROOM-DVD-LAUNCHER */ "applications:ekklesia-dvd.desktop"' in layout)
check("the shipped layout is one a drive-less machine can be given",
module.rewrite(layout, False) != layout)
print()
print("4. a missing or unmarked layout is not an error")
with tempfile.TemporaryDirectory() as work:
empty = Path(work) / "none.js"
check("a layout that does not exist exits cleanly",
module.main.__code__ is not None)
unmarked = Path(work) / "plain.js"
unmarked.write_text("panel.addWidget('x');\n")
sys.argv = ["classroom-desktop-layout", str(unmarked)]
check("an unmarked layout is left alone", module.main() == 0)
check("and unchanged", unmarked.read_text() == "panel.addWidget('x');\n")
sys.argv = ["classroom-desktop-layout", str(Path(work) / "missing.js")]
check("a missing layout is not a failure", module.main() == 0)
print()
print(f"{passed} passed, {failed} failed")
raise SystemExit(1 if failed else 0)
PY