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 | #!/usr/bin/env python |
michael@0 | 2 | # -*- coding: utf-8 -*- |
michael@0 | 3 | |
michael@0 | 4 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | # License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 6 | # You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 7 | |
michael@0 | 8 | import mozdevice |
michael@0 | 9 | import mozlog |
michael@0 | 10 | import unittest |
michael@0 | 11 | from sut import MockAgent |
michael@0 | 12 | |
michael@0 | 13 | class CopyTreeTest(unittest.TestCase): |
michael@0 | 14 | def test_copyFile(self): |
michael@0 | 15 | commands = [('dd if=/mnt/sdcard/tests/test.txt of=/mnt/sdcard/tests/test2.txt', ''), |
michael@0 | 16 | ('isdir /mnt/sdcard/tests', 'TRUE'), |
michael@0 | 17 | ('cd /mnt/sdcard/tests', ''), |
michael@0 | 18 | ('ls', 'test.txt\ntest2.txt')] |
michael@0 | 19 | |
michael@0 | 20 | m = MockAgent(self, commands=commands) |
michael@0 | 21 | d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG) |
michael@0 | 22 | |
michael@0 | 23 | self.assertEqual(None, d.copyTree('/mnt/sdcard/tests/test.txt', |
michael@0 | 24 | '/mnt/sdcard/tests/test2.txt')) |
michael@0 | 25 | expected = (commands[3][1].strip()).split('\n') |
michael@0 | 26 | self.assertEqual(expected, d.listFiles('/mnt/sdcard/tests')) |
michael@0 | 27 | |
michael@0 | 28 | def test_copyDir(self): |
michael@0 | 29 | commands = [('dd if=/mnt/sdcard/tests/foo of=/mnt/sdcard/tests/bar', ''), |
michael@0 | 30 | ('isdir /mnt/sdcard/tests', 'TRUE'), |
michael@0 | 31 | ('cd /mnt/sdcard/tests', ''), |
michael@0 | 32 | ('ls', 'foo\nbar')] |
michael@0 | 33 | |
michael@0 | 34 | m = MockAgent(self, commands=commands) |
michael@0 | 35 | d = mozdevice.DroidSUT("127.0.0.1", port=m.port, |
michael@0 | 36 | logLevel=mozlog.DEBUG) |
michael@0 | 37 | |
michael@0 | 38 | self.assertEqual(None, d.copyTree('/mnt/sdcard/tests/foo', |
michael@0 | 39 | '/mnt/sdcard/tests/bar')) |
michael@0 | 40 | expected = (commands[3][1].strip()).split('\n') |
michael@0 | 41 | self.assertEqual(expected, d.listFiles('/mnt/sdcard/tests')) |
michael@0 | 42 | |
michael@0 | 43 | def test_copyNonEmptyDir(self): |
michael@0 | 44 | commands = [('isdir /mnt/sdcard/tests/foo/bar', 'TRUE'), |
michael@0 | 45 | ('dd if=/mnt/sdcard/tests/foo of=/mnt/sdcard/tests/foo2', ''), |
michael@0 | 46 | ('isdir /mnt/sdcard/tests', 'TRUE'), |
michael@0 | 47 | ('cd /mnt/sdcard/tests', ''), |
michael@0 | 48 | ('ls', 'foo\nfoo2'), |
michael@0 | 49 | ('isdir /mnt/sdcard/tests/foo2', 'TRUE'), |
michael@0 | 50 | ('cd /mnt/sdcard/tests/foo2', ''), |
michael@0 | 51 | ('ls', 'bar')] |
michael@0 | 52 | |
michael@0 | 53 | m = MockAgent(self, commands=commands) |
michael@0 | 54 | d = mozdevice.DroidSUT("127.0.0.1", port=m.port, |
michael@0 | 55 | logLevel=mozlog.DEBUG) |
michael@0 | 56 | |
michael@0 | 57 | self.assertTrue(d.dirExists('/mnt/sdcard/tests/foo/bar')) |
michael@0 | 58 | self.assertEqual(None, d.copyTree('/mnt/sdcard/tests/foo', |
michael@0 | 59 | '/mnt/sdcard/tests/foo2')) |
michael@0 | 60 | expected = (commands[4][1].strip()).split('\n') |
michael@0 | 61 | self.assertEqual(expected, d.listFiles('/mnt/sdcard/tests')) |
michael@0 | 62 | self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2/bar')) |
michael@0 | 63 | |
michael@0 | 64 | if __name__ == "__main__": |
michael@0 | 65 | unittest.main() |