michael@0: #/usr/bin/env python michael@0: import mozdevice michael@0: import mozlog michael@0: import re michael@0: import unittest michael@0: from sut import MockAgent michael@0: michael@0: michael@0: class TestGetInfo(unittest.TestCase): michael@0: michael@0: commands = {'os': ('info os', 'JDQ39'), michael@0: 'id': ('info id', '11:22:33:44:55:66'), michael@0: 'uptime': ('info uptime', '0 days 0 hours 7 minutes 0 seconds 0 ms'), michael@0: 'uptimemillis': ('info uptimemillis', '666'), michael@0: 'systime': ('info systime', '2013/04/2 12:42:00:007'), michael@0: 'screen': ('info screen', 'X:768 Y:1184'), michael@0: 'rotation': ('info rotation', 'ROTATION:0'), michael@0: 'memory': ('info memory', 'PA:1351032832, FREE: 878645248'), michael@0: 'process': ('info process', '1000 527 system\n' michael@0: '10091 3443 org.mozilla.firefox\n' michael@0: '10112 3137 com.mozilla.SUTAgentAndroid\n' michael@0: '10035 807 com.android.launcher'), michael@0: 'disk': ('info disk', '/data: 6084923392 total, 980922368 available\n' michael@0: '/system: 867999744 total, 332333056 available\n' michael@0: '/mnt/sdcard: 6084923392 total, 980922368 available'), michael@0: 'power': ('info power', 'Power status:\n' michael@0: ' AC power OFFLINE\n' michael@0: ' Battery charge LOW DISCHARGING\n' michael@0: ' Remaining charge: 20%\n' michael@0: ' Battery Temperature: 25.2 (c)'), michael@0: 'sutuserinfo': ('info sutuserinfo', 'User Serial:0'), michael@0: 'temperature': ('info temperature', 'Temperature: unknown') michael@0: } michael@0: michael@0: def test_getInfo(self): michael@0: michael@0: for directive in self.commands.keys(): michael@0: m = MockAgent(self, commands=[self.commands[directive]]) michael@0: d = mozdevice.DroidSUT('127.0.0.1', port=m.port, logLevel=mozlog.DEBUG) michael@0: michael@0: expected = re.sub(r'\ +', ' ', self.commands[directive][1]).split('\n') michael@0: # Account for slightly different return format for 'process' michael@0: if directive is 'process': michael@0: expected = [[x] for x in expected] michael@0: michael@0: self.assertEqual(d.getInfo(directive=directive)[directive], expected) michael@0: michael@0: if __name__ == '__main__': michael@0: unittest.main()