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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, self.device_id, |
82 self.shard_index, False, | 82 self.shard_index, test_pkg, |
83 test_pkg, | |
84 self.ports_to_forward) | 83 self.ports_to_forward) |
85 try: | 84 try: |
86 java_test_runner.SetUp() | 85 java_test_runner.SetUp() |
87 return java_test_runner.RunTest(test)[0] | 86 return java_test_runner.RunTest(test)[0] |
88 finally: | 87 finally: |
89 java_test_runner.TearDown() | 88 java_test_runner.TearDown() |
90 | 89 |
91 def _RunJavaTests(self, fname, tests): | 90 def _RunJavaTests(self, fname, tests): |
92 """Calls a list of tests and stops at the first test failure. | 91 """Calls a list of tests and stops at the first test failure. |
93 | 92 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 125 |
127 def _ComposeFullTestName(self, fname, suite, test): | 126 def _ComposeFullTestName(self, fname, suite, test): |
128 package_name = self._GetPackageName(fname) | 127 package_name = self._GetPackageName(fname) |
129 return package_name + '.' + suite + '#' + test | 128 return package_name + '.' + suite + '#' + test |
130 | 129 |
131 def _GetPackageName(self, fname): | 130 def _GetPackageName(self, fname): |
132 """Extracts the package name from the test file path.""" | 131 """Extracts the package name from the test file path.""" |
133 dirname = os.path.dirname(fname) | 132 dirname = os.path.dirname(fname) |
134 package = dirname[dirname.rfind(BASE_ROOT) + len(BASE_ROOT):] | 133 package = dirname[dirname.rfind(BASE_ROOT) + len(BASE_ROOT):] |
135 return package.replace(os.sep, '.') | 134 return package.replace(os.sep, '.') |
OLD | NEW |