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

Side by Side Diff: build/android/update_verification.py

Issue 1050883002: [Android] Reland cleanup of old_interface in build/android/pylib. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 5 years, 8 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
« no previous file with comments | « build/android/test_runner.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import logging 8 import logging
9 import optparse 9 import optparse
10 import os 10 import os
11 import shutil 11 import shutil
12 import sys 12 import sys
13 import time 13 import time
14 14
15 from pylib import android_commands 15 from pylib import android_commands
16 from pylib.device import device_utils 16 from pylib.device import device_utils
17 17
18 def _SaveAppData(device, package_name, from_apk=None, data_dir=None): 18 def _SaveAppData(device, package_name, from_apk=None, data_dir=None):
19 def _BackupAppData(data_dir=None): 19 def _BackupAppData(data_dir=None):
20 device.old_interface.Adb().SendCommand('backup %s' % package_name) 20 device.adb.Backup(package_name)
21 backup_file = os.path.join(os.getcwd(), 'backup.ab') 21 backup_file = os.path.join(os.getcwd(), 'backup.ab')
22 assert os.path.exists(backup_file), 'Backup failed.' 22 assert os.path.exists(backup_file), 'Backup failed.'
23 if data_dir: 23 if data_dir:
24 if not os.path.isdir(data_dir): 24 if not os.path.isdir(data_dir):
25 os.makedirs(data_dir) 25 os.makedirs(data_dir)
26 shutil.move(backup_file, data_dir) 26 shutil.move(backup_file, data_dir)
27 backup_file = os.path.join(data_dir, 'backup.ab') 27 backup_file = os.path.join(data_dir, 'backup.ab')
28 print 'Application data saved to %s' % backup_file 28 print 'Application data saved to %s' % backup_file
29 29
30 if from_apk: 30 if from_apk:
31 logging.info('Installing %s...', from_apk) 31 logging.info('Installing %s...', from_apk)
32 # TODO(jbudorick) Switch to AdbWrapper.Install on the impl switch. 32 output = device.Install(from_apk, reinstall=True)
33 output = device.old_interface.Install(from_apk, reinstall=True)
34 if 'Success' not in output: 33 if 'Success' not in output:
35 raise Exception('Unable to install %s. output: %s' % (from_apk, output)) 34 raise Exception('Unable to install %s. output: %s' % (from_apk, output))
36 35
37 raw_input('Set the application state. Once ready, press enter and ' 36 raw_input('Set the application state. Once ready, press enter and '
38 'select "Backup my data" on the device.') 37 'select "Backup my data" on the device.')
39 _BackupAppData(data_dir) 38 _BackupAppData(data_dir)
40 39
41 40
42 def _VerifyAppUpdate(device, to_apk, app_data, from_apk=None): 41 def _VerifyAppUpdate(device, to_apk, app_data, from_apk=None):
43 def _RestoreAppData(): 42 def _RestoreAppData():
44 assert os.path.exists(app_data), 'Backup file does not exist!' 43 assert os.path.exists(app_data), 'Backup file does not exist!'
45 device.old_interface.Adb().SendCommand('restore %s' % app_data) 44 device.adb.Restore(app_data)
46 # It seems restore command is not synchronous. 45 # It seems restore command is not synchronous.
47 time.sleep(15) 46 time.sleep(15)
48 47
49 if from_apk: 48 if from_apk:
50 logging.info('Installing %s...', from_apk) 49 logging.info('Installing %s...', from_apk)
51 # TODO(jbudorick) Switch to AdbWrapper.Install on the impl switch. 50 output = device.Install(from_apk, reinstall=True)
52 output = device.old_interface.Install(from_apk, reinstall=True)
53 if 'Success' not in output: 51 if 'Success' not in output:
54 raise Exception('Unable to install %s. output: %s' % (from_apk, output)) 52 raise Exception('Unable to install %s. output: %s' % (from_apk, output))
55 53
56 logging.info('Restoring the application data...') 54 logging.info('Restoring the application data...')
57 raw_input('Press enter and select "Restore my data" on the device.') 55 raw_input('Press enter and select "Restore my data" on the device.')
58 _RestoreAppData() 56 _RestoreAppData()
59 57
60 logging.info('Verifying that %s cannot be installed side-by-side...', 58 logging.info('Verifying that %s cannot be installed side-by-side...',
61 to_apk) 59 to_apk)
62 # TODO(jbudorick) Switch to AdbWrapper.Install on the impl switch. 60 output = device.Install(to_apk)
63 output = device.old_interface.Install(to_apk)
64 if 'INSTALL_FAILED_ALREADY_EXISTS' not in output: 61 if 'INSTALL_FAILED_ALREADY_EXISTS' not in output:
65 if 'Success' in output: 62 if 'Success' in output:
66 raise Exception('Package name has changed! output: %s' % output) 63 raise Exception('Package name has changed! output: %s' % output)
67 else: 64 else:
68 raise Exception(output) 65 raise Exception(output)
69 66
70 logging.info('Verifying that %s can be overinstalled...', to_apk) 67 logging.info('Verifying that %s can be overinstalled...', to_apk)
71 # TODO(jbudorick) Switch to AdbWrapper.Install on the impl switch. 68 output = device.adb.Install(to_apk, reinstall=True)
72 output = device.old_interface.Install(to_apk, reinstall=True)
73 if 'Success' not in output: 69 if 'Success' not in output:
74 raise Exception('Unable to install %s.\n output: %s' % (to_apk, output)) 70 raise Exception('Unable to install %s.\n output: %s' % (to_apk, output))
75 logging.info('Successfully updated to the new apk. Please verify that the ' 71 logging.info('Successfully updated to the new apk. Please verify that the '
76 'the application data is preserved.') 72 'the application data is preserved.')
77 73
78 74
79 def main(): 75 def main():
80 logger = logging.getLogger() 76 logger = logging.getLogger()
81 logger.setLevel(logging.DEBUG) 77 logger.setLevel(logging.DEBUG)
82 desc = ( 78 desc = (
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 parser.print_help(sys.stderr) 127 parser.print_help(sys.stderr)
132 parser.error('Missing --to-apk or --app-data.') 128 parser.error('Missing --to-apk or --app-data.')
133 assert os.path.isfile(options.to_apk) 129 assert os.path.isfile(options.to_apk)
134 assert os.path.isfile(options.app_data) 130 assert os.path.isfile(options.app_data)
135 _VerifyAppUpdate(device, options.to_apk, options.app_data, 131 _VerifyAppUpdate(device, options.to_apk, options.app_data,
136 from_apk=options.from_apk) 132 from_apk=options.from_apk)
137 133
138 134
139 if __name__ == '__main__': 135 if __name__ == '__main__':
140 main() 136 main()
OLDNEW
« no previous file with comments | « build/android/test_runner.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698