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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 | 363 |
364 def testGetExternalStoragePath_fails(self): | 364 def testGetExternalStoragePath_fails(self): |
365 with self.assertCall(self.call.adb.Shell('echo $EXTERNAL_STORAGE'), '\n'): | 365 with self.assertCall(self.call.adb.Shell('echo $EXTERNAL_STORAGE'), '\n'): |
366 with self.assertRaises(device_errors.CommandFailedError): | 366 with self.assertRaises(device_errors.CommandFailedError): |
367 self.device.GetExternalStoragePath() | 367 self.device.GetExternalStoragePath() |
368 | 368 |
369 | 369 |
370 class DeviceUtilsGetApplicationPathTest(DeviceUtilsNewImplTest): | 370 class DeviceUtilsGetApplicationPathTest(DeviceUtilsNewImplTest): |
371 | 371 |
372 def testGetApplicationPath_exists(self): | 372 def testGetApplicationPath_exists(self): |
373 with self.assertCall(self.call.adb.Shell('pm path android'), | 373 with self.assertCalls( |
374 'package:/path/to/android.apk\n'): | 374 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), |
| 375 (self.call.adb.Shell('pm path android'), |
| 376 'package:/path/to/android.apk\n')): |
375 self.assertEquals('/path/to/android.apk', | 377 self.assertEquals('/path/to/android.apk', |
376 self.device.GetApplicationPath('android')) | 378 self.device.GetApplicationPath('android')) |
377 | 379 |
378 def testGetApplicationPath_notExists(self): | 380 def testGetApplicationPath_notExists(self): |
379 with self.assertCall(self.call.adb.Shell('pm path not.installed.app'), ''): | 381 with self.assertCalls( |
| 382 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), |
| 383 (self.call.adb.Shell('pm path not.installed.app'), '')): |
380 self.assertEquals(None, | 384 self.assertEquals(None, |
381 self.device.GetApplicationPath('not.installed.app')) | 385 self.device.GetApplicationPath('not.installed.app')) |
382 | 386 |
383 def testGetApplicationPath_fails(self): | 387 def testGetApplicationPath_fails(self): |
384 with self.assertCall(self.call.adb.Shell('pm path android'), | 388 with self.assertCalls( |
385 self.CommandError('ERROR. Is package manager running?\n')): | 389 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), |
| 390 (self.call.adb.Shell('pm path android'), |
| 391 self.CommandError('ERROR. Is package manager running?\n'))): |
386 with self.assertRaises(device_errors.CommandFailedError): | 392 with self.assertRaises(device_errors.CommandFailedError): |
387 self.device.GetApplicationPath('android') | 393 self.device.GetApplicationPath('android') |
388 | 394 |
389 | 395 |
390 @mock.patch('time.sleep', mock.Mock()) | 396 @mock.patch('time.sleep', mock.Mock()) |
391 class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsNewImplTest): | 397 class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsNewImplTest): |
392 | 398 |
393 def testWaitUntilFullyBooted_succeedsNoWifi(self): | 399 def testWaitUntilFullyBooted_succeedsNoWifi(self): |
394 with self.assertCalls( | 400 with self.assertCalls( |
395 self.call.adb.WaitForDevice(), | 401 self.call.adb.WaitForDevice(), |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 self.assertTrue( | 1541 self.assertTrue( |
1536 isinstance(device, device_utils.DeviceUtils) | 1542 isinstance(device, device_utils.DeviceUtils) |
1537 and serial == str(device), | 1543 and serial == str(device), |
1538 'Expected a DeviceUtils object with serial %s' % serial) | 1544 'Expected a DeviceUtils object with serial %s' % serial) |
1539 | 1545 |
1540 | 1546 |
1541 if __name__ == '__main__': | 1547 if __name__ == '__main__': |
1542 logging.getLogger().setLevel(logging.DEBUG) | 1548 logging.getLogger().setLevel(logging.DEBUG) |
1543 unittest.main(verbosity=2) | 1549 unittest.main(verbosity=2) |
1544 | 1550 |
OLD | NEW |