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

Side by Side Diff: build/android/pylib/remote/device/remote_device_instrumentation_test_run.py

Issue 1060933003: [Android] Add an out-of-app instrumentation driver APK. (RELAND) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revised: added @VisibleForTesting to ThreadUtils.postOnUiThreadDelayed Created 5 years, 8 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 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 """Run specific test on specific environment.""" 5 """Run specific test on specific environment."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import tempfile 9 import tempfile
10 10
11 from pylib import constants
11 from pylib.base import base_test_result 12 from pylib.base import base_test_result
12 from pylib.remote.device import remote_device_test_run 13 from pylib.remote.device import remote_device_test_run
13 from pylib.utils import apk_helper 14 from pylib.utils import apk_helper
14 15
15 16
16 class RemoteDeviceInstrumentationTestRun( 17 class RemoteDeviceInstrumentationTestRun(
17 remote_device_test_run.RemoteDeviceTestRun): 18 remote_device_test_run.RemoteDeviceTestRun):
18 """Run instrumentation tests on a remote device.""" 19 """Run instrumentation tests on a remote device."""
19 20
20 #override 21 #override
21 def TestPackage(self): 22 def TestPackage(self):
22 return self._test_instance.test_package 23 return self._test_instance.test_package
23 24
24 #override 25 #override
25 def _TriggerSetUp(self): 26 def _TriggerSetUp(self):
26 """Set up the triggering of a test run.""" 27 """Set up the triggering of a test run."""
27 logging.info('Triggering test run.') 28 logging.info('Triggering test run.')
28 self._AmInstrumentTestSetup( 29
29 self._test_instance._apk_under_test, self._test_instance.test_apk, 30 with tempfile.NamedTemporaryFile(suffix='.txt') as test_list_file:
30 self._test_instance.test_runner, environment_variables={}) 31 tests = self._test_instance.GetTests()
32 logging.debug('preparing to run %d instrumentation tests remotely:',
33 len(tests))
34 for t in tests:
35 test_name = '%s#%s' % (t['class'], t['method'])
36 logging.debug(' %s', test_name)
37 test_list_file.write('%s\n' % test_name)
38 test_list_file.flush()
39 self._test_instance._data_deps.append(
40 (os.path.abspath(test_list_file.name), None))
41
42 env_vars = self._test_instance.GetDriverEnvironmentVars(
43 test_list_file_path=test_list_file.name)
44 env_vars.update(self._test_instance.GetHttpServerEnvironmentVars())
45
46 logging.debug('extras:')
47 for k, v in env_vars.iteritems():
48 logging.debug(' %s: %s', k, v)
49
50 self._AmInstrumentTestSetup(
51 self._test_instance.apk_under_test,
52 self._test_instance.driver_apk,
53 self._test_instance.driver_name,
54 environment_variables=env_vars,
55 extra_apks=[self._test_instance.test_apk])
31 56
32 #override 57 #override
33 def _ParseTestResults(self): 58 def _ParseTestResults(self):
34 logging.info('Parsing results from stdout.') 59 logging.info('Parsing results from stdout.')
35 r = base_test_result.TestRunResults() 60 r = base_test_result.TestRunResults()
36 result_code, result_bundle, statuses = ( 61 result_code, result_bundle, statuses = (
37 self._test_instance.ParseAmInstrumentRawOutput( 62 self._test_instance.ParseAmInstrumentRawOutput(
38 self._results['results']['output'].splitlines())) 63 self._results['results']['output'].splitlines()))
39 result = self._test_instance.GenerateTestResults( 64 result = self._test_instance.GenerateTestResults(
40 result_code, result_bundle, statuses, 0, 0) 65 result_code, result_bundle, statuses, 0, 0)
41 66
42 if isinstance(result, base_test_result.BaseTestResult): 67 if isinstance(result, base_test_result.BaseTestResult):
43 r.AddResult(result) 68 r.AddResult(result)
44 elif isinstance(result, list): 69 elif isinstance(result, list):
45 r.AddResults(result) 70 r.AddResults(result)
46 else: 71 else:
47 raise Exception('Unexpected result type: %s' % type(result).__name__) 72 raise Exception('Unexpected result type: %s' % type(result).__name__)
48 73
49 return r 74 return r
OLDNEW
« no previous file with comments | « build/android/pylib/remote/device/remote_device_helper.py ('k') | build/android/pylib/remote/device/remote_device_test_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698