[Android] Set flags for uiautomator based on annotations not test name.

Also, pick up the test jar using the name instead of full path.

BUG=
NOTRY=True

Review URL: https://chromiumcodereview.appspot.com/13496004

git-svn-id: http://src.chromium.org/svn/trunk/src/build@192085 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
frankf@chromium.org 2013-04-03 17:33:57 +00:00
Родитель abfac8ed9a
Коммит df0351d77f
5 изменённых файлов: 45 добавлений и 25 удалений

Просмотреть файл

@ -63,6 +63,7 @@ TEST_SERVER_PORT_LOCKFILE = '/tmp/test_server_port.lock'
TEST_EXECUTABLE_DIR = '/data/local/tmp'
# Directories for common java libraries for SDK build.
# These constants are defined in build/android/ant/common.xml
SDK_BUILD_JAVALIB_DIR = 'lib.java'
SDK_BUILD_TEST_JAVALIB_DIR = 'test.lib.java'
SDK_BUILD_APKS_DIR = 'apks'

Просмотреть файл

@ -373,6 +373,24 @@ class TestRunner(base_test_runner.BaseTestRunner):
return 3 * 60
return 1 * 60
def _RunUIAutomatorTest(self, test, timeout):
"""Runs a single uiautomator test.
Args:
test: Test class/method.
timeout: Timeout time in seconds.
Returns:
An instance of am_instrument_parser.TestResult object.
"""
self.adb.ClearApplicationState(self.package_name)
if 'Feature:FirstRunExperience' in self.test_pkg.GetTestAnnotations(test):
self.flags.RemoveFlags(['--disable-fre'])
else:
self.flags.AddFlags(['--disable-fre'])
return self.adb.RunUIAutomatorTest(
test, self.test_pkg.GetPackageName(), timeout)
#override.
def RunTest(self, test):
raw_result = None
@ -386,14 +404,7 @@ class TestRunner(base_test_runner.BaseTestRunner):
start_date_ms = int(time.time()) * 1000
if self.is_uiautomator_test:
self.adb.ClearApplicationState(self.package_name)
# TODO(frankf): Stop-gap solution. Should use annotations.
if 'FirstRun' in test:
self.flags.RemoveFlags(['--disable-fre'])
else:
self.flags.AddFlags(['--disable-fre'])
raw_result = self.adb.RunUIAutomatorTest(
test, self.test_pkg.GetPackageName(), timeout)
raw_result = self._RunUIAutomatorTest(test, timeout)
else:
raw_result = self.adb.RunInstrumentationTest(
test, self.test_pkg.GetPackageName(),

Просмотреть файл

@ -194,11 +194,11 @@ def AddInstrumentationOptions(option_parser):
AddCommonInstrumentationOptions(option_parser)
option_parser.add_option('-I', dest='install_apk',
help='Install APK.', action='store_true')
option_parser.add_option('--test-apk', dest='test_apk',
help=('The name of the apk containing the tests '
'(without the .apk extension). For SDK '
'builds, the apk name without the debug '
'suffix(for example, ContentShellTest).'))
option_parser.add_option(
'--test-apk', dest='test_apk',
help=('The name of the apk containing the tests (without the .apk '
'extension; e.g. "ContentShellTest"). Alternatively, this can '
'be a full path to the apk.'))
def AddUIAutomatorOptions(option_parser):
@ -209,11 +209,10 @@ def AddUIAutomatorOptions(option_parser):
'--package-name',
help=('The package name used by the apk containing the application.'))
option_parser.add_option(
'--uiautomator-jar',
help=('Path to the uiautomator jar to be installed on the device.'))
option_parser.add_option(
'--uiautomator-info-jar',
help=('Path to the uiautomator jar for use by proguard.'))
'--test-jar', dest='test_jar',
help=('The name of the dexed jar containing the tests (without the '
'.dex.jar extension). Alternatively, this can be a full path to '
'the jar.'))
def ValidateCommonInstrumentationOptions(option_parser, options, args):
@ -269,9 +268,17 @@ def ValidateUIAutomatorOptions(option_parser, options, args):
if not options.package_name:
option_parser.error('--package-name must be specified.')
if not options.uiautomator_jar:
option_parser.error('--uiautomator-jar must be specified.')
if not options.test_jar:
option_parser.error('--test-jar must be specified.')
if not options.uiautomator_info_jar:
option_parser.error('--uiautomator-info-jar must be specified.')
if os.path.exists(options.test_jar):
# The dexed JAR is fully qualified, assume the info JAR lives along side.
options.uiautomator_jar = options.test_jar
else:
options.uiautomator_jar = os.path.join(
_SDK_OUT_DIR, options.build_type, constants.SDK_BUILD_JAVALIB_DIR,
'%s.dex.jar' % options.test_jar)
options.uiautomator_info_jar = (
options.uiautomator_jar[:options.uiautomator_jar.find('.dex.jar')] +
'_java.jar')

Просмотреть файл

@ -7,6 +7,7 @@
"""Runs both the Python and Java instrumentation tests."""
import optparse
import os
import sys
from pylib import buildbot_report
@ -49,7 +50,7 @@ def DispatchInstrumentationTests(options):
report_results.LogFull(
results=all_results,
test_type='Instrumentation',
test_package=options.test_apk,
test_package=os.path.basename(options.test_apk),
annotation=options.annotation,
build_type=options.build_type,
flakiness_server=options.flakiness_dashboard_server)

Просмотреть файл

@ -52,12 +52,12 @@ def DispatchUIAutomatorTests(options):
report_results.LogFull(
results=all_results,
test_type='UIAutomator',
test_package=os.path.basename(options.uiautomator_jar),
test_package=os.path.basename(options.test_jar),
annotation=options.annotation,
build_type=options.build_type,
flakiness_server=options.flakiness_dashboard_server)
return len(all_results.GetAllBroken())
return len(all_results.GetNotPass())
def main(argv):