testing/mozbase/mozdevice/tests/sut_pull.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.

     1 from sut import MockAgent
     2 import mozdevice
     3 import mozlog
     4 import unittest
     5 import hashlib
     6 import tempfile
     7 import os
     9 class PullTest(unittest.TestCase):
    11     def test_pull_success(self):
    12         for count in [ 1, 4, 1024, 2048 ]:
    13             cheeseburgers = ""
    14             for i in range(count):
    15                 cheeseburgers += "cheeseburgers"
    17             # pull file is kind of gross, make sure we can still execute commands after it's done
    18             remoteName = "/mnt/sdcard/cheeseburgers"
    19             a = MockAgent(self, commands = [("pull %s" % remoteName,
    20                                              "%s,%s\n%s" % (remoteName,
    21                                                             len(cheeseburgers),
    22                                                             cheeseburgers)),
    23                                             ("isdir /mnt/sdcard", "TRUE")])
    25             d = mozdevice.DroidSUT("127.0.0.1", port=a.port,
    26                                    logLevel=mozlog.DEBUG)
    27             pulledData = d.pullFile("/mnt/sdcard/cheeseburgers")
    28             self.assertEqual(pulledData, cheeseburgers)
    29             d.dirExists('/mnt/sdcard')
    31     def test_pull_failure(self):
    33         # this test simulates only receiving a few bytes of what we expect
    34         # to be larger file
    35         remoteName = "/mnt/sdcard/cheeseburgers"
    36         a = MockAgent(self, commands = [("pull %s" % remoteName,
    37                                          "%s,15\n%s" % (remoteName,
    38                                                         "cheeseburgh"))])
    39         d = mozdevice.DroidSUT("127.0.0.1", port=a.port,
    40                                logLevel=mozlog.DEBUG)
    41         exceptionThrown = False
    42         try:
    43             d.pullFile("/mnt/sdcard/cheeseburgers")
    44         except mozdevice.DMError:
    45             exceptionThrown = True
    46         self.assertTrue(exceptionThrown)
    48 if __name__ == '__main__':
    49     unittest.main()

mercurial