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


Python uiautomator.Adb类代码示例

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


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

示例1: adb

class adb(object):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        self.instAdb=Adb()
        
        self.devSerialNoms= self.instAdb.devices().keys()
        self.devcount = len(self.devSerialNoms)
        self.devSerial = self.instAdb.device_serial()
        
        
    def getSerials(self):
        return self.devSerialNoms
        #return self.devSerialNoms
    
    def getDeviceCount(self):
        return self.devcount
    
    def getSerial(self):
        return self.devSerial
开发者ID:sqler21c,项目名称:Python,代码行数:26,代码来源:Adb.py

示例2: test_serial

    def test_serial(self):
        serial = "abcdef1234567890"
        adb = Adb(serial)
        self.assertEqual(adb.default_serial, serial)

        adb.devices = MagicMock()
        adb.devices.return_value = [serial, "123456"]
        self.assertEqual(adb.device_serial(), serial)
开发者ID:Hening,项目名称:uiautomator,代码行数:8,代码来源:test_adb.py

示例3: test_forward_list

 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(), [])
开发者ID:Top-Q,项目名称:uiautomator,代码行数:8,代码来源:test_adb.py

示例4: test_adb_cmd

    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)
开发者ID:Andy-hpliu,项目名称:uiautomator,代码行数:14,代码来源:test_adb.py

示例5: __init__

    def __init__(self,config=None):
        """

        :return:
        """

        self.config = config




        # dict of devices connected to the hub, key is the device_id
        self.connected_devices = {}

        # dict of active devices , key is alias
        self._devices = {}




        # device_ids available ( eg not actice)
        self.available_devices = []



        self.adb = Adb()
开发者ID:cocoon-project,项目名称:droydrunner,代码行数:26,代码来源:uihub.py

示例6: __init__

 def __init__(self):
     '''
     Constructor
     '''
     self.instAdb=Adb()
     
     self.devSerialNoms= self.instAdb.devices().keys()
     self.devcount = len(self.devSerialNoms)
     self.devSerial = self.instAdb.device_serial()
开发者ID:sqler21c,项目名称:Python,代码行数:9,代码来源:Adb.py

示例7: __init__

 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"
开发者ID:huaping,项目名称:StabilityKPI,代码行数:10,代码来源:UiTestLib.py

示例8: test_adb_raw_cmd

 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)
开发者ID:Hening,项目名称:uiautomator,代码行数:14,代码来源:test_adb.py

示例9: test_adb_from_env

    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()
开发者ID:Hening,项目名称:uiautomator,代码行数:22,代码来源:test_adb.py

示例10: test_devices

 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()
开发者ID:Hening,项目名称:uiautomator,代码行数:15,代码来源:test_adb.py

示例11: test_forward_list

    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()
开发者ID:Hening,项目名称:uiautomator,代码行数:11,代码来源:test_adb.py

示例12: set_serial

    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)
开发者ID:huaping,项目名称:StabilityKPI,代码行数:22,代码来源:UiTestLib.py

示例13: BaseClient

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,代码行数:22,代码来源:base_lib.py

示例14: test_forward

 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,代码行数:6,代码来源:test_adb.py

示例15: print

'''
Created on 2015. 10. 22.

@author: User
'''

import os, sys
from Libs import ClsActivity as CLS

from uiautomator import Device, Adb, AutomatorDevice
from Libs import SaveToLog as saveLog
from Libs import ModelInfo
import Libs.ClsKeyCode


instAdb=Adb()
devSerials= instAdb.devices().keys()
print(type(devSerials))
osType = sys.platform
sndLog = saveLog()

#sndLog = CLS("test", "test")

if len(devSerials) == 1:
    devSerials = instAdb.device_serial()
    mstrDevice = Device(devSerials)
    mstrInfo = mstrDevice.info
else:
    mstrDevSerial, slavDevSerial = devSerials
    mstrDevice = Device(mstrDevSerial)
    slvDevice = Device(slavDevSerial)
开发者ID:sqler21c,项目名称:Python,代码行数:31,代码来源:uiautotest.py


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