|
1 :mod:`mozdevice` --- Interact with remote devices |
|
2 ================================================= |
|
3 |
|
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. |
|
9 |
|
10 .. automodule:: mozdevice |
|
11 |
|
12 DeviceManager interface |
|
13 ----------------------- |
|
14 .. autoclass:: DeviceManager |
|
15 |
|
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). |
|
21 |
|
22 :: |
|
23 |
|
24 import mozdevice |
|
25 |
|
26 dm = mozdevice.DeviceManagerADB() |
|
27 print dm.listFiles("/mnt/sdcard") |
|
28 if dm.processExist("org.mozilla.fennec"): |
|
29 print "Fennec is running" |
|
30 |
|
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 |
|
39 |
|
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) |
|
60 |
|
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) |
|
68 |
|
69 System control methods |
|
70 `````````````````````` |
|
71 .. automethod:: DeviceManager.reboot(self, ipAddr=None, port=30000) |
|
72 |
|
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) |
|
79 |
|
80 DeviceManagerADB implementation |
|
81 ------------------------------- |
|
82 |
|
83 .. autoclass:: mozdevice.DeviceManagerADB |
|
84 |
|
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. |
|
90 |
|
91 .. automethod:: DeviceManagerADB.forward |
|
92 .. automethod:: DeviceManagerADB.remount |
|
93 .. automethod:: DeviceManagerADB.devices |
|
94 |
|
95 DeviceManagerSUT implementation |
|
96 ------------------------------- |
|
97 |
|
98 .. autoclass:: mozdevice.DeviceManagerSUT |
|
99 |
|
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. |
|
105 |
|
106 .. automethod:: DeviceManagerSUT.unpackFile |
|
107 .. automethod:: DeviceManagerSUT.adjustResolution |
|
108 |
|
109 Android extensions |
|
110 ------------------ |
|
111 |
|
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: |
|
116 |
|
117 .. automethod:: mozdevice.DroidADB.launchApplication |
|
118 .. automethod:: mozdevice.DroidADB.launchFennec |
|
119 .. automethod:: mozdevice.DroidADB.getInstalledApps |
|
120 |
|
121 These methods are also found in the DroidSUT class. |