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 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 "adb -s 0123456789abcdef shell 'showmap 4321'", | 1477 "adb -s 0123456789abcdef shell 'showmap 4321'", |
1478 'cannot open /proc/4321/smaps: No such file or directory\r\n'): | 1478 'cannot open /proc/4321/smaps: No such file or directory\r\n'): |
1479 self.assertEqual({}, self.device.GetMemoryUsageForPid(4321)) | 1479 self.assertEqual({}, self.device.GetMemoryUsageForPid(4321)) |
1480 | 1480 |
1481 | 1481 |
1482 class DeviceUtilsStrTest(DeviceUtilsOldImplTest): | 1482 class DeviceUtilsStrTest(DeviceUtilsOldImplTest): |
1483 def testStr_noAdbCalls(self): | 1483 def testStr_noAdbCalls(self): |
1484 with self.assertNoAdbCalls(): | 1484 with self.assertNoAdbCalls(): |
1485 self.assertEqual('0123456789abcdef', str(self.device)) | 1485 self.assertEqual('0123456789abcdef', str(self.device)) |
1486 | 1486 |
| 1487 def testStr_noSerial(self): |
| 1488 self.device = device_utils.DeviceUtils(None) |
| 1489 with self.assertCalls('adb get-serialno', '0123456789abcdef'): |
| 1490 self.assertEqual('0123456789abcdef', str(self.device)) |
| 1491 |
| 1492 def testStr_noSerial_noDevices(self): |
| 1493 self.device = device_utils.DeviceUtils(None) |
| 1494 with self.assertCalls('adb get-serialno', 'unknown'), ( |
| 1495 self.assertRaises(device_errors.NoDevicesError)): |
| 1496 str(self.device) |
| 1497 |
1487 | 1498 |
1488 if __name__ == '__main__': | 1499 if __name__ == '__main__': |
1489 logging.getLogger().setLevel(logging.DEBUG) | 1500 logging.getLogger().setLevel(logging.DEBUG) |
1490 unittest.main(verbosity=2) | 1501 unittest.main(verbosity=2) |
1491 | 1502 |
OLD | NEW |