testing/mozbase/docs/mozdevice.rst

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 :mod:`mozdevice` --- Interact with remote devices
     2 =================================================
     4 Mozdevice provides an interface to interact with a remote device such
     5 as an Android- or FirefoxOS-based phone connected to a
     6 host machine. Currently there are two implementations of the interface: one
     7 uses a custom TCP-based protocol to communicate with a server running
     8 on the device, another uses Android's adb utility.
    10 .. automodule:: mozdevice
    12 DeviceManager interface
    13 -----------------------
    14 .. autoclass:: DeviceManager
    16 Here's an example script which lists the files in '/mnt/sdcard' and sees if a
    17 process called 'org.mozilla.fennec' is running. In this example, we're
    18 instantiating the DeviceManagerADB implementation, but we could just
    19 as easily have used DeviceManagerSUT (assuming the device had an agent
    20 running speaking the SUT protocol).
    22 ::
    24   import mozdevice
    26   dm = mozdevice.DeviceManagerADB()
    27   print dm.listFiles("/mnt/sdcard")
    28   if dm.processExist("org.mozilla.fennec"):
    29       print "Fennec is running"
    31 Informational methods
    32 `````````````````````
    33 .. automethod:: DeviceManager.getInfo(self, directive=None)
    34 .. automethod:: DeviceManager.getCurrentTime(self)
    35 .. automethod:: DeviceManager.getIP
    36 .. automethod:: DeviceManager.saveScreenshot
    37 .. automethod:: DeviceManager.recordLogcat
    38 .. automethod:: DeviceManager.getLogcat
    40 File management methods
    41 ```````````````````````
    42 .. automethod:: DeviceManager.pushFile(self, localFilename, remoteFilename, retryLimit=1)
    43 .. automethod:: DeviceManager.pushDir(self, localDirname, remoteDirname, retryLimit=1)
    44 .. automethod:: DeviceManager.pullFile(self, remoteFilename)
    45 .. automethod:: DeviceManager.getFile(self, remoteFilename, localFilename)
    46 .. automethod:: DeviceManager.getDirectory(self, remoteDirname, localDirname, checkDir=True)
    47 .. automethod:: DeviceManager.validateFile(self, remoteFilename, localFilename)
    48 .. automethod:: DeviceManager.mkDir(self, remoteDirname)
    49 .. automethod:: DeviceManager.mkDirs(self, filename)
    50 .. automethod:: DeviceManager.dirExists(self, dirpath)
    51 .. automethod:: DeviceManager.fileExists(self, filepath)
    52 .. automethod:: DeviceManager.listFiles(self, rootdir)
    53 .. automethod:: DeviceManager.removeFile(self, filename)
    54 .. automethod:: DeviceManager.removeDir(self, remoteDirname)
    55 .. automethod:: DeviceManager.chmodDir(self, remoteDirname, mask="777")
    56 .. automethod:: DeviceManager.getDeviceRoot(self)
    57 .. automethod:: DeviceManager.getAppRoot(self, packageName=None)
    58 .. automethod:: DeviceManager.getTestRoot(self, harnessName)
    59 .. automethod:: DeviceManager.getTempDir(self)
    61 Process management methods
    62 ``````````````````````````
    63 .. automethod:: DeviceManager.shell(self, cmd, outputfile, env=None, cwd=None, timeout=None, root=False)
    64 .. automethod:: DeviceManager.shellCheckOutput(self, cmd, env=None, cwd=None, timeout=None, root=False)
    65 .. automethod:: DeviceManager.getProcessList(self)
    66 .. automethod:: DeviceManager.processExist(self, processName)
    67 .. automethod:: DeviceManager.killProcess(self, processName)
    69 System control methods
    70 ``````````````````````
    71 .. automethod:: DeviceManager.reboot(self, ipAddr=None, port=30000)
    73 Application management methods
    74 ``````````````````````````````
    75 .. automethod:: DeviceManager.uninstallAppAndReboot(self, appName, installPath=None)
    76 .. automethod:: DeviceManager.installApp(self, appBundlePath, destPath=None)
    77 .. automethod:: DeviceManager.uninstallApp(self, appName, installPath=None)
    78 .. automethod:: DeviceManager.updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=30000)
    80 DeviceManagerADB implementation
    81 -------------------------------
    83 .. autoclass:: mozdevice.DeviceManagerADB
    85 ADB-specific methods
    86 ````````````````````
    87 DeviceManagerADB has several methods that are not present in all
    88 DeviceManager implementations. Please do not use them in code that
    89 is meant to be interoperable.
    91 .. automethod:: DeviceManagerADB.forward
    92 .. automethod:: DeviceManagerADB.remount
    93 .. automethod:: DeviceManagerADB.devices
    95 DeviceManagerSUT implementation
    96 -------------------------------
    98 .. autoclass:: mozdevice.DeviceManagerSUT
   100 SUT-specific methods
   101 ````````````````````
   102 DeviceManagerSUT has several methods that are only used in specific
   103 tests and are not present in all DeviceManager implementations. Please
   104 do not use them in code that is meant to be interoperable.
   106 .. automethod:: DeviceManagerSUT.unpackFile
   107 .. automethod:: DeviceManagerSUT.adjustResolution
   109 Android extensions
   110 ------------------
   112 For Android, we provide two variants of the `DeviceManager` interface
   113 with extensions useful for that platform. These classes are called
   114 DroidADB and DroidSUT. They inherit all methods from DeviceManagerADB
   115 and DeviceManagerSUT. Here is the interface for DroidADB:
   117 .. automethod:: mozdevice.DroidADB.launchApplication
   118 .. automethod:: mozdevice.DroidADB.launchFennec
   119 .. automethod:: mozdevice.DroidADB.getInstalledApps
   121 These methods are also found in the DroidSUT class.

mercurial