aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-11 20:29:52 +0100
committerDanilo M. <danix@danix.xyz>2026-11-11 20:29:52 +0100
commitfea2e9b221a2d18f9c73e5763adf662128cea5ec (patch)
tree018ac7111d3dce1e4768c7a702d4394baf5589e1 /tests
parentc6f23856f080feee37c4972fb6689332b9873574 (diff)
downloaddeck-it-fea2e9b221a2d18f9c73e5763adf662128cea5ec.tar.gz
deck-it-fea2e9b221a2d18f9c73e5763adf662128cea5ec.zip
feat(tablet): dim the backlight after an idle timeout
After [tablet] dim_after seconds with no touch the page covers itself and the tablet module's dim action lowers the backlight to dim_brightness over adb, with auto brightness off meanwhile; an LCD's backlight is the drain, so a dark page alone saves little. The touch on the cover only calls undim, which restores both settings, as does the module's stop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_tablet.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_tablet.py b/tests/test_tablet.py
index f2bbed6..611810a 100644
--- a/tests/test_tablet.py
+++ b/tests/test_tablet.py
@@ -20,6 +20,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
import unittest
+import unittest.mock
from deckit.modules import tablet
@@ -57,5 +58,26 @@ class Parse(unittest.TestCase):
self.assertEqual(tablet.parse_wifi("Wifi is disabled\n"), {"connected": False})
+class Dim(unittest.TestCase):
+ def test_dim_saves_and_undim_restores(self):
+ calls, orig = [], tablet._adb
+ 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"):
+ m.actions["dim"]({})
+ m.actions["dim"]({}) # already dim: the saved level is kept
+ m.actions["undim"]({})
+ m.actions["undim"]({}) # already bright: nothing sent
+ 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",
+ "settings put system screen_brightness 200; settings put system screen_brightness_mode 1"])
+
+
if __name__ == "__main__":
unittest.main()