本文整理汇总了Python中uiautomator.Adb.adb方法的典型用法代码示例。如果您正苦于以下问题:Python Adb.adb方法的具体用法?Python Adb.adb怎么用?Python Adb.adb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uiautomator.Adb
的用法示例。
在下文中一共展示了Adb.adb方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_adb_cmd_server_host
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import adb [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 adb [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_from_env
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import adb [as 别名]
def test_adb_from_env(self):
home_dir = '/android/home'
with patch.dict('os.environ', {'ANDROID_HOME': home_dir}):
with patch('os.path.exists') as exists:
exists.return_value = True
os.name = "posix" # linux
adb_obj = Adb()
adb_path = os.path.join(home_dir, "platform-tools", "adb")
self.assertEqual(adb_obj.adb(), adb_path)
exists.assert_called_once_with(adb_path)
self.assertEqual(adb_obj.adb(), adb_path)
exists.assert_called_once_with(adb_path) # the second call will return the __adb_cmd directly
os.name = "nt" # linux
adb_obj = Adb()
adb_path = os.path.join(home_dir, "platform-tools", "adb.exe")
self.assertEqual(adb_obj.adb(), adb_path)
exists.return_value = False
with self.assertRaises(EnvironmentError):
Adb().adb()