OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 | 5 |
6 import os | 6 import os |
7 import shlex | 7 import shlex |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 import time | 10 import time |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 print 'Fifo created...' | 66 print 'Fifo created...' |
67 break | 67 break |
68 time.sleep(i) | 68 time.sleep(i) |
69 else: | 69 else: |
70 raise errors.DeviceUnresponsiveError( | 70 raise errors.DeviceUnresponsiveError( |
71 'Unable to find fifo on device %s ' % self._GetFifo()) | 71 'Unable to find fifo on device %s ' % self._GetFifo()) |
72 args = shlex.split(self.adb.Adb()._target_arg) | 72 args = shlex.split(self.adb.Adb()._target_arg) |
73 args += ['shell', 'cat', self._GetFifo()] | 73 args += ['shell', 'cat', self._GetFifo()] |
74 return pexpect.spawn('adb', args, timeout=timeout, logfile=logfile) | 74 return pexpect.spawn('adb', args, timeout=timeout, logfile=logfile) |
75 | 75 |
| 76 def ClearApplicationState(self): |
| 77 """Clear the application state.""" |
| 78 self.adb.ClearApplicationState(self._apk_package_name) |
| 79 |
76 def GetAllTests(self): | 80 def GetAllTests(self): |
77 """Returns a list of all tests available in the test suite.""" | 81 """Returns a list of all tests available in the test suite.""" |
78 self._CreateTestRunnerScript('--gtest_list_tests') | 82 self._CreateTestRunnerScript('--gtest_list_tests') |
79 try: | 83 try: |
80 self.tool.SetupEnvironment() | 84 self.tool.SetupEnvironment() |
81 # Clear and start monitoring logcat. | 85 # Clear and start monitoring logcat. |
82 self._ClearFifo() | 86 self._ClearFifo() |
83 self.adb.RunShellCommand( | 87 self.adb.RunShellCommand( |
84 'am start -n ' + self._apk_package_name + '/' + | 88 'am start -n ' + self._apk_package_name + '/' + |
85 self._test_activity_name) | 89 self._test_activity_name) |
(...skipping 28 matching lines...) Expand all Loading... |
114 self.tool.CopyFiles() | 118 self.tool.CopyFiles() |
115 # Always uninstall the previous one (by activity name); we don't | 119 # Always uninstall the previous one (by activity name); we don't |
116 # know what was embedded in it. | 120 # know what was embedded in it. |
117 self.adb.ManagedInstall(self.test_suite_full, False, | 121 self.adb.ManagedInstall(self.test_suite_full, False, |
118 package_name=self._apk_package_name) | 122 package_name=self._apk_package_name) |
119 | 123 |
120 def _GetTestSuiteBaseName(self): | 124 def _GetTestSuiteBaseName(self): |
121 """Returns the base name of the test suite.""" | 125 """Returns the base name of the test suite.""" |
122 # APK test suite names end with '-debug.apk' | 126 # APK test suite names end with '-debug.apk' |
123 return os.path.basename(self.test_suite).rsplit('-debug', 1)[0] | 127 return os.path.basename(self.test_suite).rsplit('-debug', 1)[0] |
OLD | NEW |