Commit 818f601d authored by Peter Wen's avatar Peter Wen Committed by Commit Bot

Android: Add fake module support to test runner

Use fake module support added to device API: https://crrev.com/c/1811762

Bug: 1000749
Change-Id: I9810e8fea7b1ab1359693b8bc8110965416395bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835218
Commit-Queue: Peter Wen <wnwen@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702470}
parent 870705b1
......@@ -447,6 +447,7 @@ class InstrumentationTestInstance(test_instance.TestInstance):
self._apk_under_test = None
self._apk_under_test_incremental_install_json = None
self._modules = None
self._fake_modules = None
self._package_info = None
self._suite = None
self._test_apk = None
......@@ -547,6 +548,7 @@ class InstrumentationTestInstance(test_instance.TestInstance):
self._suite = self._suite[:-len('_incremental')]
self._modules = args.modules
self._fake_modules = args.fake_modules
self._test_jar = args.test_jar
self._test_support_apk = apk_helper.ToHelper(os.path.join(
......@@ -721,6 +723,10 @@ class InstrumentationTestInstance(test_instance.TestInstance):
def modules(self):
return self._modules
@property
def fake_modules(self):
return self._fake_modules
@property
def coverage_directory(self):
return self._coverage_directory
......
......@@ -190,13 +190,18 @@ class LocalDeviceInstrumentationTestRun(
steps.append(use_webview_provider)
def install_helper(apk, modules=None, permissions=None):
def install_helper(apk, modules=None, fake_modules=None,
permissions=None):
@instrumentation_tracing.no_tracing
@trace_event.traced
def install_helper_internal(d, apk_path=None):
# pylint: disable=unused-argument
d.Install(apk, modules=modules, permissions=permissions)
d.Install(
apk,
modules=modules,
fake_modules=fake_modules,
permissions=permissions)
return install_helper_internal
......@@ -208,19 +213,6 @@ class LocalDeviceInstrumentationTestRun(
installer.Install(d, json_path, apk=apk, permissions=permissions)
return incremental_install_helper_internal
if self._test_instance.apk_under_test:
permissions = self._test_instance.apk_under_test.GetPermissions()
if self._test_instance.apk_under_test_incremental_install_json:
steps.append(incremental_install_helper(
self._test_instance.apk_under_test,
self._test_instance.
apk_under_test_incremental_install_json,
permissions))
else:
steps.append(
install_helper(self._test_instance.apk_under_test,
self._test_instance.modules, permissions))
permissions = self._test_instance.test_apk.GetPermissions()
if self._test_instance.test_apk_incremental_install_json:
steps.append(incremental_install_helper(
......@@ -236,6 +228,23 @@ class LocalDeviceInstrumentationTestRun(
steps.extend(
install_helper(apk) for apk in self._test_instance.additional_apks)
# The apk under test needs to be installed last since installing other
# apks after will unintentionally clear the fake module directory.
# TODO(wnwen): Make this more robust, fix crbug.com/1010954.
if self._test_instance.apk_under_test:
permissions = self._test_instance.apk_under_test.GetPermissions()
if self._test_instance.apk_under_test_incremental_install_json:
steps.append(
incremental_install_helper(
self._test_instance.apk_under_test,
self._test_instance.apk_under_test_incremental_install_json,
permissions))
else:
steps.append(
install_helper(self._test_instance.apk_under_test,
self._test_instance.modules,
self._test_instance.fake_modules, permissions))
@trace_event.traced
def set_debug_app(dev):
# Set debug app in order to enable reading command line flags on user
......
......@@ -417,6 +417,12 @@ def AddInstrumentationTestOptions(parser):
dest='modules',
help='Specify Android App Bundle modules to install in addition to the '
'base module.')
parser.add_argument(
'--fake-module',
action='append',
dest='fake_modules',
help='Specify Android App Bundle modules to fake install in addition to '
'the real modules.')
parser.add_argument(
'--coverage-dir',
type=os.path.realpath,
......
......@@ -797,6 +797,15 @@ template("test_runner_script") {
}
}
if (defined(invoker.fake_modules)) {
foreach(fake_module, invoker.fake_modules) {
executable_args += [
"--fake-module",
fake_module,
]
}
}
if (defined(invoker.extra_args)) {
executable_args += invoker.extra_args
}
......
......@@ -3583,6 +3583,7 @@ if (enable_java_templates) {
# ignore_all_data_deps: Don't build data_deps and additional_apks.
# modules: Extra dynamic feature modules to install for test target. Can
# only be used if |apk_under_test| is an Android app bundle.
# fake_modules: Similar to |modules| but fake installed instead.
# never_incremental: Disable incremental builds.
# proguard_enabled: Enable proguard
# public_deps: List of public dependencies
......@@ -3626,6 +3627,7 @@ if (enable_java_templates) {
"data_deps",
"deps",
"extra_args",
"fake_modules",
"ignore_all_data_deps",
"modules",
"proguard_enabled",
......
......@@ -2183,6 +2183,22 @@ instrumentation_test_runner("chrome_modern_public_bundle_smoke_test") {
extra_args = _bundle_smoke_test_extra_args
}
_bundle_fake_modules_smoke_test_extra_args = [
# These are in addition to the ones listed in _bundle_smoke_test_extra_args.
"--fake-feature-module-install",
]
instrumentation_test_runner(
"chrome_modern_public_bundle_fake_modules_smoke_test") {
apk_under_test = ":chrome_modern_public_bundle_apks"
android_test_apk = ":chrome_bundle_smoke_test_apk"
android_test_apk_name = "ChromeBundleSmokeTest"
never_incremental = true
fake_modules = [ "test_dummy" ]
extra_args =
_bundle_smoke_test_extra_args + _bundle_fake_modules_smoke_test_extra_args
}
# Public webview targets don't work with non-public sdks.
# https://crbug.com/1000763
if (public_android_sdk) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment