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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 test_options.test_data, | 34 test_options.test_data, |
35 test_options.save_perf_json, | 35 test_options.save_perf_json, |
36 test_options.screenshot_failures, | 36 test_options.screenshot_failures, |
37 wait_for_debugger=False, | 37 wait_for_debugger=False, |
38 coverage_dir=None, | 38 coverage_dir=None, |
39 test_apk=None, | 39 test_apk=None, |
40 test_apk_path=None, | 40 test_apk_path=None, |
41 test_apk_jar_path=None, | 41 test_apk_jar_path=None, |
42 test_runner=None, | 42 test_runner=None, |
43 test_support_apk_path=None, | 43 test_support_apk_path=None, |
44 device_flags=None) | 44 device_flags=None, |
| 45 isolate_file_path=None) |
45 super(TestRunner, self).__init__(instrumentation_options, device, | 46 super(TestRunner, self).__init__(instrumentation_options, device, |
46 shard_index, test_pkg) | 47 shard_index, test_pkg) |
47 | 48 |
48 cmdline_file = constants.PACKAGE_INFO[test_options.package].cmdline_file | 49 cmdline_file = constants.PACKAGE_INFO[test_options.package].cmdline_file |
49 self.flags = None | 50 self.flags = None |
50 if cmdline_file: | 51 if cmdline_file: |
51 self.flags = flag_changer.FlagChanger(self.device, cmdline_file) | 52 self.flags = flag_changer.FlagChanger(self.device, cmdline_file) |
52 self._package = constants.PACKAGE_INFO[test_options.package].package | 53 self._package = constants.PACKAGE_INFO[test_options.package].package |
53 self._activity = constants.PACKAGE_INFO[test_options.package].activity | 54 self._activity = constants.PACKAGE_INFO[test_options.package].activity |
54 | 55 |
55 #override | 56 #override |
56 def InstallTestPackage(self): | 57 def InstallTestPackage(self): |
57 self.test_pkg.Install(self.device) | 58 self.test_pkg.Install(self.device) |
58 | 59 |
59 #override | 60 #override |
60 def PushDataDeps(self): | |
61 pass | |
62 | |
63 #override | |
64 def _RunTest(self, test, timeout): | 61 def _RunTest(self, test, timeout): |
65 self.device.ClearApplicationState(self._package) | 62 self.device.ClearApplicationState(self._package) |
66 if self.flags: | 63 if self.flags: |
67 if 'Feature:FirstRunExperience' in self.test_pkg.GetTestAnnotations(test): | 64 if 'Feature:FirstRunExperience' in self.test_pkg.GetTestAnnotations(test): |
68 self.flags.RemoveFlags(['--disable-fre']) | 65 self.flags.RemoveFlags(['--disable-fre']) |
69 else: | 66 else: |
70 self.flags.AddFlags(['--disable-fre']) | 67 self.flags.AddFlags(['--disable-fre']) |
71 self.device.StartActivity( | 68 self.device.StartActivity( |
72 intent.Intent(action='android.intent.action.MAIN', | 69 intent.Intent(action='android.intent.action.MAIN', |
73 activity=self._activity, | 70 activity=self._activity, |
74 package=self._package), | 71 package=self._package), |
75 blocking=True, | 72 blocking=True, |
76 force_stop=True) | 73 force_stop=True) |
77 cmd = ['uiautomator', 'runtest', self.test_pkg.GetPackageName(), | 74 cmd = ['uiautomator', 'runtest', self.test_pkg.GetPackageName(), |
78 '-e', 'class', test] | 75 '-e', 'class', test] |
79 return self.device.RunShellCommand(cmd, timeout=timeout, retries=0) | 76 return self.device.RunShellCommand(cmd, timeout=timeout, retries=0) |
80 | 77 |
81 #override | 78 #override |
82 def _GenerateTestResult(self, test, instr_statuses, start_ms, duration_ms): | 79 def _GenerateTestResult(self, test, instr_statuses, start_ms, duration_ms): |
83 # uiautomator emits its summary status with INSTRUMENTATION_STATUS_CODE, | 80 # uiautomator emits its summary status with INSTRUMENTATION_STATUS_CODE, |
84 # not INSTRUMENTATION_CODE, so we have to drop if off the list of statuses. | 81 # not INSTRUMENTATION_CODE, so we have to drop if off the list of statuses. |
85 return super(TestRunner, self)._GenerateTestResult( | 82 return super(TestRunner, self)._GenerateTestResult( |
86 test, instr_statuses[:-1], start_ms, duration_ms) | 83 test, instr_statuses[:-1], start_ms, duration_ms) |
OLD | NEW |