Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Side by Side Diff: build/android/pylib/device/device_utils_test.py

Issue 1167693002: remove stale test data on the device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 ([],[]))):
perezju 2015/06/11 08:38:47 nit: space after the comma
Menglin 2015/06/11 20:36:16 Done.
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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 self.device._PushChangedFilesZipped(test_files) 1168 self.device._PushChangedFilesZipped(test_files)
1167 1169
1168 def testPushChangedFilesZipped_single(self): 1170 def testPushChangedFilesZipped_single(self):
1169 self._testPushChangedFilesZipped_spec( 1171 self._testPushChangedFilesZipped_spec(
1170 [('/test/host/path/file1', '/test/device/path/file1')]) 1172 [('/test/host/path/file1', '/test/device/path/file1')])
1171 1173
1172 def testPushChangedFilesZipped_multiple(self): 1174 def testPushChangedFilesZipped_multiple(self):
1173 self._testPushChangedFilesZipped_spec( 1175 self._testPushChangedFilesZipped_spec(
1174 [('/test/host/path/file1', '/test/device/path/file1'), 1176 [('/test/host/path/file1', '/test/device/path/file1'),
1175 ('/test/host/path/file2', '/test/device/path/file2')]) 1177 ('/test/host/path/file2', '/test/device/path/file2')])
1176 1178
perezju 2015/06/11 08:38:48 nit: two blank lines between classes
Menglin 2015/06/11 20:36:17 Done.
1177
1178 class DeviceUtilsFileExistsTest(DeviceUtilsTest): 1179 class DeviceUtilsFileExistsTest(DeviceUtilsTest):
1179 1180
1180 def testFileExists_usingTest_fileExists(self): 1181 def testFileExists_usingTest_fileExists(self):
1181 with self.assertCall( 1182 with self.assertCall(
1182 self.call.device.RunShellCommand( 1183 self.call.device.RunShellCommand(
1183 ['test', '-e', '/path/file.exists'], check_return=True), ''): 1184 ['test', '-e', '/path/file.exists'], check_return=True), ''):
1184 self.assertTrue(self.device.FileExists('/path/file.exists')) 1185 self.assertTrue(self.device.FileExists('/path/file.exists'))
1185 1186
1186 def testFileExists_usingTest_fileDoesntExist(self): 1187 def testFileExists_usingTest_fileDoesntExist(self):
1187 with self.assertCall( 1188 with self.assertCall(
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 devices = device_utils.DeviceUtils.HealthyDevices() 1720 devices = device_utils.DeviceUtils.HealthyDevices()
1720 self.assertEquals(1, len(devices)) 1721 self.assertEquals(1, len(devices))
1721 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) 1722 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils))
1722 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) 1723 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial())
1723 1724
1724 1725
1725 if __name__ == '__main__': 1726 if __name__ == '__main__':
1726 logging.getLogger().setLevel(logging.DEBUG) 1727 logging.getLogger().setLevel(logging.DEBUG)
1727 unittest.main(verbosity=2) 1728 unittest.main(verbosity=2)
1728 1729
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698