This commit is contained in:
1 parent
60332db82b
commit
16019ee649
4 files changed
+120
-10
No files matched your search
@@ -281,6 +281,46 @@ class TestAdbFunctions:
|
||||
with pytest.raises(RuntimeError):
|
||||
resolve_adb_device("", "nonexistent_device_xyz")
|
||||
|
||||
def test_find_adb_executable_falls_back_when_default_server_port_fails(
|
||||
self, monkeypatch
|
||||
):
|
||||
from gui.gui_core_pkg import adb as adb_mod
|
||||
|
||||
calls: list[str] = []
|
||||
|
||||
class _Proc:
|
||||
def __init__(self, returncode: int, stdout: str = "", stderr: str = ""):
|
||||
self.returncode = returncode
|
||||
self.stdout = stdout
|
||||
self.stderr = stderr
|
||||
|
||||
def fake_run(_cmd, **kwargs):
|
||||
port = kwargs["env"].get("ANDROID_ADB_SERVER_PORT")
|
||||
calls.append(port)
|
||||
if port == "5037":
|
||||
return _Proc(
|
||||
1,
|
||||
"",
|
||||
"failed to start daemon\ncannot connect to daemon",
|
||||
)
|
||||
if port == "5038":
|
||||
return _Proc(0, "List of devices attached\n", "")
|
||||
return _Proc(1, "", "failed")
|
||||
|
||||
monkeypatch.delenv("ANDROID_ADB_SERVER_PORT", raising=False)
|
||||
monkeypatch.setattr(adb_mod, "_ADB_SERVER_PROBED_FOR", set())
|
||||
monkeypatch.setattr(adb_mod.os.path, "exists", lambda p: p == "C:/adb.exe")
|
||||
monkeypatch.setattr(adb_mod.path_config, "find_bundled_adb", lambda: "")
|
||||
monkeypatch.setattr(adb_mod.shutil, "which", lambda _name: "")
|
||||
monkeypatch.setattr(adb_mod.subprocess, "run", fake_run)
|
||||
monkeypatch.setenv("ADB_EXECUTABLE", "C:/adb.exe")
|
||||
|
||||
result = adb_mod.find_adb_executable()
|
||||
|
||||
assert result.endswith("adb.exe")
|
||||
assert os.environ["ANDROID_ADB_SERVER_PORT"] == "5038"
|
||||
assert calls[:2] == ["5037", "5038"]
|
||||
|
||||
|
||||
class TestWifiAdbDialog:
|
||||
def test_open_wifi_adb_dialog_binds_toggle_button_without_nameerror(self, monkeypatch):
|
||||
|
||||
Reference in new issue
Block a user