Commit fcbb3aa5 authored by Ben Pastene's avatar Ben Pastene Committed by Commit Bot

android: Make the cmd-line flag file name configurable via a test_runner arg.

It's hard-coded to test-cmdline-file, and some tests appear to have their
own location

R=jbudorick

Bug: 907899
Change-Id: I515bd8d2ff3d91a2f665754708bda94f6c0c19c4
Reviewed-on: https://chromium-review.googlesource.com/c/1357609Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615628}
parent 328bff93
...@@ -65,6 +65,11 @@ PACKAGE_INFO.update({ ...@@ -65,6 +65,11 @@ PACKAGE_INFO.update({
'org.chromium.chromedriver_webview_shell.Main', 'org.chromium.chromedriver_webview_shell.Main',
None, None,
None), None),
'android_webview_cts': chrome.PackageInfo(
'com.android.webview',
'com.android.cts.webkit.WebViewStartupCtsActivity',
'webview-command-line',
None),
}) })
......
...@@ -485,6 +485,7 @@ class InstrumentationTestInstance(test_instance.TestInstance): ...@@ -485,6 +485,7 @@ class InstrumentationTestInstance(test_instance.TestInstance):
self._initializeTestFilterAttributes(args) self._initializeTestFilterAttributes(args)
self._flags = None self._flags = None
self._use_apk_under_test_flags_file = False
self._initializeFlagAttributes(args) self._initializeFlagAttributes(args)
self._driver_apk = None self._driver_apk = None
...@@ -659,6 +660,7 @@ class InstrumentationTestInstance(test_instance.TestInstance): ...@@ -659,6 +660,7 @@ class InstrumentationTestInstance(test_instance.TestInstance):
if a not in requested_annotations) if a not in requested_annotations)
def _initializeFlagAttributes(self, args): def _initializeFlagAttributes(self, args):
self._use_apk_under_test_flags_file = args.use_apk_under_test_flags_file
self._flags = ['--enable-test-intents'] self._flags = ['--enable-test-intents']
if args.command_line_flags: if args.command_line_flags:
self._flags.extend(args.command_line_flags) self._flags.extend(args.command_line_flags)
...@@ -813,6 +815,10 @@ class InstrumentationTestInstance(test_instance.TestInstance): ...@@ -813,6 +815,10 @@ class InstrumentationTestInstance(test_instance.TestInstance):
def total_external_shards(self): def total_external_shards(self):
return self._total_external_shards return self._total_external_shards
@property
def use_apk_under_test_flags_file(self):
return self._use_apk_under_test_flags_file
@property @property
def wait_for_java_debugger(self): def wait_for_java_debugger(self):
return self._wait_for_java_debugger return self._wait_for_java_debugger
......
...@@ -46,13 +46,15 @@ class InstrumentationTestInstanceTest(unittest.TestCase): ...@@ -46,13 +46,15 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
'command_line_flags', 'command_line_flags',
'device_flags_file', 'device_flags_file',
'strict_mode', 'strict_mode',
'use_apk_under_test_flags_file'
]) ])
def createFlagAttributesArgs( def createFlagAttributesArgs(
self, command_line_flags=None, device_flags_file=None, self, command_line_flags=None, device_flags_file=None,
strict_mode=None): strict_mode=None, use_apk_under_test_flags_file=False):
return self._FlagAttributesArgs( return self._FlagAttributesArgs(
command_line_flags, device_flags_file, strict_mode) command_line_flags, device_flags_file, strict_mode,
use_apk_under_test_flags_file)
def test_initializeFlagAttributes_commandLineFlags(self): def test_initializeFlagAttributes_commandLineFlags(self):
o = self.createTestInstance() o = self.createTestInstance()
......
...@@ -343,8 +343,16 @@ class LocalDeviceInstrumentationTestRun( ...@@ -343,8 +343,16 @@ class LocalDeviceInstrumentationTestRun(
def _CreateFlagChangerIfNeeded(self, device): def _CreateFlagChangerIfNeeded(self, device):
if str(device) not in self._flag_changers: if str(device) not in self._flag_changers:
cmdline_file = 'test-cmdline-file'
if self._test_instance.use_apk_under_test_flags_file:
if self._test_instance.package_info:
cmdline_file = self._test_instance.package_info.cmdline_file
else:
logging.warning(
'No PackageInfo found, falling back to using flag file %s',
cmdline_file)
self._flag_changers[str(device)] = flag_changer.FlagChanger( self._flag_changers[str(device)] = flag_changer.FlagChanger(
device, "test-cmdline-file") device, cmdline_file)
#override #override
def _CreateShards(self, tests): def _CreateShards(self, tests):
......
...@@ -106,6 +106,11 @@ def AddCommandLineOptions(parser): ...@@ -106,6 +106,11 @@ def AddCommandLineOptions(parser):
type=os.path.realpath, type=os.path.realpath,
help='The relative filepath to a file containing ' help='The relative filepath to a file containing '
'command-line flags to set on the device') 'command-line flags to set on the device')
parser.add_argument(
'--use-apk-under-test-flags-file',
action='store_true',
help='Wether to use the flags file for the apk under test. If set, '
"the filename will be looked up in the APK's PackageInfo.")
parser.set_defaults(allow_unknown=True) parser.set_defaults(allow_unknown=True)
parser.set_defaults(command_line_flags=None) parser.set_defaults(command_line_flags=None)
......
...@@ -1431,6 +1431,9 @@ ...@@ -1431,6 +1431,9 @@
"--skip-expected-failures", "--skip-expected-failures",
"--additional-apk", "--additional-apk",
"apks/SystemWebView.apk", "apks/SystemWebView.apk",
"--apk-under-test",
"apks/SystemWebView.apk",
"--use-apk-under-test-flags-file",
"-v", "-v",
], ],
}, },
......
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