OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import copy | 5 import copy |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import pickle | 8 import pickle |
9 import re | 9 import re |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 _ACTIVITY_RESULT_CANCELED = 0 | 29 _ACTIVITY_RESULT_CANCELED = 0 |
30 _ACTIVITY_RESULT_OK = -1 | 30 _ACTIVITY_RESULT_OK = -1 |
31 | 31 |
32 _COMMAND_LINE_PARAMETER = 'cmdlinearg-parameter' | 32 _COMMAND_LINE_PARAMETER = 'cmdlinearg-parameter' |
33 _DEFAULT_ANNOTATIONS = [ | 33 _DEFAULT_ANNOTATIONS = [ |
34 'SmallTest', 'MediumTest', 'LargeTest', 'EnormousTest', 'IntegrationTest'] | 34 'SmallTest', 'MediumTest', 'LargeTest', 'EnormousTest', 'IntegrationTest'] |
35 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS = [ | 35 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS = [ |
36 'DisabledTest', 'FlakyTest'] | 36 'DisabledTest', 'FlakyTest'] |
37 _VALID_ANNOTATIONS = set(['Manual'] + _DEFAULT_ANNOTATIONS + | 37 _VALID_ANNOTATIONS = set(['Manual'] + _DEFAULT_ANNOTATIONS + |
38 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS) | 38 _EXCLUDE_UNLESS_REQUESTED_ANNOTATIONS) |
| 39 |
| 40 # These test methods are inherited from android.test base test class and |
| 41 # should be permitted for not having size annotation. For more, please check |
| 42 # https://developer.android.com/reference/android/test/AndroidTestCase.html |
| 43 # https://developer.android.com/reference/android/test/ServiceTestCase.html |
| 44 _TEST_WITHOUT_SIZE_ANNOTATIONS = [ |
| 45 'testAndroidTestCaseSetupProperly', 'testServiceTestCaseSetUpProperly'] |
| 46 |
39 _EXTRA_DRIVER_TEST_LIST = ( | 47 _EXTRA_DRIVER_TEST_LIST = ( |
40 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestList') | 48 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestList') |
41 _EXTRA_DRIVER_TEST_LIST_FILE = ( | 49 _EXTRA_DRIVER_TEST_LIST_FILE = ( |
42 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestListFile') | 50 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TestListFile') |
43 _EXTRA_DRIVER_TARGET_PACKAGE = ( | 51 _EXTRA_DRIVER_TARGET_PACKAGE = ( |
44 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetPackage') | 52 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetPackage') |
45 _EXTRA_DRIVER_TARGET_CLASS = ( | 53 _EXTRA_DRIVER_TARGET_CLASS = ( |
46 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetClass') | 54 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TargetClass') |
47 _EXTRA_TIMEOUT_SCALE = ( | 55 _EXTRA_TIMEOUT_SCALE = ( |
48 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TimeoutScale') | 56 'org.chromium.test.driver.OnDeviceInstrumentationDriver.TimeoutScale') |
(...skipping 11 matching lines...) Expand all Loading... |
60 super(MissingSizeAnnotationError, self).__init__(class_name + | 68 super(MissingSizeAnnotationError, self).__init__(class_name + |
61 ': Test method is missing required size annotation. Add one of: ' + | 69 ': Test method is missing required size annotation. Add one of: ' + |
62 ', '.join('@' + a for a in _VALID_ANNOTATIONS)) | 70 ', '.join('@' + a for a in _VALID_ANNOTATIONS)) |
63 | 71 |
64 | 72 |
65 class TestListPickleException(test_exception.TestException): | 73 class TestListPickleException(test_exception.TestException): |
66 pass | 74 pass |
67 | 75 |
68 | 76 |
69 # TODO(jbudorick): Make these private class methods of | 77 # TODO(jbudorick): Make these private class methods of |
70 # InstrumentationTestInstance once the instrumentation test_runner is | 78 # InstrumentationTestInstance once the instrumentation junit3_runner_class is |
71 # deprecated. | 79 # deprecated. |
72 def ParseAmInstrumentRawOutput(raw_output): | 80 def ParseAmInstrumentRawOutput(raw_output): |
73 """Parses the output of an |am instrument -r| call. | 81 """Parses the output of an |am instrument -r| call. |
74 | 82 |
75 Args: | 83 Args: |
76 raw_output: the output of an |am instrument -r| call as a list of lines | 84 raw_output: the output of an |am instrument -r| call as a list of lines |
77 Returns: | 85 Returns: |
78 A 3-tuple containing: | 86 A 3-tuple containing: |
79 - the instrumentation code as an integer | 87 - the instrumentation code as an integer |
80 - the instrumentation result as a list of lines | 88 - the instrumentation result as a list of lines |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 164 |
157 return results | 165 return results |
158 | 166 |
159 | 167 |
160 def FilterTests(tests, test_filter=None, annotations=None, | 168 def FilterTests(tests, test_filter=None, annotations=None, |
161 excluded_annotations=None): | 169 excluded_annotations=None): |
162 """Filter a list of tests | 170 """Filter a list of tests |
163 | 171 |
164 Args: | 172 Args: |
165 tests: a list of tests. e.g. [ | 173 tests: a list of tests. e.g. [ |
166 {'annotations": {}, 'class': 'com.example.TestA', 'methods':[]}, | 174 {'annotations": {}, 'class': 'com.example.TestA', 'method':'test1'}, |
167 {'annotations": {}, 'class': 'com.example.TestB', 'methods':[]}] | 175 {'annotations": {}, 'class': 'com.example.TestB', 'method':'test2'}] |
168 test_filter: googletest-style filter string. | 176 test_filter: googletest-style filter string. |
169 annotations: a dict of wanted annotations for test methods. | 177 annotations: a dict of wanted annotations for test methods. |
170 exclude_annotations: a dict of annotations to exclude. | 178 exclude_annotations: a dict of annotations to exclude. |
171 | 179 |
172 Return: | 180 Return: |
173 A list of filtered tests | 181 A list of filtered tests |
174 """ | 182 """ |
175 def gtest_filter(t): | 183 def gtest_filter(t): |
176 if not test_filter: | 184 if not test_filter: |
177 return True | 185 return True |
178 # Allow fully-qualified name as well as an omitted package. | 186 # Allow fully-qualified name as well as an omitted package. |
179 unqualified_class_test = { | 187 unqualified_class_test = { |
180 'class': t['class'].split('.')[-1], | 188 'class': t['class'].split('.')[-1], |
181 'method': t['method'] | 189 'method': t['method'] |
182 } | 190 } |
183 names = [ | 191 names = [ |
184 GetTestName(t, sep='.'), | 192 GetTestName(t, sep='.'), |
185 GetTestName(unqualified_class_test, sep='.'), | 193 GetTestName(unqualified_class_test, sep='.'), |
186 GetUniqueTestName(t, sep='.') | 194 GetUniqueTestName(t, sep='.') |
187 ] | 195 ] |
188 | 196 |
| 197 if t['is_junit4']: |
| 198 names += [ |
| 199 GetTestNameWithoutParameterPostfix(t, sep='.'), |
| 200 GetTestNameWithoutParameterPostfix(unqualified_class_test, sep='.') |
| 201 ] |
| 202 |
189 pattern_groups = test_filter.split('-') | 203 pattern_groups = test_filter.split('-') |
190 if len(pattern_groups) > 1: | 204 if len(pattern_groups) > 1: |
191 negative_filter = pattern_groups[1] | 205 negative_filter = pattern_groups[1] |
192 if unittest_util.FilterTestNames(names, negative_filter): | 206 if unittest_util.FilterTestNames(names, negative_filter): |
193 return [] | 207 return [] |
194 | 208 |
195 positive_filter = pattern_groups[0] | 209 positive_filter = pattern_groups[0] |
196 return unittest_util.FilterTestNames(names, positive_filter) | 210 return unittest_util.FilterTestNames(names, positive_filter) |
197 | 211 |
198 def annotation_filter(all_annotations): | 212 def annotation_filter(all_annotations): |
(...skipping 22 matching lines...) Expand all Loading... |
221 return filter_av in av | 235 return filter_av in av |
222 return filter_av == av | 236 return filter_av == av |
223 | 237 |
224 filtered_tests = [] | 238 filtered_tests = [] |
225 for t in tests: | 239 for t in tests: |
226 # Gtest filtering | 240 # Gtest filtering |
227 if not gtest_filter(t): | 241 if not gtest_filter(t): |
228 continue | 242 continue |
229 | 243 |
230 # Enforce that all tests declare their size. | 244 # Enforce that all tests declare their size. |
231 if not any(a in _VALID_ANNOTATIONS for a in t['annotations']): | 245 if (not any(a in _VALID_ANNOTATIONS for a in t['annotations']) |
| 246 and t['method'] not in _TEST_WITHOUT_SIZE_ANNOTATIONS): |
232 raise MissingSizeAnnotationError(GetTestName(t)) | 247 raise MissingSizeAnnotationError(GetTestName(t)) |
233 | 248 |
234 if (not annotation_filter(t['annotations']) | 249 if (not annotation_filter(t['annotations']) |
235 or not excluded_annotation_filter(t['annotations'])): | 250 or not excluded_annotation_filter(t['annotations'])): |
236 continue | 251 continue |
237 | 252 |
238 filtered_tests.append(t) | 253 filtered_tests.append(t) |
239 | 254 |
240 return filtered_tests | 255 return filtered_tests |
241 | 256 |
242 | 257 |
| 258 # TODO(yolandyan): remove this once the tests are converted to junit4 |
243 def GetAllTestsFromJar(test_jar): | 259 def GetAllTestsFromJar(test_jar): |
244 pickle_path = '%s-proguard.pickle' % test_jar | 260 pickle_path = '%s-proguard.pickle' % test_jar |
245 try: | 261 try: |
246 tests = _GetTestsFromPickle(pickle_path, test_jar) | 262 tests = GetTestsFromPickle(pickle_path, test_jar) |
247 except TestListPickleException as e: | 263 except TestListPickleException as e: |
248 logging.info('Could not get tests from pickle: %s', e) | 264 logging.info('Could not get tests from pickle: %s', e) |
249 logging.info('Getting tests from JAR via proguard.') | 265 logging.info('Getting tests from JAR via proguard.') |
250 tests = _GetTestsFromProguard(test_jar) | 266 tests = _GetTestsFromProguard(test_jar) |
251 _SaveTestsToPickle(pickle_path, test_jar, tests) | 267 SaveTestsToPickle(pickle_path, test_jar, tests) |
252 return tests | 268 return tests |
253 | 269 |
254 | 270 |
255 def GetAllTestsFromApk(test_apk): | 271 def GetAllTestsFromApk(test_apk): |
256 pickle_path = '%s-dexdump.pickle' % test_apk | 272 pickle_path = '%s-dexdump.pickle' % test_apk |
257 try: | 273 try: |
258 tests = _GetTestsFromPickle(pickle_path, test_apk) | 274 tests = GetTestsFromPickle(pickle_path, test_apk) |
259 except TestListPickleException as e: | 275 except TestListPickleException as e: |
260 logging.info('Could not get tests from pickle: %s', e) | 276 logging.info('Could not get tests from pickle: %s', e) |
261 logging.info('Getting tests from dex via dexdump.') | 277 logging.info('Getting tests from dex via dexdump.') |
262 tests = _GetTestsFromDexdump(test_apk) | 278 tests = _GetTestsFromDexdump(test_apk) |
263 _SaveTestsToPickle(pickle_path, test_apk, tests) | 279 SaveTestsToPickle(pickle_path, test_apk, tests) |
264 return tests | 280 return tests |
265 | 281 |
266 def _GetTestsFromPickle(pickle_path, jar_path): | 282 def GetTestsFromPickle(pickle_path, jar_path): |
267 if not os.path.exists(pickle_path): | 283 if not os.path.exists(pickle_path): |
268 raise TestListPickleException('%s does not exist.' % pickle_path) | 284 raise TestListPickleException('%s does not exist.' % pickle_path) |
269 if os.path.getmtime(pickle_path) <= os.path.getmtime(jar_path): | 285 if os.path.getmtime(pickle_path) <= os.path.getmtime(jar_path): |
270 raise TestListPickleException( | 286 raise TestListPickleException( |
271 '%s newer than %s.' % (jar_path, pickle_path)) | 287 '%s newer than %s.' % (jar_path, pickle_path)) |
272 | 288 |
273 with open(pickle_path, 'r') as f: | 289 with open(pickle_path, 'r') as f: |
274 pickle_data = pickle.load(f) | 290 pickle_data = pickle.load(f) |
275 jar_md5 = md5sum.CalculateHostMd5Sums(jar_path)[jar_path] | 291 jar_md5 = md5sum.CalculateHostMd5Sums(jar_path)[jar_path] |
276 | 292 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 for class_name, class_info in package_info['classes'].iteritems(): | 347 for class_name, class_info in package_info['classes'].iteritems(): |
332 if class_name.endswith('Test'): | 348 if class_name.endswith('Test'): |
333 tests.append({ | 349 tests.append({ |
334 'class': '%s.%s' % (package_name, class_name), | 350 'class': '%s.%s' % (package_name, class_name), |
335 'annotations': {}, | 351 'annotations': {}, |
336 'methods': get_test_methods(class_info['methods']), | 352 'methods': get_test_methods(class_info['methods']), |
337 'superclass': class_info['superclass'], | 353 'superclass': class_info['superclass'], |
338 }) | 354 }) |
339 return tests | 355 return tests |
340 | 356 |
341 | 357 def SaveTestsToPickle(pickle_path, jar_path, tests): |
342 def _SaveTestsToPickle(pickle_path, jar_path, tests): | |
343 jar_md5 = md5sum.CalculateHostMd5Sums(jar_path)[jar_path] | 358 jar_md5 = md5sum.CalculateHostMd5Sums(jar_path)[jar_path] |
344 pickle_data = { | 359 pickle_data = { |
345 'VERSION': _PICKLE_FORMAT_VERSION, | 360 'VERSION': _PICKLE_FORMAT_VERSION, |
346 'JAR_MD5SUM': jar_md5, | 361 'JAR_MD5SUM': jar_md5, |
347 'TEST_METHODS': tests, | 362 'TEST_METHODS': tests, |
348 } | 363 } |
349 with open(pickle_path, 'w') as pickle_file: | 364 with open(pickle_path, 'w') as pickle_file: |
350 pickle.dump(pickle_data, pickle_file) | 365 pickle.dump(pickle_data, pickle_file) |
351 | 366 |
352 | 367 |
(...skipping 21 matching lines...) Expand all Loading... |
374 | 389 |
375 Args: | 390 Args: |
376 test: the instrumentation test dict. | 391 test: the instrumentation test dict. |
377 sep: the character(s) that should join the class name and the method name. | 392 sep: the character(s) that should join the class name and the method name. |
378 Returns: | 393 Returns: |
379 The test name as a string. | 394 The test name as a string. |
380 """ | 395 """ |
381 return '%s%s%s' % (test['class'], sep, test['method']) | 396 return '%s%s%s' % (test['class'], sep, test['method']) |
382 | 397 |
383 | 398 |
| 399 def GetTestNameWithoutParameterPostfix( |
| 400 test, sep='#', parameterization_sep='__'): |
| 401 """Gets the name of the given JUnit4 test without parameter postfix. |
| 402 |
| 403 For most WebView JUnit4 javatests, each test is parameterizatized with |
| 404 "__sandboxed_mode" to run in both non-sandboxed mode and sandboxed mode. |
| 405 |
| 406 This function returns the name of the test without parameterization |
| 407 so test filters can match both parameterized and non-parameterized tests. |
| 408 |
| 409 Args: |
| 410 test: the instrumentation test dict. |
| 411 sep: the character(s) that should join the class name and the method name. |
| 412 parameterization_sep: the character(s) that seperate method name and method |
| 413 parameterization postfix. |
| 414 Returns: |
| 415 The test name without parameter postfix as a string. |
| 416 """ |
| 417 name = GetTestName(test, sep=sep) |
| 418 return name.split(parameterization_sep)[0] |
| 419 |
| 420 |
384 def GetUniqueTestName(test, sep='#'): | 421 def GetUniqueTestName(test, sep='#'): |
385 """Gets the unique name of the given test. | 422 """Gets the unique name of the given test. |
386 | 423 |
387 This will include text to disambiguate between tests for which GetTestName | 424 This will include text to disambiguate between tests for which GetTestName |
388 would return the same name. | 425 would return the same name. |
389 | 426 |
390 Args: | 427 Args: |
391 test: the instrumentation test dict. | 428 test: the instrumentation test dict. |
392 sep: the character(s) that should join the class name and the method name. | 429 sep: the character(s) that should join the class name and the method name. |
393 Returns: | 430 Returns: |
(...skipping 12 matching lines...) Expand all Loading... |
406 | 443 |
407 self._additional_apks = [] | 444 self._additional_apks = [] |
408 self._apk_under_test = None | 445 self._apk_under_test = None |
409 self._apk_under_test_incremental_install_script = None | 446 self._apk_under_test_incremental_install_script = None |
410 self._package_info = None | 447 self._package_info = None |
411 self._suite = None | 448 self._suite = None |
412 self._test_apk = None | 449 self._test_apk = None |
413 self._test_apk_incremental_install_script = None | 450 self._test_apk_incremental_install_script = None |
414 self._test_jar = None | 451 self._test_jar = None |
415 self._test_package = None | 452 self._test_package = None |
416 self._test_runner = None | 453 self._junit3_runner_class = None |
417 self._test_runner_junit4 = None | 454 self._junit4_runner_class = None |
418 self._test_support_apk = None | 455 self._test_support_apk = None |
419 self._initializeApkAttributes(args, error_func) | 456 self._initializeApkAttributes(args, error_func) |
420 | 457 |
421 self._data_deps = None | 458 self._data_deps = None |
422 self._data_deps_delegate = None | 459 self._data_deps_delegate = None |
423 self._runtime_deps_path = None | 460 self._runtime_deps_path = None |
424 self._initializeDataDependencyAttributes(args, data_deps_delegate) | 461 self._initializeDataDependencyAttributes(args, data_deps_delegate) |
425 | 462 |
426 self._annotations = None | 463 self._annotations = None |
427 self._excluded_annotations = None | 464 self._excluded_annotations = None |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 error_func('Unable to find test APK: %s' % self._test_apk.path) | 551 error_func('Unable to find test APK: %s' % self._test_apk.path) |
515 if not self._test_jar: | 552 if not self._test_jar: |
516 logging.warning('Test jar not specified. Test runner will not have ' | 553 logging.warning('Test jar not specified. Test runner will not have ' |
517 'Java annotation info available. May not handle test ' | 554 'Java annotation info available. May not handle test ' |
518 'timeouts correctly.') | 555 'timeouts correctly.') |
519 elif not os.path.exists(self._test_jar): | 556 elif not os.path.exists(self._test_jar): |
520 error_func('Unable to find test JAR: %s' % self._test_jar) | 557 error_func('Unable to find test JAR: %s' % self._test_jar) |
521 | 558 |
522 self._test_package = self._test_apk.GetPackageName() | 559 self._test_package = self._test_apk.GetPackageName() |
523 all_instrumentations = self._test_apk.GetAllInstrumentations() | 560 all_instrumentations = self._test_apk.GetAllInstrumentations() |
524 test_runners = [ | 561 all_junit3_runner_classes = [ |
525 x for x in all_instrumentations if ('true' not in x.get( | 562 x for x in all_instrumentations if ('true' not in x.get( |
526 'chromium-junit4', ''))] | 563 'chromium-junit4', ''))] |
527 test_runners_junit4 = [ | 564 all_junit4_test_runner_classes = [ |
528 x for x in all_instrumentations if ('true' in x.get( | 565 x for x in all_instrumentations if ('true' in x.get( |
529 'chromium-junit4', ''))] | 566 'chromium-junit4', ''))] |
530 | 567 |
531 if len(test_runners) > 1: | 568 if len(all_junit3_runner_classes) > 1: |
532 logging.warning('This test apk has more than one JUnit3 instrumentation') | 569 logging.warning('This test apk has more than one JUnit3 instrumentation') |
533 if len(test_runners_junit4) > 1: | 570 if len(all_junit4_test_runner_classes) > 1: |
534 logging.warning('This test apk has more than one JUnit4 instrumentation') | 571 logging.warning('This test apk has more than one JUnit4 instrumentation') |
535 | 572 |
536 self._test_runner = ( | 573 self._junit3_runner_class = ( |
537 test_runners[0]['android:name'] if test_runners else | 574 all_junit3_runner_classes[0]['android:name'] |
538 self.test_apk.GetInstrumentationName()) | 575 if all_junit3_runner_classes else self.test_apk.GetInstrumentationName()) |
539 self._test_runner_junit4 = ( | 576 |
540 test_runners_junit4[0]['android:name'] if test_runners_junit4 else None) | 577 self._junit4_runner_class = ( |
| 578 all_junit4_test_runner_classes[0]['android:name'] |
| 579 if all_junit4_test_runner_classes else None) |
541 | 580 |
542 self._package_info = None | 581 self._package_info = None |
543 if self._apk_under_test: | 582 if self._apk_under_test: |
544 package_under_test = self._apk_under_test.GetPackageName() | 583 package_under_test = self._apk_under_test.GetPackageName() |
545 for package_info in constants.PACKAGE_INFO.itervalues(): | 584 for package_info in constants.PACKAGE_INFO.itervalues(): |
546 if package_under_test == package_info.package: | 585 if package_under_test == package_info.package: |
547 self._package_info = package_info | 586 self._package_info = package_info |
548 break | 587 break |
549 if not self._package_info: | 588 if not self._package_info: |
550 logging.warning('Unable to find package info for %s', self._test_package) | 589 logging.warning('Unable to find package info for %s', self._test_package) |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 | 723 |
685 @property | 724 @property |
686 def flags(self): | 725 def flags(self): |
687 return self._flags | 726 return self._flags |
688 | 727 |
689 @property | 728 @property |
690 def gs_results_bucket(self): | 729 def gs_results_bucket(self): |
691 return self._gs_results_bucket | 730 return self._gs_results_bucket |
692 | 731 |
693 @property | 732 @property |
| 733 def junit3_runner_class(self): |
| 734 return self._junit3_runner_class |
| 735 |
| 736 @property |
| 737 def junit4_runner_class(self): |
| 738 return self._junit4_runner_class |
| 739 |
| 740 @property |
694 def should_save_logcat(self): | 741 def should_save_logcat(self): |
695 return self._should_save_logcat | 742 return self._should_save_logcat |
696 | 743 |
697 @property | 744 @property |
698 def package_info(self): | 745 def package_info(self): |
699 return self._package_info | 746 return self._package_info |
700 | 747 |
701 @property | 748 @property |
702 def render_results_dir(self): | 749 def render_results_dir(self): |
703 return self._render_results_dir | 750 return self._render_results_dir |
(...skipping 28 matching lines...) Expand all Loading... |
732 | 779 |
733 @property | 780 @property |
734 def test_support_apk(self): | 781 def test_support_apk(self): |
735 return self._test_support_apk | 782 return self._test_support_apk |
736 | 783 |
737 @property | 784 @property |
738 def test_package(self): | 785 def test_package(self): |
739 return self._test_package | 786 return self._test_package |
740 | 787 |
741 @property | 788 @property |
742 def test_runner(self): | |
743 return self._test_runner | |
744 | |
745 @property | |
746 def test_runner_junit4(self): | |
747 return self._test_runner_junit4 | |
748 | |
749 @property | |
750 def timeout_scale(self): | 789 def timeout_scale(self): |
751 return self._timeout_scale | 790 return self._timeout_scale |
752 | 791 |
753 @property | 792 @property |
754 def total_external_shards(self): | 793 def total_external_shards(self): |
755 return self._total_external_shards | 794 return self._total_external_shards |
756 | 795 |
757 @property | 796 @property |
758 def ui_screenshot_dir(self): | 797 def ui_screenshot_dir(self): |
759 return self._ui_screenshot_dir | 798 return self._ui_screenshot_dir |
760 | 799 |
761 #override | 800 #override |
762 def TestType(self): | 801 def TestType(self): |
763 return 'instrumentation' | 802 return 'instrumentation' |
764 | 803 |
765 #override | 804 #override |
766 def SetUp(self): | 805 def SetUp(self): |
767 self._data_deps.extend( | 806 self._data_deps.extend( |
768 self._data_deps_delegate(self._runtime_deps_path)) | 807 self._data_deps_delegate(self._runtime_deps_path)) |
769 | 808 |
770 def GetDataDependencies(self): | 809 def GetDataDependencies(self): |
771 return self._data_deps | 810 return self._data_deps |
772 | 811 |
773 def GetTests(self): | 812 def GetTests(self): |
774 if self.test_jar: | 813 if self.test_jar: |
775 tests = GetAllTestsFromJar(self.test_jar) | 814 raw_tests = GetAllTestsFromJar(self.test_jar) |
776 else: | 815 else: |
777 tests = GetAllTestsFromApk(self.test_apk.path) | 816 raw_tests = GetAllTestsFromApk(self.test_apk.path) |
778 inflated_tests = self._ParameterizeTestsWithFlags(self._InflateTests(tests)) | 817 return self.ProcessRawTests(raw_tests) |
779 if self._test_runner_junit4 is None and any( | 818 |
| 819 def ProcessRawTests(self, raw_tests): |
| 820 inflated_tests = self._ParameterizeTestsWithFlags( |
| 821 self._InflateTests(raw_tests)) |
| 822 if self._junit4_runner_class is None and any( |
780 t['is_junit4'] for t in inflated_tests): | 823 t['is_junit4'] for t in inflated_tests): |
781 raise MissingJUnit4RunnerException() | 824 raise MissingJUnit4RunnerException() |
782 filtered_tests = FilterTests( | 825 filtered_tests = FilterTests( |
783 inflated_tests, self._test_filter, self._annotations, | 826 inflated_tests, self._test_filter, self._annotations, |
784 self._excluded_annotations) | 827 self._excluded_annotations) |
785 if self._test_filter and not filtered_tests: | 828 if self._test_filter and not filtered_tests: |
786 for t in inflated_tests: | 829 for t in inflated_tests: |
787 logging.debug(' %s', GetUniqueTestName(t)) | 830 logging.debug(' %s', GetUniqueTestName(t)) |
788 raise UnmatchedFilterException(self._test_filter) | 831 raise UnmatchedFilterException(self._test_filter) |
789 return filtered_tests | 832 return filtered_tests |
(...skipping 26 matching lines...) Expand all Loading... |
816 for p in parameters[1:]: | 859 for p in parameters[1:]: |
817 parameterized_t = copy.copy(t) | 860 parameterized_t = copy.copy(t) |
818 parameterized_t['flags'] = ['--%s' % p] | 861 parameterized_t['flags'] = ['--%s' % p] |
819 new_tests.append(parameterized_t) | 862 new_tests.append(parameterized_t) |
820 return tests + new_tests | 863 return tests + new_tests |
821 | 864 |
822 def GetDriverEnvironmentVars( | 865 def GetDriverEnvironmentVars( |
823 self, test_list=None, test_list_file_path=None): | 866 self, test_list=None, test_list_file_path=None): |
824 env = { | 867 env = { |
825 _EXTRA_DRIVER_TARGET_PACKAGE: self.test_package, | 868 _EXTRA_DRIVER_TARGET_PACKAGE: self.test_package, |
826 _EXTRA_DRIVER_TARGET_CLASS: self.test_runner, | 869 _EXTRA_DRIVER_TARGET_CLASS: self.junit3_runner_class, |
827 _EXTRA_TIMEOUT_SCALE: self._timeout_scale, | 870 _EXTRA_TIMEOUT_SCALE: self._timeout_scale, |
828 } | 871 } |
829 | 872 |
830 if test_list: | 873 if test_list: |
831 env[_EXTRA_DRIVER_TEST_LIST] = ','.join(test_list) | 874 env[_EXTRA_DRIVER_TEST_LIST] = ','.join(test_list) |
832 | 875 |
833 if test_list_file_path: | 876 if test_list_file_path: |
834 env[_EXTRA_DRIVER_TEST_LIST_FILE] = ( | 877 env[_EXTRA_DRIVER_TEST_LIST_FILE] = ( |
835 os.path.basename(test_list_file_path)) | 878 os.path.basename(test_list_file_path)) |
836 | 879 |
837 return env | 880 return env |
838 | 881 |
839 @staticmethod | 882 @staticmethod |
840 def ParseAmInstrumentRawOutput(raw_output): | 883 def ParseAmInstrumentRawOutput(raw_output): |
841 return ParseAmInstrumentRawOutput(raw_output) | 884 return ParseAmInstrumentRawOutput(raw_output) |
842 | 885 |
843 @staticmethod | 886 @staticmethod |
844 def GenerateTestResults( | 887 def GenerateTestResults( |
845 result_code, result_bundle, statuses, start_ms, duration_ms): | 888 result_code, result_bundle, statuses, start_ms, duration_ms): |
846 return GenerateTestResults(result_code, result_bundle, statuses, | 889 return GenerateTestResults(result_code, result_bundle, statuses, |
847 start_ms, duration_ms) | 890 start_ms, duration_ms) |
848 | 891 |
849 #override | 892 #override |
850 def TearDown(self): | 893 def TearDown(self): |
851 pass | 894 pass |
OLD | NEW |