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

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: remove stale data from device 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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), 503 (self.call.device.GetApplicationPath('this.is.a.test.package'), None),
504 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): 504 self.call.adb.Install('/fake/test/app.apk', reinstall=False)):
505 self.device.Install('/fake/test/app.apk', retries=0) 505 self.device.Install('/fake/test/app.apk', retries=0)
506 506
507 def testInstall_differentPriorInstall(self): 507 def testInstall_differentPriorInstall(self):
508 with self.assertCalls( 508 with self.assertCalls(
509 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), 509 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'),
510 'this.is.a.test.package'), 510 'this.is.a.test.package'),
511 (self.call.device.GetApplicationPath('this.is.a.test.package'), 511 (self.call.device.GetApplicationPath('this.is.a.test.package'),
512 '/fake/data/app/this.is.a.test.package.apk'), 512 '/fake/data/app/this.is.a.test.package.apk'),
513 (self.call.device._GetChangedFilesImpl( 513 (self.call.device._GetChangedAndStaleFiles(
514 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), 514 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'),
515 [('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')]), 515 ([('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')],
516 [])),
516 self.call.adb.Uninstall('this.is.a.test.package'), 517 self.call.adb.Uninstall('this.is.a.test.package'),
517 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): 518 self.call.adb.Install('/fake/test/app.apk', reinstall=False)):
518 self.device.Install('/fake/test/app.apk', retries=0) 519 self.device.Install('/fake/test/app.apk', retries=0)
519 520
520 def testInstall_differentPriorInstall_reinstall(self): 521 def testInstall_differentPriorInstall_reinstall(self):
521 with self.assertCalls( 522 with self.assertCalls(
522 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), 523 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'),
523 'this.is.a.test.package'), 524 'this.is.a.test.package'),
524 (self.call.device.GetApplicationPath('this.is.a.test.package'), 525 (self.call.device.GetApplicationPath('this.is.a.test.package'),
525 '/fake/data/app/this.is.a.test.package.apk'), 526 '/fake/data/app/this.is.a.test.package.apk'),
526 (self.call.device._GetChangedFilesImpl( 527 (self.call.device._GetChangedAndStaleFiles(
527 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), 528 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'),
528 [('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')]), 529 ([('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')],
530 [])),
529 self.call.adb.Install('/fake/test/app.apk', reinstall=True)): 531 self.call.adb.Install('/fake/test/app.apk', reinstall=True)):
530 self.device.Install('/fake/test/app.apk', reinstall=True, retries=0) 532 self.device.Install('/fake/test/app.apk', reinstall=True, retries=0)
531 533
532 def testInstall_identicalPriorInstall(self): 534 def testInstall_identicalPriorInstall(self):
533 with self.assertCalls( 535 with self.assertCalls(
534 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), 536 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'),
535 'this.is.a.test.package'), 537 'this.is.a.test.package'),
536 (self.call.device.GetApplicationPath('this.is.a.test.package'), 538 (self.call.device.GetApplicationPath('this.is.a.test.package'),
537 '/fake/data/app/this.is.a.test.package.apk'), 539 '/fake/data/app/this.is.a.test.package.apk'),
538 (self.call.device._GetChangedFilesImpl( 540 (self.call.device._GetChangedAndStaleFiles(
539 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), 541 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'),
540 [])): 542 ([],[]))):
541 self.device.Install('/fake/test/app.apk', retries=0) 543 self.device.Install('/fake/test/app.apk', retries=0)
542 544
543 def testInstall_fails(self): 545 def testInstall_fails(self):
544 with self.assertCalls( 546 with self.assertCalls(
545 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), 547 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'),
546 'this.is.a.test.package'), 548 'this.is.a.test.package'),
547 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), 549 (self.call.device.GetApplicationPath('this.is.a.test.package'), None),
548 (self.call.adb.Install('/fake/test/app.apk', reinstall=False), 550 (self.call.adb.Install('/fake/test/app.apk', reinstall=False),
549 self.CommandError('Failure\r\n'))): 551 self.CommandError('Failure\r\n'))):
550 with self.assertRaises(device_errors.CommandFailedError): 552 with self.assertRaises(device_errors.CommandFailedError):
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 1150
1149 def testPushChangedFilesZipped_single(self): 1151 def testPushChangedFilesZipped_single(self):
1150 self._testPushChangedFilesZipped_spec( 1152 self._testPushChangedFilesZipped_spec(
1151 [('/test/host/path/file1', '/test/device/path/file1')]) 1153 [('/test/host/path/file1', '/test/device/path/file1')])
1152 1154
1153 def testPushChangedFilesZipped_multiple(self): 1155 def testPushChangedFilesZipped_multiple(self):
1154 self._testPushChangedFilesZipped_spec( 1156 self._testPushChangedFilesZipped_spec(
1155 [('/test/host/path/file1', '/test/device/path/file1'), 1157 [('/test/host/path/file1', '/test/device/path/file1'),
1156 ('/test/host/path/file2', '/test/device/path/file2')]) 1158 ('/test/host/path/file2', '/test/device/path/file2')])
1157 1159
1160 class DeviceUtilsDeleteStaleFilesTest(DeviceUtilsTest):
1161
1162 def testDeleteStaleFiles_emtpy(self):
1163 files = []
1164 with self.assertCalls():
1165 self.device._DeleteStaleFiles(files)
1166
1167 def testDeleteStaleFiles_single(self):
1168 files = ['/test/device/path/file1']
1169 with self.assertCalls((self.call.adb.Shell(
1170 'rm /test/device/path/file1'), '')):
1171 self.device._DeleteStaleFiles(files)
1172
1173 def testDeleteStaleFiles_multiple(self):
1174 files = ['/test/device/path/file1', '/test/device/path/file2']
1175 with self.assertCalls(
1176 (self.call.adb.Shell('rm /test/device/path/file1'), ''),
1177 (self.call.adb.Shell('rm /test/device/path/file2'), '')):
1178 self.device._DeleteStaleFiles(files)
1158 1179
1159 class DeviceUtilsFileExistsTest(DeviceUtilsTest): 1180 class DeviceUtilsFileExistsTest(DeviceUtilsTest):
1160 1181
1161 def testFileExists_usingTest_fileExists(self): 1182 def testFileExists_usingTest_fileExists(self):
1162 with self.assertCall( 1183 with self.assertCall(
1163 self.call.device.RunShellCommand( 1184 self.call.device.RunShellCommand(
1164 ['test', '-e', '/path/file.exists'], check_return=True), ''): 1185 ['test', '-e', '/path/file.exists'], check_return=True), ''):
1165 self.assertTrue(self.device.FileExists('/path/file.exists')) 1186 self.assertTrue(self.device.FileExists('/path/file.exists'))
1166 1187
1167 def testFileExists_usingTest_fileDoesntExist(self): 1188 def testFileExists_usingTest_fileDoesntExist(self):
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 devices = device_utils.DeviceUtils.HealthyDevices() 1721 devices = device_utils.DeviceUtils.HealthyDevices()
1701 self.assertEquals(1, len(devices)) 1722 self.assertEquals(1, len(devices))
1702 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) 1723 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils))
1703 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) 1724 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial())
1704 1725
1705 1726
1706 if __name__ == '__main__': 1727 if __name__ == '__main__':
1707 logging.getLogger().setLevel(logging.DEBUG) 1728 logging.getLogger().setLevel(logging.DEBUG)
1708 unittest.main(verbosity=2) 1729 unittest.main(verbosity=2)
1709 1730
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698