|
1 #/usr/bin/env python |
|
2 import mozdevice |
|
3 import mozlog |
|
4 import re |
|
5 import unittest |
|
6 from sut import MockAgent |
|
7 |
|
8 |
|
9 class TestGetInfo(unittest.TestCase): |
|
10 |
|
11 commands = {'os': ('info os', 'JDQ39'), |
|
12 'id': ('info id', '11:22:33:44:55:66'), |
|
13 'uptime': ('info uptime', '0 days 0 hours 7 minutes 0 seconds 0 ms'), |
|
14 'uptimemillis': ('info uptimemillis', '666'), |
|
15 'systime': ('info systime', '2013/04/2 12:42:00:007'), |
|
16 'screen': ('info screen', 'X:768 Y:1184'), |
|
17 'rotation': ('info rotation', 'ROTATION:0'), |
|
18 'memory': ('info memory', 'PA:1351032832, FREE: 878645248'), |
|
19 'process': ('info process', '1000 527 system\n' |
|
20 '10091 3443 org.mozilla.firefox\n' |
|
21 '10112 3137 com.mozilla.SUTAgentAndroid\n' |
|
22 '10035 807 com.android.launcher'), |
|
23 'disk': ('info disk', '/data: 6084923392 total, 980922368 available\n' |
|
24 '/system: 867999744 total, 332333056 available\n' |
|
25 '/mnt/sdcard: 6084923392 total, 980922368 available'), |
|
26 'power': ('info power', 'Power status:\n' |
|
27 ' AC power OFFLINE\n' |
|
28 ' Battery charge LOW DISCHARGING\n' |
|
29 ' Remaining charge: 20%\n' |
|
30 ' Battery Temperature: 25.2 (c)'), |
|
31 'sutuserinfo': ('info sutuserinfo', 'User Serial:0'), |
|
32 'temperature': ('info temperature', 'Temperature: unknown') |
|
33 } |
|
34 |
|
35 def test_getInfo(self): |
|
36 |
|
37 for directive in self.commands.keys(): |
|
38 m = MockAgent(self, commands=[self.commands[directive]]) |
|
39 d = mozdevice.DroidSUT('127.0.0.1', port=m.port, logLevel=mozlog.DEBUG) |
|
40 |
|
41 expected = re.sub(r'\ +', ' ', self.commands[directive][1]).split('\n') |
|
42 # Account for slightly different return format for 'process' |
|
43 if directive is 'process': |
|
44 expected = [[x] for x in expected] |
|
45 |
|
46 self.assertEqual(d.getInfo(directive=directive)[directive], expected) |
|
47 |
|
48 if __name__ == '__main__': |
|
49 unittest.main() |