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

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

Issue 26422003: [Android] Launch chrome using an intent before running uiautomator tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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 all types of tests from one unified interface.""" 7 """Runs all types of tests from one unified interface."""
8 8
9 import collections 9 import collections
10 import logging 10 import logging
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 options.test_apk_jar_path) 291 options.test_apk_jar_path)
292 292
293 293
294 def AddUIAutomatorTestOptions(option_parser): 294 def AddUIAutomatorTestOptions(option_parser):
295 """Adds UI Automator test options to |option_parser|.""" 295 """Adds UI Automator test options to |option_parser|."""
296 296
297 option_parser.usage = '%prog uiautomator [options]' 297 option_parser.usage = '%prog uiautomator [options]'
298 option_parser.commands_dict = {} 298 option_parser.commands_dict = {}
299 option_parser.example = ( 299 option_parser.example = (
300 '%prog uiautomator --test-jar=chromium_testshell_uiautomator_tests' 300 '%prog uiautomator --test-jar=chromium_testshell_uiautomator_tests'
301 ' --package-name=org.chromium.chrome.testshell') 301 ' --package=chromium_test_shell')
302 option_parser.add_option( 302 option_parser.add_option(
303 '--package-name', 303 '--package',
304 help='The package name used by the apk containing the application.') 304 help=('Package under test. Possible values: %s' %
305 constants.PACKAGE_INFO.keys()))
305 option_parser.add_option( 306 option_parser.add_option(
306 '--test-jar', dest='test_jar', 307 '--test-jar', dest='test_jar',
307 help=('The name of the dexed jar containing the tests (without the ' 308 help=('The name of the dexed jar containing the tests (without the '
308 '.dex.jar extension). Alternatively, this can be a full path ' 309 '.dex.jar extension). Alternatively, this can be a full path '
309 'to the jar.')) 310 'to the jar.'))
310 311
311 AddJavaTestOptions(option_parser) 312 AddJavaTestOptions(option_parser)
312 AddCommonOptions(option_parser) 313 AddCommonOptions(option_parser)
313 314
314 315
315 def ProcessUIAutomatorOptions(options, error_func): 316 def ProcessUIAutomatorOptions(options, error_func):
316 """Processes UIAutomator options/arguments. 317 """Processes UIAutomator options/arguments.
317 318
318 Args: 319 Args:
319 options: optparse.Options object. 320 options: optparse.Options object.
320 error_func: Function to call with the error message in case of an error. 321 error_func: Function to call with the error message in case of an error.
321 322
322 Returns: 323 Returns:
323 A UIAutomatorOptions named tuple which contains all options relevant to 324 A UIAutomatorOptions named tuple which contains all options relevant to
324 uiautomator tests. 325 uiautomator tests.
325 """ 326 """
326 327
327 ProcessJavaTestOptions(options, error_func) 328 ProcessJavaTestOptions(options, error_func)
328 329
329 if not options.package_name: 330 if not options.package:
330 error_func('--package-name must be specified.') 331 error_func('--package is required.')
332
333 if options.package not in constants.PACKAGE_INFO:
334 error_func('Invalid package.')
331 335
332 if not options.test_jar: 336 if not options.test_jar:
333 error_func('--test-jar must be specified.') 337 error_func('--test-jar must be specified.')
334 338
335 if os.path.exists(options.test_jar): 339 if os.path.exists(options.test_jar):
336 # The dexed JAR is fully qualified, assume the info JAR lives along side. 340 # The dexed JAR is fully qualified, assume the info JAR lives along side.
337 options.uiautomator_jar = options.test_jar 341 options.uiautomator_jar = options.test_jar
338 else: 342 else:
339 options.uiautomator_jar = os.path.join( 343 options.uiautomator_jar = os.path.join(
340 constants.GetOutDirectory(), 344 constants.GetOutDirectory(),
341 constants.SDK_BUILD_JAVALIB_DIR, 345 constants.SDK_BUILD_JAVALIB_DIR,
342 '%s.dex.jar' % options.test_jar) 346 '%s.dex.jar' % options.test_jar)
343 options.uiautomator_info_jar = ( 347 options.uiautomator_info_jar = (
344 options.uiautomator_jar[:options.uiautomator_jar.find('.dex.jar')] + 348 options.uiautomator_jar[:options.uiautomator_jar.find('.dex.jar')] +
345 '_java.jar') 349 '_java.jar')
346 350
347 return uiautomator_test_options.UIAutomatorOptions( 351 return uiautomator_test_options.UIAutomatorOptions(
348 options.tool, 352 options.tool,
349 options.cleanup_test_files, 353 options.cleanup_test_files,
350 options.push_deps, 354 options.push_deps,
351 options.annotations, 355 options.annotations,
352 options.exclude_annotations, 356 options.exclude_annotations,
353 options.test_filter, 357 options.test_filter,
354 options.test_data, 358 options.test_data,
355 options.save_perf_json, 359 options.save_perf_json,
356 options.screenshot_failures, 360 options.screenshot_failures,
357 options.uiautomator_jar, 361 options.uiautomator_jar,
358 options.uiautomator_info_jar, 362 options.uiautomator_info_jar,
359 options.package_name) 363 options.package)
360 364
361 365
362 def AddMonkeyTestOptions(option_parser): 366 def AddMonkeyTestOptions(option_parser):
363 """Adds monkey test options to |option_parser|.""" 367 """Adds monkey test options to |option_parser|."""
364 368
365 option_parser.usage = '%prog monkey [options]' 369 option_parser.usage = '%prog monkey [options]'
366 option_parser.commands_dict = {} 370 option_parser.commands_dict = {}
367 option_parser.example = ( 371 option_parser.example = (
368 '%prog monkey --package-name=org.chromium.content_shell_apk' 372 '%prog monkey --package=chromium_test_shell')
369 ' --activity-name=.ContentShellActivity')
370 373
371 option_parser.add_option('--package-name', help='Allowed package.')
372 option_parser.add_option( 374 option_parser.add_option(
373 '--activity-name', help='Name of the activity to start.') 375 '--package',
376 help=('Package under test. Possible values: %s' %
377 constants.PACKAGE_INFO.keys()))
374 option_parser.add_option( 378 option_parser.add_option(
375 '--event-count', default=10000, type='int', 379 '--event-count', default=10000, type='int',
376 help='Number of events to generate [default: %default].') 380 help='Number of events to generate [default: %default].')
377 option_parser.add_option( 381 option_parser.add_option(
378 '--category', default='', 382 '--category', default='',
379 help='A list of allowed categories.') 383 help='A list of allowed categories.')
380 option_parser.add_option( 384 option_parser.add_option(
381 '--throttle', default=100, type='int', 385 '--throttle', default=100, type='int',
382 help='Delay between events (ms) [default: %default]. ') 386 help='Delay between events (ms) [default: %default]. ')
383 option_parser.add_option( 387 option_parser.add_option(
(...skipping 12 matching lines...) Expand all
396 """Processes all monkey test options. 400 """Processes all monkey test options.
397 401
398 Args: 402 Args:
399 options: optparse.Options object. 403 options: optparse.Options object.
400 error_func: Function to call with the error message in case of an error. 404 error_func: Function to call with the error message in case of an error.
401 405
402 Returns: 406 Returns:
403 A MonkeyOptions named tuple which contains all options relevant to 407 A MonkeyOptions named tuple which contains all options relevant to
404 monkey tests. 408 monkey tests.
405 """ 409 """
406 if not options.package_name: 410 if not options.package:
407 error_func('Package name is required.') 411 error_func('--package is required.')
412
413 if options.package not in constants.PACKAGE_INFO:
414 error_func('Invalid package.')
408 415
409 category = options.category 416 category = options.category
410 if category: 417 if category:
411 category = options.category.split(',') 418 category = options.category.split(',')
412 419
413 return monkey_test_options.MonkeyOptions( 420 return monkey_test_options.MonkeyOptions(
414 options.verbose_count, 421 options.verbose_count,
415 options.package_name, 422 options.package,
416 options.activity_name,
417 options.event_count, 423 options.event_count,
418 category, 424 category,
419 options.throttle, 425 options.throttle,
420 options.seed, 426 options.seed,
421 options.extra_args) 427 options.extra_args)
422 428
423 429
424 def AddPerfTestOptions(option_parser): 430 def AddPerfTestOptions(option_parser):
425 """Adds perf test options to |option_parser|.""" 431 """Adds perf test options to |option_parser|."""
426 432
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 765
760 766
761 def main(argv): 767 def main(argv):
762 option_parser = command_option_parser.CommandOptionParser( 768 option_parser = command_option_parser.CommandOptionParser(
763 commands_dict=VALID_COMMANDS) 769 commands_dict=VALID_COMMANDS)
764 return command_option_parser.ParseAndExecute(option_parser) 770 return command_option_parser.ParseAndExecute(option_parser)
765 771
766 772
767 if __name__ == '__main__': 773 if __name__ == '__main__':
768 sys.exit(main(sys.argv)) 774 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698