Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: build/android/pylib/utils/md5sum_test.py

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/utils/md5sum.py ('k') | build/android/rezip/RezipApk.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 def testCalculateDeviceMd5Sums_singlePath_linkerWarning(self): 192 def testCalculateDeviceMd5Sums_singlePath_linkerWarning(self):
193 # See crbug/479966 193 # See crbug/479966
194 test_path = '/storage/emulated/legacy/test/file.dat' 194 test_path = '/storage/emulated/legacy/test/file.dat'
195 195
196 device = mock.NonCallableMock() 196 device = mock.NonCallableMock()
197 device.adb = mock.NonCallableMock() 197 device.adb = mock.NonCallableMock()
198 device.adb.Push = mock.Mock() 198 device.adb.Push = mock.Mock()
199 device_md5sum_output = [ 199 device_md5sum_output = [
200 'WARNING: linker: /data/local/tmp/md5sum/md5sum_bin: ' 200 'WARNING: linker: /data/local/tmp/md5sum/md5sum_bin: '
201 'unused DT entry: type 0x1d arg 0x15db', 201 'unused DT entry: type 0x1d arg 0x15db',
202 'THIS_IS_NOT_A_VALID_CHECKSUM_ZZZ some random text',
202 '0123456789abcdeffedcba9876543210 ' 203 '0123456789abcdeffedcba9876543210 '
203 '/storage/emulated/legacy/test/file.dat', 204 '/storage/emulated/legacy/test/file.dat',
204 ] 205 ]
205 device.RunShellCommand = mock.Mock(return_value=device_md5sum_output) 206 device.RunShellCommand = mock.Mock(return_value=device_md5sum_output)
206 207
207 mock_temp_file = mock.mock_open() 208 mock_temp_file = mock.mock_open()
208 mock_temp_file.return_value.name = '/tmp/test/script/file.sh' 209 mock_temp_file.return_value.name = '/tmp/test/script/file.sh'
209 210
210 mock_device_temp_file = mock.mock_open() 211 mock_device_temp_file = mock.mock_open()
211 mock_device_temp_file.return_value.name = ( 212 mock_device_temp_file.return_value.name = (
212 '/data/local/tmp/test/script/file.sh') 213 '/data/local/tmp/test/script/file.sh')
213 214
214 with mock.patch('tempfile.NamedTemporaryFile', new=mock_temp_file), ( 215 with mock.patch('tempfile.NamedTemporaryFile', new=mock_temp_file), (
215 mock.patch('pylib.utils.device_temp_file.DeviceTempFile', 216 mock.patch('pylib.utils.device_temp_file.DeviceTempFile',
216 new=mock_device_temp_file)): 217 new=mock_device_temp_file)):
217 out = md5sum.CalculateDeviceMd5Sums(test_path, device) 218 out = md5sum.CalculateDeviceMd5Sums(test_path, device)
218 self.assertEquals(1, len(out)) 219 self.assertEquals(1, len(out))
219 self.assertTrue('/storage/emulated/legacy/test/file.dat' in out) 220 self.assertTrue('/storage/emulated/legacy/test/file.dat' in out)
220 self.assertEquals('0123456789abcdeffedcba9876543210', 221 self.assertEquals('0123456789abcdeffedcba9876543210',
221 out['/storage/emulated/legacy/test/file.dat']) 222 out['/storage/emulated/legacy/test/file.dat'])
222 device.adb.Push.assert_called_once_with( 223 device.adb.Push.assert_called_once_with(
223 '/tmp/test/script/file.sh', '/data/local/tmp/test/script/file.sh') 224 '/tmp/test/script/file.sh', '/data/local/tmp/test/script/file.sh')
224 device.RunShellCommand.assert_called_once_with( 225 device.RunShellCommand.assert_called_once_with(
225 ['sh', '/data/local/tmp/test/script/file.sh']) 226 ['sh', '/data/local/tmp/test/script/file.sh'])
226 227
227 228
228 if __name__ == '__main__': 229 if __name__ == '__main__':
229 unittest.main(verbosity=2) 230 unittest.main(verbosity=2)
230 231
OLDNEW
« no previous file with comments | « build/android/pylib/utils/md5sum.py ('k') | build/android/rezip/RezipApk.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698