| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), | 522 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), |
| 523 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): | 523 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): |
| 524 self.device.Install('/fake/test/app.apk', retries=0) | 524 self.device.Install('/fake/test/app.apk', retries=0) |
| 525 | 525 |
| 526 def testInstall_differentPriorInstall(self): | 526 def testInstall_differentPriorInstall(self): |
| 527 with self.assertCalls( | 527 with self.assertCalls( |
| 528 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 528 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
| 529 'this.is.a.test.package'), | 529 'this.is.a.test.package'), |
| 530 (self.call.device.GetApplicationPath('this.is.a.test.package'), | 530 (self.call.device.GetApplicationPath('this.is.a.test.package'), |
| 531 '/fake/data/app/this.is.a.test.package.apk'), | 531 '/fake/data/app/this.is.a.test.package.apk'), |
| 532 (self.call.device._GetChangedFilesImpl( | 532 (self.call.device._GetChangedAndStaleFiles( |
| 533 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 533 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), |
| 534 [('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')]), | 534 ([('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')], |
| 535 [])), |
| 535 self.call.adb.Uninstall('this.is.a.test.package'), | 536 self.call.adb.Uninstall('this.is.a.test.package'), |
| 536 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): | 537 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): |
| 537 self.device.Install('/fake/test/app.apk', retries=0) | 538 self.device.Install('/fake/test/app.apk', retries=0) |
| 538 | 539 |
| 539 def testInstall_differentPriorInstall_reinstall(self): | 540 def testInstall_differentPriorInstall_reinstall(self): |
| 540 with self.assertCalls( | 541 with self.assertCalls( |
| 541 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 542 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
| 542 'this.is.a.test.package'), | 543 'this.is.a.test.package'), |
| 543 (self.call.device.GetApplicationPath('this.is.a.test.package'), | 544 (self.call.device.GetApplicationPath('this.is.a.test.package'), |
| 544 '/fake/data/app/this.is.a.test.package.apk'), | 545 '/fake/data/app/this.is.a.test.package.apk'), |
| 545 (self.call.device._GetChangedFilesImpl( | 546 (self.call.device._GetChangedAndStaleFiles( |
| 546 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 547 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), |
| 547 [('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')]), | 548 ([('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')], |
| 549 [])), |
| 548 self.call.adb.Install('/fake/test/app.apk', reinstall=True)): | 550 self.call.adb.Install('/fake/test/app.apk', reinstall=True)): |
| 549 self.device.Install('/fake/test/app.apk', reinstall=True, retries=0) | 551 self.device.Install('/fake/test/app.apk', reinstall=True, retries=0) |
| 550 | 552 |
| 551 def testInstall_identicalPriorInstall(self): | 553 def testInstall_identicalPriorInstall(self): |
| 552 with self.assertCalls( | 554 with self.assertCalls( |
| 553 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 555 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
| 554 'this.is.a.test.package'), | 556 'this.is.a.test.package'), |
| 555 (self.call.device.GetApplicationPath('this.is.a.test.package'), | 557 (self.call.device.GetApplicationPath('this.is.a.test.package'), |
| 556 '/fake/data/app/this.is.a.test.package.apk'), | 558 '/fake/data/app/this.is.a.test.package.apk'), |
| 557 (self.call.device._GetChangedFilesImpl( | 559 (self.call.device._GetChangedAndStaleFiles( |
| 558 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 560 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), |
| 559 [])): | 561 ([], []))): |
| 560 self.device.Install('/fake/test/app.apk', retries=0) | 562 self.device.Install('/fake/test/app.apk', retries=0) |
| 561 | 563 |
| 562 def testInstall_fails(self): | 564 def testInstall_fails(self): |
| 563 with self.assertCalls( | 565 with self.assertCalls( |
| 564 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 566 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
| 565 'this.is.a.test.package'), | 567 'this.is.a.test.package'), |
| 566 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), | 568 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), |
| 567 (self.call.adb.Install('/fake/test/app.apk', reinstall=False), | 569 (self.call.adb.Install('/fake/test/app.apk', reinstall=False), |
| 568 self.CommandError('Failure\r\n'))): | 570 self.CommandError('Failure\r\n'))): |
| 569 with self.assertRaises(device_errors.CommandFailedError): | 571 with self.assertRaises(device_errors.CommandFailedError): |
| (...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 devices = device_utils.DeviceUtils.HealthyDevices() | 1721 devices = device_utils.DeviceUtils.HealthyDevices() |
| 1720 self.assertEquals(1, len(devices)) | 1722 self.assertEquals(1, len(devices)) |
| 1721 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) | 1723 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) |
| 1722 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) | 1724 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) |
| 1723 | 1725 |
| 1724 | 1726 |
| 1725 if __name__ == '__main__': | 1727 if __name__ == '__main__': |
| 1726 logging.getLogger().setLevel(logging.DEBUG) | 1728 logging.getLogger().setLevel(logging.DEBUG) |
| 1727 unittest.main(verbosity=2) | 1729 unittest.main(verbosity=2) |
| 1728 | 1730 |
| OLD | NEW |