aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_tablet.py
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-12 09:01:06 +0100
committerDanilo M. <danix@danix.xyz>2026-11-12 09:01:06 +0100
commit512a2b4a2821a1edadf5530d060e3ae5468d75e8 (patch)
treef81dcb1d2238403bdcf68cf9298cc34b6a010672 /tests/test_tablet.py
parentfea2e9b221a2d18f9c73e5763adf662128cea5ec (diff)
downloaddeck-it-512a2b4a2821a1edadf5530d060e3ae5468d75e8.tar.gz
deck-it-512a2b4a2821a1edadf5530d060e3ae5468d75e8.zip
fix(tablet): restore the backlight after a restart or shutdown
The server never ran the modules' stop: `deck-it stop` ends it with SIGTERM and nothing called stop_all, so a shutdown left the tablet dim. A SIGTERM handler now runs stop_all before exiting. The settings from before a dim lived only in memory, so a new server's undim had nothing to put back. They are now kept in ~/.cache/deck-it/dim, and a freshly loaded page asks for undim, since it is never dimmed itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_tablet.py')
-rw-r--r--tests/test_tablet.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/test_tablet.py b/tests/test_tablet.py
index 611810a..9f5f007 100644
--- a/tests/test_tablet.py
+++ b/tests/test_tablet.py
@@ -15,6 +15,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import sys
+import tempfile
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
@@ -64,15 +65,19 @@ class Dim(unittest.TestCase):
answers = {"settings get system screen_brightness_mode": "1\n",
"settings get system screen_brightness": "200\n"}
tablet._adb = lambda *a, **k: calls.append(a[-1]) or answers.get(a[-1], "")
- try:
- m = tablet.make({"tablet": {"dim_brightness": 5}})
- with unittest.mock.patch.object(tablet, "_find_tablet", return_value="x"):
+ with tempfile.TemporaryDirectory() as d, \
+ unittest.mock.patch.object(tablet, "DIM_FILE", Path(d) / "dim"), \
+ unittest.mock.patch.object(tablet, "_find_tablet", return_value="x"):
+ try:
+ m = tablet.make({"tablet": {"dim_brightness": 5}})
m.actions["dim"]({})
m.actions["dim"]({}) # already dim: the saved level is kept
+ m = tablet.make({"tablet": {"dim_brightness": 5}}) # a restarted server
m.actions["undim"]({})
m.actions["undim"]({}) # already bright: nothing sent
- finally:
- tablet._adb = orig
+ self.assertFalse(tablet.DIM_FILE.exists())
+ finally:
+ tablet._adb = orig
sets = [c for c in calls if "put" in c]
self.assertEqual(sets, [
"settings put system screen_brightness_mode 0; settings put system screen_brightness 5",