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 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 and serial == str(device), | 1583 and serial == str(device), |
1584 'Expected a DeviceUtils object with serial %s' % serial) | 1584 'Expected a DeviceUtils object with serial %s' % serial) |
1585 | 1585 |
1586 def testParallel_noDevices(self): | 1586 def testParallel_noDevices(self): |
1587 with self.assertCall( | 1587 with self.assertCall( |
1588 mock.call.pylib.device.adb_wrapper.AdbWrapper.GetDevices(), []): | 1588 mock.call.pylib.device.adb_wrapper.AdbWrapper.GetDevices(), []): |
1589 with self.assertRaises(device_errors.NoDevicesError): | 1589 with self.assertRaises(device_errors.NoDevicesError): |
1590 device_utils.DeviceUtils.parallel() | 1590 device_utils.DeviceUtils.parallel() |
1591 | 1591 |
1592 | 1592 |
| 1593 class DeviceUtilsClientCache(DeviceUtilsTest): |
| 1594 |
| 1595 def testClientCache_twoCaches(self): |
| 1596 self.device._cache['test'] = 0 |
| 1597 client_cache_one = self.device.GetClientCache('ClientOne') |
| 1598 client_cache_one['test'] = 1 |
| 1599 client_cache_two = self.device.GetClientCache('ClientTwo') |
| 1600 client_cache_two['test'] = 2 |
| 1601 self.assertEqual(self.device._cache, {'test': 0}) |
| 1602 self.assertEqual(client_cache_one, {'test': 1}) |
| 1603 self.assertEqual(client_cache_two, {'test': 2}) |
| 1604 self.device._ClearCache() |
| 1605 self.assertEqual(self.device._cache, {}) |
| 1606 self.assertEqual(client_cache_one, {}) |
| 1607 self.assertEqual(client_cache_two, {}) |
| 1608 |
| 1609 def testClientCache_multipleInstances(self): |
| 1610 client_cache_one = self.device.GetClientCache('ClientOne') |
| 1611 client_cache_one['test'] = 1 |
| 1612 client_cache_two = self.device.GetClientCache('ClientOne') |
| 1613 self.assertEqual(client_cache_one, {'test': 1}) |
| 1614 self.assertEqual(client_cache_two, {'test': 1}) |
| 1615 self.device._ClearCache() |
| 1616 self.assertEqual(client_cache_one, {}) |
| 1617 self.assertEqual(client_cache_two, {}) |
| 1618 |
1593 if __name__ == '__main__': | 1619 if __name__ == '__main__': |
1594 logging.getLogger().setLevel(logging.DEBUG) | 1620 logging.getLogger().setLevel(logging.DEBUG) |
1595 unittest.main(verbosity=2) | 1621 unittest.main(verbosity=2) |
1596 | 1622 |
OLD | NEW |