Merge "Add --no-hidden-api-checks to runtest"

This commit is contained in:
Remi NGUYEN VAN
2018-06-08 09:28:13 +00:00
committed by Gerrit Code Review
3 changed files with 34 additions and 18 deletions

View File

@@ -176,7 +176,8 @@ class AdbInterface:
def StartInstrumentationForPackage( def StartInstrumentationForPackage(
self, package_name, runner_name, timeout_time=60*10, self, package_name, runner_name, timeout_time=60*10,
no_window_animation=False, instrumentation_args={}, user=None): no_window_animation=False, instrumentation_args={}, user=None,
no_hidden_api_checks=False):
"""Run instrumentation test for given package and runner. """Run instrumentation test for given package and runner.
Equivalent to StartInstrumentation, except instrumentation path is Equivalent to StartInstrumentation, except instrumentation path is
@@ -186,11 +187,13 @@ class AdbInterface:
return self.StartInstrumentation(instrumentation_path, timeout_time=timeout_time, return self.StartInstrumentation(instrumentation_path, timeout_time=timeout_time,
no_window_animation=no_window_animation, no_window_animation=no_window_animation,
instrumentation_args=instrumentation_args, instrumentation_args=instrumentation_args,
user=user) user=user,
no_hidden_api_checks=no_hidden_api_checks)
def StartInstrumentation( def StartInstrumentation(
self, instrumentation_path, timeout_time=60*10, no_window_animation=False, self, instrumentation_path, timeout_time=60*10, no_window_animation=False,
profile=False, instrumentation_args={}, user=None): profile=False, instrumentation_args={}, user=None,
no_hidden_api_checks=False):
"""Runs an instrumentation class on the target. """Runs an instrumentation class on the target.
@@ -232,7 +235,7 @@ class AdbInterface:
instrumentation_path, no_window_animation=no_window_animation, instrumentation_path, no_window_animation=no_window_animation,
profile=profile, raw_mode=True, profile=profile, raw_mode=True,
instrumentation_args=instrumentation_args, instrumentation_args=instrumentation_args,
user=user) user=user, no_hidden_api_checks=no_hidden_api_checks)
logger.Log(command_string) logger.Log(command_string)
(test_results, inst_finished_bundle) = ( (test_results, inst_finished_bundle) = (
am_instrument_parser.ParseAmInstrumentOutput( am_instrument_parser.ParseAmInstrumentOutput(
@@ -258,7 +261,8 @@ class AdbInterface:
def StartInstrumentationNoResults( def StartInstrumentationNoResults(
self, package_name, runner_name, no_window_animation=False, self, package_name, runner_name, no_window_animation=False,
raw_mode=False, instrumentation_args={}, user=None): raw_mode=False, instrumentation_args={}, user=None,
no_hidden_api_checks=False):
"""Runs instrumentation and dumps output to stdout. """Runs instrumentation and dumps output to stdout.
Equivalent to StartInstrumentation, but will dump instrumentation Equivalent to StartInstrumentation, but will dump instrumentation
@@ -268,18 +272,19 @@ class AdbInterface:
adb_command_string = self.PreviewInstrumentationCommand( adb_command_string = self.PreviewInstrumentationCommand(
package_name, runner_name, no_window_animation=no_window_animation, package_name, runner_name, no_window_animation=no_window_animation,
raw_mode=raw_mode, instrumentation_args=instrumentation_args, raw_mode=raw_mode, instrumentation_args=instrumentation_args,
user=user) user=user, no_hidden_api_checks=no_hidden_api_checks)
logger.Log(adb_command_string) logger.Log(adb_command_string)
run_command.RunCommand(adb_command_string, return_output=False) run_command.RunCommand(adb_command_string, return_output=False)
def PreviewInstrumentationCommand( def PreviewInstrumentationCommand(
self, package_name, runner_name, no_window_animation=False, self, package_name, runner_name, no_window_animation=False,
raw_mode=False, instrumentation_args={}, user=None): raw_mode=False, instrumentation_args={}, user=None,
no_hidden_api_checks=False):
"""Returns a string of adb command that will be executed.""" """Returns a string of adb command that will be executed."""
inst_command_string = self._BuildInstrumentationCommand( inst_command_string = self._BuildInstrumentationCommand(
package_name, runner_name, no_window_animation=no_window_animation, package_name, runner_name, no_window_animation=no_window_animation,
raw_mode=raw_mode, instrumentation_args=instrumentation_args, raw_mode=raw_mode, instrumentation_args=instrumentation_args,
user=user) user=user, no_hidden_api_checks=no_hidden_api_checks)
return self.PreviewShellCommand(inst_command_string) return self.PreviewShellCommand(inst_command_string)
def PreviewShellCommand(self, cmd): def PreviewShellCommand(self, cmd):
@@ -287,18 +292,23 @@ class AdbInterface:
def _BuildInstrumentationCommand( def _BuildInstrumentationCommand(
self, package, runner_name, no_window_animation=False, profile=False, self, package, runner_name, no_window_animation=False, profile=False,
raw_mode=True, instrumentation_args={}, user=None): raw_mode=True, instrumentation_args={}, user=None,
no_hidden_api_checks=False):
instrumentation_path = "%s/%s" % (package, runner_name) instrumentation_path = "%s/%s" % (package, runner_name)
return self._BuildInstrumentationCommandPath( return self._BuildInstrumentationCommandPath(
instrumentation_path, no_window_animation=no_window_animation, instrumentation_path, no_window_animation=no_window_animation,
profile=profile, raw_mode=raw_mode, profile=profile, raw_mode=raw_mode,
instrumentation_args=instrumentation_args, user=user) instrumentation_args=instrumentation_args, user=user,
no_hidden_api_checks=no_hidden_api_checks)
def _BuildInstrumentationCommandPath( def _BuildInstrumentationCommandPath(
self, instrumentation_path, no_window_animation=False, profile=False, self, instrumentation_path, no_window_animation=False, profile=False,
raw_mode=True, instrumentation_args={}, user=None): raw_mode=True, instrumentation_args={}, user=None,
no_hidden_api_checks=False):
command_string = "am instrument" command_string = "am instrument"
if no_hidden_api_checks:
command_string += " --no-hidden-api-checks"
if user: if user:
command_string += " --user %s" % user command_string += " --user %s" % user
if no_window_animation: if no_window_animation:

View File

@@ -183,6 +183,10 @@ class TestRunner(object):
" and will install all packages built. This is" " and will install all packages built. This is"
" useful when the test path has a lot of apks but you" " useful when the test path has a lot of apks but you"
" only care about one.") " only care about one.")
parser.add_option("--no-hidden-api-checks", dest="no_hidden_api_checks",
default=False, action="store_true",
help="Disable hidden API checks in instrumentation"
" tests.")
group = optparse.OptionGroup( group = optparse.OptionGroup(
parser, "Targets", "Use these options to direct tests to a specific " parser, "Targets", "Use these options to direct tests to a specific "
"Android target") "Android target")

View File

@@ -155,7 +155,8 @@ class InstrumentationTestSuite(test_suite.AbstractTestSuite):
runner_name=self.GetRunnerName(), runner_name=self.GetRunnerName(),
timeout_time=60*60, timeout_time=60*60,
instrumentation_args=instrumentation_args, instrumentation_args=instrumentation_args,
user=options.user) user=options.user,
no_hidden_api_checks=options.no_hidden_api_checks)
except errors.InstrumentationError, errors.DeviceUnresponsiveError: except errors.InstrumentationError, errors.DeviceUnresponsiveError:
return return
self._PrintTestResults(test_results) self._PrintTestResults(test_results)
@@ -172,12 +173,13 @@ class InstrumentationTestSuite(test_suite.AbstractTestSuite):
else: else:
self._CheckInstrumentationInstalled(adb) self._CheckInstrumentationInstalled(adb)
adb.StartInstrumentationNoResults(package_name=self.GetPackageName(), adb.StartInstrumentationNoResults(
runner_name=self.GetRunnerName(), package_name=self.GetPackageName(),
raw_mode=options.raw_mode, runner_name=self.GetRunnerName(),
instrumentation_args= raw_mode=options.raw_mode,
instrumentation_args, instrumentation_args=instrumentation_args,
user=options.user) user=options.user,
no_hidden_api_checks=options.no_hidden_api_checks)
def _CheckInstrumentationInstalled(self, adb): def _CheckInstrumentationInstalled(self, adb):
if not adb.IsInstrumentationInstalled(self.GetPackageName(), if not adb.IsInstrumentationInstalled(self.GetPackageName(),