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 sys | 10 import sys |
11 import time | 11 import time |
12 | 12 |
13 from devil.android import apk_helper | 13 from devil.android import apk_helper |
14 from devil.android import device_errors | 14 from devil.android import device_errors |
15 from devil.android.sdk import intent | 15 from devil.android.sdk import intent |
16 from pylib import constants | 16 from pylib import constants |
17 from pylib import pexpect | 17 from pylib import pexpect |
18 from pylib.gtest import gtest_test_instance | 18 from pylib.gtest import gtest_test_instance |
19 from pylib.gtest import local_device_gtest_run | |
20 from pylib.gtest.test_package import TestPackage | 19 from pylib.gtest.test_package import TestPackage |
| 20 from pylib.local.device import local_device_gtest_run |
21 | 21 |
22 | 22 |
23 class TestPackageApk(TestPackage): | 23 class TestPackageApk(TestPackage): |
24 """A helper class for running APK-based native tests.""" | 24 """A helper class for running APK-based native tests.""" |
25 | 25 |
26 def __init__(self, suite_name): | 26 def __init__(self, suite_name): |
27 """ | 27 """ |
28 Args: | 28 Args: |
29 suite_name: Name of the test suite (e.g. base_unittests). | 29 suite_name: Name of the test suite (e.g. base_unittests). |
30 """ | 30 """ |
31 TestPackage.__init__(self, suite_name) | 31 TestPackage.__init__(self, suite_name) |
32 self.suite_path = os.path.join( | 32 self.suite_path = os.path.join( |
33 constants.GetOutDirectory(), '%s_apk' % suite_name, | 33 constants.GetOutDirectory(), '%s_apk' % suite_name, |
34 '%s-debug.apk' % suite_name) | 34 '%s-debug.apk' % suite_name) |
35 if suite_name == 'content_browsertests': | 35 if suite_name == 'content_browsertests': |
36 self._package_info = constants.PACKAGE_INFO['content_browsertests'] | 36 self._package_info = constants.PACKAGE_INFO['content_browsertests'] |
37 elif suite_name == 'components_browsertests': | 37 elif suite_name == 'components_browsertests': |
38 self._package_info = constants.PACKAGE_INFO['components_browsertests'] | 38 self._package_info = constants.PACKAGE_INFO['components_browsertests'] |
39 else: | 39 else: |
40 self._package_info = constants.PACKAGE_INFO['gtest'] | 40 self._package_info = constants.PACKAGE_INFO['gtest'] |
41 | 41 |
42 if suite_name == 'net_unittests': | 42 if suite_name == 'net_unittests': |
43 self._extras = {'RunInSubThread': None} | 43 self._extras = { |
| 44 'org.chromium.native_test.NativeTestActivity.RunInSubThread': None |
| 45 } |
44 else: | 46 else: |
45 self._extras = [] | 47 self._extras = [] |
46 | 48 |
47 def _CreateCommandLineFileOnDevice(self, device, options): | 49 def _CreateCommandLineFileOnDevice(self, device, options): |
48 device.WriteFile(self._package_info.cmdline_file, | 50 device.WriteFile(self._package_info.cmdline_file, |
49 self.suite_name + ' ' + options) | 51 self.suite_name + ' ' + options) |
50 | 52 |
51 def _GetFifo(self): | 53 def _GetFifo(self): |
52 # The test.fifo path is determined by: | 54 # The test.fifo path is determined by: |
53 # testing/android/native_test/java/src/org/chromium/native_test/ | 55 # testing/android/native_test/java/src/org/chromium/native_test/ |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 #override | 162 #override |
161 def PullAppFiles(self, device, files, directory): | 163 def PullAppFiles(self, device, files, directory): |
162 local_device_gtest_run.PullAppFilesImpl( | 164 local_device_gtest_run.PullAppFilesImpl( |
163 device, self._package_info.package, files, directory) | 165 device, self._package_info.package, files, directory) |
164 | 166 |
165 #override | 167 #override |
166 def SetPermissions(self, device): | 168 def SetPermissions(self, device): |
167 permissions = apk_helper.ApkHelper(self.suite_path).GetPermissions() | 169 permissions = apk_helper.ApkHelper(self.suite_path).GetPermissions() |
168 device.GrantPermissions( | 170 device.GrantPermissions( |
169 apk_helper.GetPackageName(self.suite_path), permissions) | 171 apk_helper.GetPackageName(self.suite_path), permissions) |
OLD | NEW |