| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Runs semi-automated update testing on a non-rooted device. | 7 """Runs semi-automated update testing on a non-rooted device. |
| 8 | 8 |
| 9 This script will help verify that app data is preserved during an update. | 9 This script will help verify that app data is preserved during an update. |
| 10 To use this script first run it with the create_app_data option. | 10 To use this script first run it with the create_app_data option. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 'select "Backup my data" on the device.') | 42 'select "Backup my data" on the device.') |
| 43 device.adb.Backup(app_data, packages=[package_name]) | 43 device.adb.Backup(app_data, packages=[package_name]) |
| 44 logging.critical('Application data saved to %s' % app_data) | 44 logging.critical('Application data saved to %s' % app_data) |
| 45 | 45 |
| 46 def TestUpdate(device, old_apk, new_apk, app_data, package_name): | 46 def TestUpdate(device, old_apk, new_apk, app_data, package_name): |
| 47 device.Install(old_apk) | 47 device.Install(old_apk) |
| 48 device.adb.Restore(app_data) | 48 device.adb.Restore(app_data) |
| 49 # Restore command is not synchronous | 49 # Restore command is not synchronous |
| 50 raw_input('Select "Restore my data" on the device. Then press enter to ' | 50 raw_input('Select "Restore my data" on the device. Then press enter to ' |
| 51 'continue.') | 51 'continue.') |
| 52 device_path = device.GetApplicationPath(package_name) | 52 device_path = device.GetApplicationPaths(package_name) |
| 53 if not device_path: | 53 if not device_path: |
| 54 raise Exception('Expected package %s to already be installed. ' | 54 raise Exception('Expected package %s to already be installed. ' |
| 55 'Package name might have changed!' % package_name) | 55 'Package name might have changed!' % package_name) |
| 56 | 56 |
| 57 logging.info('Verifying that %s can be overinstalled.', new_apk) | 57 logging.info('Verifying that %s can be overinstalled.', new_apk) |
| 58 device.adb.Install(new_apk, reinstall=True) | 58 device.adb.Install(new_apk, reinstall=True) |
| 59 logging.critical('Successfully updated to the new apk. Please verify that ' | 59 logging.critical('Successfully updated to the new apk. Please verify that ' |
| 60 'the application data is preserved.') | 60 'the application data is preserved.') |
| 61 | 61 |
| 62 def main(): | 62 def main(): |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 if args.command == 'create_app_data': | 99 if args.command == 'create_app_data': |
| 100 CreateAppData(device, args.old_apk, args.app_data, package_name) | 100 CreateAppData(device, args.old_apk, args.app_data, package_name) |
| 101 elif args.command == 'test_update': | 101 elif args.command == 'test_update': |
| 102 TestUpdate( | 102 TestUpdate( |
| 103 device, args.old_apk, args.new_apk, args.app_data, package_name) | 103 device, args.old_apk, args.new_apk, args.app_data, package_name) |
| 104 else: | 104 else: |
| 105 raise Exception('Unknown test command: %s' % args.command) | 105 raise Exception('Unknown test command: %s' % args.command) |
| 106 | 106 |
| 107 if __name__ == '__main__': | 107 if __name__ == '__main__': |
| 108 sys.exit(main()) | 108 sys.exit(main()) |
| OLD | NEW |