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

Side by Side Diff: build/android/pylib/monkey/test_runner.py

Issue 338353004: [Android] Switch KillAll, StartActivity, and BroadcastIntent to DeviceUtils. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: appeasing windows Created 6 years, 6 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
« no previous file with comments | « build/android/pylib/linker/test_case.py ('k') | build/android/pylib/perf/cache_control.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Runs a monkey test on a single device.""" 5 """Runs a monkey test on a single device."""
6 6
7 import logging 7 import logging
8 import random 8 import random
9 9
10 from pylib import constants 10 from pylib import constants
11 from pylib.base import base_test_result 11 from pylib.base import base_test_result
12 from pylib.base import base_test_runner 12 from pylib.base import base_test_runner
13 13 from pylib.device import intent
14 14
15 class TestRunner(base_test_runner.BaseTestRunner): 15 class TestRunner(base_test_runner.BaseTestRunner):
16 """A TestRunner instance runs a monkey test on a single device.""" 16 """A TestRunner instance runs a monkey test on a single device."""
17 17
18 def __init__(self, test_options, device, _): 18 def __init__(self, test_options, device, _):
19 super(TestRunner, self).__init__(device, None) 19 super(TestRunner, self).__init__(device, None)
20 self._options = test_options 20 self._options = test_options
21 self._package = constants.PACKAGE_INFO[self._options.package].package 21 self._package = constants.PACKAGE_INFO[self._options.package].package
22 self._activity = constants.PACKAGE_INFO[self._options.package].activity 22 self._activity = constants.PACKAGE_INFO[self._options.package].activity
23 23
(...skipping 20 matching lines...) Expand all
44 44
45 def RunTest(self, test_name): 45 def RunTest(self, test_name):
46 """Run a Monkey test on the device. 46 """Run a Monkey test on the device.
47 47
48 Args: 48 Args:
49 test_name: String to use for logging the test result. 49 test_name: String to use for logging the test result.
50 50
51 Returns: 51 Returns:
52 A tuple of (TestRunResults, retry). 52 A tuple of (TestRunResults, retry).
53 """ 53 """
54 self.device.old_interface.StartActivity( 54 self.device.StartActivity(
55 self._package, self._activity, wait_for_completion=True, 55 intent.Intent(package=self._package, activity=self._activity,
56 action='android.intent.action.MAIN', force_stop=True) 56 action='android.intent.action.MAIN'),
57 blocking=True, force_stop=True)
57 58
58 # Chrome crashes are not always caught by Monkey test runner. 59 # Chrome crashes are not always caught by Monkey test runner.
59 # Verify Chrome has the same PID before and after the test. 60 # Verify Chrome has the same PID before and after the test.
60 before_pids = self.device.old_interface.ExtractPid(self._package) 61 before_pids = self.device.old_interface.ExtractPid(self._package)
61 62
62 # Run the test. 63 # Run the test.
63 output = '' 64 output = ''
64 if before_pids: 65 if before_pids:
65 output = '\n'.join(self._LaunchMonkeyTest()) 66 output = '\n'.join(self._LaunchMonkeyTest())
66 after_pids = self.device.old_interface.ExtractPid(self._package) 67 after_pids = self.device.old_interface.ExtractPid(self._package)
(...skipping 18 matching lines...) Expand all
85 result = base_test_result.BaseTestResult( 86 result = base_test_result.BaseTestResult(
86 test_name, base_test_result.ResultType.FAIL, log=output) 87 test_name, base_test_result.ResultType.FAIL, log=output)
87 if 'chrome' in self._options.package: 88 if 'chrome' in self._options.package:
88 logging.warning('Starting MinidumpUploadService...') 89 logging.warning('Starting MinidumpUploadService...')
89 try: 90 try:
90 self.device.old_interface.StartCrashUploadService(self._package) 91 self.device.old_interface.StartCrashUploadService(self._package)
91 except AssertionError as e: 92 except AssertionError as e:
92 logging.error('Failed to start MinidumpUploadService: %s', e) 93 logging.error('Failed to start MinidumpUploadService: %s', e)
93 results.AddResult(result) 94 results.AddResult(result)
94 return results, False 95 return results, False
OLDNEW
« no previous file with comments | « build/android/pylib/linker/test_case.py ('k') | build/android/pylib/perf/cache_control.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698