1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/testing/mozbase/mozdevice/tests/sut_movetree.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +#!/usr/bin/env python 1.5 +# -*- coding: utf-8 -*- 1.6 + 1.7 +# This Source Code Form is subject to the terms of the Mozilla Public 1.8 +# License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.9 +# You can obtain one at http://mozilla.org/MPL/2.0/. 1.10 + 1.11 +import mozdevice 1.12 +import mozlog 1.13 +import unittest 1.14 +from sut import MockAgent 1.15 + 1.16 +class MoveTreeTest(unittest.TestCase): 1.17 + def test_moveFile(self): 1.18 + commands = [('mv /mnt/sdcard/tests/test.txt /mnt/sdcard/tests/test1.txt', ''), 1.19 + ('isdir /mnt/sdcard/tests', 'TRUE'), 1.20 + ('cd /mnt/sdcard/tests', ''), 1.21 + ('ls', 'test1.txt'), 1.22 + ('isdir /mnt/sdcard/tests', 'TRUE'), 1.23 + ('cd /mnt/sdcard/tests', ''), 1.24 + ('ls', 'test1.txt')] 1.25 + 1.26 + m = MockAgent(self, commands=commands) 1.27 + d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG) 1.28 + self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/test.txt', 1.29 + '/mnt/sdcard/tests/test1.txt')) 1.30 + self.assertFalse(d.fileExists('/mnt/sdcard/tests/test.txt')) 1.31 + self.assertTrue(d.fileExists('/mnt/sdcard/tests/test1.txt')) 1.32 + 1.33 + def test_moveDir(self): 1.34 + commands = [("mv /mnt/sdcard/tests/foo /mnt/sdcard/tests/bar", ""), 1.35 + ('isdir /mnt/sdcard/tests', 'TRUE'), 1.36 + ('cd /mnt/sdcard/tests', ''), 1.37 + ('ls', 'bar')] 1.38 + 1.39 + m = MockAgent(self, commands=commands) 1.40 + d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG) 1.41 + self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/foo', 1.42 + '/mnt/sdcard/tests/bar')) 1.43 + self.assertTrue(d.fileExists('/mnt/sdcard/tests/bar')) 1.44 + 1.45 + def test_moveNonEmptyDir(self): 1.46 + commands = [('isdir /mnt/sdcard/tests/foo/bar', 'TRUE'), 1.47 + ('mv /mnt/sdcard/tests/foo /mnt/sdcard/tests/foo2', ''), 1.48 + ('isdir /mnt/sdcard/tests', 'TRUE'), 1.49 + ('cd /mnt/sdcard/tests', ''), 1.50 + ('ls', 'foo2'), 1.51 + ('isdir /mnt/sdcard/tests/foo2', 'TRUE'), 1.52 + ('cd /mnt/sdcard/tests/foo2', ''), 1.53 + ('ls', 'bar')] 1.54 + 1.55 + m = MockAgent(self, commands=commands) 1.56 + d = mozdevice.DroidSUT("127.0.0.1", port=m.port, 1.57 + logLevel=mozlog.DEBUG) 1.58 + 1.59 + self.assertTrue(d.dirExists('/mnt/sdcard/tests/foo/bar')) 1.60 + self.assertEqual(None, d.moveTree('/mnt/sdcard/tests/foo', 1.61 + '/mnt/sdcard/tests/foo2')) 1.62 + self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2')) 1.63 + self.assertTrue(d.fileExists('/mnt/sdcard/tests/foo2/bar')) 1.64 + 1.65 +if __name__ == "__main__": 1.66 + unittest.main()