aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/status/test-statusctl.sh
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/modules/status/test-statusctl.sh')
-rwxr-xr-xdesktop/modules/status/test-statusctl.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/desktop/modules/status/test-statusctl.sh b/desktop/modules/status/test-statusctl.sh
index 7b1b188..38da27c 100755
--- a/desktop/modules/status/test-statusctl.sh
+++ b/desktop/modules/status/test-statusctl.sh
@@ -92,5 +92,46 @@ kill "$watcher2" 2>/dev/null
wait "$watcher2" 2>/dev/null
check "watch reports deactivated when absent" "1" "$(grep -c '"class": *"deactivated"' "$out2")"
+# A running game is reported as its own state, not as plain activated: the
+# widget draws a different icon and the tooltip says why the mode is on.
+rm -f "$tmp/status.presentation"
+printf '1\n' > "$tmp/status.gaming"
+out3="$tmp/watch3.out"
+"$ctl" presentation watch > "$out3" 2>/dev/null &
+watcher3=$!
+sleep 0.5
+kill "$watcher3" 2>/dev/null
+wait "$watcher3" 2>/dev/null
+check "watch reports gaming" "1" "$(grep -c '"class": *"gaming"' "$out3")"
+
+# The gaming file is the shell's, so presentation's own file stays off and
+# `get` keeps reporting the manual half rather than the OR.
+check "get reads the manual half" "0" "$("$ctl" presentation get)"
+
+# Toggling while a game runs is refused: the detector would reassert it, so a
+# write here would not stick.
+"$ctl" presentation toggle 2>/dev/null
+check "toggle refused while gaming" "1" "$?"
+check "toggle wrote nothing" "0" "$("$ctl" presentation get)"
+
+# The refusal is specific to presentation; another mode toggles normally with
+# a game running.
+"$ctl" dnd set 0
+"$ctl" dnd toggle
+check "dnd toggles while gaming" "1" "$("$ctl" dnd get)"
+
+# A game ending redraws the widget, which is why the watch follows
+# status.gaming as well as its own file.
+out4="$tmp/watch4.out"
+"$ctl" presentation watch > "$out4" 2>/dev/null &
+watcher4=$!
+sleep 0.3
+printf '0\n' > "$tmp/status.gaming.tmp"
+mv -f "$tmp/status.gaming.tmp" "$tmp/status.gaming"
+sleep 0.5
+kill "$watcher4" 2>/dev/null
+wait "$watcher4" 2>/dev/null
+check "game ending redraws" "1" "$(grep -c '"class": *"deactivated"' "$out4")"
+
printf '\n%d passed, %d failed\n' "$pass" "$fail"
[[ "$fail" -eq 0 ]]