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

Side by Side Diff: third_party/android_testrunner/adb_interface.py

Issue 10823093: [Android] Upstream changes to android_testrunner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « third_party/android_testrunner/README.chromium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # 2 #
3 # 3 #
4 # Copyright 2008, The Android Open Source Project 4 # Copyright 2008, The Android Open Source Project
5 # 5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License. 7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at 8 # You may obtain a copy of the License at
9 # 9 #
10 # http://www.apache.org/licenses/LICENSE-2.0 10 # http://www.apache.org/licenses/LICENSE-2.0
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 Equivalent to StartInstrumentation, except instrumentation path is 169 Equivalent to StartInstrumentation, except instrumentation path is
170 separated into its package and runner components. 170 separated into its package and runner components.
171 """ 171 """
172 instrumentation_path = "%s/%s" % (package_name, runner_name) 172 instrumentation_path = "%s/%s" % (package_name, runner_name)
173 return self.StartInstrumentation(instrumentation_path, timeout_time=timeout_ time, 173 return self.StartInstrumentation(instrumentation_path, timeout_time=timeout_ time,
174 no_window_animation=no_window_animation, 174 no_window_animation=no_window_animation,
175 instrumentation_args=instrumentation_args) 175 instrumentation_args=instrumentation_args)
176 176
177 def StartInstrumentation( 177 def StartInstrumentation(
178 self, instrumentation_path, timeout_time=60*10, no_window_animation=False, 178 self, instrumentation_path, timeout_time=60*10, no_window_animation=False,
179 profile=False, instrumentation_args={}): 179 profile=False, instrumentation_args={}, silent_log=False):
180 180
181 """Runs an instrumentation class on the target. 181 """Runs an instrumentation class on the target.
182 182
183 Returns a dictionary containing the key value pairs from the 183 Returns a dictionary containing the key value pairs from the
184 instrumentations result bundle and a list of TestResults. Also handles the 184 instrumentations result bundle and a list of TestResults. Also handles the
185 interpreting of error output from the device and raises the necessary 185 interpreting of error output from the device and raises the necessary
186 exceptions. 186 exceptions.
187 187
188 Args: 188 Args:
189 instrumentation_path: string. It should be the fully classified package 189 instrumentation_path: string. It should be the fully classified package
190 name, and instrumentation test runner, separated by "/" 190 name, and instrumentation test runner, separated by "/"
191 e.g. com.android.globaltimelaunch/.GlobalTimeLaunch 191 e.g. com.android.globaltimelaunch/.GlobalTimeLaunch
192 timeout_time: Timeout value for the am command. 192 timeout_time: Timeout value for the am command.
193 no_window_animation: boolean, Whether you want window animations enabled 193 no_window_animation: boolean, Whether you want window animations enabled
194 or disabled 194 or disabled
195 profile: If True, profiling will be turned on for the instrumentation. 195 profile: If True, profiling will be turned on for the instrumentation.
196 instrumentation_args: Dictionary of key value bundle arguments to pass to 196 instrumentation_args: Dictionary of key value bundle arguments to pass to
bulach 2012/07/31 10:31:06 nit: silent_log needs doc string
Yaron 2012/07/31 15:34:39 Done.
197 instrumentation. 197 instrumentation.
198 198
199 Returns: 199 Returns:
200 (test_results, inst_finished_bundle) 200 (test_results, inst_finished_bundle)
201 201
202 test_results: a list of TestResults 202 test_results: a list of TestResults
203 inst_finished_bundle (dict): Key/value pairs contained in the bundle that 203 inst_finished_bundle (dict): Key/value pairs contained in the bundle that
204 is passed into ActivityManager.finishInstrumentation(). Included in this 204 is passed into ActivityManager.finishInstrumentation(). Included in this
205 bundle is the return code of the Instrumentation process, any error 205 bundle is the return code of the Instrumentation process, any error
206 codes reported by the activity manager, and any results explicitly added 206 codes reported by the activity manager, and any results explicitly added
207 by the instrumentation code. 207 by the instrumentation code.
208 208
209 Raises: 209 Raises:
210 WaitForResponseTimedOutError: if timeout occurred while waiting for 210 WaitForResponseTimedOutError: if timeout occurred while waiting for
211 response to adb instrument command 211 response to adb instrument command
212 DeviceUnresponsiveError: if device system process is not responding 212 DeviceUnresponsiveError: if device system process is not responding
213 InstrumentationError: if instrumentation failed to run 213 InstrumentationError: if instrumentation failed to run
214 """ 214 """
215 215
216 command_string = self._BuildInstrumentationCommandPath( 216 command_string = self._BuildInstrumentationCommandPath(
217 instrumentation_path, no_window_animation=no_window_animation, 217 instrumentation_path, no_window_animation=no_window_animation,
218 profile=profile, raw_mode=True, 218 profile=profile, raw_mode=True,
219 instrumentation_args=instrumentation_args) 219 instrumentation_args=instrumentation_args)
220 logger.Log(command_string) 220 if silent_log:
221 logger.SilentLog(command_string)
222 else:
223 logger.Log(command_string)
221 (test_results, inst_finished_bundle) = ( 224 (test_results, inst_finished_bundle) = (
222 am_instrument_parser.ParseAmInstrumentOutput( 225 am_instrument_parser.ParseAmInstrumentOutput(
223 self.SendShellCommand(command_string, timeout_time=timeout_time, 226 self.SendShellCommand(command_string, timeout_time=timeout_time,
224 retry_count=2))) 227 retry_count=2)))
225
226 if "code" not in inst_finished_bundle: 228 if "code" not in inst_finished_bundle:
229 logger.Log('No code available. inst_finished_bundle contains: %s '
230 % inst_finished_bundle)
227 raise errors.InstrumentationError("no test results... device setup " 231 raise errors.InstrumentationError("no test results... device setup "
228 "correctly?") 232 "correctly?")
229 233
230 if inst_finished_bundle["code"] == "0": 234 if inst_finished_bundle["code"] == "0":
231 short_msg_result = "no error message" 235 long_msg_result = "no error message"
232 if "shortMsg" in inst_finished_bundle: 236 if "longMsg" in inst_finished_bundle:
233 short_msg_result = inst_finished_bundle["shortMsg"] 237 long_msg_result = inst_finished_bundle["longMsg"]
234 logger.Log("Error! Test run failed: %s" % short_msg_result) 238 logger.Log("Error! Test run failed: %s" % long_msg_result)
235 raise errors.InstrumentationError(short_msg_result) 239 raise errors.InstrumentationError(long_msg_result)
236 240
237 if "INSTRUMENTATION_ABORTED" in inst_finished_bundle: 241 if "INSTRUMENTATION_ABORTED" in inst_finished_bundle:
238 logger.Log("INSTRUMENTATION ABORTED!") 242 logger.Log("INSTRUMENTATION ABORTED!")
239 raise errors.DeviceUnresponsiveError 243 raise errors.DeviceUnresponsiveError
240 244
241 return (test_results, inst_finished_bundle) 245 return (test_results, inst_finished_bundle)
242 246
243 def StartInstrumentationNoResults( 247 def StartInstrumentationNoResults(
244 self, package_name, runner_name, no_window_animation=False, 248 self, package_name, runner_name, no_window_animation=False,
245 raw_mode=False, instrumentation_args={}): 249 raw_mode=False, instrumentation_args={}):
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 # press the MENU key, this will disable key guard if runtime is started 502 # press the MENU key, this will disable key guard if runtime is started
499 # with ro.monkey set to 1 503 # with ro.monkey set to 1
500 self.SendShellCommand("input keyevent 82", retry_count=retry_count) 504 self.SendShellCommand("input keyevent 82", retry_count=retry_count)
501 else: 505 else:
502 self.WaitForDevicePm() 506 self.WaitForDevicePm()
503 return output 507 return output
504 508
505 def GetSerialNumber(self): 509 def GetSerialNumber(self):
506 """Returns the serial number of the targeted device.""" 510 """Returns the serial number of the targeted device."""
507 return self.SendCommand("get-serialno").strip() 511 return self.SendCommand("get-serialno").strip()
OLDNEW
« no previous file with comments | « third_party/android_testrunner/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698