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

Side by Side Diff: build/android/monkeyrunner_screenshot.py

Issue 11470004: [Android] Add screenshot command line tool. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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/screenshot.py » ('j') | build/android/screenshot.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 import sys
8 from optparse import OptionParser
9 from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
10
11 def main(argv):
12 # Parse options.
13 parser = OptionParser()
14 parser.add_option("--serial", dest="serial",
15 help="connect to device with specified SERIAL",
16 metavar="SERIAL")
17 parser.add_option("--file", dest="filename",
18 help="write screenshot to FILE",
19 metavar="FILE", default="Screenshot.png")
20 parser.add_option("--timeout", dest="timeout",
21 help="TIMEOUT in seconds for connecting to a device",
22 metavar="TIMEOUT", default=120)
23 (options, args) = parser.parse_args(argv)
24
25 # Connect to the current device, returning a MonkeyDevice object.
26 # Monkeyrunner fails with a NullPointerException if options.serial is None.
27 if options.serial:
28 device = MonkeyRunner.waitForConnection(options.timeout, options.serial)
29 else:
30 device = MonkeyRunner.waitForConnection(options.timeout)
31
32 if not device:
33 return 1
34
35 # Grab screenshot and write to disk.
36 result = device.takeSnapshot()
37 result.writeToFile(options.filename, 'png')
38 return 0
39
40 if __name__ == '__main__':
41 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | build/android/screenshot.py » ('j') | build/android/screenshot.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698