OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Parses options for the instrumentation tests.""" | 5 """Parses options for the instrumentation tests.""" |
6 | 6 |
7 #TODO(craigdh): pylib/utils/ should not depend on pylib/. | 7 #TODO(craigdh): pylib/utils/ should not depend on pylib/. |
8 from pylib import constants | 8 from pylib import constants |
9 | 9 |
10 import optparse | 10 import optparse |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 'directory, and <source> is relative to the ' | 187 'directory, and <source> is relative to the ' |
188 'chromium build directory.')) | 188 'chromium build directory.')) |
189 | 189 |
190 | 190 |
191 def AddInstrumentationOptions(option_parser): | 191 def AddInstrumentationOptions(option_parser): |
192 """Decorates OptionParser with instrumentation tests options.""" | 192 """Decorates OptionParser with instrumentation tests options.""" |
193 | 193 |
194 AddCommonInstrumentationOptions(option_parser) | 194 AddCommonInstrumentationOptions(option_parser) |
195 option_parser.add_option('-I', dest='install_apk', | 195 option_parser.add_option('-I', dest='install_apk', |
196 help='Install APK.', action='store_true') | 196 help='Install APK.', action='store_true') |
197 option_parser.add_option('--test-apk', dest='test_apk', | 197 option_parser.add_option( |
198 help=('The name of the apk containing the tests ' | 198 '--test-apk', dest='test_apk', |
199 '(without the .apk extension). For SDK ' | 199 help=('The name of the apk containing the tests (without the .apk ' |
200 'builds, the apk name without the debug ' | 200 'extension; e.g. "ContentShellTest"). Alternatively, this can ' |
201 'suffix(for example, ContentShellTest).')) | 201 'be a full path to the apk.')) |
202 | 202 |
203 | 203 |
204 def AddUIAutomatorOptions(option_parser): | 204 def AddUIAutomatorOptions(option_parser): |
205 """Decorates OptionParser with uiautomator tests options.""" | 205 """Decorates OptionParser with uiautomator tests options.""" |
206 | 206 |
207 AddCommonInstrumentationOptions(option_parser) | 207 AddCommonInstrumentationOptions(option_parser) |
208 option_parser.add_option( | 208 option_parser.add_option( |
209 '--package-name', | 209 '--package-name', |
210 help=('The package name used by the apk containing the application.')) | 210 help=('The package name used by the apk containing the application.')) |
211 option_parser.add_option( | 211 option_parser.add_option( |
212 '--uiautomator-jar', | 212 '--test-jar', dest='test_jar', |
213 help=('Path to the uiautomator jar to be installed on the device.')) | 213 help=('The name of the dexed jar containing the tests (without the ' |
214 option_parser.add_option( | 214 '.dex.jar extension). Alternatively, this can be a full path to ' |
215 '--uiautomator-info-jar', | 215 'the jar.')) |
216 help=('Path to the uiautomator jar for use by proguard.')) | |
217 | 216 |
218 | 217 |
219 def ValidateCommonInstrumentationOptions(option_parser, options, args): | 218 def ValidateCommonInstrumentationOptions(option_parser, options, args): |
220 """Validate common options/arguments and populate options with defaults.""" | 219 """Validate common options/arguments and populate options with defaults.""" |
221 if len(args) > 1: | 220 if len(args) > 1: |
222 option_parser.print_help(sys.stderr) | 221 option_parser.print_help(sys.stderr) |
223 option_parser.error('Unknown arguments: %s' % args[1:]) | 222 option_parser.error('Unknown arguments: %s' % args[1:]) |
224 | 223 |
225 if options.java_only and options.python_only: | 224 if options.java_only and options.python_only: |
226 option_parser.error('Options java_only (-j) and python_only (-p) ' | 225 option_parser.error('Options java_only (-j) and python_only (-p) ' |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 '%s.jar' % options.test_apk) | 261 '%s.jar' % options.test_apk) |
263 | 262 |
264 | 263 |
265 def ValidateUIAutomatorOptions(option_parser, options, args): | 264 def ValidateUIAutomatorOptions(option_parser, options, args): |
266 """Validate uiautomator options/arguments.""" | 265 """Validate uiautomator options/arguments.""" |
267 ValidateCommonInstrumentationOptions(option_parser, options, args) | 266 ValidateCommonInstrumentationOptions(option_parser, options, args) |
268 | 267 |
269 if not options.package_name: | 268 if not options.package_name: |
270 option_parser.error('--package-name must be specified.') | 269 option_parser.error('--package-name must be specified.') |
271 | 270 |
272 if not options.uiautomator_jar: | 271 if not options.test_jar: |
273 option_parser.error('--uiautomator-jar must be specified.') | 272 option_parser.error('--test-jar must be specified.') |
274 | 273 |
275 if not options.uiautomator_info_jar: | 274 if os.path.exists(options.test_jar): |
276 option_parser.error('--uiautomator-info-jar must be specified.') | 275 # The dexed JAR is fully qualified, assume the info JAR lives along side. |
| 276 options.uiautomator_jar = options.test_jar |
| 277 else: |
| 278 options.uiautomator_jar = os.path.join( |
| 279 _SDK_OUT_DIR, options.build_type, constants.SDK_BUILD_JAVALIB_DIR, |
| 280 '%s.dex.jar' % options.test_jar) |
| 281 options.uiautomator_info_jar = ( |
| 282 options.uiautomator_jar[:options.uiautomator_jar.find('.dex.jar')] + |
| 283 '_java.jar') |
277 | 284 |
OLD | NEW |