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 """Defines TestPackageApk to help run APK-based native tests.""" | 5 """Defines TestPackageApk to help run APK-based native tests.""" |
6 # pylint: disable=W0212 | 6 # pylint: disable=W0212 |
7 | 7 |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import shlex | 10 import shlex |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 self._package_info.cmdline_file) | 48 self._package_info.cmdline_file) |
49 | 49 |
50 def _GetFifo(self): | 50 def _GetFifo(self): |
51 # The test.fifo path is determined by: | 51 # The test.fifo path is determined by: |
52 # testing/android/java/src/org/chromium/native_test/ | 52 # testing/android/java/src/org/chromium/native_test/ |
53 # ChromeNativeTestActivity.java and | 53 # ChromeNativeTestActivity.java and |
54 # testing/android/native_test_launcher.cc | 54 # testing/android/native_test_launcher.cc |
55 return '/data/data/' + self._package_info.package + '/files/test.fifo' | 55 return '/data/data/' + self._package_info.package + '/files/test.fifo' |
56 | 56 |
57 def _ClearFifo(self, device): | 57 def _ClearFifo(self, device): |
58 device.old_interface.RunShellCommand('rm -f ' + self._GetFifo()) | 58 device.RunShellCommand('rm -f ' + self._GetFifo()) |
59 | 59 |
60 def _WatchFifo(self, device, timeout, logfile=None): | 60 def _WatchFifo(self, device, timeout, logfile=None): |
61 for i in range(10): | 61 for i in range(10): |
62 if device.old_interface.FileExistsOnDevice(self._GetFifo()): | 62 if device.old_interface.FileExistsOnDevice(self._GetFifo()): |
63 logging.info('Fifo created.') | 63 logging.info('Fifo created.') |
64 break | 64 break |
65 time.sleep(i) | 65 time.sleep(i) |
66 else: | 66 else: |
67 raise device_errors.DeviceUnreachableError( | 67 raise device_errors.DeviceUnreachableError( |
68 'Unable to find fifo on device %s ' % self._GetFifo()) | 68 'Unable to find fifo on device %s ' % self._GetFifo()) |
(...skipping 10 matching lines...) Expand all Loading... |
79 action='android.intent.action.MAIN', | 79 action='android.intent.action.MAIN', |
80 force_stop=True) | 80 force_stop=True) |
81 | 81 |
82 #override | 82 #override |
83 def ClearApplicationState(self, device): | 83 def ClearApplicationState(self, device): |
84 device.old_interface.ClearApplicationState(self._package_info.package) | 84 device.old_interface.ClearApplicationState(self._package_info.package) |
85 # Content shell creates a profile on the sdscard which accumulates cache | 85 # Content shell creates a profile on the sdscard which accumulates cache |
86 # files over time. | 86 # files over time. |
87 if self.suite_name == 'content_browsertests': | 87 if self.suite_name == 'content_browsertests': |
88 try: | 88 try: |
89 device.old_interface.RunShellCommand( | 89 device.RunShellCommand( |
90 'rm -r %s/content_shell' % device.GetExternalStoragePath(), | 90 'rm -r %s/content_shell' % device.GetExternalStoragePath(), |
91 timeout_time=60 * 2) | 91 timeout=60 * 2) |
92 except device_errors.CommandFailedError: | 92 except device_errors.CommandFailedError: |
93 # TODO(jbudorick) Handle this exception appropriately once the | 93 # TODO(jbudorick) Handle this exception appropriately once the |
94 # conversions are done. | 94 # conversions are done. |
95 pass | 95 pass |
96 | 96 |
97 #override | 97 #override |
98 def CreateCommandLineFileOnDevice(self, device, test_filter, test_arguments): | 98 def CreateCommandLineFileOnDevice(self, device, test_filter, test_arguments): |
99 self._CreateCommandLineFileOnDevice( | 99 self._CreateCommandLineFileOnDevice( |
100 device, '--gtest_filter=%s %s' % (test_filter, test_arguments)) | 100 device, '--gtest_filter=%s %s' % (test_filter, test_arguments)) |
101 | 101 |
(...skipping 23 matching lines...) Expand all Loading... |
125 self._StartActivity(device) | 125 self._StartActivity(device) |
126 finally: | 126 finally: |
127 self.tool.CleanUpEnvironment() | 127 self.tool.CleanUpEnvironment() |
128 logfile = android_commands.NewLineNormalizer(sys.stdout) | 128 logfile = android_commands.NewLineNormalizer(sys.stdout) |
129 return self._WatchFifo(device, timeout=10, logfile=logfile) | 129 return self._WatchFifo(device, timeout=10, logfile=logfile) |
130 | 130 |
131 #override | 131 #override |
132 def Install(self, device): | 132 def Install(self, device): |
133 self.tool.CopyFiles() | 133 self.tool.CopyFiles() |
134 device.Install(self.suite_path) | 134 device.Install(self.suite_path) |
OLD | NEW |