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. |
11 | 11 |
12 ./update_verification.py create_app_data --old-apk <path> --app-data <path> | 12 ./update_verification.py create_app_data --old-apk <path> --app-data <path> |
13 | 13 |
14 The script will then install the old apk, prompt you to create some app data | 14 The script will then install the old apk, prompt you to create some app data |
15 (bookmarks, etc.), and then save the app data in the path you gave it. | 15 (bookmarks, etc.), and then save the app data in the path you gave it. |
16 | 16 |
17 Next, once you have some app data saved, run this script with the test_update | 17 Next, once you have some app data saved, run this script with the test_update |
18 option. | 18 option. |
19 | 19 |
20 ./update_verification.py test_update --old-apk <path> --new-apk <path> | 20 ./update_verification.py test_update --old-apk <path> --new-apk <path> |
21 --app-data <path> | 21 --app-data <path> |
22 | 22 |
23 This will install the old apk, load the saved app data, install the new apk, | 23 This will install the old apk, load the saved app data, install the new apk, |
24 and ask the user to verify that all of the app data was preserved. | 24 and ask the user to verify that all of the app data was preserved. |
25 """ | 25 """ |
26 | 26 |
27 import argparse | 27 import argparse |
28 import logging | 28 import logging |
29 import os | |
30 import sys | 29 import sys |
31 import time | |
32 | 30 |
33 from pylib import constants | |
34 from devil.android import apk_helper | 31 from devil.android import apk_helper |
35 from devil.android import device_blacklist | 32 from devil.android import device_blacklist |
36 from devil.android import device_errors | 33 from devil.android import device_errors |
37 from devil.android import device_utils | 34 from devil.android import device_utils |
38 from devil.utils import run_tests_helper | 35 from devil.utils import run_tests_helper |
39 | 36 |
40 def CreateAppData(device, old_apk, app_data, package_name): | 37 def CreateAppData(device, old_apk, app_data, package_name): |
41 device.Install(old_apk) | 38 device.Install(old_apk) |
42 raw_input('Set the application state. Once ready, press enter and ' | 39 raw_input('Set the application state. Once ready, press enter and ' |
43 'select "Backup my data" on the device.') | 40 'select "Backup my data" on the device.') |
44 device.adb.Backup(app_data, packages=[package_name]) | 41 device.adb.Backup(app_data, packages=[package_name]) |
45 logging.critical('Application data saved to %s' % app_data) | 42 logging.critical('Application data saved to %s', app_data) |
46 | 43 |
47 def TestUpdate(device, old_apk, new_apk, app_data, package_name): | 44 def TestUpdate(device, old_apk, new_apk, app_data, package_name): |
48 device.Install(old_apk) | 45 device.Install(old_apk) |
49 device.adb.Restore(app_data) | 46 device.adb.Restore(app_data) |
50 # Restore command is not synchronous | 47 # Restore command is not synchronous |
51 raw_input('Select "Restore my data" on the device. Then press enter to ' | 48 raw_input('Select "Restore my data" on the device. Then press enter to ' |
52 'continue.') | 49 'continue.') |
53 device_path = device.GetApplicationPaths(package_name) | 50 device_path = device.GetApplicationPaths(package_name) |
54 if not device_path: | 51 if not device_path: |
55 raise Exception('Expected package %s to already be installed. ' | 52 raise Exception('Expected package %s to already be installed. ' |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 89 |
93 if args.blacklist_file: | 90 if args.blacklist_file: |
94 blacklist = device_blacklist.Blacklist(args.blacklist_file) | 91 blacklist = device_blacklist.Blacklist(args.blacklist_file) |
95 else: | 92 else: |
96 blacklist = None | 93 blacklist = None |
97 | 94 |
98 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) | 95 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) |
99 if not devices: | 96 if not devices: |
100 raise device_errors.NoDevicesError() | 97 raise device_errors.NoDevicesError() |
101 device = devices[0] | 98 device = devices[0] |
102 logging.info('Using device %s for testing.' % str(device)) | 99 logging.info('Using device %s for testing.', str(device)) |
103 | 100 |
104 package_name = (args.package_name if args.package_name | 101 package_name = (args.package_name if args.package_name |
105 else apk_helper.GetPackageName(args.old_apk)) | 102 else apk_helper.GetPackageName(args.old_apk)) |
106 if args.command == 'create_app_data': | 103 if args.command == 'create_app_data': |
107 CreateAppData(device, args.old_apk, args.app_data, package_name) | 104 CreateAppData(device, args.old_apk, args.app_data, package_name) |
108 elif args.command == 'test_update': | 105 elif args.command == 'test_update': |
109 TestUpdate( | 106 TestUpdate( |
110 device, args.old_apk, args.new_apk, args.app_data, package_name) | 107 device, args.old_apk, args.new_apk, args.app_data, package_name) |
111 else: | 108 else: |
112 raise Exception('Unknown test command: %s' % args.command) | 109 raise Exception('Unknown test command: %s' % args.command) |
113 | 110 |
114 if __name__ == '__main__': | 111 if __name__ == '__main__': |
115 sys.exit(main()) | 112 sys.exit(main()) |
OLD | NEW |