edisonn@google.com | 2a827e8 | 2012-10-10 15:20:34 +0000 | [diff] [blame] | 1 | ''' |
| 2 | Compares the rendererings of serialized SkPictures to expected images. |
| 3 | |
| 4 | Launch with --help to see more information. |
| 5 | |
| 6 | |
| 7 | Copyright 2012 Google Inc. |
| 8 | |
| 9 | Use of this source code is governed by a BSD-style license that can be |
| 10 | found in the LICENSE file. |
| 11 | ''' |
| 12 | # common Python modules |
| 13 | import os |
| 14 | import optparse |
| 15 | import sys |
| 16 | import shutil |
| 17 | import tempfile |
| 18 | import test_rendering |
| 19 | |
| 20 | USAGE_STRING = 'Usage: %s input... expectedDir' |
| 21 | HELP_STRING = ''' |
| 22 | |
| 23 | Takes input SkPicture files and renders them as PDF files, and then compares |
| 24 | those resulting PDF files against PDF files found in expectedDir. |
| 25 | |
| 26 | Each instance of "input" can be either a file (name must end in .skp), or a |
| 27 | directory (in which case this script will process all .skp files within the |
| 28 | directory). |
| 29 | ''' |
| 30 | |
| 31 | |
| 32 | def Main(args): |
| 33 | """Allow other scripts to call this script with fake command-line args. |
| 34 | |
| 35 | @param The commandline argument list |
| 36 | """ |
| 37 | parser = optparse.OptionParser(USAGE_STRING % '%prog' + HELP_STRING) |
| 38 | parser.add_option('--render_dir', dest='render_dir', |
| 39 | help = ('specify the location to output the rendered ' |
| 40 | 'files. Default is a temp directory.')) |
| 41 | parser.add_option('--diff_dir', dest='diff_dir', |
| 42 | help = ('specify the location to output the diff files. ' |
| 43 | 'Default is a temp directory.')) |
| 44 | |
| 45 | options, arguments = parser.parse_args(args) |
| 46 | |
| 47 | if (len(arguments) < 3): |
| 48 | print("Expected at least one input and one ouput folder.") |
| 49 | parser.print_help() |
| 50 | sys.exit(-1) |
| 51 | |
| 52 | inputs = arguments[1:-1] |
| 53 | expected_dir = arguments[-1] |
| 54 | |
| 55 | test_rendering.TestRenderSkps(inputs, expected_dir, options.render_dir, |
| 56 | options.diff_dir, 'render_pdfs', '') |
| 57 | |
| 58 | if __name__ == '__main__': |
| 59 | Main(sys.argv) |
| 60 | |