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