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.instrumentation import test_options as instr_test_options | 9 from pylib.instrumentation import test_options as instr_test_options |
9 from pylib.instrumentation import test_runner as instr_test_runner | 10 from pylib.instrumentation import test_runner as instr_test_runner |
10 | 11 |
11 | 12 |
12 class TestRunner(instr_test_runner.TestRunner): | 13 class TestRunner(instr_test_runner.TestRunner): |
13 """Responsible for running a series of tests connected to a single device.""" | 14 """Responsible for running a series of tests connected to a single device.""" |
14 | 15 |
15 def __init__(self, test_options, device, shard_index, test_pkg): | 16 def __init__(self, test_options, device, shard_index, test_pkg): |
16 """Create a new TestRunner. | 17 """Create a new TestRunner. |
17 | 18 |
(...skipping 15 matching lines...) Expand all Loading... |
33 test_options.save_perf_json, | 34 test_options.save_perf_json, |
34 test_options.screenshot_failures, | 35 test_options.screenshot_failures, |
35 wait_for_debugger=False, | 36 wait_for_debugger=False, |
36 coverage_dir=None, | 37 coverage_dir=None, |
37 test_apk=None, | 38 test_apk=None, |
38 test_apk_path=None, | 39 test_apk_path=None, |
39 test_apk_jar_path=None) | 40 test_apk_jar_path=None) |
40 super(TestRunner, self).__init__(instrumentation_options, device, | 41 super(TestRunner, self).__init__(instrumentation_options, device, |
41 shard_index, test_pkg) | 42 shard_index, test_pkg) |
42 | 43 |
| 44 cmdline_file = constants.PACKAGE_INFO[test_options.package].cmdline_file |
| 45 self.flags = None |
| 46 if cmdline_file: |
| 47 self.flags = flag_changer.FlagChanger(self.adb, cmdline_file) |
43 self._package = constants.PACKAGE_INFO[test_options.package].package | 48 self._package = constants.PACKAGE_INFO[test_options.package].package |
44 self._activity = constants.PACKAGE_INFO[test_options.package].activity | 49 self._activity = constants.PACKAGE_INFO[test_options.package].activity |
45 | 50 |
46 #override | 51 #override |
47 def InstallTestPackage(self): | 52 def InstallTestPackage(self): |
48 self.test_pkg.Install(self.adb) | 53 self.test_pkg.Install(self.adb) |
49 | 54 |
50 #override | 55 #override |
51 def PushDataDeps(self): | 56 def PushDataDeps(self): |
52 pass | 57 pass |
53 | 58 |
54 #override | 59 #override |
55 def _RunTest(self, test, timeout): | 60 def _RunTest(self, test, timeout): |
56 self.adb.ClearApplicationState(self._package) | 61 self.adb.ClearApplicationState(self._package) |
57 if self.flags: | 62 if self.flags: |
58 if 'Feature:FirstRunExperience' in self.test_pkg.GetTestAnnotations(test): | 63 if 'Feature:FirstRunExperience' in self.test_pkg.GetTestAnnotations(test): |
59 self.flags.RemoveFlags(['--disable-fre']) | 64 self.flags.RemoveFlags(['--disable-fre']) |
60 else: | 65 else: |
61 self.flags.AddFlags(['--disable-fre']) | 66 self.flags.AddFlags(['--disable-fre']) |
62 self.adb.StartActivity(self._package, | 67 self.adb.StartActivity(self._package, |
63 self._activity, | 68 self._activity, |
64 wait_for_completion=True, | 69 wait_for_completion=True, |
65 action='android.intent.action.MAIN', | 70 action='android.intent.action.MAIN', |
66 force_stop=True) | 71 force_stop=True) |
67 return self.adb.RunUIAutomatorTest( | 72 return self.adb.RunUIAutomatorTest( |
68 test, self.test_pkg.GetPackageName(), timeout) | 73 test, self.test_pkg.GetPackageName(), timeout) |
OLD | NEW |