| 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.instrumentation import test_runner as instr_test_runner | 7 from pylib.instrumentation import test_runner as instr_test_runner |
| 8 from pylib.test_options import InstrumentationOptions |
| 8 | 9 |
| 9 | 10 |
| 10 class TestRunner(instr_test_runner.TestRunner): | 11 class TestRunner(instr_test_runner.TestRunner): |
| 11 """Responsible for running a series of tests connected to a single device.""" | 12 """Responsible for running a series of tests connected to a single device.""" |
| 12 | 13 |
| 13 def __init__(self, package_name, build_type, test_data, save_perf_json, | 14 def __init__(self, test_options, device, shard_index, test_pkg, |
| 14 screenshot_failures, tool, wait_for_debugger, | 15 ports_to_forward): |
| 15 disable_assertions, push_deps, cleanup_test_files, device, | |
| 16 shard_index, test_pkg, ports_to_forward): | |
| 17 """Create a new TestRunner. | 16 """Create a new TestRunner. |
| 18 | 17 |
| 19 Args: | 18 Args: |
| 20 package_name: Application package name under test. | 19 test_options: A UIAutomatorOptions object containing the set of options |
| 21 See the super class for all other args. | 20 relevant to running instrumentation tests. |
| 21 device: Attached android device. |
| 22 shard_index: Shard index. |
| 23 test_pkg: A TestPackage object. |
| 24 ports_to_forward: A list of port numbers for which to set up forwarders. |
| 25 Can be optionally requested by a test case. |
| 22 """ | 26 """ |
| 23 super(TestRunner, self).__init__( | 27 # Create an InstrumentationOptions object to pass to the super class |
| 24 build_type, test_data, False, save_perf_json, screenshot_failures, tool, | 28 instrumentation_options = InstrumentationOptions( |
| 25 wait_for_debugger, disable_assertions, push_deps, cleanup_test_files, | 29 test_options.build_type, |
| 26 device, shard_index, test_pkg, ports_to_forward) | 30 test_options.annotations, |
| 31 test_options.exclude_annotations, |
| 32 test_options.test_filter, |
| 33 test_options.test_data, |
| 34 test_options.save_perf_json, |
| 35 test_options.screenshot_failures, |
| 36 test_options.tool, |
| 37 test_options.disable_assertions, |
| 38 test_options.push_deps, |
| 39 test_options.cleanup_test_filters, |
| 40 wait_for_debugger=False, |
| 41 install_apk=False, |
| 42 test_apk=None) |
| 43 super(TestRunner, self).__init__(instrumentation_options, device, |
| 44 shard_index, test_pkg, ports_to_forward) |
| 27 | 45 |
| 28 self.package_name = package_name | 46 self.package_name = test_options.package_name |
| 29 | 47 |
| 30 #override | 48 #override |
| 31 def InstallTestPackage(self): | 49 def InstallTestPackage(self): |
| 32 self.test_pkg.Install(self.adb) | 50 self.test_pkg.Install(self.adb) |
| 33 | 51 |
| 34 #override | 52 #override |
| 35 def PushDataDeps(self): | 53 def PushDataDeps(self): |
| 36 pass | 54 pass |
| 37 | 55 |
| 38 #override | 56 #override |
| 39 def _RunTest(self, test, timeout): | 57 def _RunTest(self, test, timeout): |
| 40 self.adb.ClearApplicationState(self.package_name) | 58 self.adb.ClearApplicationState(self.package_name) |
| 41 if 'Feature:FirstRunExperience' in self.test_pkg.GetTestAnnotations(test): | 59 if 'Feature:FirstRunExperience' in self.test_pkg.GetTestAnnotations(test): |
| 42 self.flags.RemoveFlags(['--disable-fre']) | 60 self.flags.RemoveFlags(['--disable-fre']) |
| 43 else: | 61 else: |
| 44 self.flags.AddFlags(['--disable-fre']) | 62 self.flags.AddFlags(['--disable-fre']) |
| 45 return self.adb.RunUIAutomatorTest( | 63 return self.adb.RunUIAutomatorTest( |
| 46 test, self.test_pkg.GetPackageName(), timeout) | 64 test, self.test_pkg.GetPackageName(), timeout) |
| OLD | NEW |