OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import logging | 5 import logging |
6 import os | 6 import os |
7 import pickle | 7 import pickle |
8 import re | 8 import re |
9 import sys | 9 import sys |
10 | 10 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 return results | 134 return results |
135 | 135 |
136 | 136 |
137 class InstrumentationTestInstance(test_instance.TestInstance): | 137 class InstrumentationTestInstance(test_instance.TestInstance): |
138 | 138 |
139 def __init__(self, args, isolate_delegate, error_func): | 139 def __init__(self, args, isolate_delegate, error_func): |
140 super(InstrumentationTestInstance, self).__init__() | 140 super(InstrumentationTestInstance, self).__init__() |
141 | 141 |
142 self._apk_under_test = None | 142 self._apk_under_test = None |
| 143 self._apk_under_test_permissions = None |
143 self._package_info = None | 144 self._package_info = None |
144 self._suite = None | 145 self._suite = None |
145 self._test_apk = None | 146 self._test_apk = None |
146 self._test_jar = None | 147 self._test_jar = None |
147 self._test_package = None | 148 self._test_package = None |
| 149 self._test_permissions = None |
148 self._test_runner = None | 150 self._test_runner = None |
149 self._test_support_apk = None | 151 self._test_support_apk = None |
150 self._initializeApkAttributes(args, error_func) | 152 self._initializeApkAttributes(args, error_func) |
151 | 153 |
152 self._data_deps = None | 154 self._data_deps = None |
153 self._isolate_abs_path = None | 155 self._isolate_abs_path = None |
154 self._isolate_delegate = None | 156 self._isolate_delegate = None |
155 self._isolated_abs_path = None | 157 self._isolated_abs_path = None |
156 self._test_data = None | 158 self._test_data = None |
157 self._initializeDataDependencyAttributes(args, isolate_delegate) | 159 self._initializeDataDependencyAttributes(args, isolate_delegate) |
(...skipping 15 matching lines...) Expand all Loading... |
173 if args.apk_under_test.endswith('.apk'): | 175 if args.apk_under_test.endswith('.apk'): |
174 self._apk_under_test = args.apk_under_test | 176 self._apk_under_test = args.apk_under_test |
175 else: | 177 else: |
176 self._apk_under_test = os.path.join( | 178 self._apk_under_test = os.path.join( |
177 constants.GetOutDirectory(), constants.SDK_BUILD_APKS_DIR, | 179 constants.GetOutDirectory(), constants.SDK_BUILD_APKS_DIR, |
178 '%s.apk' % args.apk_under_test) | 180 '%s.apk' % args.apk_under_test) |
179 | 181 |
180 if not os.path.exists(self._apk_under_test): | 182 if not os.path.exists(self._apk_under_test): |
181 error_func('Unable to find APK under test: %s' % self._apk_under_test) | 183 error_func('Unable to find APK under test: %s' % self._apk_under_test) |
182 | 184 |
| 185 apk = apk_helper.ApkHelper(self._apk_under_test) |
| 186 self._apk_under_test_permissions = apk.GetPermissions() |
| 187 |
183 if args.test_apk.endswith('.apk'): | 188 if args.test_apk.endswith('.apk'): |
184 self._suite = os.path.splitext(os.path.basename(args.test_apk))[0] | 189 self._suite = os.path.splitext(os.path.basename(args.test_apk))[0] |
185 self._test_apk = args.test_apk | 190 self._test_apk = args.test_apk |
186 else: | 191 else: |
187 self._suite = args.test_apk | 192 self._suite = args.test_apk |
188 self._test_apk = os.path.join( | 193 self._test_apk = os.path.join( |
189 constants.GetOutDirectory(), constants.SDK_BUILD_APKS_DIR, | 194 constants.GetOutDirectory(), constants.SDK_BUILD_APKS_DIR, |
190 '%s.apk' % args.test_apk) | 195 '%s.apk' % args.test_apk) |
191 | 196 |
192 self._test_jar = os.path.join( | 197 self._test_jar = os.path.join( |
193 constants.GetOutDirectory(), constants.SDK_BUILD_TEST_JAVALIB_DIR, | 198 constants.GetOutDirectory(), constants.SDK_BUILD_TEST_JAVALIB_DIR, |
194 '%s.jar' % self._suite) | 199 '%s.jar' % self._suite) |
195 self._test_support_apk = os.path.join( | 200 self._test_support_apk = os.path.join( |
196 constants.GetOutDirectory(), constants.SDK_BUILD_TEST_JAVALIB_DIR, | 201 constants.GetOutDirectory(), constants.SDK_BUILD_TEST_JAVALIB_DIR, |
197 '%sSupport.apk' % self._suite) | 202 '%sSupport.apk' % self._suite) |
198 | 203 |
199 if not os.path.exists(self._test_apk): | 204 if not os.path.exists(self._test_apk): |
200 error_func('Unable to find test APK: %s' % self._test_apk) | 205 error_func('Unable to find test APK: %s' % self._test_apk) |
201 if not os.path.exists(self._test_jar): | 206 if not os.path.exists(self._test_jar): |
202 error_func('Unable to find test JAR: %s' % self._test_jar) | 207 error_func('Unable to find test JAR: %s' % self._test_jar) |
203 | 208 |
204 apk = apk_helper.ApkHelper(self.test_apk) | 209 apk = apk_helper.ApkHelper(self.test_apk) |
205 self._test_package = apk.GetPackageName() | 210 self._test_package = apk.GetPackageName() |
| 211 self._test_permissions = apk.GetPermissions() |
206 self._test_runner = apk.GetInstrumentationName() | 212 self._test_runner = apk.GetInstrumentationName() |
207 | 213 |
208 self._package_info = None | 214 self._package_info = None |
209 for package_info in constants.PACKAGE_INFO.itervalues(): | 215 for package_info in constants.PACKAGE_INFO.itervalues(): |
210 if self._test_package == package_info.test_package: | 216 if self._test_package == package_info.test_package: |
211 self._package_info = package_info | 217 self._package_info = package_info |
212 if not self._package_info: | 218 if not self._package_info: |
213 logging.warning('Unable to find package info for %s', self._test_package) | 219 logging.warning('Unable to find package info for %s', self._test_package) |
214 | 220 |
215 def _initializeDataDependencyAttributes(self, args, isolate_delegate): | 221 def _initializeDataDependencyAttributes(self, args, isolate_delegate): |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 self._driver_package = driver_apk.GetPackageName() | 285 self._driver_package = driver_apk.GetPackageName() |
280 self._driver_name = driver_apk.GetInstrumentationName() | 286 self._driver_name = driver_apk.GetInstrumentationName() |
281 else: | 287 else: |
282 self._driver_apk = None | 288 self._driver_apk = None |
283 | 289 |
284 @property | 290 @property |
285 def apk_under_test(self): | 291 def apk_under_test(self): |
286 return self._apk_under_test | 292 return self._apk_under_test |
287 | 293 |
288 @property | 294 @property |
| 295 def apk_under_test_permissions(self): |
| 296 return self._apk_under_test_permissions |
| 297 |
| 298 @property |
289 def flags(self): | 299 def flags(self): |
290 return self._flags | 300 return self._flags |
291 | 301 |
292 @property | 302 @property |
293 def driver_apk(self): | 303 def driver_apk(self): |
294 return self._driver_apk | 304 return self._driver_apk |
295 | 305 |
296 @property | 306 @property |
297 def driver_package(self): | 307 def driver_package(self): |
298 return self._driver_package | 308 return self._driver_package |
(...skipping 20 matching lines...) Expand all Loading... |
319 | 329 |
320 @property | 330 @property |
321 def test_support_apk(self): | 331 def test_support_apk(self): |
322 return self._test_support_apk | 332 return self._test_support_apk |
323 | 333 |
324 @property | 334 @property |
325 def test_package(self): | 335 def test_package(self): |
326 return self._test_package | 336 return self._test_package |
327 | 337 |
328 @property | 338 @property |
| 339 def test_permissions(self): |
| 340 return self._test_permissions |
| 341 |
| 342 @property |
329 def test_runner(self): | 343 def test_runner(self): |
330 return self._test_runner | 344 return self._test_runner |
331 | 345 |
332 #override | 346 #override |
333 def TestType(self): | 347 def TestType(self): |
334 return 'instrumentation' | 348 return 'instrumentation' |
335 | 349 |
336 #override | 350 #override |
337 def SetUp(self): | 351 def SetUp(self): |
338 if self._isolate_delegate: | 352 if self._isolate_delegate: |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 def GenerateTestResults( | 530 def GenerateTestResults( |
517 result_code, result_bundle, statuses, start_ms, duration_ms): | 531 result_code, result_bundle, statuses, start_ms, duration_ms): |
518 return GenerateTestResults(result_code, result_bundle, statuses, | 532 return GenerateTestResults(result_code, result_bundle, statuses, |
519 start_ms, duration_ms) | 533 start_ms, duration_ms) |
520 | 534 |
521 #override | 535 #override |
522 def TearDown(self): | 536 def TearDown(self): |
523 if self._isolate_delegate: | 537 if self._isolate_delegate: |
524 self._isolate_delegate.Clear() | 538 self._isolate_delegate.Clear() |
525 | 539 |
OLD | NEW |