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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 self.device.Reboot(block=True, wifi=True) | 467 self.device.Reboot(block=True, wifi=True) |
468 | 468 |
469 | 469 |
470 class DeviceUtilsInstallTest(DeviceUtilsTest): | 470 class DeviceUtilsInstallTest(DeviceUtilsTest): |
471 | 471 |
472 def testInstall_noPriorInstall(self): | 472 def testInstall_noPriorInstall(self): |
473 with self.assertCalls( | 473 with self.assertCalls( |
474 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 474 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
475 'this.is.a.test.package'), | 475 'this.is.a.test.package'), |
476 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), | 476 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), |
477 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): | 477 self.call.adb.Install('/fake/test/app.apk', reinstall=False, |
| 478 split_paths=None)): |
478 self.device.Install('/fake/test/app.apk', retries=0) | 479 self.device.Install('/fake/test/app.apk', retries=0) |
479 | 480 |
| 481 def testInstall_withSplits(self): |
| 482 with self.assertCalls( |
| 483 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
| 484 'this.is.a.test.package'), |
| 485 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), |
| 486 self.call.adb.Install('/fake/test/app.apk', reinstall=False, |
| 487 split_paths=['/fake/test/split.apk'])): |
| 488 self.device.Install('/fake/test/app.apk', retries=0, |
| 489 split_paths=['/fake/test/split.apk']) |
| 490 |
480 def testInstall_differentPriorInstall(self): | 491 def testInstall_differentPriorInstall(self): |
481 with self.assertCalls( | 492 with self.assertCalls( |
482 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 493 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
483 'this.is.a.test.package'), | 494 'this.is.a.test.package'), |
484 (self.call.device.GetApplicationPath('this.is.a.test.package'), | 495 (self.call.device.GetApplicationPath('this.is.a.test.package'), |
485 '/fake/data/app/this.is.a.test.package.apk'), | 496 '/fake/data/app/this.is.a.test.package.apk'), |
486 (self.call.device._GetChangedFilesImpl( | 497 (self.call.device._GetChangedFilesImpl( |
487 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 498 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), |
488 [('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')]), | 499 [('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')]), |
489 self.call.adb.Uninstall('this.is.a.test.package'), | 500 self.call.adb.Uninstall('this.is.a.test.package'), |
490 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): | 501 self.call.adb.Install('/fake/test/app.apk', reinstall=False, |
| 502 split_paths=None)): |
491 self.device.Install('/fake/test/app.apk', retries=0) | 503 self.device.Install('/fake/test/app.apk', retries=0) |
492 | 504 |
493 def testInstall_differentPriorInstall_reinstall(self): | 505 def testInstall_differentPriorInstall_reinstall(self): |
494 with self.assertCalls( | 506 with self.assertCalls( |
495 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 507 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
496 'this.is.a.test.package'), | 508 'this.is.a.test.package'), |
497 (self.call.device.GetApplicationPath('this.is.a.test.package'), | 509 (self.call.device.GetApplicationPath('this.is.a.test.package'), |
498 '/fake/data/app/this.is.a.test.package.apk'), | 510 '/fake/data/app/this.is.a.test.package.apk'), |
499 (self.call.device._GetChangedFilesImpl( | 511 (self.call.device._GetChangedFilesImpl( |
500 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 512 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), |
501 [('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')]), | 513 [('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')]), |
502 self.call.adb.Install('/fake/test/app.apk', reinstall=True)): | 514 self.call.adb.Install('/fake/test/app.apk', reinstall=True, |
| 515 split_paths=None)): |
503 self.device.Install('/fake/test/app.apk', reinstall=True, retries=0) | 516 self.device.Install('/fake/test/app.apk', reinstall=True, retries=0) |
504 | 517 |
505 def testInstall_identicalPriorInstall(self): | 518 def testInstall_identicalPriorInstall(self): |
506 with self.assertCalls( | 519 with self.assertCalls( |
507 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 520 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
508 'this.is.a.test.package'), | 521 'this.is.a.test.package'), |
509 (self.call.device.GetApplicationPath('this.is.a.test.package'), | 522 (self.call.device.GetApplicationPath('this.is.a.test.package'), |
510 '/fake/data/app/this.is.a.test.package.apk'), | 523 '/fake/data/app/this.is.a.test.package.apk'), |
511 (self.call.device._GetChangedFilesImpl( | 524 (self.call.device._GetChangedFilesImpl( |
512 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 525 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), |
513 [])): | 526 [])): |
514 self.device.Install('/fake/test/app.apk', retries=0) | 527 self.device.Install('/fake/test/app.apk', retries=0) |
515 | 528 |
516 def testInstall_fails(self): | 529 def testInstall_fails(self): |
517 with self.assertCalls( | 530 with self.assertCalls( |
518 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 531 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
519 'this.is.a.test.package'), | 532 'this.is.a.test.package'), |
520 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), | 533 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), |
521 (self.call.adb.Install('/fake/test/app.apk', reinstall=False), | 534 (self.call.adb.Install('/fake/test/app.apk', reinstall=False, |
| 535 split_paths=None), |
522 self.CommandError('Failure\r\n'))): | 536 self.CommandError('Failure\r\n'))): |
523 with self.assertRaises(device_errors.CommandFailedError): | 537 with self.assertRaises(device_errors.CommandFailedError): |
524 self.device.Install('/fake/test/app.apk', retries=0) | 538 self.device.Install('/fake/test/app.apk', retries=0) |
525 | 539 |
526 | 540 |
527 class DeviceUtilsRunShellCommandTest(DeviceUtilsTest): | 541 class DeviceUtilsRunShellCommandTest(DeviceUtilsTest): |
528 | 542 |
529 def setUp(self): | 543 def setUp(self): |
530 super(DeviceUtilsRunShellCommandTest, self).setUp() | 544 super(DeviceUtilsRunShellCommandTest, self).setUp() |
531 self.device.NeedsSU = mock.Mock(return_value=False) | 545 self.device.NeedsSU = mock.Mock(return_value=False) |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 [self._createAdbWrapperMock(s) for s in test_serials])): | 1686 [self._createAdbWrapperMock(s) for s in test_serials])): |
1673 devices = device_utils.DeviceUtils.HealthyDevices() | 1687 devices = device_utils.DeviceUtils.HealthyDevices() |
1674 self.assertEquals(1, len(devices)) | 1688 self.assertEquals(1, len(devices)) |
1675 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) | 1689 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) |
1676 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) | 1690 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) |
1677 | 1691 |
1678 | 1692 |
1679 if __name__ == '__main__': | 1693 if __name__ == '__main__': |
1680 logging.getLogger().setLevel(logging.DEBUG) | 1694 logging.getLogger().setLevel(logging.DEBUG) |
1681 unittest.main(verbosity=2) | 1695 unittest.main(verbosity=2) |
1682 | |
OLD | NEW |