diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-10 11:32:07 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-10 11:32:07 +0100 |
| commit | 1a2607a7a5f6ad9a0b22d6544de3228c7fafc9d8 (patch) | |
| tree | dc2b1e9d0d03de0d2c554121ca482175417b28ef /tests/test_tablet.py | |
| parent | 24ffea5a7f25b179a8b2fb7f3605a4977c854069 (diff) | |
| download | deck-it-1a2607a7a5f6ad9a0b22d6544de3228c7fafc9d8.tar.gz deck-it-1a2607a7a5f6ad9a0b22d6544de3228c7fafc9d8.zip | |
feat(tablet): battery and Wi-Fi card on the dashboard
Reads `dumpsys battery` and `cmd wifi status` (Android 11+) over adb
from the device whose reverse carries the dashboard socket, so a switch
between USB and Wi-Fi is followed. Reads are cached for 10s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_tablet.py')
| -rw-r--r-- | tests/test_tablet.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/test_tablet.py b/tests/test_tablet.py new file mode 100644 index 0000000..f2bbed6 --- /dev/null +++ b/tests/test_tablet.py @@ -0,0 +1,61 @@ +# deck-it - tests for tablet +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) + +import unittest + +from deckit.modules import tablet + +BATTERY = """Current Battery Service state: + AC powered: false + USB powered: true + Wireless powered: false + status: 2 + health: 2 + present: true + level: 85 + scale: 100 + voltage: 4200 + temperature: 312 +""" + +WIFI = """Wifi is enabled +Wifi scanning is always available +==== Primary ClientModeManager instance ==== +Wifi is connected to "ExampleNet" +WifiInfo: SSID: "ExampleNet", BSSID: 02:00:00:00:00:00, RSSI: -58, Link speed: 866Mbps, Frequency: 5180MHz +""" + + +class Parse(unittest.TestCase): + def test_battery(self): + self.assertEqual(tablet.parse_battery(BATTERY), + {"level": 85, "status": "charging", "plug": "USB", "temp": 31.2}) + + def test_wifi(self): + self.assertEqual(tablet.parse_wifi(WIFI), + {"connected": True, "ssid": "ExampleNet", "rssi": -58, "speed": 866, "band": "5.2 GHz"}) + + def test_wifi_off(self): + self.assertEqual(tablet.parse_wifi("Wifi is disabled\n"), {"connected": False}) + + +if __name__ == "__main__": + unittest.main() |
