Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: build/android/pylib/gtest/gtest_test_instance.py

Issue 1398953002: Android gtest runner: Create only a single ApkHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gtest-faster-10
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 re 7 import re
8 import sys 8 import sys
9 import tempfile 9 import tempfile
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 def __init__(self, args, isolate_delegate, error_func): 132 def __init__(self, args, isolate_delegate, error_func):
133 super(GtestTestInstance, self).__init__() 133 super(GtestTestInstance, self).__init__()
134 # TODO(jbudorick): Support multiple test suites. 134 # TODO(jbudorick): Support multiple test suites.
135 if len(args.suite_name) > 1: 135 if len(args.suite_name) > 1:
136 raise ValueError('Platform mode currently supports only 1 gtest suite') 136 raise ValueError('Platform mode currently supports only 1 gtest suite')
137 self._suite = args.suite_name[0] 137 self._suite = args.suite_name[0]
138 138
139 self._shard_timeout = args.shard_timeout 139 self._shard_timeout = args.shard_timeout
140 140
141 self._apk_path = os.path.join( 141 apk_path = os.path.join(
142 constants.GetOutDirectory(), '%s_apk' % self._suite, 142 constants.GetOutDirectory(), '%s_apk' % self._suite,
143 '%s-debug.apk' % self._suite) 143 '%s-debug.apk' % self._suite)
144 self._exe_path = os.path.join(constants.GetOutDirectory(), 144 self._exe_path = os.path.join(constants.GetOutDirectory(),
145 self._suite) 145 self._suite)
146 if not os.path.exists(self._apk_path): 146 if not os.path.exists(apk_path):
147 self._apk_path = None 147 self._apk_helper = None
148 self._activity = None
149 self._package = None
150 self._runner = None
151 else: 148 else:
152 helper = apk_helper.ApkHelper(self._apk_path) 149 self._apk_helper = apk_helper.ApkHelper(apk_path)
153 self._activity = helper.GetActivityName()
154 self._package = helper.GetPackageName()
155 self._runner = helper.GetInstrumentationName()
156 self._permissions = helper.GetPermissions()
157 self._extras = { 150 self._extras = {
158 _EXTRA_NATIVE_TEST_ACTIVITY: self._activity, 151 _EXTRA_NATIVE_TEST_ACTIVITY: self._apk_helper.GetActivityName(),
159 } 152 }
160 if self._suite in RUN_IN_SUB_THREAD_TEST_SUITES: 153 if self._suite in RUN_IN_SUB_THREAD_TEST_SUITES:
161 self._extras[_EXTRA_RUN_IN_SUB_THREAD] = 1 154 self._extras[_EXTRA_RUN_IN_SUB_THREAD] = 1
162 if self._suite in BROWSER_TEST_SUITES: 155 if self._suite in BROWSER_TEST_SUITES:
163 self._extras[_EXTRA_SHARD_SIZE_LIMIT] = 1 156 self._extras[_EXTRA_SHARD_SIZE_LIMIT] = 1
164 self._extras[EXTRA_SHARD_NANO_TIMEOUT] = int(1e9 * self._shard_timeout) 157 self._extras[EXTRA_SHARD_NANO_TIMEOUT] = int(1e9 * self._shard_timeout)
165 self._shard_timeout = 900 158 self._shard_timeout = 900
166 159
167 if not os.path.exists(self._exe_path): 160 if not os.path.exists(self._exe_path):
168 self._exe_path = None 161 self._exe_path = None
169 if not self._apk_path and not self._exe_path: 162 if not apk_path and not self._exe_path:
170 error_func('Could not find apk or executable for %s' % self._suite) 163 error_func('Could not find apk or executable for %s' % self._suite)
171 164
172 self._data_deps = [] 165 self._data_deps = []
173 if args.test_filter: 166 if args.test_filter:
174 self._gtest_filter = args.test_filter 167 self._gtest_filter = args.test_filter
175 elif args.test_filter_file: 168 elif args.test_filter_file:
176 with open(args.test_filter_file, 'r') as f: 169 with open(args.test_filter_file, 'r') as f:
177 self._gtest_filter = ':'.join(l.strip() for l in f) 170 self._gtest_filter = ':'.join(l.strip() for l in f)
178 else: 171 else:
179 self._gtest_filter = None 172 self._gtest_filter = None
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 return results 304 return results
312 305
313 #override 306 #override
314 def TearDown(self): 307 def TearDown(self):
315 """Clear the mappings created by SetUp.""" 308 """Clear the mappings created by SetUp."""
316 if self._isolate_delegate: 309 if self._isolate_delegate:
317 self._isolate_delegate.Clear() 310 self._isolate_delegate.Clear()
318 311
319 @property 312 @property
320 def activity(self): 313 def activity(self):
321 return self._activity 314 return self._apk_helper and self._apk_helper.GetActivityName()
322 315
323 @property 316 @property
324 def apk(self): 317 def apk(self):
325 return self._apk_path 318 return self._apk_helper and self._apk_helper.path
319
320 @property
321 def apk_helper(self):
322 return self._apk_helper
326 323
327 @property 324 @property
328 def app_file_dir(self): 325 def app_file_dir(self):
329 return self._app_data_file_dir 326 return self._app_data_file_dir
330 327
331 @property 328 @property
332 def app_files(self): 329 def app_files(self):
333 return self._app_data_files 330 return self._app_data_files
334 331
335 @property 332 @property
336 def exe(self): 333 def exe(self):
337 return self._exe_path 334 return self._exe_path
338 335
339 @property 336 @property
340 def extras(self): 337 def extras(self):
341 return self._extras 338 return self._extras
342 339
343 @property 340 @property
344 def package(self): 341 def package(self):
345 return self._package 342 return self._apk_helper and self._apk_helper.GetPackageName()
346 343
347 @property 344 @property
348 def permissions(self): 345 def permissions(self):
349 return self._permissions 346 return self._apk_helper and self._apk_helper.GetPermissions()
350 347
351 @property 348 @property
352 def runner(self): 349 def runner(self):
353 return self._runner 350 return self._apk_helper and self._apk_helper.GetInstrumentationName()
354 351
355 @property 352 @property
356 def shard_timeout(self): 353 def shard_timeout(self):
357 return self._shard_timeout 354 return self._shard_timeout
358 355
359 @property 356 @property
360 def suite(self): 357 def suite(self):
361 return self._suite 358 return self._suite
362 359
OLDNEW
« no previous file with comments | « build/android/incremental_install/installer.py ('k') | build/android/pylib/local/device/local_device_gtest_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698