當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。