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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 # tests in the overall results. | 61 # tests in the overall results. |
62 self.test_name = test_name | 62 self.test_name = test_name |
63 self.qualified_name = '%s.%s' % (class_name, self.test_name) | 63 self.qualified_name = '%s.%s' % (class_name, self.test_name) |
64 self.tagged_name = '%s_%s' % (self._HOST_DRIVEN_TAG, self.qualified_name) | 64 self.tagged_name = '%s_%s' % (self._HOST_DRIVEN_TAG, self.qualified_name) |
65 | 65 |
66 # TODO(bulach): make ports_to_forward not optional and move the Forwarder | 66 # TODO(bulach): make ports_to_forward not optional and move the Forwarder |
67 # mapping here. | 67 # mapping here. |
68 def SetUp(self, device, shard_index, ports_to_forward=None): | 68 def SetUp(self, device, shard_index, ports_to_forward=None): |
69 if not ports_to_forward: | 69 if not ports_to_forward: |
70 ports_to_forward = [] | 70 ports_to_forward = [] |
71 self.device_id = device | 71 self.device = device |
72 self.shard_index = shard_index | 72 self.shard_index = shard_index |
73 self.device = device_utils.DeviceUtils(self.device_id) | 73 self.device_id = str(self.device) |
74 if ports_to_forward: | 74 if ports_to_forward: |
75 self.ports_to_forward = ports_to_forward | 75 self.ports_to_forward = ports_to_forward |
76 | 76 |
77 def TearDown(self): | 77 def TearDown(self): |
78 pass | 78 pass |
79 | 79 |
80 # TODO(craigdh): Remove GetOutDir once references have been removed | 80 # TODO(craigdh): Remove GetOutDir once references have been removed |
81 # downstream. | 81 # downstream. |
82 @staticmethod | 82 @staticmethod |
83 def GetOutDir(): | 83 def GetOutDir(): |
(...skipping 26 matching lines...) Expand all Loading... |
110 test: Fully qualified test name (ex. foo.bar.TestClass#testMethod) | 110 test: Fully qualified test name (ex. foo.bar.TestClass#testMethod) |
111 test_pkg: TestPackage object. | 111 test_pkg: TestPackage object. |
112 additional_flags: A list of additional flags to add to the command line. | 112 additional_flags: A list of additional flags to add to the command line. |
113 | 113 |
114 Returns: | 114 Returns: |
115 TestRunResults object with a single test result. | 115 TestRunResults object with a single test result. |
116 """ | 116 """ |
117 # TODO(bulach): move this to SetUp() stage. | 117 # TODO(bulach): move this to SetUp() stage. |
118 self.__StartForwarder() | 118 self.__StartForwarder() |
119 | 119 |
120 java_test_runner = test_runner.TestRunner(self.instrumentation_options, | 120 java_test_runner = test_runner.TestRunner( |
121 self.device_id, | 121 self.instrumentation_options, self.device, self.shard_index, |
122 self.shard_index, test_pkg, | 122 test_pkg, additional_flags=additional_flags) |
123 additional_flags=additional_flags) | |
124 try: | 123 try: |
125 java_test_runner.SetUp() | 124 java_test_runner.SetUp() |
126 return java_test_runner.RunTest(test)[0] | 125 return java_test_runner.RunTest(test)[0] |
127 finally: | 126 finally: |
128 java_test_runner.TearDown() | 127 java_test_runner.TearDown() |
129 | 128 |
130 def _RunJavaTestFilters(self, test_filters, additional_flags=None): | 129 def _RunJavaTestFilters(self, test_filters, additional_flags=None): |
131 """Calls a list of tests and stops at the first test failure. | 130 """Calls a list of tests and stops at the first test failure. |
132 | 131 |
133 This method iterates until either it encounters a non-passing test or it | 132 This method iterates until either it encounters a non-passing test or it |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 overall_result.AddResult( | 180 overall_result.AddResult( |
182 test_result.InstrumentationTestResult( | 181 test_result.InstrumentationTestResult( |
183 self.tagged_name, test_type, start_ms, duration_ms, log=log)) | 182 self.tagged_name, test_type, start_ms, duration_ms, log=log)) |
184 return overall_result | 183 return overall_result |
185 | 184 |
186 def __str__(self): | 185 def __str__(self): |
187 return self.tagged_name | 186 return self.tagged_name |
188 | 187 |
189 def __repr__(self): | 188 def __repr__(self): |
190 return self.tagged_name | 189 return self.tagged_name |
OLD | NEW |