Chromium Code Reviews| Index: build/android/pylib/instrumentation/instrumentation_test_instance.py |
| diff --git a/build/android/pylib/instrumentation/instrumentation_test_instance.py b/build/android/pylib/instrumentation/instrumentation_test_instance.py |
| index 6f31a33008538c3add76dfc29129a79251cfa10c..7092bfd60e777b39f99b99062f82f006ac25e59a 100644 |
| --- a/build/android/pylib/instrumentation/instrumentation_test_instance.py |
| +++ b/build/android/pylib/instrumentation/instrumentation_test_instance.py |
| @@ -47,6 +47,9 @@ _EXTRA_DRIVER_TARGET_CLASS = ( |
| _EXTRA_TIMEOUT_SCALE = ( |
| 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TimeoutScale') |
| +_WEBVIEW_JUNIT4_PARAMETERIZATION = 'WebViewParameterization' |
| +_WEBVIEW_JUNIT4_SKIP_PARAMETERIZATION = 'SkipWebViewParameterization' |
| + |
| _PARAMETERIZED_TEST_ANNOTATION = 'ParameterizedTest' |
| _PARAMETERIZED_TEST_SET_ANNOTATION = 'ParameterizedTest$Set' |
| _NATIVE_CRASH_RE = re.compile('(process|native) crash', re.IGNORECASE) |
| @@ -236,6 +239,12 @@ def FilterTests(tests, test_filter=None, annotations=None, |
| GetUniqueTestName(t, sep='.') |
| ] |
| + if t['is_junit4'] and t.get('webview_parameterization'): |
|
jbudorick
2017/06/12 13:21:43
I'm not sure why this is necessary beyond what Get
|
| + names += [ |
| + GetTestNameWithoutParameterPostfix(t, sep='.'), |
| + GetTestNameWithoutParameterPostfix(unqualified_class_test, sep='.') |
| + ] |
| + |
| pattern_groups = test_filter.split('-') |
| if len(pattern_groups) > 1: |
| negative_filter = pattern_groups[1] |
| @@ -430,6 +439,28 @@ def GetTestName(test, sep='#'): |
| return '%s%s%s' % (test['class'], sep, test['method']) |
| +def GetTestNameWithoutParameterPostfix( |
| + test, sep='#', parameter_postfix='__'): |
| + """Gets the name of the given JUnit4 test withouth parameter postfix. |
| + |
| + For most WebView JUnit4 javatests, each test is parameterizatized with |
| + "__sandboxed_mode" to run in both non-sandboxed mode and sandboxed mode. |
| + |
| + This function returns the name of the test without parameterization |
| + so test filters can match both parameterized and non-parameterized tests. |
| + |
| + Args: |
| + test: the instrumentation test dict. |
| + sep: the character(s) that should join the class name and the method name. |
| + parameterization_sep: the character(s) that seperate method name and method |
| + parameterization postfix. |
| + Returns: |
| + The test name without parameter postfix as a string. |
| + """ |
| + name = GetTestName(test, sep=sep) |
| + return name.split(parameter_postfix)[0] |
| + |
| + |
| def GetUniqueTestName(test, sep='#'): |
| """Gets the unique name of the given test. |
| @@ -859,13 +890,21 @@ class InstrumentationTestInstance(test_instance.TestInstance): |
| def _ParametrizeTestsWithFlags(self, tests): |
| new_tests = [] |
| for t in tests: |
| - parameters = ParseCommandLineFlagParameters(t['annotations']) |
| - if parameters: |
| - t['flags'] = parameters[0] |
| - for p in parameters[1:]: |
| - parameterized_t = copy.copy(t) |
| - parameterized_t['flags'] = p |
| - new_tests.append(parameterized_t) |
| + if (_WEBVIEW_JUNIT4_PARAMETERIZATION in t['annotations'] |
|
jbudorick
2017/06/12 13:21:43
This is too webview-specific. Let's talk about gen
|
| + and _WEBVIEW_JUNIT4_SKIP_PARAMETERIZATION not in t['annotations'] |
| + and t['is_junit4']): |
| + parameterized_t = copy.copy(t) |
| + parameterized_t['webview_parameterization'] = True |
| + parameterized_t['method'] += '__sandboxed_mode' |
| + new_tests.append(parameterized_t) |
| + else: |
| + parameters = ParseCommandLineFlagParameters(t['annotations']) |
| + if parameters: |
| + t['flags'] = parameters[0] |
| + for p in parameters[1:]: |
| + parameterized_t = copy.copy(t) |
| + parameterized_t['flags'] = p |
| + new_tests.append(parameterized_t) |
| return tests + new_tests |
| def GetDriverEnvironmentVars( |