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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 #override | 58 #override |
59 def PushDataDeps(self): | 59 def PushDataDeps(self): |
60 pass | 60 pass |
61 | 61 |
62 #override | 62 #override |
63 def _RunTest(self, test, timeout): | 63 def _RunTest(self, test, timeout): |
64 self.device.ClearApplicationState(self._package) | 64 self.device.ClearApplicationState(self._package) |
65 if self.flags: | 65 if self.flags: |
66 annotations = self.test_pkg.GetTestAnnotations(test) | 66 annotations = self.test_pkg.GetTestAnnotations(test) |
67 if ('FirstRunExperience' == annotations.get('Feature', None)): | 67 if 'FirstRunExperience' == annotations.get('Feature', None): |
68 self.flags.RemoveFlags(['--disable-fre']) | 68 self.flags.RemoveFlags(['--disable-fre']) |
69 else: | 69 else: |
70 self.flags.AddFlags(['--disable-fre']) | 70 self.flags.AddFlags(['--disable-fre']) |
71 self.device.StartActivity( | 71 self.device.StartActivity( |
72 intent.Intent(action='android.intent.action.MAIN', | 72 intent.Intent(action='android.intent.action.MAIN', |
73 activity=self._activity, | 73 activity=self._activity, |
74 package=self._package), | 74 package=self._package), |
75 blocking=True, | 75 blocking=True, |
76 force_stop=True) | 76 force_stop=True) |
77 cmd = ['uiautomator', 'runtest', | 77 cmd = ['uiautomator', 'runtest', |
78 self.test_pkg.UIAUTOMATOR_PATH + self.test_pkg.GetPackageName(), | 78 self.test_pkg.UIAUTOMATOR_PATH + self.test_pkg.GetPackageName(), |
79 '-e', 'class', test] | 79 '-e', 'class', test] |
80 return self.device.RunShellCommand(cmd, timeout=timeout, retries=0) | 80 return self.device.RunShellCommand(cmd, timeout=timeout, retries=0) |
81 | 81 |
82 #override | 82 #override |
83 def _GenerateTestResult(self, test, instr_statuses, start_ms, duration_ms): | 83 def _GenerateTestResult(self, test, instr_statuses, start_ms, duration_ms): |
84 # uiautomator emits its summary status with INSTRUMENTATION_STATUS_CODE, | 84 # uiautomator emits its summary status with INSTRUMENTATION_STATUS_CODE, |
85 # not INSTRUMENTATION_CODE, so we have to drop if off the list of statuses. | 85 # not INSTRUMENTATION_CODE, so we have to drop if off the list of statuses. |
86 return super(TestRunner, self)._GenerateTestResult( | 86 return super(TestRunner, self)._GenerateTestResult( |
87 test, instr_statuses[:-1], start_ms, duration_ms) | 87 test, instr_statuses[:-1], start_ms, duration_ms) |
OLD | NEW |