111f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org#!/usr/bin/python 211f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 311f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org""" 411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgCopyright 2014 Google Inc. 511f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 611f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgUse of this source code is governed by a BSD-style license that can be 711f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgfound in the LICENSE file. 811f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 911f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgTest the render_pictures binary. 1011f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org""" 1111f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 1211f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org# System-level imports 13205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.orgimport copy 1411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgimport json 1511f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgimport os 1611f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgimport shutil 1711f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgimport tempfile 1811f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 1911f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org# Imports from within Skia 2011f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgimport base_unittest 2111f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 22c3147c668cb454d3762515313ea7bbdc38af146bcommit-bot@chromium.org# Maximum length of text diffs to show when tests fail 23c3147c668cb454d3762515313ea7bbdc38af146bcommit-bot@chromium.orgMAX_DIFF_LENGTH = 30000 24c3147c668cb454d3762515313ea7bbdc38af146bcommit-bot@chromium.org 2524c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.orgEXPECTED_HEADER_CONTENTS = { 2624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "type" : "ChecksummedImages", 2724c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "revision" : 1, 2824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org} 2924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org 304610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org# Manually verified: 640x400 red rectangle with black border 31205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org# Standard expectations will be set up in such a way that this image fails 32205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org# the comparison. 334610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.orgRED_WHOLEIMAGE = { 344610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 354610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 11092453015575919668, 36205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "failed", 374610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "red_skp.png", 384610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org} 394610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org 404610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org# Manually verified: 640x400 green rectangle with black border 41205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org# Standard expectations will be set up in such a way that this image passes 42205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org# the comparison. 434610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.orgGREEN_WHOLEIMAGE = { 444610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 454610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 8891695120562235492, 46205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "succeeded", 474610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "green_skp.png", 484610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org} 494610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org 504610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org# Manually verified these 6 images, all 256x256 tiles, 514610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org# consistent with a tiled version of the 640x400 red rect 524610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org# with black borders. 53205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org# Standard expectations will be set up in such a way that these images fail 54205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org# the comparison. 554610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.orgRED_TILES = [{ 564610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 574610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 5815827069051002745, 58205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "failed", 594610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "red_skp-tile0.png", 604610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org},{ 614610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 624610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 9323613075234140270, 63205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "failed", 644610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "red_skp-tile1.png", 654610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}, { 664610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 674610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 16670399404877552232, 68205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "failed", 694610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "red_skp-tile2.png", 704610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}, { 714610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 724610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 2507897274083364964, 73205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "failed", 744610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "red_skp-tile3.png", 754610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}, { 764610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 774610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 7325267995523877959, 78205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "failed", 794610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "red_skp-tile4.png", 804610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}, { 814610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 824610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 2181381724594493116, 83205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "failed", 844610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "red_skp-tile5.png", 854610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}] 864610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org 874610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org# Manually verified these 6 images, all 256x256 tiles, 884610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org# consistent with a tiled version of the 640x400 green rect 894610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org# with black borders. 90205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org# Standard expectations will be set up in such a way that these images pass 91205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org# the comparison. 924610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.orgGREEN_TILES = [{ 934610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 944610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 12587324416545178013, 95205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "succeeded", 964610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "green_skp-tile0.png", 974610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}, { 984610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 994610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 7624374914829746293, 100205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "succeeded", 1014610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "green_skp-tile1.png", 1024610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}, { 1034610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 1044610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 5686489729535631913, 105205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "succeeded", 1064610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "green_skp-tile2.png", 1074610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}, { 1084610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 1094610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 7980646035555096146, 110205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "succeeded", 1114610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "green_skp-tile3.png", 1124610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}, { 1134610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 1144610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 17817086664365875131, 115205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "succeeded", 1164610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "green_skp-tile4.png", 1174610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}, { 1184610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 1194610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "checksumValue" : 10673669813016809363, 120205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "comparisonResult" : "succeeded", 1214610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "filepath" : "green_skp-tile5.png", 1224610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org}] 1234610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org 12411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 125205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.orgdef modified_dict(input_dict, modification_dict): 126205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org """Returns a dict, with some modifications applied to it. 127205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org 128205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org Args: 129205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org input_dict: a dictionary (which will be copied, not modified in place) 130205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org modification_dict: a set of key/value pairs to overwrite in the dict 131205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org """ 132205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org output_dict = input_dict.copy() 133205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org output_dict.update(modification_dict) 134205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org return output_dict 135205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org 136205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org 137205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.orgdef modified_list_of_dicts(input_list, modification_dict): 138205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org """Returns a list of dicts, with some modifications applied to each dict. 139205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org 140205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org Args: 141205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org input_list: a list of dictionaries; these dicts will be copied, not 142205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org modified in place 143205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org modification_dict: a set of key/value pairs to overwrite in each dict 144205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org within input_list 145205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org """ 146205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org output_list = [] 147205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org for input_dict in input_list: 148205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org output_dict = modified_dict(input_dict, modification_dict) 149205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org output_list.append(output_dict) 150205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org return output_list 151205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org 152205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org 15311f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgclass RenderPicturesTest(base_unittest.TestCase): 15411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 15511f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org def setUp(self): 156205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org self.maxDiff = MAX_DIFF_LENGTH 157205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org self._expectations_dir = tempfile.mkdtemp() 158f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org self._input_skp_dir = tempfile.mkdtemp() 1593f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org # All output of render_pictures binary will go into this directory. 1603f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org self._output_dir = tempfile.mkdtemp() 16111f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 16211f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org def tearDown(self): 163205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org shutil.rmtree(self._expectations_dir) 164f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org shutil.rmtree(self._input_skp_dir) 1653f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org shutil.rmtree(self._output_dir) 16611f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 167f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org def test_tiled_whole_image(self): 1684610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org """Run render_pictures with tiles and --writeWholeImage flag. 1694610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org 1704610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org TODO(epoger): This test generates undesired results! The JSON summary 1714610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org includes both whole-image and tiled-images (as it should), but only 1724610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org whole-images are written out to disk. See http://skbug.com/2463 1733f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org Once I fix that, I should add a similar test that exercises mismatchPath. 1744610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org 1754610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org TODO(epoger): I noticed that when this is run without --writePath being 1764610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org specified, this test writes red_skp.png and green_skp.png to the current 1774610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org directory. We should fix that... if --writePath is not specified, this 1784610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org probably shouldn't write out red_skp.png and green_skp.png at all! 1794610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org See http://skbug.com/2464 1804610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org """ 1813f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org output_json_path = os.path.join(self._output_dir, 'actuals.json') 1823f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org write_path_dir = self.create_empty_dir( 1833f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org path=os.path.join(self._output_dir, 'writePath')) 184f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org self._generate_skps() 185205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org expectations_path = self._create_expectations() 186205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org self._run_render_pictures([ 187205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '-r', self._input_skp_dir, 188205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--bbh', 'grid', '256', '256', 189205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--mode', 'tile', '256', '256', 190205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--readJsonSummaryPath', expectations_path, 191205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--writeJsonSummaryPath', output_json_path, 1923f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--writePath', write_path_dir, 193205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--writeWholeImage']) 19411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org expected_summary_dict = { 19524c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "header" : EXPECTED_HEADER_CONTENTS, 19611f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org "actual-results" : { 19724c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "red.skp": { 1984610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "tiled-images": RED_TILES, 1994610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "whole-image": RED_WHOLEIMAGE, 20024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, 20124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "green.skp": { 2024610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "tiled-images": GREEN_TILES, 2034610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "whole-image": GREEN_WHOLEIMAGE, 20411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org } 20511f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org } 206238771c9309e491373bdd68bf7e27c57f54175eccommit-bot@chromium.org } 20711f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org self._assert_json_contents(output_json_path, expected_summary_dict) 208f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self._assert_directory_contents( 2093f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org write_path_dir, ['red_skp.png', 'green_skp.png']) 210205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org 211205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org def test_missing_tile_and_whole_image(self): 212205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org """test_tiled_whole_image, but missing expectations for some images. 213205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org """ 2143f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org output_json_path = os.path.join(self._output_dir, 'actuals.json') 2153f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org write_path_dir = self.create_empty_dir( 2163f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org path=os.path.join(self._output_dir, 'writePath')) 217205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org self._generate_skps() 218205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org expectations_path = self._create_expectations(missing_some_images=True) 219205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org self._run_render_pictures([ 220205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '-r', self._input_skp_dir, 221205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--bbh', 'grid', '256', '256', 222205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--mode', 'tile', '256', '256', 223205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--readJsonSummaryPath', expectations_path, 224205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--writeJsonSummaryPath', output_json_path, 2253f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--writePath', write_path_dir, 226205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--writeWholeImage']) 227205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org modified_red_tiles = copy.deepcopy(RED_TILES) 228205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org modified_red_tiles[5]['comparisonResult'] = 'no-comparison' 229205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org expected_summary_dict = { 230205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "header" : EXPECTED_HEADER_CONTENTS, 231205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "actual-results" : { 232205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "red.skp": { 233205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "tiled-images": modified_red_tiles, 234205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "whole-image": modified_dict( 235205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), 236205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org }, 237205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "green.skp": { 238205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "tiled-images": GREEN_TILES, 239205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "whole-image": GREEN_WHOLEIMAGE, 240205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org } 241205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org } 242205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org } 243205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org self._assert_json_contents(output_json_path, expected_summary_dict) 24411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 245abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org def _test_untiled(self, expectations_path=None, expected_summary_dict=None, 246abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org additional_args=None): 247abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org """Base for multiple tests without tiles. 248abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org 249abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org Args: 250abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org expectations_path: path we should pass using --readJsonSummaryPath, or 251abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org None if we should create the default expectations file 252abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org expected_summary_dict: dict we should compare against the output actual 253abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org results summary, or None if we should use a default comparison dict 254abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org additional_args: array of command-line args to add when we run 255abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org render_pictures 256abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org """ 2573f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org output_json_path = os.path.join(self._output_dir, 'actuals.json') 2583f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org write_path_dir = self.create_empty_dir( 2593f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org path=os.path.join(self._output_dir, 'writePath')) 260f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org self._generate_skps() 261abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org if expectations_path == None: 262abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org expectations_path = self._create_expectations() 263abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org args = [ 264205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '-r', self._input_skp_dir, 265205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--readJsonSummaryPath', expectations_path, 2663f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--writePath', write_path_dir, 267abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org '--writeJsonSummaryPath', output_json_path, 268abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org ] 269abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org if additional_args: 270abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org args.extend(additional_args) 271abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org self._run_render_pictures(args) 272abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org if expected_summary_dict == None: 273abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org expected_summary_dict = { 274abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org "header" : EXPECTED_HEADER_CONTENTS, 275abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org "actual-results" : { 276abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org "red.skp": { 277abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org "whole-image": RED_WHOLEIMAGE, 278abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org }, 279abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org "green.skp": { 280abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org "whole-image": GREEN_WHOLEIMAGE, 281abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org } 282abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org } 283abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org } 284abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org self._assert_json_contents(output_json_path, expected_summary_dict) 285abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org self._assert_directory_contents( 286abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org write_path_dir, ['red_skp.png', 'green_skp.png']) 287abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org 288abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org def test_untiled(self): 289abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org """Basic test without tiles.""" 290abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org self._test_untiled() 291abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org 292abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org def test_untiled_empty_expectations_file(self): 293abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org """Same as test_untiled, but with an empty expectations file.""" 294abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org expectations_path = os.path.join(self._expectations_dir, 'empty') 295abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org with open(expectations_path, 'w') as fh: 296abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org pass 29711f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org expected_summary_dict = { 29824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "header" : EXPECTED_HEADER_CONTENTS, 29911f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org "actual-results" : { 30024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "red.skp": { 301abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org "whole-image": modified_dict( 302abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), 30324c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, 30424c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "green.skp": { 305abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org "whole-image": modified_dict( 306abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org GREEN_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), 30711f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org } 30811f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org } 309c3147c668cb454d3762515313ea7bbdc38af146bcommit-bot@chromium.org } 310abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org self._test_untiled(expectations_path=expectations_path, 311abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org expected_summary_dict=expected_summary_dict) 312f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 313f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org def test_untiled_writeChecksumBasedFilenames(self): 314f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org """Same as test_untiled, but with --writeChecksumBasedFilenames.""" 3153f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org output_json_path = os.path.join(self._output_dir, 'actuals.json') 3163f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org write_path_dir = self.create_empty_dir( 3173f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org path=os.path.join(self._output_dir, 'writePath')) 318f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self._generate_skps() 319f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self._run_render_pictures(['-r', self._input_skp_dir, 320f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org '--writeChecksumBasedFilenames', 3213f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--writePath', write_path_dir, 322f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org '--writeJsonSummaryPath', output_json_path]) 323f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org expected_summary_dict = { 32424c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "header" : EXPECTED_HEADER_CONTENTS, 325f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org "actual-results" : { 32624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "red.skp": { 327f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org # Manually verified: 640x400 red rectangle with black border 32824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "whole-image": { 32924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 33024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 11092453015575919668, 33124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 33224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "red_skp/bitmap-64bitMD5_11092453015575919668.png", 33324c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, 33424c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, 33524c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "green.skp": { 336f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org # Manually verified: 640x400 green rectangle with black border 33724c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "whole-image": { 33824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 33924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 8891695120562235492, 34024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 34124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "green_skp/bitmap-64bitMD5_8891695120562235492.png", 34224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, 343f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org } 344f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org } 345f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org } 346f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self._assert_json_contents(output_json_path, expected_summary_dict) 3473f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org self._assert_directory_contents(write_path_dir, ['red_skp', 'green_skp']) 34824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org self._assert_directory_contents( 3493f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org os.path.join(write_path_dir, 'red_skp'), 35024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org ['bitmap-64bitMD5_11092453015575919668.png']) 351f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self._assert_directory_contents( 3523f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org os.path.join(write_path_dir, 'green_skp'), 35324c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org ['bitmap-64bitMD5_8891695120562235492.png']) 35411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 355f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org def test_untiled_validate(self): 3564610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org """Same as test_untiled, but with --validate.""" 357abeb9589ec9e918203249652b15e7af6c9b33e18commit-bot@chromium.org self._test_untiled(additional_args=['--validate']) 358c3147c668cb454d3762515313ea7bbdc38af146bcommit-bot@chromium.org 359f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org def test_untiled_without_writePath(self): 3604610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org """Same as test_untiled, but without --writePath.""" 3613f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org output_json_path = os.path.join(self._output_dir, 'actuals.json') 362f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org self._generate_skps() 363205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org expectations_path = self._create_expectations() 364205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org self._run_render_pictures([ 365205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '-r', self._input_skp_dir, 366205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--readJsonSummaryPath', expectations_path, 367205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--writeJsonSummaryPath', output_json_path]) 368c3147c668cb454d3762515313ea7bbdc38af146bcommit-bot@chromium.org expected_summary_dict = { 36924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "header" : EXPECTED_HEADER_CONTENTS, 3704610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "actual-results" : { 3714610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "red.skp": { 3724610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "whole-image": RED_WHOLEIMAGE, 3734610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org }, 3744610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "green.skp": { 3754610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "whole-image": GREEN_WHOLEIMAGE, 3764610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org } 3774610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org } 378c3147c668cb454d3762515313ea7bbdc38af146bcommit-bot@chromium.org } 379c3147c668cb454d3762515313ea7bbdc38af146bcommit-bot@chromium.org self._assert_json_contents(output_json_path, expected_summary_dict) 38011f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 381f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org def test_tiled(self): 382c3147c668cb454d3762515313ea7bbdc38af146bcommit-bot@chromium.org """Generate individual tiles.""" 3833f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org output_json_path = os.path.join(self._output_dir, 'actuals.json') 3843f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org write_path_dir = self.create_empty_dir( 3853f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org path=os.path.join(self._output_dir, 'writePath')) 386f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org self._generate_skps() 387205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org expectations_path = self._create_expectations() 388205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org self._run_render_pictures([ 389205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '-r', self._input_skp_dir, 390205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--bbh', 'grid', '256', '256', 391205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--mode', 'tile', '256', '256', 392205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--readJsonSummaryPath', expectations_path, 3933f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--writePath', write_path_dir, 394205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org '--writeJsonSummaryPath', output_json_path]) 39511f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org expected_summary_dict = { 39624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "header" : EXPECTED_HEADER_CONTENTS, 39711f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org "actual-results" : { 39824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "red.skp": { 3994610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "tiled-images": RED_TILES, 40024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, 40124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "green.skp": { 4024610a465b61f27ea5de2254a0e0b79ea2f327617commit-bot@chromium.org "tiled-images": GREEN_TILES, 40311f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org } 40411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org } 405c3147c668cb454d3762515313ea7bbdc38af146bcommit-bot@chromium.org } 40611f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org self._assert_json_contents(output_json_path, expected_summary_dict) 407f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self._assert_directory_contents( 4083f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org write_path_dir, 40924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org ['red_skp-tile0.png', 'red_skp-tile1.png', 'red_skp-tile2.png', 41024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org 'red_skp-tile3.png', 'red_skp-tile4.png', 'red_skp-tile5.png', 41124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org 'green_skp-tile0.png', 'green_skp-tile1.png', 'green_skp-tile2.png', 41224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org 'green_skp-tile3.png', 'green_skp-tile4.png', 'green_skp-tile5.png', 4133f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org ]) 4143f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org 4153f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org def test_tiled_mismatches(self): 4163f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org """Same as test_tiled, but only write out mismatching images.""" 4173f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org output_json_path = os.path.join(self._output_dir, 'actuals.json') 4183f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org mismatch_path_dir = self.create_empty_dir( 4193f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org path=os.path.join(self._output_dir, 'mismatchPath')) 4203f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org self._generate_skps() 4213f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org expectations_path = self._create_expectations() 4223f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org self._run_render_pictures([ 4233f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '-r', self._input_skp_dir, 4243f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--bbh', 'grid', '256', '256', 4253f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--mode', 'tile', '256', '256', 4263f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--readJsonSummaryPath', expectations_path, 4273f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--mismatchPath', mismatch_path_dir, 4283f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--writeJsonSummaryPath', output_json_path]) 4293f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org expected_summary_dict = { 4303f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org "header" : EXPECTED_HEADER_CONTENTS, 4313f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org "actual-results" : { 4323f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org "red.skp": { 4333f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org "tiled-images": RED_TILES, 4343f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org }, 4353f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org "green.skp": { 4363f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org "tiled-images": GREEN_TILES, 4373f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org } 4383f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org } 4393f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org } 4403f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org self._assert_json_contents(output_json_path, expected_summary_dict) 4413f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org self._assert_directory_contents( 4423f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org mismatch_path_dir, 4433f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org ['red_skp-tile0.png', 'red_skp-tile1.png', 'red_skp-tile2.png', 4443f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org 'red_skp-tile3.png', 'red_skp-tile4.png', 'red_skp-tile5.png', 4453f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org ]) 446f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 447f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org def test_tiled_writeChecksumBasedFilenames(self): 448f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org """Same as test_tiled, but with --writeChecksumBasedFilenames.""" 4493f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org output_json_path = os.path.join(self._output_dir, 'actuals.json') 4503f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org write_path_dir = self.create_empty_dir( 4513f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org path=os.path.join(self._output_dir, 'writePath')) 452f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self._generate_skps() 453f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self._run_render_pictures(['-r', self._input_skp_dir, 454f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org '--bbh', 'grid', '256', '256', 455f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org '--mode', 'tile', '256', '256', 456f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org '--writeChecksumBasedFilenames', 4573f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org '--writePath', write_path_dir, 458f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org '--writeJsonSummaryPath', output_json_path]) 459f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org expected_summary_dict = { 46024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "header" : EXPECTED_HEADER_CONTENTS, 461f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org "actual-results" : { 46224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "red.skp": { 463f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org # Manually verified these 6 images, all 256x256 tiles, 464f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org # consistent with a tiled version of the 640x400 red rect 465f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org # with black borders. 46624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "tiled-images": [{ 46724c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 46824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 5815827069051002745, 46924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 47024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "red_skp/bitmap-64bitMD5_5815827069051002745.png", 47124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, { 47224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 47324c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 9323613075234140270, 47424c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 47524c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "red_skp/bitmap-64bitMD5_9323613075234140270.png", 47624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, { 47724c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 47824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 16670399404877552232, 47924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 48024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "red_skp/bitmap-64bitMD5_16670399404877552232.png", 48124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, { 48224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 48324c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 2507897274083364964, 48424c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 48524c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "red_skp/bitmap-64bitMD5_2507897274083364964.png", 48624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, { 48724c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 48824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 7325267995523877959, 48924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 49024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "red_skp/bitmap-64bitMD5_7325267995523877959.png", 49124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, { 49224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 49324c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 2181381724594493116, 49424c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 49524c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "red_skp/bitmap-64bitMD5_2181381724594493116.png", 49624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }], 49724c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, 49824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "green.skp": { 499f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org # Manually verified these 6 images, all 256x256 tiles, 500f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org # consistent with a tiled version of the 640x400 green rect 501f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org # with black borders. 50224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "tiled-images": [{ 50324c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 50424c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 12587324416545178013, 50524c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 50624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "green_skp/bitmap-64bitMD5_12587324416545178013.png", 50724c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, { 50824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 50924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 7624374914829746293, 51024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 51124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "green_skp/bitmap-64bitMD5_7624374914829746293.png", 51224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, { 51324c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 51424c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 5686489729535631913, 51524c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 51624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "green_skp/bitmap-64bitMD5_5686489729535631913.png", 51724c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, { 51824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 51924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 7980646035555096146, 52024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 52124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "green_skp/bitmap-64bitMD5_7980646035555096146.png", 52224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, { 52324c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 52424c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 17817086664365875131, 52524c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 52624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "green_skp/bitmap-64bitMD5_17817086664365875131.png", 52724c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }, { 52824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumAlgorithm" : "bitmap-64bitMD5", 52924c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "checksumValue" : 10673669813016809363, 53024c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "comparisonResult" : "no-comparison", 53124c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org "filepath" : "green_skp/bitmap-64bitMD5_10673669813016809363.png", 53224c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org }], 533f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org } 534f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org } 535f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org } 536f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self._assert_json_contents(output_json_path, expected_summary_dict) 5373f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org self._assert_directory_contents(write_path_dir, ['red_skp', 'green_skp']) 538f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self._assert_directory_contents( 5393f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org os.path.join(write_path_dir, 'red_skp'), 540f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org ['bitmap-64bitMD5_5815827069051002745.png', 541f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 'bitmap-64bitMD5_9323613075234140270.png', 542f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 'bitmap-64bitMD5_16670399404877552232.png', 543f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 'bitmap-64bitMD5_2507897274083364964.png', 544f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 'bitmap-64bitMD5_7325267995523877959.png', 54524c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org 'bitmap-64bitMD5_2181381724594493116.png']) 54624c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org self._assert_directory_contents( 5473f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org os.path.join(write_path_dir, 'green_skp'), 54824c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org ['bitmap-64bitMD5_12587324416545178013.png', 549f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 'bitmap-64bitMD5_7624374914829746293.png', 550f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 'bitmap-64bitMD5_5686489729535631913.png', 551f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 'bitmap-64bitMD5_7980646035555096146.png', 552f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 'bitmap-64bitMD5_17817086664365875131.png', 55324c568c1597de9f54df8cea3b46f2e93028a5aeccommit-bot@chromium.org 'bitmap-64bitMD5_10673669813016809363.png']) 55411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 55511f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org def _run_render_pictures(self, args): 55611f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org binary = self.find_path_to_program('render_pictures') 55711f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org return self.run_command([binary, 55811f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org '--clone', '1', 55911f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org '--config', '8888', 56011f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org ] + args) 56111f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 562205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org def _create_expectations(self, missing_some_images=False, 563205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org rel_path='expectations.json'): 564205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org """Creates expectations JSON file within self._expectations_dir . 565205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org 566205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org Args: 567205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org missing_some_images: (bool) whether to remove expectations for a subset 568205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org of the images 569205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org rel_path: (string) relative path within self._expectations_dir to write 570205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org the expectations into 571205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org 572205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org Returns: full path to the expectations file created. 573205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org """ 574205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org expectations_dict = { 575205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "header" : EXPECTED_HEADER_CONTENTS, 576205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "expected-results" : { 577205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org # red.skp: these should fail the comparison 578205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "red.skp": { 579205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "tiled-images": modified_list_of_dicts( 580205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org RED_TILES, {'checksumValue': 11111}), 581205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "whole-image": modified_dict( 582205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org RED_WHOLEIMAGE, {'checksumValue': 22222}), 583205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org }, 584205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org # green.skp: these should pass the comparison 585205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "green.skp": { 586205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "tiled-images": GREEN_TILES, 587205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org "whole-image": GREEN_WHOLEIMAGE, 588205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org } 589205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org } 590205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org } 591205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org if missing_some_images: 592205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org del expectations_dict['expected-results']['red.skp']['whole-image'] 593205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org del expectations_dict['expected-results']['red.skp']['tiled-images'][-1] 594205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org path = os.path.join(self._expectations_dir, rel_path) 595205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org with open(path, 'w') as fh: 596205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org json.dump(expectations_dict, fh) 597205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org return path 598205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org 599f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org def _generate_skps(self): 600f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org """Runs the skpmaker binary to generate files in self._input_skp_dir.""" 601f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org self._run_skpmaker( 602f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org output_path=os.path.join(self._input_skp_dir, 'red.skp'), red=255) 603f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org self._run_skpmaker( 604f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org output_path=os.path.join(self._input_skp_dir, 'green.skp'), green=255) 605f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org 606f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org def _run_skpmaker(self, output_path, red=0, green=0, blue=0, 607f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org width=640, height=400): 608f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org """Runs the skpmaker binary to generate SKP with known characteristics. 609f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org 610f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org Args: 611f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org output_path: Filepath to write the SKP into. 612f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org red: Value of red color channel in image, 0-255. 613f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org green: Value of green color channel in image, 0-255. 614f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org blue: Value of blue color channel in image, 0-255. 615f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org width: Width of canvas to create. 616f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org height: Height of canvas to create. 617f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org """ 61811f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org binary = self.find_path_to_program('skpmaker') 61911f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org return self.run_command([binary, 620f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org '--red', str(red), 621f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org '--green', str(green), 622f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org '--blue', str(blue), 623f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org '--width', str(width), 624f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org '--height', str(height), 625f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org '--writePath', str(output_path), 626f11943f21d985cba5af38b1609dbe8a4cfa58179commit-bot@chromium.org ]) 62711f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 628f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org def _assert_directory_contents(self, dir_path, expected_filenames): 629f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org """Asserts that files found in a dir are identical to expected_filenames. 630f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 631f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org Args: 632f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org dir_path: Path to a directory on local disk. 633f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org expected_filenames: Set containing the expected filenames within the dir. 634f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 635f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org Raises: 636f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org AssertionError: contents of the directory are not identical to 637f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org expected_filenames. 638f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org """ 639f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org self.assertEqual(set(os.listdir(dir_path)), set(expected_filenames)) 640f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org 64111f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org def _assert_json_contents(self, json_path, expected_dict): 64211f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org """Asserts that contents of a JSON file are identical to expected_dict. 64311f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 64411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org Args: 64511f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org json_path: Path to a JSON file. 64611f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org expected_dict: Dictionary indicating the expected contents of the JSON 64711f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org file. 64811f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 64911f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org Raises: 65011f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org AssertionError: contents of the JSON file are not identical to 65111f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org expected_dict. 65211f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org """ 653205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org prettyprinted_expected_dict = json.dumps(expected_dict, sort_keys=True, 654205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org indent=2) 655205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org with open(json_path, 'r') as fh: 656205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org prettyprinted_json_dict = json.dumps(json.load(fh), sort_keys=True, 657205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org indent=2) 658205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org self.assertMultiLineEqual(prettyprinted_expected_dict, 659205ce48c38c55ec7527d26042b5cea689369be8bcommit-bot@chromium.org prettyprinted_json_dict) 66011f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 66111f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 66211f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgdef main(): 66311f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org base_unittest.main(RenderPicturesTest) 66411f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 66511f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org 66611f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.orgif __name__ == '__main__': 66711f156201abe0d5e30f25a60bce1f4ae547c4083commit-bot@chromium.org main() 668