testing/mozbase/mozdevice/tests/sut_movetree.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 MoveTreeTest(unittest.TestCase):
michael@0 14 def test_moveFile(self):
michael@0 15 commands = [('mv /mnt/sdcard/tests/test.txt /mnt/sdcard/tests/test1.txt', ''),
michael@0 16 ('isdir /mnt/sdcard/tests', 'TRUE'),
michael@0 17 ('cd /mnt/sdcard/tests', ''),
michael@0 18 ('ls', 'test1.txt'),
michael@0 19 ('isdir /mnt/sdcard/tests', 'TRUE'),
michael@0 20 ('cd /mnt/sdcard/tests', ''),
michael@0 21 ('ls', 'test1.txt')]
michael@0 22
michael@0 23 m = MockAgent(self, commands=commands)
michael@0 24 d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG)
michael@0 25 self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/test.txt',
michael@0 26 '/mnt/sdcard/tests/test1.txt'))
michael@0 27 self.assertFalse(d.fileExists('/mnt/sdcard/tests/test.txt'))
michael@0 28 self.assertTrue(d.fileExists('/mnt/sdcard/tests/test1.txt'))
michael@0 29
michael@0 30 def test_moveDir(self):
michael@0 31 commands = [("mv /mnt/sdcard/tests/foo /mnt/sdcard/tests/bar", ""),
michael@0 32 ('isdir /mnt/sdcard/tests', 'TRUE'),
michael@0 33 ('cd /mnt/sdcard/tests', ''),
michael@0 34 ('ls', 'bar')]
michael@0 35
michael@0 36 m = MockAgent(self, commands=commands)
michael@0 37 d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG)
michael@0 38 self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/foo',
michael@0 39 '/mnt/sdcard/tests/bar'))
michael@0 40 self.assertTrue(d.fileExists('/mnt/sdcard/tests/bar'))
michael@0 41
michael@0 42 def test_moveNonEmptyDir(self):
michael@0 43 commands = [('isdir /mnt/sdcard/tests/foo/bar', 'TRUE'),
michael@0 44 ('mv /mnt/sdcard/tests/foo /mnt/sdcard/tests/foo2', ''),
michael@0 45 ('isdir /mnt/sdcard/tests', 'TRUE'),
michael@0 46 ('cd /mnt/sdcard/tests', ''),
michael@0 47 ('ls', 'foo2'),
michael@0 48 ('isdir /mnt/sdcard/tests/foo2', 'TRUE'),
michael@0 49 ('cd /mnt/sdcard/tests/foo2', ''),
michael@0 50 ('ls', 'bar')]
michael@0 51
michael@0 52 m = MockAgent(self, commands=commands)
michael@0 53 d = mozdevice.DroidSUT("127.0.0.1", port=m.port,
michael@0 54 logLevel=mozlog.DEBUG)
michael@0 55
michael@0 56 self.assertTrue(d.dirExists('/mnt/sdcard/tests/foo/bar'))
michael@0 57 self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/foo',
michael@0 58 '/mnt/sdcard/tests/foo2'))
michael@0 59 self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2'))
michael@0 60 self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2/bar'))
michael@0 61
michael@0 62 if __name__ == "__main__":
michael@0 63 unittest.main()

mercurial