| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Base class for host-driven test cases. | 5 """Base class for host-driven test cases. |
| 6 | 6 |
| 7 This test case is intended to serve as the base class for any host-driven | 7 This test case is intended to serve as the base class for any host-driven |
| 8 test cases. It is similar to the Python unitttest module in that test cases | 8 test cases. It is similar to the Python unitttest module in that test cases |
| 9 inherit from this class and add methods which will be run as tests. | 9 inherit from this class and add methods which will be run as tests. |
| 10 | 10 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 test_filters: A list of Java test filters. | 139 test_filters: A list of Java test filters. |
| 140 additional_flags: A list of addition flags to add to the command line. | 140 additional_flags: A list of addition flags to add to the command line. |
| 141 | 141 |
| 142 Returns: | 142 Returns: |
| 143 A TestRunResults object containing an overall result for this set of Java | 143 A TestRunResults object containing an overall result for this set of Java |
| 144 tests. If any Java tests do not pass, this is a fail overall. | 144 tests. If any Java tests do not pass, this is a fail overall. |
| 145 """ | 145 """ |
| 146 test_type = base_test_result.ResultType.PASS | 146 test_type = base_test_result.ResultType.PASS |
| 147 log = '' | 147 log = '' |
| 148 | 148 |
| 149 opts = self.instrumentation_options |
| 149 test_pkg = test_package.TestPackage( | 150 test_pkg = test_package.TestPackage( |
| 150 self.instrumentation_options.test_apk_path, | 151 opts.test_apk_path, |
| 151 self.instrumentation_options.test_apk_jar_path, | 152 opts.test_apk_jar_path, |
| 152 self.instrumentation_options.test_support_apk_path) | 153 opts.test_support_apk_path, |
| 154 test_apk_install_script=opts.test_apk_install_script) |
| 153 | 155 |
| 154 start_ms = int(time.time()) * 1000 | 156 start_ms = int(time.time()) * 1000 |
| 155 done = False | 157 done = False |
| 156 for test_filter in test_filters: | 158 for test_filter in test_filters: |
| 157 tests = test_pkg.GetAllMatchingTests( | 159 tests = test_pkg.GetAllMatchingTests( |
| 158 None, None, test_filter, [self.device]) | 160 None, None, test_filter, [self.device]) |
| 159 # Filters should always result in >= 1 test. | 161 # Filters should always result in >= 1 test. |
| 160 if len(tests) == 0: | 162 if len(tests) == 0: |
| 161 raise Exception('Java test filter "%s" returned no tests.' | 163 raise Exception('Java test filter "%s" returned no tests.' |
| 162 % test_filter) | 164 % test_filter) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 180 overall_result.AddResult( | 182 overall_result.AddResult( |
| 181 test_result.InstrumentationTestResult( | 183 test_result.InstrumentationTestResult( |
| 182 self.tagged_name, test_type, start_ms, duration_ms, log=log)) | 184 self.tagged_name, test_type, start_ms, duration_ms, log=log)) |
| 183 return overall_result | 185 return overall_result |
| 184 | 186 |
| 185 def __str__(self): | 187 def __str__(self): |
| 186 return self.tagged_name | 188 return self.tagged_name |
| 187 | 189 |
| 188 def __repr__(self): | 190 def __repr__(self): |
| 189 return self.tagged_name | 191 return self.tagged_name |
| OLD | NEW |