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 """Base class for Android Python-driven tests. | 5 """Base class for Android Python-driven tests. |
6 | 6 |
7 This test case is intended to serve as the base class for any Python-driven | 7 This test case is intended to serve as the base class for any Python-driven |
8 tests. It is similar to the Python unitttest module in that the user's tests | 8 tests. It is similar to the Python unitttest module in that the user's tests |
9 inherit from this case and add their tests in that case. | 9 inherit from this case and add their tests in that case. |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 fname: filename for the test (e.g. foo/bar/baz/tests/FooTest.py) | 71 fname: filename for the test (e.g. foo/bar/baz/tests/FooTest.py) |
72 suite: name of the Java test suite (e.g. FooTest) | 72 suite: name of the Java test suite (e.g. FooTest) |
73 test: name of the test method to run (e.g. testFooBar) | 73 test: name of the test method to run (e.g. testFooBar) |
74 | 74 |
75 Returns: | 75 Returns: |
76 TestRunResults object with a single test result. | 76 TestRunResults object with a single test result. |
77 """ | 77 """ |
78 test = self._ComposeFullTestName(fname, suite, test) | 78 test = self._ComposeFullTestName(fname, suite, test) |
79 test_pkg = test_package.TestPackage( | 79 test_pkg = test_package.TestPackage( |
80 self.options.test_apk_path, self.options.test_apk_jar_path) | 80 self.options.test_apk_path, self.options.test_apk_jar_path) |
81 java_test_runner = test_runner.TestRunner(self.options, self.device_id, | 81 java_test_runner = test_runner.TestRunner(self.options.build_type, |
| 82 self.options.test_data, |
| 83 self.options.install_apk, |
| 84 self.options.save_perf_json, |
| 85 self.options.screenshot_failures, |
| 86 self.options.tool, |
| 87 self.options.wait_for_debugger, |
| 88 self.options.disable_assertions, |
| 89 self.options.push_deps, |
| 90 self.options.cleanup_test_files, |
| 91 self.device_id, |
82 self.shard_index, test_pkg, | 92 self.shard_index, test_pkg, |
83 self.ports_to_forward) | 93 self.ports_to_forward) |
84 try: | 94 try: |
85 java_test_runner.SetUp() | 95 java_test_runner.SetUp() |
86 return java_test_runner.RunTest(test)[0] | 96 return java_test_runner.RunTest(test)[0] |
87 finally: | 97 finally: |
88 java_test_runner.TearDown() | 98 java_test_runner.TearDown() |
89 | 99 |
90 def _RunJavaTests(self, fname, tests): | 100 def _RunJavaTests(self, fname, tests): |
91 """Calls a list of tests and stops at the first test failure. | 101 """Calls a list of tests and stops at the first test failure. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 135 |
126 def _ComposeFullTestName(self, fname, suite, test): | 136 def _ComposeFullTestName(self, fname, suite, test): |
127 package_name = self._GetPackageName(fname) | 137 package_name = self._GetPackageName(fname) |
128 return package_name + '.' + suite + '#' + test | 138 return package_name + '.' + suite + '#' + test |
129 | 139 |
130 def _GetPackageName(self, fname): | 140 def _GetPackageName(self, fname): |
131 """Extracts the package name from the test file path.""" | 141 """Extracts the package name from the test file path.""" |
132 dirname = os.path.dirname(fname) | 142 dirname = os.path.dirname(fname) |
133 package = dirname[dirname.rfind(BASE_ROOT) + len(BASE_ROOT):] | 143 package = dirname[dirname.rfind(BASE_ROOT) + len(BASE_ROOT):] |
134 return package.replace(os.sep, '.') | 144 return package.replace(os.sep, '.') |
OLD | NEW |