build: include android runtime helpers

This commit is contained in:
Your Name committed 2026-06-27 19:33:27 +08:00
1 parent f257c4e3fc
commit 63c726ddea
12 files changed
+129 -29

No files matched your search

+44
View File
@@ -86,6 +86,50 @@ class TestPickAdbKeyboardIme:
assert result in ("", None)
def test_ensure_adbkeyboard_installs_bundled_apk_when_missing(monkeypatch, tmp_path):
from douyin.core.underlying_operations_pkg import text_input
apk = tmp_path / "ADBKeyboard.apk"
apk.write_bytes(b"apk")
calls = []
class Ops:
def __init__(self):
self.list_count = 0
def get_current_ime(self, _device_id):
return "com.example/.Ime"
def list_imes(self, _device_id):
self.list_count += 1
if self.list_count == 1:
return ["com.example/.Ime"]
return ["com.android.adbkeyboard/.AdbIME"]
def _pick_adbkeyboard_ime(self, imes):
return _pick_adbkeyboard_ime(imes)
def _adb_path(self):
return "adb"
def try_set_ime(self, _device_id, ime_id):
return ime_id == "com.android.adbkeyboard/.AdbIME"
def fake_run(cmd, **_kwargs):
calls.append(cmd)
return type("Proc", (), {"returncode": 0})()
monkeypatch.setattr(text_input.path_config, "get_bundled_adbkeyboard_apk_path", lambda: str(apk))
monkeypatch.setattr(text_input.subprocess, "run", fake_run)
ok, prev, ime = text_input.ensure_adbkeyboard_ime(Ops(), "device1")
assert ok is True
assert prev == "com.example/.Ime"
assert ime == "com.android.adbkeyboard/.AdbIME"
assert calls and calls[0][-2:] == ["-r", str(apk)]
# ============================================================
# bounds.py — _parse_bounds
# ============================================================