| 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 """ | 6 """ |
| 7 Unit tests for the contents of device_utils.py (mostly DeviceUtils). | 7 Unit tests for the contents of device_utils.py (mostly DeviceUtils). |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 # pylint: disable=C0321 | 10 # pylint: disable=C0321 |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 | 1137 |
| 1138 def testPushChangedFilesZipped_single(self): | 1138 def testPushChangedFilesZipped_single(self): |
| 1139 self._testPushChangedFilesZipped_spec( | 1139 self._testPushChangedFilesZipped_spec( |
| 1140 [('/test/host/path/file1', '/test/device/path/file1')]) | 1140 [('/test/host/path/file1', '/test/device/path/file1')]) |
| 1141 | 1141 |
| 1142 def testPushChangedFilesZipped_multiple(self): | 1142 def testPushChangedFilesZipped_multiple(self): |
| 1143 self._testPushChangedFilesZipped_spec( | 1143 self._testPushChangedFilesZipped_spec( |
| 1144 [('/test/host/path/file1', '/test/device/path/file1'), | 1144 [('/test/host/path/file1', '/test/device/path/file1'), |
| 1145 ('/test/host/path/file2', '/test/device/path/file2')]) | 1145 ('/test/host/path/file2', '/test/device/path/file2')]) |
| 1146 | 1146 |
| 1147 class DeviceUtilsDeleteStaleFilesTest(DeviceUtilsTest): |
| 1148 |
| 1149 def testDeleteStaleFiles_emtpy(self): |
| 1150 files = [] |
| 1151 with self.assertCalls(): |
| 1152 self.device._DeleteStaleFiles(files) |
| 1153 |
| 1154 def testDeleteStaleFiles_single(self): |
| 1155 files = ['/test/device/path/file1'] |
| 1156 with self.assertCalls((self.call.adb.Shell( |
| 1157 'rm /test/device/path/file1'), '')): |
| 1158 self.device._DeleteStaleFiles(files) |
| 1159 |
| 1160 def testDeleteStaleFiles_multiple(self): |
| 1161 files = ['/test/device/path/file1', '/test/device/path/file2'] |
| 1162 with self.assertCalls( |
| 1163 (self.call.adb.Shell('rm /test/device/path/file1'), ''), |
| 1164 (self.call.adb.Shell('rm /test/device/path/file2'), '')): |
| 1165 self.device._DeleteStaleFiles(files) |
| 1147 | 1166 |
| 1148 class DeviceUtilsFileExistsTest(DeviceUtilsTest): | 1167 class DeviceUtilsFileExistsTest(DeviceUtilsTest): |
| 1149 | 1168 |
| 1150 def testFileExists_usingTest_fileExists(self): | 1169 def testFileExists_usingTest_fileExists(self): |
| 1151 with self.assertCall( | 1170 with self.assertCall( |
| 1152 self.call.device.RunShellCommand( | 1171 self.call.device.RunShellCommand( |
| 1153 ['test', '-e', '/path/file.exists'], check_return=True), ''): | 1172 ['test', '-e', '/path/file.exists'], check_return=True), ''): |
| 1154 self.assertTrue(self.device.FileExists('/path/file.exists')) | 1173 self.assertTrue(self.device.FileExists('/path/file.exists')) |
| 1155 | 1174 |
| 1156 def testFileExists_usingTest_fileDoesntExist(self): | 1175 def testFileExists_usingTest_fileDoesntExist(self): |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 devices = device_utils.DeviceUtils.HealthyDevices() | 1699 devices = device_utils.DeviceUtils.HealthyDevices() |
| 1681 self.assertEquals(1, len(devices)) | 1700 self.assertEquals(1, len(devices)) |
| 1682 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) | 1701 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) |
| 1683 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) | 1702 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) |
| 1684 | 1703 |
| 1685 | 1704 |
| 1686 if __name__ == '__main__': | 1705 if __name__ == '__main__': |
| 1687 logging.getLogger().setLevel(logging.DEBUG) | 1706 logging.getLogger().setLevel(logging.DEBUG) |
| 1688 unittest.main(verbosity=2) | 1707 unittest.main(verbosity=2) |
| 1689 | 1708 |
| OLD | NEW |