本文整理汇总了Python中uiautomator.Adb.raw_cmd方法的典型用法代码示例。如果您正苦于以下问题:Python Adb.raw_cmd方法的具体用法?Python Adb.raw_cmd怎么用?Python Adb.raw_cmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uiautomator.Adb
的用法示例。
在下文中一共展示了Adb.raw_cmd方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_adb_cmd_server_host
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import raw_cmd [as 别名]
def test_adb_cmd_server_host(self):
adb = Adb(adb_server_host="localhost", adb_server_port=5037)
adb.adb = MagicMock()
adb.adb.return_value = "adb"
adb.device_serial = MagicMock()
adb.device_serial.return_value = "ANDROID_SERIAL"
args = ["a", "b", "c"]
with patch("subprocess.Popen") as Popen:
os.name = "nt"
adb.raw_cmd(*args)
Popen.assert_called_once_with(
[adb.adb()] + args,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
adb = Adb(adb_server_host="test.com", adb_server_port=1000)
adb.adb = MagicMock()
adb.adb.return_value = "adb"
adb.device_serial = MagicMock()
adb.device_serial.return_value = "ANDROID_SERIAL"
args = ["a", "b", "c"]
with patch("subprocess.Popen") as Popen:
os.name = "posix"
adb.raw_cmd(*args)
Popen.assert_called_once_with(
[" ".join([adb.adb()] + ["-H", "test.com", "-P", "1000"] + args)],
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
示例2: test_adb_raw_cmd
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import raw_cmd [as 别名]
def test_adb_raw_cmd(self):
import subprocess
adb = Adb()
adb.adb = MagicMock()
adb.adb.return_value = "adb"
args = ["a", "b", "c"]
with patch("subprocess.Popen") as Popen:
os.name = "posix"
adb.raw_cmd(*args)
Popen.assert_called_once_with(["%s %s" % (adb.adb(), " ".join(args))], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
with patch("subprocess.Popen") as Popen:
os.name = "nt"
adb.raw_cmd(*args)
Popen.assert_called_once_with([adb.adb()] + list(args), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
示例3: test_adb_cmd
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import raw_cmd [as 别名]
def test_adb_cmd(self):
adb = Adb()
adb.device_serial = MagicMock()
adb.device_serial.return_value = "ANDROID_SERIAL"
adb.raw_cmd = MagicMock()
args = ["a", "b", "c"]
adb.cmd(*args)
adb.raw_cmd.assert_called_once_with("-s", "%s" % adb.device_serial(), *args)
adb.device_serial.return_value = "ANDROID SERIAL"
adb.raw_cmd = MagicMock()
args = ["a", "b", "c"]
adb.cmd(*args)
adb.raw_cmd.assert_called_once_with("-s", "'%s'" % adb.device_serial(), *args)
示例4: test_adb_cmd_server_host
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import raw_cmd [as 别名]
def test_adb_cmd_server_host(self):
adb = Adb(adb_server_host="localhost", adb_server_port=5037)
adb.device_serial = MagicMock()
adb.device_serial.return_value = "ANDROID_SERIAL"
adb.raw_cmd = MagicMock()
args = ["a", "b", "c"]
adb.cmd(*args)
adb.raw_cmd.assert_called_once_with("-H", "localhost", "-P", "5037", "-s", "%s" % adb.device_serial(), *args)
adb = Adb(adb_server_host="localhost")
adb.device_serial = MagicMock()
adb.device_serial.return_value = "ANDROID_SERIAL"
adb.raw_cmd = MagicMock()
args = ["a", "b", "c"]
adb.cmd(*args)
adb.raw_cmd.assert_called_once_with("-H", "localhost", "-s", "%s" % adb.device_serial(), *args)
示例5: test_forward_list
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import raw_cmd [as 别名]
def test_forward_list(self):
adb = Adb()
os.name = 'posix'
adb.raw_cmd = MagicMock()
adb.raw_cmd.return_value.communicate.return_value = (b"014E05DE0F02000E tcp:9008 tcp:9008\r\n489328DKFL7DF tcp:9008 tcp:9008", b"")
self.assertEqual(adb.forward_list(), [['014E05DE0F02000E', 'tcp:9008', 'tcp:9008'], ['489328DKFL7DF', 'tcp:9008', 'tcp:9008']])
os.name = 'nt'
self.assertEqual(adb.forward_list(), [])
示例6: test_forward_list
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import raw_cmd [as 别名]
def test_forward_list(self):
adb = Adb()
adb.version = MagicMock()
adb.version.return_value = ['1.0.31', '1', '0', '31']
adb.raw_cmd = MagicMock()
adb.raw_cmd.return_value.communicate.return_value = (b"014E05DE0F02000E tcp:9008 tcp:9008\r\n489328DKFL7DF tcp:9008 tcp:9008", b"")
self.assertEqual(adb.forward_list(), [['014E05DE0F02000E', 'tcp:9008', 'tcp:9008'], ['489328DKFL7DF', 'tcp:9008', 'tcp:9008']])
adb.version.return_value = ['1.0.29', '1', '0', '29']
with self.assertRaises(EnvironmentError):
adb.forward_list()
示例7: test_devices
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import raw_cmd [as 别名]
def test_devices(self):
adb = Adb()
adb.raw_cmd = MagicMock()
adb.raw_cmd.return_value.communicate.return_value = (b"List of devices attached \r\n014E05DE0F02000E device\r\n489328DKFL7DF device", b"")
self.assertEqual(adb.devices(), {"014E05DE0F02000E": "device", "489328DKFL7DF": "device"})
adb.raw_cmd.assert_called_once_with("devices")
adb.raw_cmd.return_value.communicate.return_value = (b"List of devices attached \n\r014E05DE0F02000E device\n\r489328DKFL7DF device", b"")
self.assertEqual(adb.devices(), {"014E05DE0F02000E": "device", "489328DKFL7DF": "device"})
adb.raw_cmd.return_value.communicate.return_value = (b"List of devices attached \r014E05DE0F02000E device\r489328DKFL7DF device", b"")
self.assertEqual(adb.devices(), {"014E05DE0F02000E": "device", "489328DKFL7DF": "device"})
adb.raw_cmd.return_value.communicate.return_value = (b"List of devices attached \n014E05DE0F02000E device\n489328DKFL7DF device", b"")
self.assertEqual(adb.devices(), {"014E05DE0F02000E": "device", "489328DKFL7DF": "device"})
adb.raw_cmd.return_value.communicate.return_value = (b"not match", "")
with self.assertRaises(EnvironmentError):
adb.devices()