| 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 |
| 11 When a PythonTestBase object is instantiated, its purpose is to run only one of | 11 When a PythonTestBase object is instantiated, its purpose is to run only one of |
| 12 its tests. The test runner gives it the name of the test the instance will | 12 its tests. The test runner gives it the name of the test the instance will |
| 13 run. The test runner calls SetUp with the Android device ID which the test will | 13 run. The test runner calls SetUp with the Android device ID which the test will |
| 14 run against. The runner runs the test method itself, collecting the result, | 14 run against. The runner runs the test method itself, collecting the result, |
| 15 and calls TearDown. | 15 and calls TearDown. |
| 16 | 16 |
| 17 Tests can basically do whatever they want in the test methods, such as call | 17 Tests can basically do whatever they want in the test methods, such as call |
| 18 Java tests using _RunJavaTests. Those methods have the advantage of massaging | 18 Java tests using _RunJavaTests. Those methods have the advantage of massaging |
| 19 the Java test results into Python test results. | 19 the Java test results into Python test results. |
| 20 """ | 20 """ |
| 21 | 21 |
| 22 import logging | 22 import logging |
| 23 import os | 23 import os |
| 24 import time | 24 import time |
| 25 | 25 |
| 26 from pylib import android_commands | 26 from pylib import android_commands |
| 27 from pylib.base.test_result import SingleTestResult, TestResults |
| 27 from pylib.instrumentation import apk_info | 28 from pylib.instrumentation import apk_info |
| 28 from pylib.instrumentation.run_java_tests import TestRunner | 29 from pylib.instrumentation.run_java_tests import TestRunner |
| 29 from pylib.test_result import SingleTestResult, TestResults | |
| 30 | 30 |
| 31 | 31 |
| 32 # aka the parent of com.google.android | 32 # aka the parent of com.google.android |
| 33 BASE_ROOT = 'src' + os.sep | 33 BASE_ROOT = 'src' + os.sep |
| 34 | 34 |
| 35 | 35 |
| 36 class PythonTestBase(object): | 36 class PythonTestBase(object): |
| 37 """Base class for Python-driven tests.""" | 37 """Base class for Python-driven tests.""" |
| 38 | 38 |
| 39 def __init__(self, test_name): | 39 def __init__(self, test_name): |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 def _ComposeFullTestName(self, fname, suite, test): | 164 def _ComposeFullTestName(self, fname, suite, test): |
| 165 package_name = self._GetPackageName(fname) | 165 package_name = self._GetPackageName(fname) |
| 166 return package_name + '.' + suite + '#' + test | 166 return package_name + '.' + suite + '#' + test |
| 167 | 167 |
| 168 def _GetPackageName(self, fname): | 168 def _GetPackageName(self, fname): |
| 169 """Extracts the package name from the test file path.""" | 169 """Extracts the package name from the test file path.""" |
| 170 dirname = os.path.dirname(fname) | 170 dirname = os.path.dirname(fname) |
| 171 package = dirname[dirname.rfind(BASE_ROOT) + len(BASE_ROOT):] | 171 package = dirname[dirname.rfind(BASE_ROOT) + len(BASE_ROOT):] |
| 172 return package.replace(os.sep, '.') | 172 return package.replace(os.sep, '.') |
| OLD | NEW |