feat: 检测 Android 设备 PDD 安装状态 (#29)
This commit is contained in:
@@ -202,6 +202,55 @@ USB-002 unauthorized usb:1-2 transport_id:3
|
||||
with self.assertRaisesRegex(AndroidDeviceSearchError, "didn't ACK"):
|
||||
AndroidDeviceService(runner).search()
|
||||
|
||||
def test_package_is_installed_when_pm_returns_apk_path(self):
|
||||
commands = []
|
||||
|
||||
def runner(command, _timeout):
|
||||
commands.append(list(command))
|
||||
return completed(
|
||||
command,
|
||||
"package:/data/app/com.xunmeng.pinduoduo/base.apk\n",
|
||||
)
|
||||
|
||||
installed = AndroidDeviceService(runner).is_package_installed(
|
||||
"USB-001"
|
||||
)
|
||||
|
||||
self.assertTrue(installed)
|
||||
self.assertEqual(
|
||||
commands,
|
||||
[[
|
||||
"adb",
|
||||
"-s",
|
||||
"USB-001",
|
||||
"shell",
|
||||
"pm",
|
||||
"path",
|
||||
"com.xunmeng.pinduoduo",
|
||||
]],
|
||||
)
|
||||
|
||||
def test_package_is_not_installed_when_pm_returns_no_path(self):
|
||||
def runner(command, _timeout):
|
||||
return completed(command, "")
|
||||
|
||||
installed = AndroidDeviceService(runner).is_package_installed(
|
||||
"USB-001"
|
||||
)
|
||||
|
||||
self.assertFalse(installed)
|
||||
|
||||
def test_package_check_reports_adb_failure(self):
|
||||
def runner(command, _timeout):
|
||||
return completed(
|
||||
command,
|
||||
stderr="device offline",
|
||||
returncode=1,
|
||||
)
|
||||
|
||||
with self.assertRaisesRegex(AndroidDeviceSearchError, "device offline"):
|
||||
AndroidDeviceService(runner).is_package_installed("USB-001")
|
||||
|
||||
def test_convert_usb_to_wifi_connects_while_usb_is_attached(self):
|
||||
commands = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user