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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 11366068: Take screenshots using /system/bin/screencap instead of monkeyrunner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | « no previous file | build/android/pylib/constants.py » ('j') | build/android/pylib/run_java_tests.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Provides an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 9
10 import collections 10 import collections
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 1059
1060 status = self._adb.SendShellCommand( 1060 status = self._adb.SendShellCommand(
1061 '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name)) 1061 '\'ls "%s" >/dev/null 2>&1; echo $?\'' % (file_name))
1062 return int(status) == 0 1062 return int(status) == 0
1063 except ValueError: 1063 except ValueError:
1064 if IsDeviceAttached(self._device): 1064 if IsDeviceAttached(self._device):
1065 raise errors.DeviceUnresponsiveError('Device may be offline.') 1065 raise errors.DeviceUnresponsiveError('Device may be offline.')
1066 1066
1067 return False 1067 return False
1068 1068
1069 def TakeScreenshot(self, host_file):
1070 """Saves a screenshot image to |host_file| on the host.
1071
1072 Args:
1073 host_file: Absolute path to the image file to store on the host.
1074 """
1075 device_file = '%s/screenshot.png' % self.GetExternalStorage()
1076 self.RunShellCommand('/system/bin/screencap -p %s' % device_file)
1077 assert self._adb.Pull(device_file, host_file)
1078 assert os.path.exists(host_file)
1079
1069 1080
1070 class NewLineNormalizer(object): 1081 class NewLineNormalizer(object):
1071 """A file-like object to normalize EOLs to '\n'. 1082 """A file-like object to normalize EOLs to '\n'.
1072 1083
1073 Pexpect runs adb within a pseudo-tty device (see 1084 Pexpect runs adb within a pseudo-tty device (see
1074 http://www.noah.org/wiki/pexpect), so any '\n' printed by adb is written 1085 http://www.noah.org/wiki/pexpect), so any '\n' printed by adb is written
1075 as '\r\n' to the logfile. Since adb already uses '\r\n' to terminate 1086 as '\r\n' to the logfile. Since adb already uses '\r\n' to terminate
1076 lines, the log ends up having '\r\r\n' at the end of each line. This 1087 lines, the log ends up having '\r\r\n' at the end of each line. This
1077 filter replaces the above with a single '\n' in the data stream. 1088 filter replaces the above with a single '\n' in the data stream.
1078 """ 1089 """
1079 def __init__(self, output): 1090 def __init__(self, output):
1080 self._output = output 1091 self._output = output
1081 1092
1082 def write(self, data): 1093 def write(self, data):
1083 data = data.replace('\r\r\n', '\n') 1094 data = data.replace('\r\r\n', '\n')
1084 self._output.write(data) 1095 self._output.write(data)
1085 1096
1086 def flush(self): 1097 def flush(self):
1087 self._output.flush() 1098 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/constants.py » ('j') | build/android/pylib/run_java_tests.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698