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 |
11 When a HostDrivenTestCase object is instantiated, its purpose is to run only one | 11 When a HostDrivenTestCase object is instantiated, its purpose is to run only one |
12 test method in the derived class. The test runner gives it the name of the test | 12 test method in the derived class. The test runner gives it the name of the test |
13 method the instance will run. The test runner calls SetUp with the device ID | 13 method the instance will run. The test runner calls SetUp with the device ID |
14 which the test method will run against. The test runner runs the test method | 14 which the test method will run against. The test runner runs the test method |
15 itself, collecting the result, and calls TearDown. | 15 itself, collecting the result, and calls TearDown. |
16 | 16 |
17 Tests can perform arbitrary Python commands and asserts in test methods. Tests | 17 Tests can perform arbitrary Python commands and asserts in test methods. Tests |
18 that run instrumentation tests can make use of the _RunJavaTestFilters helper | 18 that run instrumentation tests can make use of the _RunJavaTestFilters helper |
19 function to trigger Java tests and convert results into a single host-driven | 19 function to trigger Java tests and convert results into a single host-driven |
20 test result. | 20 test result. |
21 """ | 21 """ |
22 | 22 |
23 import logging | 23 import logging |
24 import os | 24 import os |
25 import time | 25 import time |
26 | 26 |
| 27 from devil.android import device_utils |
27 from pylib import constants | 28 from pylib import constants |
28 from pylib import forwarder | 29 from pylib import forwarder |
29 from pylib import valgrind_tools | 30 from pylib import valgrind_tools |
30 from pylib.base import base_test_result | 31 from pylib.base import base_test_result |
31 from pylib.device import device_utils | |
32 from pylib.instrumentation import test_package | 32 from pylib.instrumentation import test_package |
33 from pylib.instrumentation import test_result | 33 from pylib.instrumentation import test_result |
34 from pylib.instrumentation import test_runner | 34 from pylib.instrumentation import test_runner |
35 | 35 |
36 # aka the parent of com.google.android | 36 # aka the parent of com.google.android |
37 BASE_ROOT = 'src' + os.sep | 37 BASE_ROOT = 'src' + os.sep |
38 | 38 |
39 | 39 |
40 class HostDrivenTestCase(object): | 40 class HostDrivenTestCase(object): |
41 """Base class for host-driven test cases.""" | 41 """Base class for host-driven test cases.""" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 overall_result.AddResult( | 181 overall_result.AddResult( |
182 test_result.InstrumentationTestResult( | 182 test_result.InstrumentationTestResult( |
183 self.tagged_name, test_type, start_ms, duration_ms, log=log)) | 183 self.tagged_name, test_type, start_ms, duration_ms, log=log)) |
184 return overall_result | 184 return overall_result |
185 | 185 |
186 def __str__(self): | 186 def __str__(self): |
187 return self.tagged_name | 187 return self.tagged_name |
188 | 188 |
189 def __repr__(self): | 189 def __repr__(self): |
190 return self.tagged_name | 190 return self.tagged_name |
OLD | NEW |