OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 """Class for running uiautomator tests on a single device.""" | 5 """Class for running uiautomator tests on a single device.""" |
6 | 6 |
7 from pylib import constants | 7 from pylib import constants |
8 from pylib import flag_changer | 8 from pylib import flag_changer |
9 from pylib.device import intent | 9 from pylib.device import intent |
10 from pylib.instrumentation import test_options as instr_test_options | 10 from pylib.instrumentation import test_options as instr_test_options |
11 from pylib.instrumentation import test_runner as instr_test_runner | 11 from pylib.instrumentation import test_runner as instr_test_runner |
12 | 12 |
13 | 13 |
14 class TestRunner(instr_test_runner.TestRunner): | 14 class TestRunner(instr_test_runner.TestRunner): |
15 """Responsible for running a series of tests connected to a single device.""" | 15 """Responsible for running a series of tests connected to a single device.""" |
16 | 16 |
17 def __init__(self, test_options, device, shard_index, test_pkg): | 17 def __init__(self, test_options, device, shard_index, test_pkg): |
18 """Create a new TestRunner. | 18 """Create a new TestRunner. |
19 | 19 |
20 Args: | 20 Args: |
21 test_options: A UIAutomatorOptions object. | 21 test_options: A UIAutomatorOptions object. |
22 device: Attached android device. | 22 device: Attached android device. |
23 shard_index: Shard index. | 23 shard_index: Shard index. |
24 test_pkg: A TestPackage object. | 24 test_pkg: A TestPackage object. |
25 """ | 25 """ |
26 # Create an InstrumentationOptions object to pass to the super class | 26 # Create an InstrumentationOptions object to pass to the super class |
27 instrumentation_options = instr_test_options.InstrumentationOptions( | 27 instrumentation_options = instr_test_options.InstrumentationOptions( |
28 test_options.tool, | 28 test_options.tool, |
29 test_options.cleanup_test_files, | 29 test_options.cleanup_test_files, |
30 test_options.push_deps, | |
31 test_options.annotations, | 30 test_options.annotations, |
32 test_options.exclude_annotations, | 31 test_options.exclude_annotations, |
33 test_options.test_filter, | 32 test_options.test_filter, |
34 test_options.test_data, | 33 test_options.test_data, |
35 test_options.save_perf_json, | 34 test_options.save_perf_json, |
36 test_options.screenshot_failures, | 35 test_options.screenshot_failures, |
37 wait_for_debugger=False, | 36 wait_for_debugger=False, |
38 coverage_dir=None, | 37 coverage_dir=None, |
39 test_apk=None, | 38 test_apk=None, |
40 test_apk_path=None, | 39 test_apk_path=None, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 cmd = ['uiautomator', 'runtest', self.test_pkg.GetPackageName(), | 76 cmd = ['uiautomator', 'runtest', self.test_pkg.GetPackageName(), |
78 '-e', 'class', test] | 77 '-e', 'class', test] |
79 return self.device.RunShellCommand(cmd, timeout=timeout, retries=0) | 78 return self.device.RunShellCommand(cmd, timeout=timeout, retries=0) |
80 | 79 |
81 #override | 80 #override |
82 def _GenerateTestResult(self, test, instr_statuses, start_ms, duration_ms): | 81 def _GenerateTestResult(self, test, instr_statuses, start_ms, duration_ms): |
83 # uiautomator emits its summary status with INSTRUMENTATION_STATUS_CODE, | 82 # uiautomator emits its summary status with INSTRUMENTATION_STATUS_CODE, |
84 # not INSTRUMENTATION_CODE, so we have to drop if off the list of statuses. | 83 # not INSTRUMENTATION_CODE, so we have to drop if off the list of statuses. |
85 return super(TestRunner, self)._GenerateTestResult( | 84 return super(TestRunner, self)._GenerateTestResult( |
86 test, instr_statuses[:-1], start_ms, duration_ms) | 85 test, instr_statuses[:-1], start_ms, duration_ms) |
OLD | NEW |