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 | # Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | # http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 3 | |
michael@0 | 4 | import mozdevice |
michael@0 | 5 | import mozlog |
michael@0 | 6 | import unittest |
michael@0 | 7 | from sut import MockAgent |
michael@0 | 8 | |
michael@0 | 9 | class MkDirsTest(unittest.TestCase): |
michael@0 | 10 | |
michael@0 | 11 | def test_mkdirs(self): |
michael@0 | 12 | subTests = [{'cmds': [('isdir /mnt/sdcard/baz/boop', 'FALSE'), |
michael@0 | 13 | ('isdir /mnt', 'TRUE'), |
michael@0 | 14 | ('isdir /mnt/sdcard', 'TRUE'), |
michael@0 | 15 | ('isdir /mnt/sdcard/baz', 'FALSE'), |
michael@0 | 16 | ('mkdr /mnt/sdcard/baz', |
michael@0 | 17 | '/mnt/sdcard/baz successfully created'), |
michael@0 | 18 | ('isdir /mnt/sdcard/baz/boop', 'FALSE'), |
michael@0 | 19 | ('mkdr /mnt/sdcard/baz/boop', |
michael@0 | 20 | '/mnt/sdcard/baz/boop successfully created')], |
michael@0 | 21 | 'expectException': False}, |
michael@0 | 22 | {'cmds': [('isdir /mnt/sdcard/baz/boop', 'FALSE'), |
michael@0 | 23 | ('isdir /mnt', 'TRUE'), |
michael@0 | 24 | ('isdir /mnt/sdcard', 'TRUE'), |
michael@0 | 25 | ('isdir /mnt/sdcard/baz', 'FALSE'), |
michael@0 | 26 | ('mkdr /mnt/sdcard/baz', |
michael@0 | 27 | '##AGENT-WARNING## Could not create the directory /mnt/sdcard/baz')], |
michael@0 | 28 | 'expectException': True}, |
michael@0 | 29 | ] |
michael@0 | 30 | for subTest in subTests: |
michael@0 | 31 | a = MockAgent(self, commands=subTest['cmds']) |
michael@0 | 32 | |
michael@0 | 33 | exceptionThrown = False |
michael@0 | 34 | try: |
michael@0 | 35 | d = mozdevice.DroidSUT('127.0.0.1', port=a.port, |
michael@0 | 36 | logLevel=mozlog.DEBUG) |
michael@0 | 37 | d.mkDirs('/mnt/sdcard/baz/boop/bip') |
michael@0 | 38 | except mozdevice.DMError: |
michael@0 | 39 | exceptionThrown = True |
michael@0 | 40 | self.assertEqual(exceptionThrown, subTest['expectException']) |
michael@0 | 41 | |
michael@0 | 42 | a.wait() |
michael@0 | 43 | |
michael@0 | 44 | def test_repeated_path_part(self): |
michael@0 | 45 | """ |
michael@0 | 46 | Ensure that all dirs are created when last path part also found |
michael@0 | 47 | earlier in the path (bug 826492). |
michael@0 | 48 | """ |
michael@0 | 49 | |
michael@0 | 50 | cmds = [('isdir /mnt/sdcard/foo', 'FALSE'), |
michael@0 | 51 | ('isdir /mnt', 'TRUE'), |
michael@0 | 52 | ('isdir /mnt/sdcard', 'TRUE'), |
michael@0 | 53 | ('isdir /mnt/sdcard/foo', 'FALSE'), |
michael@0 | 54 | ('mkdr /mnt/sdcard/foo', |
michael@0 | 55 | '/mnt/sdcard/foo successfully created')] |
michael@0 | 56 | a = MockAgent(self, commands=cmds) |
michael@0 | 57 | d = mozdevice.DroidSUT('127.0.0.1', port=a.port, |
michael@0 | 58 | logLevel=mozlog.DEBUG) |
michael@0 | 59 | d.mkDirs('/mnt/sdcard/foo/foo') |
michael@0 | 60 | a.wait() |
michael@0 | 61 | |
michael@0 | 62 | def test_mkdirs_on_root(self): |
michael@0 | 63 | cmds = [('isdir /', 'TRUE')] |
michael@0 | 64 | a = MockAgent(self, commands=cmds) |
michael@0 | 65 | d = mozdevice.DroidSUT('127.0.0.1', port=a.port, |
michael@0 | 66 | logLevel=mozlog.DEBUG) |
michael@0 | 67 | d.mkDirs('/foo') |
michael@0 | 68 | |
michael@0 | 69 | a.wait() |
michael@0 | 70 | |
michael@0 | 71 | |
michael@0 | 72 | if __name__ == '__main__': |
michael@0 | 73 | unittest.main() |