13eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org#!/usr/bin/python
23eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
33eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org"""
43eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgCopyright 2014 Google Inc.
53eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
63eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgUse of this source code is governed by a BSD-style license that can be
73eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgfound in the LICENSE file.
83eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
93eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgTest compare_rendered_pictures.py
103eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
113eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgTODO(epoger): Create a command to update the expected results (in
123eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgself._output_dir_expected) when appropriate.  For now, you should:
1366ed8dc4bfd63e4552a213cb17909f9fbbf59abdepoger1. examine the results in self.output_dir_actual and make sure they are ok
143eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org2. rm -rf self._output_dir_expected
1566ed8dc4bfd63e4552a213cb17909f9fbbf59abdepoger3. mv self.output_dir_actual self._output_dir_expected
163eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgAlthough, if you're using an SVN checkout, this will blow away .svn directories
173eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgwithin self._output_dir_expected, which wouldn't be good...
183eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
193eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org"""
203eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
2166ed8dc4bfd63e4552a213cb17909f9fbbf59abdepoger# System-level imports
223eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgimport os
23e73cd5ab0f693ae0c81f5f1ca76045363b6f999depogerimport posixpath
24a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.orgimport subprocess
2566ed8dc4bfd63e4552a213cb17909f9fbbf59abdepoger
2666ed8dc4bfd63e4552a213cb17909f9fbbf59abdepoger# Must fix up PYTHONPATH before importing from within Skia
273b5c86c7a2db25f82a8415b6c79d1ac580fc64aestephanaimport rs_fixpypath  # pylint: disable=W0611
283eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
293eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org# Imports from within Skia
303eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgimport base_unittest
313eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgimport compare_rendered_pictures
3266ed8dc4bfd63e4552a213cb17909f9fbbf59abdepogerimport find_run_binary
3366ed8dc4bfd63e4552a213cb17909f9fbbf59abdepogerimport gm_json
340b7127635d8245de7ac704080d722d06e47621d0epogerimport imagediffdb
352529f2e72cddf87904c8ad4b613942cbef802cfbrmistryimport imagepairset
363eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgimport results
373eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
383eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
393eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgclass CompareRenderedPicturesTest(base_unittest.TestCase):
403eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
413eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org  def test_endToEnd(self):
42a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    """Generate two sets of SKPs, run render_pictures over both, and compare
43a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    the results."""
448d66dd1d4317e84c07c93c023e299e9a88069206epoger    setA_subdir = 'before_patch'
458d66dd1d4317e84c07c93c023e299e9a88069206epoger    setB_subdir = 'after_patch'
46a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    self._generate_skps_and_run_render_pictures(
478d66dd1d4317e84c07c93c023e299e9a88069206epoger        subdir=setA_subdir, skpdict={
48a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org            'changed.skp': 200,
49a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org            'unchanged.skp': 100,
50a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org            'only-in-before.skp': 128,
51a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        })
52a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    self._generate_skps_and_run_render_pictures(
538d66dd1d4317e84c07c93c023e299e9a88069206epoger        subdir=setB_subdir, skpdict={
54a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org            'changed.skp': 201,
55a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org            'unchanged.skp': 100,
56a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org            'only-in-after.skp': 128,
57a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        })
58a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org
593eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org    results_obj = compare_rendered_pictures.RenderedPicturesComparisons(
60caa80b9a46ea00a7b582d96d73302939aa21b5eeepoger        setA_dir=os.path.join(self.temp_dir, setA_subdir),
61caa80b9a46ea00a7b582d96d73302939aa21b5eeepoger        setB_dir=os.path.join(self.temp_dir, setB_subdir),
62e73cd5ab0f693ae0c81f5f1ca76045363b6f999depoger        setA_section=gm_json.JSONKEY_ACTUALRESULTS,
63e73cd5ab0f693ae0c81f5f1ca76045363b6f999depoger        setB_section=gm_json.JSONKEY_ACTUALRESULTS,
640b7127635d8245de7ac704080d722d06e47621d0epoger        image_diff_db=imagediffdb.ImageDiffDB(self.temp_dir),
650b7127635d8245de7ac704080d722d06e47621d0epoger        image_base_gs_url='gs://fakebucket/fake/path',
668d66dd1d4317e84c07c93c023e299e9a88069206epoger        diff_base_url='/static/generated-images')
673eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org    results_obj.get_timestamp = mock_get_timestamp
68a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org
695c4b137592a7937b4d02d72a976fa783f8d3675aepoger    # Overwrite elements within the results that change from one test run
705c4b137592a7937b4d02d72a976fa783f8d3675aepoger    # to the next.
715c4b137592a7937b4d02d72a976fa783f8d3675aepoger    # pylint: disable=W0212
725c4b137592a7937b4d02d72a976fa783f8d3675aepoger    results_obj._setA_descriptions[results.KEY__SET_DESCRIPTIONS__DIR] = [
735c4b137592a7937b4d02d72a976fa783f8d3675aepoger        'before-patch-fake-dir']
745c4b137592a7937b4d02d72a976fa783f8d3675aepoger    results_obj._setB_descriptions[results.KEY__SET_DESCRIPTIONS__DIR] = [
755c4b137592a7937b4d02d72a976fa783f8d3675aepoger        'after-patch-fake-dir']
765c4b137592a7937b4d02d72a976fa783f8d3675aepoger
773eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org    gm_json.WriteToFile(
783eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org        results_obj.get_packaged_results_of_type(
793eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org            results.KEY__HEADER__RESULTS_ALL),
8066ed8dc4bfd63e4552a213cb17909f9fbbf59abdepoger        os.path.join(self.output_dir_actual, 'compare_rendered_pictures.json'))
813eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
822529f2e72cddf87904c8ad4b613942cbef802cfbrmistry  def test_endToEnd_withImageBaseGSUrl(self):
832529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    """Generate two sets of SKPs, run render_pictures over both, and compare
842529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    the results."""
852529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    setA_subdir = 'before_patch'
862529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    setB_subdir = 'after_patch'
872529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    imageA_gs_base = 'superman/kent-camera/pictures'
882529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    imageB_gs_base = 'batman/batarang/pictures'
892529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    self._generate_skps_and_run_render_pictures(
902529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        subdir=setA_subdir, skpdict={
912529f2e72cddf87904c8ad4b613942cbef802cfbrmistry            'changed.skp': 200,
922529f2e72cddf87904c8ad4b613942cbef802cfbrmistry            'unchanged.skp': 100,
932529f2e72cddf87904c8ad4b613942cbef802cfbrmistry            'only-in-before.skp': 128,
942529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        },
952529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        image_base_gs_url='gs://%s' % imageA_gs_base)
962529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    self._generate_skps_and_run_render_pictures(
972529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        subdir=setB_subdir, skpdict={
982529f2e72cddf87904c8ad4b613942cbef802cfbrmistry            'changed.skp': 201,
992529f2e72cddf87904c8ad4b613942cbef802cfbrmistry            'unchanged.skp': 100,
1002529f2e72cddf87904c8ad4b613942cbef802cfbrmistry            'only-in-after.skp': 128,
1012529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        },
1022529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        image_base_gs_url='gs://%s' % imageB_gs_base)
1032529f2e72cddf87904c8ad4b613942cbef802cfbrmistry
1042529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    results_obj = compare_rendered_pictures.RenderedPicturesComparisons(
1052529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        setA_dir=os.path.join(self.temp_dir, setA_subdir),
1062529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        setB_dir=os.path.join(self.temp_dir, setB_subdir),
1072529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        setA_section=gm_json.JSONKEY_ACTUALRESULTS,
1082529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        setB_section=gm_json.JSONKEY_ACTUALRESULTS,
1092529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        image_diff_db=imagediffdb.ImageDiffDB(self.temp_dir),
1102529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        image_base_gs_url='gs://fakebucket/fake/path',
1112529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        diff_base_url='/static/generated-images')
1122529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    results_obj.get_timestamp = mock_get_timestamp
1132529f2e72cddf87904c8ad4b613942cbef802cfbrmistry
1142529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    output_dict = results_obj.get_packaged_results_of_type(
1152529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        results.KEY__HEADER__RESULTS_ALL)
1162529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    # Assert that the baseURLs are as expected.
1172529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    self.assertEquals(
1182529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        output_dict[imagepairset.KEY__ROOT__IMAGESETS]
1192529f2e72cddf87904c8ad4b613942cbef802cfbrmistry                   [imagepairset.KEY__IMAGESETS__SET__IMAGE_A]
1202529f2e72cddf87904c8ad4b613942cbef802cfbrmistry                   [imagepairset.KEY__IMAGESETS__FIELD__BASE_URL],
1212529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        'http://storage.cloud.google.com/%s' % imageA_gs_base)
1222529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    self.assertEquals(
1232529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        output_dict[imagepairset.KEY__ROOT__IMAGESETS]
1242529f2e72cddf87904c8ad4b613942cbef802cfbrmistry                   [imagepairset.KEY__IMAGESETS__SET__IMAGE_B]
1252529f2e72cddf87904c8ad4b613942cbef802cfbrmistry                   [imagepairset.KEY__IMAGESETS__FIELD__BASE_URL],
1262529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        'http://storage.cloud.google.com/%s' % imageB_gs_base)
1272529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    # Overwrite elements within the results that change from one test run
1282529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    # to the next.
1292529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    # pylint: disable=W0212
1302529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    results_obj._setA_descriptions[results.KEY__SET_DESCRIPTIONS__DIR] = [
1312529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        'before-patch-fake-dir']
1322529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    results_obj._setB_descriptions[results.KEY__SET_DESCRIPTIONS__DIR] = [
1332529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        'after-patch-fake-dir']
1342529f2e72cddf87904c8ad4b613942cbef802cfbrmistry
1352529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    gm_json.WriteToFile(
1362529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        output_dict,
1372529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        os.path.join(self.output_dir_actual,
1382529f2e72cddf87904c8ad4b613942cbef802cfbrmistry                               'compare_rendered_pictures.json'))
1392529f2e72cddf87904c8ad4b613942cbef802cfbrmistry
1407909f47b423dacaff8623e8be247586108c3be66epoger  def test_repo_url(self):
1417909f47b423dacaff8623e8be247586108c3be66epoger    """Use repo: URL to specify summary files."""
142e73cd5ab0f693ae0c81f5f1ca76045363b6f999depoger    base_repo_url = 'repo:gm/rebaseline_server/testdata/inputs/skp-summaries'
1437909f47b423dacaff8623e8be247586108c3be66epoger    results_obj = compare_rendered_pictures.RenderedPicturesComparisons(
144caa80b9a46ea00a7b582d96d73302939aa21b5eeepoger        setA_dir=posixpath.join(base_repo_url, 'expectations'),
145caa80b9a46ea00a7b582d96d73302939aa21b5eeepoger        setB_dir=posixpath.join(base_repo_url, 'actuals'),
146e73cd5ab0f693ae0c81f5f1ca76045363b6f999depoger        setA_section=gm_json.JSONKEY_EXPECTEDRESULTS,
147e73cd5ab0f693ae0c81f5f1ca76045363b6f999depoger        setB_section=gm_json.JSONKEY_ACTUALRESULTS,
1487909f47b423dacaff8623e8be247586108c3be66epoger        image_diff_db=imagediffdb.ImageDiffDB(self.temp_dir),
1497909f47b423dacaff8623e8be247586108c3be66epoger        image_base_gs_url='gs://fakebucket/fake/path',
1508d66dd1d4317e84c07c93c023e299e9a88069206epoger        diff_base_url='/static/generated-images')
1517909f47b423dacaff8623e8be247586108c3be66epoger    results_obj.get_timestamp = mock_get_timestamp
1527909f47b423dacaff8623e8be247586108c3be66epoger
1535c4b137592a7937b4d02d72a976fa783f8d3675aepoger    # Overwrite elements within the results that change from one test run
1545c4b137592a7937b4d02d72a976fa783f8d3675aepoger    # to the next.
1555c4b137592a7937b4d02d72a976fa783f8d3675aepoger    # pylint: disable=W0212
1565c4b137592a7937b4d02d72a976fa783f8d3675aepoger    results_obj._setA_descriptions\
1575c4b137592a7937b4d02d72a976fa783f8d3675aepoger        [results.KEY__SET_DESCRIPTIONS__REPO_REVISION] = 'fake-repo-revision'
1585c4b137592a7937b4d02d72a976fa783f8d3675aepoger    results_obj._setB_descriptions\
1595c4b137592a7937b4d02d72a976fa783f8d3675aepoger        [results.KEY__SET_DESCRIPTIONS__REPO_REVISION] = 'fake-repo-revision'
1605c4b137592a7937b4d02d72a976fa783f8d3675aepoger
1617909f47b423dacaff8623e8be247586108c3be66epoger    gm_json.WriteToFile(
1627909f47b423dacaff8623e8be247586108c3be66epoger        results_obj.get_packaged_results_of_type(
1637909f47b423dacaff8623e8be247586108c3be66epoger            results.KEY__HEADER__RESULTS_ALL),
1647909f47b423dacaff8623e8be247586108c3be66epoger        os.path.join(self.output_dir_actual, 'compare_rendered_pictures.json'))
1657909f47b423dacaff8623e8be247586108c3be66epoger
1662529f2e72cddf87904c8ad4b613942cbef802cfbrmistry  def _generate_skps_and_run_render_pictures(self, subdir, skpdict,
1672529f2e72cddf87904c8ad4b613942cbef802cfbrmistry                                             image_base_gs_url=None):
168a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    """Generate SKPs and run render_pictures on them.
169a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org
170a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    Args:
17166ed8dc4bfd63e4552a213cb17909f9fbbf59abdepoger      subdir: subdirectory (within self.temp_dir) to write all files into
172a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org      skpdict: {skpname: redvalue} dictionary describing the SKP files to render
173a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    """
17466ed8dc4bfd63e4552a213cb17909f9fbbf59abdepoger    out_path = os.path.join(self.temp_dir, subdir)
175a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    os.makedirs(out_path)
176a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    for skpname, redvalue in skpdict.iteritems():
177a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org      self._run_skpmaker(
178a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org          output_path=os.path.join(out_path, skpname), red=redvalue)
179a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org
180a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    # TODO(epoger): Add --mode tile 256 256 --writeWholeImage to the unittest,
181a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    # and fix its result!  (imageURLs within whole-image entries are wrong when
182a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    # I tried adding that)
18366ed8dc4bfd63e4552a213cb17909f9fbbf59abdepoger    binary = find_run_binary.find_path_to_program('render_pictures')
1842529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    render_pictures_cmd = [
185a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        binary,
186a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        '--config', '8888',
187a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        '-r', out_path,
188a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        '--writeChecksumBasedFilenames',
189a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        '--writeJsonSummaryPath', os.path.join(out_path, 'summary.json'),
1902529f2e72cddf87904c8ad4b613942cbef802cfbrmistry        '--writePath', out_path]
1912529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    if image_base_gs_url:
1922529f2e72cddf87904c8ad4b613942cbef802cfbrmistry      render_pictures_cmd.extend(['--imageBaseGSUrl', image_base_gs_url])
1932529f2e72cddf87904c8ad4b613942cbef802cfbrmistry    return subprocess.check_output(render_pictures_cmd)
194a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org
195a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org  def _run_skpmaker(self, output_path, red=0, green=0, blue=0,
196a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org                    width=640, height=400):
197a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    """Runs the skpmaker binary to generate SKP with known characteristics.
198a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org
199a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    Args:
200a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org      output_path: Filepath to write the SKP into.
201a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org      red: Value of red color channel in image, 0-255.
202a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org      green: Value of green color channel in image, 0-255.
203a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org      blue: Value of blue color channel in image, 0-255.
204a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org      width: Width of canvas to create.
205a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org      height: Height of canvas to create.
206a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    """
20766ed8dc4bfd63e4552a213cb17909f9fbbf59abdepoger    binary = find_run_binary.find_path_to_program('skpmaker')
208a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org    return subprocess.check_output([
209a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        binary,
210a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        '--red', str(red),
211a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        '--green', str(green),
212a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        '--blue', str(blue),
213a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        '--width', str(width),
214a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        '--height', str(height),
215a60d0370b11b2905059be9f6d84b09da7ee2b4fbcommit-bot@chromium.org        '--writePath', str(output_path)])
2163eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
2173eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgdef mock_get_timestamp():
2183eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org  """Mock version of BaseComparisons.get_timestamp() for testing."""
2193eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org  return 12345678
2203eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
2213eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
2223eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgdef main():
2233eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org  base_unittest.main(CompareRenderedPicturesTest)
2243eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
2253eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org
2263eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.orgif __name__ == '__main__':
2273eb77e4d5a381fa55197f6bd03c599e709146069commit-bot@chromium.org  main()
228