| 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 itertools | |
| 9 import logging | 8 import logging |
| 10 import os | 9 import os |
| 11 import posixpath | |
| 12 import shlex | |
| 13 import sys | 10 import sys |
| 14 import tempfile | |
| 15 import time | 11 import time |
| 16 | 12 |
| 17 from devil.android import device_errors | 13 from devil.android import device_errors |
| 18 from devil.android.sdk import intent | 14 from devil.android.sdk import intent |
| 19 from pylib import constants | 15 from pylib import constants |
| 20 from pylib import pexpect | 16 from pylib import pexpect |
| 21 from pylib.gtest import gtest_test_instance | 17 from pylib.gtest import gtest_test_instance |
| 22 from pylib.gtest import local_device_gtest_run | 18 from pylib.gtest import local_device_gtest_run |
| 23 from pylib.gtest.test_package import TestPackage | 19 from pylib.gtest.test_package import TestPackage |
| 24 | 20 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 # NativeTestActivity.java and | 53 # NativeTestActivity.java and |
| 58 # testing/android/native_test_launcher.cc | 54 # testing/android/native_test_launcher.cc |
| 59 return '/data/data/' + self._package_info.package + '/files/test.fifo' | 55 return '/data/data/' + self._package_info.package + '/files/test.fifo' |
| 60 | 56 |
| 61 def _ClearFifo(self, device): | 57 def _ClearFifo(self, device): |
| 62 device.RunShellCommand('rm -f ' + self._GetFifo()) | 58 device.RunShellCommand('rm -f ' + self._GetFifo()) |
| 63 | 59 |
| 64 def _WatchFifo(self, device, timeout, logfile=None): | 60 def _WatchFifo(self, device, timeout, logfile=None): |
| 65 for i in range(100): | 61 for i in range(100): |
| 66 if device.FileExists(self._GetFifo()): | 62 if device.FileExists(self._GetFifo()): |
| 67 logging.info('Fifo created. Slept for %f secs' % (i * 0.5)) | 63 logging.info('Fifo created. Slept for %f secs', i * 0.5) |
| 68 break | 64 break |
| 69 time.sleep(0.5) | 65 time.sleep(0.5) |
| 70 else: | 66 else: |
| 71 raise device_errors.DeviceUnreachableError( | 67 raise device_errors.DeviceUnreachableError( |
| 72 'Unable to find fifo on device %s ' % self._GetFifo()) | 68 'Unable to find fifo on device %s ' % self._GetFifo()) |
| 73 args = ['-s', device.adb.GetDeviceSerial(), 'shell', 'cat', self._GetFifo()] | 69 args = ['-s', device.adb.GetDeviceSerial(), 'shell', 'cat', self._GetFifo()] |
| 74 return pexpect.spawn('adb', args, timeout=timeout, logfile=logfile) | 70 return pexpect.spawn('adb', args, timeout=timeout, logfile=logfile) |
| 75 | 71 |
| 76 def _StartActivity(self, device, force_stop=True): | 72 def _StartActivity(self, device, force_stop=True): |
| 77 device.StartActivity( | 73 device.StartActivity( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 153 |
| 158 #override | 154 #override |
| 159 def Install(self, device): | 155 def Install(self, device): |
| 160 self.tool.CopyFiles(device) | 156 self.tool.CopyFiles(device) |
| 161 device.Install(self.suite_path) | 157 device.Install(self.suite_path) |
| 162 | 158 |
| 163 #override | 159 #override |
| 164 def PullAppFiles(self, device, files, directory): | 160 def PullAppFiles(self, device, files, directory): |
| 165 local_device_gtest_run.PullAppFilesImpl( | 161 local_device_gtest_run.PullAppFilesImpl( |
| 166 device, self._package_info.package, files, directory) | 162 device, self._package_info.package, files, directory) |
| OLD | NEW |