Cold start Douyin before CLI fudai runs
This commit is contained in:
1 parent
2042c56257
commit
0c8166d616
2 files changed
+138
-8
No files matched your search
@@ -97,6 +97,7 @@ class TestRunCliParseArgs:
|
||||
|
||||
result = parse_args([])
|
||||
assert isinstance(result, argparse.Namespace)
|
||||
assert result.reenter_live_entry_mode == 'screen_center'
|
||||
|
||||
def test_device_id_arg(self):
|
||||
from bin.run_cli import parse_args
|
||||
@@ -137,6 +138,71 @@ class TestRunCliModule:
|
||||
|
||||
assert callable(main)
|
||||
|
||||
def test_cold_start_force_stops_all_douyin_packages_then_launches(self, monkeypatch):
|
||||
from bin import run_cli
|
||||
|
||||
class FakeOperation:
|
||||
def __init__(self):
|
||||
self.calls = []
|
||||
|
||||
def _run_adb_shell(self, device_id, cmd, timeout_seconds=3.0):
|
||||
self.calls.append(("shell", device_id, cmd, timeout_seconds))
|
||||
return True
|
||||
|
||||
def delay(self, seconds):
|
||||
self.calls.append(("delay", seconds))
|
||||
|
||||
def launch_package(self, device_id, package_name="", timeout_seconds=5.0):
|
||||
self.calls.append(("launch", device_id, package_name, timeout_seconds))
|
||||
return True, "com.ss.android.ugc.aweme"
|
||||
|
||||
def get_top_package(self, device_id):
|
||||
self.calls.append(("top", device_id))
|
||||
return "com.ss.android.ugc.aweme"
|
||||
|
||||
class FakeAnalyser:
|
||||
operation = FakeOperation()
|
||||
|
||||
monkeypatch.setattr(
|
||||
run_cli.path_config,
|
||||
"get_douyin_packages",
|
||||
lambda: ("pkg.a", "pkg.b"),
|
||||
)
|
||||
|
||||
assert run_cli._cold_start_douyin_for_test(FakeAnalyser(), "dev1") is True
|
||||
calls = FakeAnalyser.operation.calls
|
||||
assert ("shell", "dev1", "am force-stop pkg.a", 3.0) in calls
|
||||
assert ("shell", "dev1", "am force-stop pkg.b", 3.0) in calls
|
||||
assert ("launch", "dev1", "", 5.0) in calls
|
||||
assert ("top", "dev1") in calls
|
||||
|
||||
def test_cold_start_fails_when_foreground_is_not_douyin(self, monkeypatch):
|
||||
from bin import run_cli
|
||||
|
||||
class FakeOperation:
|
||||
def _run_adb_shell(self, device_id, cmd, timeout_seconds=3.0):
|
||||
return True
|
||||
|
||||
def delay(self, seconds):
|
||||
return None
|
||||
|
||||
def launch_package(self, device_id, package_name="", timeout_seconds=5.0):
|
||||
return True, "com.ss.android.ugc.aweme"
|
||||
|
||||
def get_top_package(self, device_id):
|
||||
return "com.android.launcher"
|
||||
|
||||
class FakeAnalyser:
|
||||
operation = FakeOperation()
|
||||
|
||||
monkeypatch.setattr(
|
||||
run_cli.path_config,
|
||||
"get_douyin_packages",
|
||||
lambda: ("com.ss.android.ugc.aweme",),
|
||||
)
|
||||
|
||||
assert run_cli._cold_start_douyin_for_test(FakeAnalyser(), "dev1") is False
|
||||
|
||||
|
||||
class TestBinModules:
|
||||
"""bin 子模块存在性测试。"""
|
||||
|
||||
Reference in new issue
Block a user