| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 from pylib import cmd_helper | 10 from pylib import cmd_helper |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 device.adb.Push = mock.Mock() | 206 device.adb.Push = mock.Mock() |
| 207 device_md5sum_output = [ | 207 device_md5sum_output = [ |
| 208 'WARNING: linker: /data/local/tmp/md5sum/md5sum_bin: ' | 208 'WARNING: linker: /data/local/tmp/md5sum/md5sum_bin: ' |
| 209 'unused DT entry: type 0x1d arg 0x15db', | 209 'unused DT entry: type 0x1d arg 0x15db', |
| 210 'THIS_IS_NOT_A_VALID_CHECKSUM_ZZZ some random text', | 210 'THIS_IS_NOT_A_VALID_CHECKSUM_ZZZ some random text', |
| 211 '0123456789abcdeffedcba9876543210 ' | 211 '0123456789abcdeffedcba9876543210 ' |
| 212 '/storage/emulated/legacy/test/file.dat', | 212 '/storage/emulated/legacy/test/file.dat', |
| 213 ] | 213 ] |
| 214 error = device_errors.AdbShellCommandFailedError('cmd', 'out', 2) | 214 error = device_errors.AdbShellCommandFailedError('cmd', 'out', 2) |
| 215 device.RunShellCommand = mock.Mock( | 215 device.RunShellCommand = mock.Mock( |
| 216 side_effect=(error, device_md5sum_output)) | 216 side_effect=(error, '', device_md5sum_output)) |
| 217 | 217 |
| 218 with mock.patch('os.path.getsize', return_value=1337): | 218 with mock.patch('os.path.getsize', return_value=1337): |
| 219 out = md5sum.CalculateDeviceMd5Sums(test_path, device) | 219 out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
| 220 self.assertEquals(1, len(out)) | 220 self.assertEquals(1, len(out)) |
| 221 self.assertTrue('/storage/emulated/legacy/test/file.dat' in out) | 221 self.assertTrue('/storage/emulated/legacy/test/file.dat' in out) |
| 222 self.assertEquals('0123456789abcdeffedcba9876543210', | 222 self.assertEquals('0123456789abcdeffedcba9876543210', |
| 223 out['/storage/emulated/legacy/test/file.dat']) | 223 out['/storage/emulated/legacy/test/file.dat']) |
| 224 self.assertEquals(2, len(device.RunShellCommand.call_args_list)) | 224 self.assertEquals(3, len(device.RunShellCommand.call_args_list)) |
| 225 device.adb.Push.assert_called_once_with( | 225 device.adb.Push.assert_called_once_with( |
| 226 'test/out/directory/md5sum_dist', '/data/local/tmp/md5sum/') | 226 'test/out/directory/md5sum_dist', '/data/local/tmp/md5sum/') |
| 227 | 227 |
| 228 | 228 |
| 229 if __name__ == '__main__': | 229 if __name__ == '__main__': |
| 230 unittest.main(verbosity=2) | 230 unittest.main(verbosity=2) |
| 231 | 231 |
| OLD | NEW |