Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | from sut import MockAgent |
michael@0 | 2 | import mozdevice |
michael@0 | 3 | import unittest |
michael@0 | 4 | |
michael@0 | 5 | class PsTest(unittest.TestCase): |
michael@0 | 6 | |
michael@0 | 7 | pscommands = [('ps', |
michael@0 | 8 | "10029 549 com.android.launcher\n" |
michael@0 | 9 | "10066 1198 com.twitter.android")] |
michael@0 | 10 | |
michael@0 | 11 | bad_pscommands = [('ps', |
michael@0 | 12 | "abcdef 549 com.android.launcher\n" |
michael@0 | 13 | "10066 1198 com.twitter.android")] |
michael@0 | 14 | |
michael@0 | 15 | def test_processList(self): |
michael@0 | 16 | a = MockAgent(self, |
michael@0 | 17 | commands=self.pscommands) |
michael@0 | 18 | d = mozdevice.DroidSUT("127.0.0.1", port=a.port) |
michael@0 | 19 | pslist = d.getProcessList() |
michael@0 | 20 | self.assertEqual(len(pslist), 2) |
michael@0 | 21 | self.assertEqual(pslist[0], [549, 'com.android.launcher', 10029]) |
michael@0 | 22 | self.assertEqual(pslist[1], [1198, 'com.twitter.android', 10066]) |
michael@0 | 23 | |
michael@0 | 24 | a.wait() |
michael@0 | 25 | |
michael@0 | 26 | def test_badProcessList(self): |
michael@0 | 27 | a = MockAgent(self, |
michael@0 | 28 | commands=self.bad_pscommands) |
michael@0 | 29 | d = mozdevice.DroidSUT("127.0.0.1", port=a.port) |
michael@0 | 30 | exceptionTriggered = False |
michael@0 | 31 | try: |
michael@0 | 32 | d.getProcessList() |
michael@0 | 33 | except mozdevice.DMError: |
michael@0 | 34 | exceptionTriggered = True |
michael@0 | 35 | |
michael@0 | 36 | self.assertTrue(exceptionTriggered) |
michael@0 | 37 | |
michael@0 | 38 | a.wait() |
michael@0 | 39 | |
michael@0 | 40 | def test_processExist(self): |
michael@0 | 41 | for i in [('com.android.launcher', 549), |
michael@0 | 42 | ('com.fennec.android', None)]: |
michael@0 | 43 | a = MockAgent(self, commands=self.pscommands) |
michael@0 | 44 | d = mozdevice.DroidSUT("127.0.0.1", port=a.port) |
michael@0 | 45 | self.assertEqual(d.processExist(i[0]), i[1]) |
michael@0 | 46 | a.wait() |
michael@0 | 47 | |
michael@0 | 48 | if __name__ == '__main__': |
michael@0 | 49 | unittest.main() |