testing/mozbase/docs/mozdevice.rst

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial