当前位置: 首页>>代码示例>>Python>>正文


Python Adb.cmd方法代码示例

本文整理汇总了Python中uiautomator.Adb.cmd方法的典型用法代码示例。如果您正苦于以下问题:Python Adb.cmd方法的具体用法?Python Adb.cmd怎么用?Python Adb.cmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在uiautomator.Adb的用法示例。


在下文中一共展示了Adb.cmd方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_adb_cmd

# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import 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", adb.device_serial(), *args)
开发者ID:Hening,项目名称:uiautomator,代码行数:10,代码来源:test_adb.py

示例2: test_adb_cmd_server_host

# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import 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)
开发者ID:Prathapnagaraj,项目名称:uiautomator,代码行数:18,代码来源:test_adb.py

示例3: BaseClient

# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import cmd [as 别名]
class BaseClient(object):

    def __init__(self, device_id):
        self._device_id = device_id
        self._adb_commander = Adb(self._device_id)
        self._logcat_thread = threading.Thread(target=self._start_logcat)
        self._logcat_thread.start()
        self._device = Device(self._device_id)

    def open_app(self):
        self._device.screen.on()
        _package_name, _main_activity_name = utils.get_package_and_main_activity_name()
        os.system('adb -s %s shell am force-stop %s' % (self._device_id, _package_name))
        self._adb_commander.cmd('shell am start -W %s/%s' % (_package_name, _main_activity_name))

    def _start_logcat(self):
        log_file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, 'log'))
        self._adb_commander.cmd('logcat -c' % self._device_id)
        self._adb_commander.cmd('logcat> %s/%s.log' % (log_file_path, self._device_id))

    def stop_logcat(self):
        os.system('ps -e | grep "adb -s %s logcat" | xargs kill' % self._device_id)
开发者ID:ChenFromNB,项目名称:uiautomatorManager,代码行数:24,代码来源:base_lib.py

示例4: test_forward

# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import cmd [as 别名]
 def test_forward(self):
     adb = Adb()
     adb.cmd = MagicMock()
     adb.forward(90, 91)
     adb.cmd.assert_called_once_with("forward", "tcp:90", "tcp:91")
     adb.cmd.return_value.wait.assert_called_once_with()
开发者ID:Hening,项目名称:uiautomator,代码行数:8,代码来源:test_adb.py

示例5: UiTestLib

# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import cmd [as 别名]
class UiTestLib(object):
    """Ui Test Lib

    """

    def __init__(self, serial=None):
        """
        """
        logger.info("<p>Device=%s>" % serial, html=True)
        print "<p>Device=%s>" % serial
        self._result = ""
        self.starttime = 0
        self.d = Device(serial)
        self.adb = Adb(serial)
        self.debug = "True"

    def set_debugable(flag):
        self.debug = flag

    def set_serial(self, serial):
        """Specify given *serial* device to perform test.
        or export ANDROID_SERIAL=CXFS42343 if you have many devices connected but you don't use this
        interface

        When you need to use multiple devices, do not use this keyword to switch between devices in test execution.
        And set the serial to each library.
        Using different library name when importing this library according to
        http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.5.

        Examples:
        | Setting | Value |  Value |  Value |
        | Library | UiTestLib | WITH NAME | Mobile1 |
        | Library | UiTestLib | WITH NAME | Mobile2 |

        And set the serial to each library.
        | Test Case        | Action             | Argument           |
        | Multiple Devices | Mobile1.Set Serial | device_1's serial  |
        |                  | Mobile2.Set Serial | device_2's serial  |
        """
        self.d = Device(serial)
        self.adb = Adb(serial)

    def logmsg(self, msg):
        if self.debug == "True":
            print msg

    def exe_adb_command(self, cmd):
        """ Execute adb *cmd*
         Examples:
        | Exe Adb Command | shell getprop  |
        """
        return self.adb.cmd(cmd).wait()

    def exe_adb_and_result(self, cmd):
        """Execute adb *cmd* and return lines of the command"""
        lproc = self.adb.cmd(cmd)
        lproc.poll()
        lines = lproc.stdout.readlines()
        return lines

    def get_device_info(self):
        """Get Device information
        return info dictionary
        """
        return self.d.info

    def light_screen(self):
        """Light screen by wakeup.

        Examples:
        | Action     |
        |Light screen|

        Use `Light screen` to light screen.
        """

        self.d.wakeup()
        self._result = self.d.press.home()

    def open_application(self, appname):
        """Open application by it name `appname`.

        Example:
        | Action           | Argument      |
        | Open application | "com.android.settings/com.android.settings.Settings" |
        """
        appname = "shell am start -n " + appname
        print "Open Application:", appname
        self._result = self.exe_adb_command(appname)

    def click_text(self, text, instance=0):
        """Click text label on screen
        instance=0 is default, change when you needed.

        Example:
        | Action     | Argument   |  Argument  |
        | Click Text | text | instance |
        """

        return self.d(text=text, instance=instance).click.wait()
#.........这里部分代码省略.........
开发者ID:huaping,项目名称:StabilityKPI,代码行数:103,代码来源:UiTestLib.py


注:本文中的uiautomator.Adb.cmd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。