OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" | 5 """Runs the Java tests. See more information on run_instrumentation_tests.py.""" |
6 | 6 |
7 import fnmatch | 7 import fnmatch |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 has_match = has_match or fnmatch.fnmatch(_TestNameToExpectation(t), | 58 has_match = has_match or fnmatch.fnmatch(_TestNameToExpectation(t), |
59 pattern) | 59 pattern) |
60 if has_match == inclusive: | 60 if has_match == inclusive: |
61 ret += [t] | 61 ret += [t] |
62 return ret | 62 return ret |
63 | 63 |
64 | 64 |
65 class TestRunner(BaseTestRunner): | 65 class TestRunner(BaseTestRunner): |
66 """Responsible for running a series of tests connected to a single device.""" | 66 """Responsible for running a series of tests connected to a single device.""" |
67 | 67 |
68 _DEVICE_DATA_DIR = constants.TEST_DATA_DIR + '/chrome/test/data' | 68 _DEVICE_DATA_DIR = 'chrome/test/data' |
69 _EMMA_JAR = os.path.join(os.environ.get('ANDROID_BUILD_TOP', ''), | 69 _EMMA_JAR = os.path.join(os.environ.get('ANDROID_BUILD_TOP', ''), |
70 'external/emma/lib/emma.jar') | 70 'external/emma/lib/emma.jar') |
71 _COVERAGE_MERGED_FILENAME = 'unittest_coverage.es' | 71 _COVERAGE_MERGED_FILENAME = 'unittest_coverage.es' |
72 _COVERAGE_WEB_ROOT_DIR = os.environ.get('EMMA_WEB_ROOTDIR') | 72 _COVERAGE_WEB_ROOT_DIR = os.environ.get('EMMA_WEB_ROOTDIR') |
73 _COVERAGE_FILENAME = 'coverage.ec' | 73 _COVERAGE_FILENAME = 'coverage.ec' |
74 _COVERAGE_RESULT_PATH = ('/data/data/com.google.android.apps.chrome/files/' + | 74 _COVERAGE_RESULT_PATH = ('/data/data/com.google.android.apps.chrome/files/' + |
75 _COVERAGE_FILENAME) | 75 _COVERAGE_FILENAME) |
76 _COVERAGE_META_INFO_PATH = os.path.join(os.environ.get('ANDROID_BUILD_TOP', | 76 _COVERAGE_META_INFO_PATH = os.path.join(os.environ.get('ANDROID_BUILD_TOP', |
77 ''), | 77 ''), |
78 'out/target/common/obj/APPS', | 78 'out/target/common/obj/APPS', |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 def CopyTestFilesOnce(self): | 159 def CopyTestFilesOnce(self): |
160 """Pushes the test data files to the device. Installs the apk if opted.""" | 160 """Pushes the test data files to the device. Installs the apk if opted.""" |
161 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): | 161 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): |
162 logging.warning('Already copied test files to device %s, skipping.', | 162 logging.warning('Already copied test files to device %s, skipping.', |
163 self.device) | 163 self.device) |
164 return | 164 return |
165 host_test_files_path = (constants.CHROME_DIR + | 165 host_test_files_path = (constants.CHROME_DIR + |
166 '/chrome/test/data/android/device_files') | 166 '/chrome/test/data/android/device_files') |
167 if os.path.exists(host_test_files_path): | 167 if os.path.exists(host_test_files_path): |
168 self.adb.PushIfNeeded(host_test_files_path, | 168 self.adb.PushIfNeeded(host_test_files_path, |
| 169 self.adb.GetExternalStorage() + '/' + |
169 TestRunner._DEVICE_DATA_DIR) | 170 TestRunner._DEVICE_DATA_DIR) |
170 if self.install_apk: | 171 if self.install_apk: |
171 for apk in self.apks: | 172 for apk in self.apks: |
172 self.adb.ManagedInstall(apk.GetApkPath(), | 173 self.adb.ManagedInstall(apk.GetApkPath(), |
173 package_name=apk.GetPackageName()) | 174 package_name=apk.GetPackageName()) |
174 self.tool.CopyFiles() | 175 self.tool.CopyFiles() |
175 TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True | 176 TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True |
176 | 177 |
177 def SaveCoverageData(self, test): | 178 def SaveCoverageData(self, test): |
178 """Saves the Emma coverage data before it's overwritten by the next test. | 179 """Saves the Emma coverage data before it's overwritten by the next test. |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 | 582 |
582 logging.info('Will run: %s', str(tests)) | 583 logging.info('Will run: %s', str(tests)) |
583 | 584 |
584 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): | 585 if len(attached_devices) > 1 and (coverage or options.wait_for_debugger): |
585 logging.warning('Coverage / debugger can not be sharded, ' | 586 logging.warning('Coverage / debugger can not be sharded, ' |
586 'using first available device') | 587 'using first available device') |
587 attached_devices = attached_devices[:1] | 588 attached_devices = attached_devices[:1] |
588 sharder = TestSharder(attached_devices, options, tests, apks) | 589 sharder = TestSharder(attached_devices, options, tests, apks) |
589 test_results = sharder.RunShardedTests() | 590 test_results = sharder.RunShardedTests() |
590 return test_results | 591 return test_results |
OLD | NEW |