testing/mozbase/mozdevice/tests/sut_info.py

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.

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

mercurial