Chromium Code Reviews| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 def assertNoAdbCalls(self): | 208 def assertNoAdbCalls(self): |
| 209 return type(self).AndroidCommandsCalls(self, [], str.__eq__) | 209 return type(self).AndroidCommandsCalls(self, [], str.__eq__) |
| 210 | 210 |
| 211 def assertCalls(self, cmd, ret, comp=str.__eq__): | 211 def assertCalls(self, cmd, ret, comp=str.__eq__): |
| 212 return type(self).AndroidCommandsCalls(self, [(cmd, ret)], comp) | 212 return type(self).AndroidCommandsCalls(self, [(cmd, ret)], comp) |
| 213 | 213 |
| 214 def assertCallsSequence(self, cmd_ret, comp=str.__eq__): | 214 def assertCallsSequence(self, cmd_ret, comp=str.__eq__): |
| 215 return type(self).AndroidCommandsCalls(self, cmd_ret, comp) | 215 return type(self).AndroidCommandsCalls(self, cmd_ret, comp) |
| 216 | 216 |
| 217 def setUp(self): | 217 def setUp(self): |
| 218 self._getadbpath_patch = mock.patch('pylib.constants.GetAdbPath', | |
|
jbudorick
2014/11/19 20:52:14
nit: self._get_adb_path_patch
| |
| 219 mock.Mock(return_value='adb')) | |
| 220 self._getadbpath_patch.start() | |
| 218 self.device = device_utils.DeviceUtils( | 221 self.device = device_utils.DeviceUtils( |
| 219 '0123456789abcdef', default_timeout=1, default_retries=0) | 222 '0123456789abcdef', default_timeout=1, default_retries=0) |
| 220 | 223 |
| 224 def tearDown(self): | |
| 225 self._getadbpath_patch.stop() | |
| 221 | 226 |
| 222 class DeviceUtilsNewImplTest(mock_calls.TestCase): | 227 class DeviceUtilsNewImplTest(mock_calls.TestCase): |
| 223 | 228 |
| 224 def setUp(self): | 229 def setUp(self): |
| 225 test_serial = '0123456789abcdef' | 230 test_serial = '0123456789abcdef' |
| 226 self.adb = mock.Mock(spec=adb_wrapper.AdbWrapper) | 231 self.adb = mock.Mock(spec=adb_wrapper.AdbWrapper) |
| 227 self.adb.__str__ = mock.Mock(return_value=test_serial) | 232 self.adb.__str__ = mock.Mock(return_value=test_serial) |
| 228 self.adb.GetDeviceSerial.return_value = test_serial | 233 self.adb.GetDeviceSerial.return_value = test_serial |
| 229 self.device = device_utils.DeviceUtils( | 234 self.device = device_utils.DeviceUtils( |
| 230 self.adb, default_timeout=10, default_retries=0) | 235 self.adb, default_timeout=10, default_retries=0) |
| (...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1616 self.device = device_utils.DeviceUtils(None) | 1621 self.device = device_utils.DeviceUtils(None) |
| 1617 with self.assertCalls('adb get-serialno', 'unknown'), ( | 1622 with self.assertCalls('adb get-serialno', 'unknown'), ( |
| 1618 self.assertRaises(device_errors.NoDevicesError)): | 1623 self.assertRaises(device_errors.NoDevicesError)): |
| 1619 str(self.device) | 1624 str(self.device) |
| 1620 | 1625 |
| 1621 | 1626 |
| 1622 if __name__ == '__main__': | 1627 if __name__ == '__main__': |
| 1623 logging.getLogger().setLevel(logging.DEBUG) | 1628 logging.getLogger().setLevel(logging.DEBUG) |
| 1624 unittest.main(verbosity=2) | 1629 unittest.main(verbosity=2) |
| 1625 | 1630 |
| OLD | NEW |