testing/mozbase/mozdevice/tests/sut_info.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/mozbase/mozdevice/tests/sut_info.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +#/usr/bin/env python
     1.5 +import mozdevice
     1.6 +import mozlog
     1.7 +import re
     1.8 +import unittest
     1.9 +from sut import MockAgent
    1.10 +
    1.11 +
    1.12 +class TestGetInfo(unittest.TestCase):
    1.13 +
    1.14 +    commands = {'os': ('info os', 'JDQ39'),
    1.15 +                'id': ('info id', '11:22:33:44:55:66'),
    1.16 +                'uptime': ('info uptime', '0 days 0 hours 7 minutes 0 seconds 0 ms'),
    1.17 +                'uptimemillis': ('info uptimemillis', '666'),
    1.18 +                'systime': ('info systime', '2013/04/2 12:42:00:007'),
    1.19 +                'screen': ('info screen', 'X:768 Y:1184'),
    1.20 +                'rotation': ('info rotation', 'ROTATION:0'),
    1.21 +                'memory': ('info memory', 'PA:1351032832, FREE: 878645248'),
    1.22 +                'process': ('info process', '1000    527     system\n'
    1.23 +                            '10091   3443    org.mozilla.firefox\n'
    1.24 +                            '10112   3137    com.mozilla.SUTAgentAndroid\n'
    1.25 +                            '10035   807     com.android.launcher'),
    1.26 +                'disk': ('info disk', '/data: 6084923392 total, 980922368 available\n'
    1.27 +                         '/system: 867999744 total, 332333056 available\n'
    1.28 +                         '/mnt/sdcard: 6084923392 total, 980922368 available'),
    1.29 +                'power': ('info power', 'Power status:\n'
    1.30 +                          '  AC power OFFLINE\n'
    1.31 +                          '  Battery charge LOW DISCHARGING\n'
    1.32 +                          '  Remaining charge:      20%\n'
    1.33 +                          '  Battery Temperature:   25.2 (c)'),
    1.34 +                'sutuserinfo': ('info sutuserinfo', 'User Serial:0'),
    1.35 +                'temperature': ('info temperature', 'Temperature: unknown')
    1.36 +                }
    1.37 +
    1.38 +    def test_getInfo(self):
    1.39 +
    1.40 +        for directive in self.commands.keys():
    1.41 +            m = MockAgent(self, commands=[self.commands[directive]])
    1.42 +            d = mozdevice.DroidSUT('127.0.0.1', port=m.port, logLevel=mozlog.DEBUG)
    1.43 +
    1.44 +            expected = re.sub(r'\ +', ' ', self.commands[directive][1]).split('\n')
    1.45 +            # Account for slightly different return format for 'process'
    1.46 +            if directive is 'process':
    1.47 +                expected = [[x] for x in expected]
    1.48 +
    1.49 +            self.assertEqual(d.getInfo(directive=directive)[directive], expected)
    1.50 +
    1.51 +if __name__ == '__main__':
    1.52 +    unittest.main()

mercurial