blob: 9a2dd72bac62fa8e4dd74ab1b23a1b010501539b [file] [log] [blame]
commit-bot@chromium.org11f15622014-01-07 17:03:40 +00001#!/usr/bin/python
2
3"""
4Copyright 2014 Google Inc.
5
6Use of this source code is governed by a BSD-style license that can be
7found in the LICENSE file.
8
9Test the render_pictures binary.
commit-bot@chromium.org11f15622014-01-07 17:03:40 +000010"""
11
12# System-level imports
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000013import copy
commit-bot@chromium.org11f15622014-01-07 17:03:40 +000014import json
15import os
16import shutil
17import tempfile
18
epoger66ed8dc2014-07-17 12:54:16 -070019# Must fix up PYTHONPATH before importing from within Skia
20import fix_pythonpath # pylint: disable=W0611
21
commit-bot@chromium.org11f15622014-01-07 17:03:40 +000022# Imports from within Skia
23import base_unittest
epoger66ed8dc2014-07-17 12:54:16 -070024import find_run_binary
commit-bot@chromium.org11f15622014-01-07 17:03:40 +000025
commit-bot@chromium.orgc3147c62014-01-15 20:35:54 +000026# Maximum length of text diffs to show when tests fail
27MAX_DIFF_LENGTH = 30000
28
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +000029EXPECTED_HEADER_CONTENTS = {
30 "type" : "ChecksummedImages",
31 "revision" : 1,
32}
33
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000034# Manually verified: 640x400 red rectangle with black border
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000035# Standard expectations will be set up in such a way that this image fails
36# the comparison.
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000037RED_WHOLEIMAGE = {
38 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -070039 "checksumValue" : 2853310525600416231,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000040 "comparisonResult" : "failed",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000041 "filepath" : "red_skp.png",
42}
43
44# Manually verified: 640x400 green rectangle with black border
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000045# Standard expectations will be set up in such a way that this image passes
46# the comparison.
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000047GREEN_WHOLEIMAGE = {
48 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -070049 "checksumValue" : 11143979097452425335,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000050 "comparisonResult" : "succeeded",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000051 "filepath" : "green_skp.png",
52}
53
54# Manually verified these 6 images, all 256x256 tiles,
55# consistent with a tiled version of the 640x400 red rect
56# with black borders.
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000057# Standard expectations will be set up in such a way that these images fail
58# the comparison.
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000059RED_TILES = [{
60 "checksumAlgorithm" : "bitmap-64bitMD5",
61 "checksumValue" : 5815827069051002745,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000062 "comparisonResult" : "failed",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000063 "filepath" : "red_skp-tile0.png",
64},{
65 "checksumAlgorithm" : "bitmap-64bitMD5",
66 "checksumValue" : 9323613075234140270,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000067 "comparisonResult" : "failed",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000068 "filepath" : "red_skp-tile1.png",
69}, {
70 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -070071 "checksumValue" : 15939355025996362179,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000072 "comparisonResult" : "failed",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000073 "filepath" : "red_skp-tile2.png",
74}, {
75 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -070076 "checksumValue" : 649771916797529222,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000077 "comparisonResult" : "failed",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000078 "filepath" : "red_skp-tile3.png",
79}, {
80 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -070081 "checksumValue" : 8132820002266077288,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000082 "comparisonResult" : "failed",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000083 "filepath" : "red_skp-tile4.png",
84}, {
85 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -070086 "checksumValue" : 2406160701181324581,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000087 "comparisonResult" : "failed",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000088 "filepath" : "red_skp-tile5.png",
89}]
90
91# Manually verified these 6 images, all 256x256 tiles,
92# consistent with a tiled version of the 640x400 green rect
93# with black borders.
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000094# Standard expectations will be set up in such a way that these images pass
95# the comparison.
commit-bot@chromium.org4610a462014-04-29 19:39:22 +000096GREEN_TILES = [{
97 "checksumAlgorithm" : "bitmap-64bitMD5",
98 "checksumValue" : 12587324416545178013,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +000099 "comparisonResult" : "succeeded",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000100 "filepath" : "green_skp-tile0.png",
101}, {
102 "checksumAlgorithm" : "bitmap-64bitMD5",
103 "checksumValue" : 7624374914829746293,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000104 "comparisonResult" : "succeeded",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000105 "filepath" : "green_skp-tile1.png",
106}, {
107 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700108 "checksumValue" : 11866144860997809880,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000109 "comparisonResult" : "succeeded",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000110 "filepath" : "green_skp-tile2.png",
111}, {
112 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700113 "checksumValue" : 3893392565127823822,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000114 "comparisonResult" : "succeeded",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000115 "filepath" : "green_skp-tile3.png",
116}, {
117 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700118 "checksumValue" : 2083084978343901738,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000119 "comparisonResult" : "succeeded",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000120 "filepath" : "green_skp-tile4.png",
121}, {
122 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700123 "checksumValue" : 89620927366502076,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000124 "comparisonResult" : "succeeded",
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000125 "filepath" : "green_skp-tile5.png",
126}]
127
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000128
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000129def modified_dict(input_dict, modification_dict):
130 """Returns a dict, with some modifications applied to it.
131
132 Args:
133 input_dict: a dictionary (which will be copied, not modified in place)
134 modification_dict: a set of key/value pairs to overwrite in the dict
135 """
136 output_dict = input_dict.copy()
137 output_dict.update(modification_dict)
138 return output_dict
139
140
141def modified_list_of_dicts(input_list, modification_dict):
142 """Returns a list of dicts, with some modifications applied to each dict.
143
144 Args:
145 input_list: a list of dictionaries; these dicts will be copied, not
146 modified in place
147 modification_dict: a set of key/value pairs to overwrite in each dict
148 within input_list
149 """
150 output_list = []
151 for input_dict in input_list:
152 output_dict = modified_dict(input_dict, modification_dict)
153 output_list.append(output_dict)
154 return output_list
155
156
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000157class RenderPicturesTest(base_unittest.TestCase):
158
159 def setUp(self):
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000160 self.maxDiff = MAX_DIFF_LENGTH
161 self._expectations_dir = tempfile.mkdtemp()
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000162 self._input_skp_dir = tempfile.mkdtemp()
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000163 # All output of render_pictures binary will go into this directory.
164 self._output_dir = tempfile.mkdtemp()
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000165
166 def tearDown(self):
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000167 shutil.rmtree(self._expectations_dir)
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000168 shutil.rmtree(self._input_skp_dir)
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000169 shutil.rmtree(self._output_dir)
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000170
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000171 def test_tiled_whole_image(self):
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000172 """Run render_pictures with tiles and --writeWholeImage flag.
173
174 TODO(epoger): This test generates undesired results! The JSON summary
175 includes both whole-image and tiled-images (as it should), but only
176 whole-images are written out to disk. See http://skbug.com/2463
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000177 Once I fix that, I should add a similar test that exercises mismatchPath.
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000178
179 TODO(epoger): I noticed that when this is run without --writePath being
180 specified, this test writes red_skp.png and green_skp.png to the current
181 directory. We should fix that... if --writePath is not specified, this
182 probably shouldn't write out red_skp.png and green_skp.png at all!
183 See http://skbug.com/2464
184 """
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000185 output_json_path = os.path.join(self._output_dir, 'actuals.json')
186 write_path_dir = self.create_empty_dir(
187 path=os.path.join(self._output_dir, 'writePath'))
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000188 self._generate_skps()
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000189 expectations_path = self._create_expectations()
190 self._run_render_pictures([
191 '-r', self._input_skp_dir,
192 '--bbh', 'grid', '256', '256',
193 '--mode', 'tile', '256', '256',
194 '--readJsonSummaryPath', expectations_path,
195 '--writeJsonSummaryPath', output_json_path,
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000196 '--writePath', write_path_dir,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000197 '--writeWholeImage'])
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000198 expected_summary_dict = {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000199 "header" : EXPECTED_HEADER_CONTENTS,
rmistry2529f2e2014-08-22 04:46:30 -0700200 "image-base-gs-url" : None,
epogerb492c6f2014-08-14 07:32:49 -0700201 "descriptions" : None,
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000202 "actual-results" : {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000203 "red.skp": {
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000204 "tiled-images": RED_TILES,
205 "whole-image": RED_WHOLEIMAGE,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000206 },
207 "green.skp": {
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000208 "tiled-images": GREEN_TILES,
209 "whole-image": GREEN_WHOLEIMAGE,
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000210 }
211 }
commit-bot@chromium.org238771c2014-01-15 16:33:31 +0000212 }
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000213 self._assert_json_contents(output_json_path, expected_summary_dict)
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000214 self._assert_directory_contents(
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000215 write_path_dir, ['red_skp.png', 'green_skp.png'])
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000216
epoger85b438d2014-08-21 23:21:32 -0700217 def test_ignore_some_failures(self):
218 """test_tiled_whole_image, but ignoring some failed tests.
219 """
220 output_json_path = os.path.join(self._output_dir, 'actuals.json')
221 write_path_dir = self.create_empty_dir(
222 path=os.path.join(self._output_dir, 'writePath'))
223 self._generate_skps()
224 expectations_path = self._create_expectations(ignore_some_failures=True)
225 self._run_render_pictures([
226 '-r', self._input_skp_dir,
227 '--bbh', 'grid', '256', '256',
228 '--mode', 'tile', '256', '256',
229 '--readJsonSummaryPath', expectations_path,
230 '--writeJsonSummaryPath', output_json_path,
231 '--writePath', write_path_dir,
232 '--writeWholeImage'])
233 modified_red_tiles = copy.deepcopy(RED_TILES)
234 modified_red_tiles[5]['comparisonResult'] = 'failure-ignored'
235 expected_summary_dict = {
236 "header" : EXPECTED_HEADER_CONTENTS,
rmistry2529f2e2014-08-22 04:46:30 -0700237 "image-base-gs-url" : None,
epoger85b438d2014-08-21 23:21:32 -0700238 "descriptions" : None,
239 "actual-results" : {
240 "red.skp": {
241 "tiled-images": modified_red_tiles,
242 "whole-image": modified_dict(
243 RED_WHOLEIMAGE, {"comparisonResult" : "failure-ignored"}),
244 },
245 "green.skp": {
246 "tiled-images": GREEN_TILES,
247 "whole-image": GREEN_WHOLEIMAGE,
248 }
249 }
250 }
251 self._assert_json_contents(output_json_path, expected_summary_dict)
252 self._assert_directory_contents(
253 write_path_dir, ['red_skp.png', 'green_skp.png'])
254
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000255 def test_missing_tile_and_whole_image(self):
256 """test_tiled_whole_image, but missing expectations for some images.
257 """
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000258 output_json_path = os.path.join(self._output_dir, 'actuals.json')
259 write_path_dir = self.create_empty_dir(
260 path=os.path.join(self._output_dir, 'writePath'))
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000261 self._generate_skps()
262 expectations_path = self._create_expectations(missing_some_images=True)
263 self._run_render_pictures([
264 '-r', self._input_skp_dir,
265 '--bbh', 'grid', '256', '256',
266 '--mode', 'tile', '256', '256',
267 '--readJsonSummaryPath', expectations_path,
268 '--writeJsonSummaryPath', output_json_path,
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000269 '--writePath', write_path_dir,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000270 '--writeWholeImage'])
271 modified_red_tiles = copy.deepcopy(RED_TILES)
272 modified_red_tiles[5]['comparisonResult'] = 'no-comparison'
273 expected_summary_dict = {
274 "header" : EXPECTED_HEADER_CONTENTS,
rmistry2529f2e2014-08-22 04:46:30 -0700275 "image-base-gs-url" : None,
epogerb492c6f2014-08-14 07:32:49 -0700276 "descriptions" : None,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000277 "actual-results" : {
278 "red.skp": {
279 "tiled-images": modified_red_tiles,
280 "whole-image": modified_dict(
281 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}),
282 },
283 "green.skp": {
284 "tiled-images": GREEN_TILES,
285 "whole-image": GREEN_WHOLEIMAGE,
286 }
287 }
288 }
289 self._assert_json_contents(output_json_path, expected_summary_dict)
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000290
commit-bot@chromium.orgabeb9582014-05-19 15:25:10 +0000291 def _test_untiled(self, expectations_path=None, expected_summary_dict=None,
292 additional_args=None):
293 """Base for multiple tests without tiles.
294
295 Args:
296 expectations_path: path we should pass using --readJsonSummaryPath, or
297 None if we should create the default expectations file
298 expected_summary_dict: dict we should compare against the output actual
299 results summary, or None if we should use a default comparison dict
300 additional_args: array of command-line args to add when we run
301 render_pictures
302 """
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000303 output_json_path = os.path.join(self._output_dir, 'actuals.json')
304 write_path_dir = self.create_empty_dir(
305 path=os.path.join(self._output_dir, 'writePath'))
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000306 self._generate_skps()
commit-bot@chromium.orgabeb9582014-05-19 15:25:10 +0000307 if expectations_path == None:
308 expectations_path = self._create_expectations()
309 args = [
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000310 '-r', self._input_skp_dir,
311 '--readJsonSummaryPath', expectations_path,
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000312 '--writePath', write_path_dir,
commit-bot@chromium.orgabeb9582014-05-19 15:25:10 +0000313 '--writeJsonSummaryPath', output_json_path,
314 ]
315 if additional_args:
316 args.extend(additional_args)
317 self._run_render_pictures(args)
318 if expected_summary_dict == None:
319 expected_summary_dict = {
320 "header" : EXPECTED_HEADER_CONTENTS,
rmistry2529f2e2014-08-22 04:46:30 -0700321 "image-base-gs-url" : None,
epogerb492c6f2014-08-14 07:32:49 -0700322 "descriptions" : None,
commit-bot@chromium.orgabeb9582014-05-19 15:25:10 +0000323 "actual-results" : {
324 "red.skp": {
325 "whole-image": RED_WHOLEIMAGE,
326 },
327 "green.skp": {
328 "whole-image": GREEN_WHOLEIMAGE,
329 }
330 }
331 }
332 self._assert_json_contents(output_json_path, expected_summary_dict)
333 self._assert_directory_contents(
334 write_path_dir, ['red_skp.png', 'green_skp.png'])
335
336 def test_untiled(self):
337 """Basic test without tiles."""
338 self._test_untiled()
339
340 def test_untiled_empty_expectations_file(self):
341 """Same as test_untiled, but with an empty expectations file."""
342 expectations_path = os.path.join(self._expectations_dir, 'empty')
epoger66ed8dc2014-07-17 12:54:16 -0700343 with open(expectations_path, 'w'):
commit-bot@chromium.orgabeb9582014-05-19 15:25:10 +0000344 pass
commit-bot@chromium.orgc3147c62014-01-15 20:35:54 +0000345 expected_summary_dict = {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000346 "header" : EXPECTED_HEADER_CONTENTS,
rmistry2529f2e2014-08-22 04:46:30 -0700347 "image-base-gs-url" : None,
epogerb492c6f2014-08-14 07:32:49 -0700348 "descriptions" : None,
commit-bot@chromium.orgc3147c62014-01-15 20:35:54 +0000349 "actual-results" : {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000350 "red.skp": {
commit-bot@chromium.orgabeb9582014-05-19 15:25:10 +0000351 "whole-image": modified_dict(
352 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}),
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000353 },
354 "green.skp": {
commit-bot@chromium.orgabeb9582014-05-19 15:25:10 +0000355 "whole-image": modified_dict(
356 GREEN_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}),
commit-bot@chromium.orgc3147c62014-01-15 20:35:54 +0000357 }
358 }
359 }
commit-bot@chromium.orgabeb9582014-05-19 15:25:10 +0000360 self._test_untiled(expectations_path=expectations_path,
361 expected_summary_dict=expected_summary_dict)
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000362
363 def test_untiled_writeChecksumBasedFilenames(self):
364 """Same as test_untiled, but with --writeChecksumBasedFilenames."""
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000365 output_json_path = os.path.join(self._output_dir, 'actuals.json')
366 write_path_dir = self.create_empty_dir(
367 path=os.path.join(self._output_dir, 'writePath'))
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000368 self._generate_skps()
epogerb492c6f2014-08-14 07:32:49 -0700369 self._run_render_pictures([
370 '-r', self._input_skp_dir,
371 '--descriptions', 'builder=builderName', 'renderMode=renderModeName',
372 '--writeChecksumBasedFilenames',
373 '--writePath', write_path_dir,
374 '--writeJsonSummaryPath', output_json_path,
375 ])
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000376 expected_summary_dict = {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000377 "header" : EXPECTED_HEADER_CONTENTS,
rmistry2529f2e2014-08-22 04:46:30 -0700378 "image-base-gs-url" : None,
epogerb492c6f2014-08-14 07:32:49 -0700379 "descriptions" : {
380 "builder": "builderName",
381 "renderMode": "renderModeName",
382 },
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000383 "actual-results" : {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000384 "red.skp": {
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000385 # Manually verified: 640x400 red rectangle with black border
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000386 "whole-image": {
387 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700388 "checksumValue" : 2853310525600416231,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000389 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700390 "filepath" :
stephana7260d722014-09-05 13:21:42 -0700391 "red_skp/bitmap-64bitMD5_2853310525600416231.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000392 },
393 },
394 "green.skp": {
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000395 # Manually verified: 640x400 green rectangle with black border
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000396 "whole-image": {
397 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700398 "checksumValue" : 11143979097452425335,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000399 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700400 "filepath" :
stephana7260d722014-09-05 13:21:42 -0700401 "green_skp/bitmap-64bitMD5_11143979097452425335.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000402 },
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000403 }
404 }
405 }
406 self._assert_json_contents(output_json_path, expected_summary_dict)
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000407 self._assert_directory_contents(write_path_dir, ['red_skp', 'green_skp'])
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000408 self._assert_directory_contents(
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000409 os.path.join(write_path_dir, 'red_skp'),
stephana7260d722014-09-05 13:21:42 -0700410 ['bitmap-64bitMD5_2853310525600416231.png'])
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000411 self._assert_directory_contents(
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000412 os.path.join(write_path_dir, 'green_skp'),
stephana7260d722014-09-05 13:21:42 -0700413 ['bitmap-64bitMD5_11143979097452425335.png'])
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000414
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000415 def test_untiled_validate(self):
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000416 """Same as test_untiled, but with --validate."""
commit-bot@chromium.orgabeb9582014-05-19 15:25:10 +0000417 self._test_untiled(additional_args=['--validate'])
commit-bot@chromium.orgc3147c62014-01-15 20:35:54 +0000418
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000419 def test_untiled_without_writePath(self):
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000420 """Same as test_untiled, but without --writePath."""
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000421 output_json_path = os.path.join(self._output_dir, 'actuals.json')
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000422 self._generate_skps()
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000423 expectations_path = self._create_expectations()
424 self._run_render_pictures([
425 '-r', self._input_skp_dir,
426 '--readJsonSummaryPath', expectations_path,
427 '--writeJsonSummaryPath', output_json_path])
commit-bot@chromium.orgc3147c62014-01-15 20:35:54 +0000428 expected_summary_dict = {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000429 "header" : EXPECTED_HEADER_CONTENTS,
rmistry2529f2e2014-08-22 04:46:30 -0700430 "image-base-gs-url" : None,
epogerb492c6f2014-08-14 07:32:49 -0700431 "descriptions" : None,
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000432 "actual-results" : {
433 "red.skp": {
434 "whole-image": RED_WHOLEIMAGE,
435 },
436 "green.skp": {
437 "whole-image": GREEN_WHOLEIMAGE,
438 }
439 }
commit-bot@chromium.orgc3147c62014-01-15 20:35:54 +0000440 }
441 self._assert_json_contents(output_json_path, expected_summary_dict)
442
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000443 def test_tiled(self):
commit-bot@chromium.orgc3147c62014-01-15 20:35:54 +0000444 """Generate individual tiles."""
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000445 output_json_path = os.path.join(self._output_dir, 'actuals.json')
446 write_path_dir = self.create_empty_dir(
447 path=os.path.join(self._output_dir, 'writePath'))
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000448 self._generate_skps()
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000449 expectations_path = self._create_expectations()
450 self._run_render_pictures([
451 '-r', self._input_skp_dir,
452 '--bbh', 'grid', '256', '256',
453 '--mode', 'tile', '256', '256',
454 '--readJsonSummaryPath', expectations_path,
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000455 '--writePath', write_path_dir,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000456 '--writeJsonSummaryPath', output_json_path])
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000457 expected_summary_dict = {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000458 "header" : EXPECTED_HEADER_CONTENTS,
rmistry2529f2e2014-08-22 04:46:30 -0700459 "image-base-gs-url" : None,
epogerb492c6f2014-08-14 07:32:49 -0700460 "descriptions" : None,
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000461 "actual-results" : {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000462 "red.skp": {
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000463 "tiled-images": RED_TILES,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000464 },
465 "green.skp": {
commit-bot@chromium.org4610a462014-04-29 19:39:22 +0000466 "tiled-images": GREEN_TILES,
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000467 }
468 }
commit-bot@chromium.orgc3147c62014-01-15 20:35:54 +0000469 }
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000470 self._assert_json_contents(output_json_path, expected_summary_dict)
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000471 self._assert_directory_contents(
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000472 write_path_dir,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000473 ['red_skp-tile0.png', 'red_skp-tile1.png', 'red_skp-tile2.png',
474 'red_skp-tile3.png', 'red_skp-tile4.png', 'red_skp-tile5.png',
475 'green_skp-tile0.png', 'green_skp-tile1.png', 'green_skp-tile2.png',
476 'green_skp-tile3.png', 'green_skp-tile4.png', 'green_skp-tile5.png',
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000477 ])
478
479 def test_tiled_mismatches(self):
480 """Same as test_tiled, but only write out mismatching images."""
481 output_json_path = os.path.join(self._output_dir, 'actuals.json')
482 mismatch_path_dir = self.create_empty_dir(
483 path=os.path.join(self._output_dir, 'mismatchPath'))
484 self._generate_skps()
485 expectations_path = self._create_expectations()
486 self._run_render_pictures([
487 '-r', self._input_skp_dir,
488 '--bbh', 'grid', '256', '256',
489 '--mode', 'tile', '256', '256',
490 '--readJsonSummaryPath', expectations_path,
491 '--mismatchPath', mismatch_path_dir,
492 '--writeJsonSummaryPath', output_json_path])
493 expected_summary_dict = {
494 "header" : EXPECTED_HEADER_CONTENTS,
rmistry2529f2e2014-08-22 04:46:30 -0700495 "image-base-gs-url" : None,
epogerb492c6f2014-08-14 07:32:49 -0700496 "descriptions" : None,
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000497 "actual-results" : {
498 "red.skp": {
499 "tiled-images": RED_TILES,
500 },
501 "green.skp": {
502 "tiled-images": GREEN_TILES,
503 }
504 }
505 }
506 self._assert_json_contents(output_json_path, expected_summary_dict)
507 self._assert_directory_contents(
508 mismatch_path_dir,
509 ['red_skp-tile0.png', 'red_skp-tile1.png', 'red_skp-tile2.png',
510 'red_skp-tile3.png', 'red_skp-tile4.png', 'red_skp-tile5.png',
511 ])
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000512
513 def test_tiled_writeChecksumBasedFilenames(self):
514 """Same as test_tiled, but with --writeChecksumBasedFilenames."""
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000515 output_json_path = os.path.join(self._output_dir, 'actuals.json')
516 write_path_dir = self.create_empty_dir(
517 path=os.path.join(self._output_dir, 'writePath'))
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000518 self._generate_skps()
519 self._run_render_pictures(['-r', self._input_skp_dir,
520 '--bbh', 'grid', '256', '256',
521 '--mode', 'tile', '256', '256',
522 '--writeChecksumBasedFilenames',
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000523 '--writePath', write_path_dir,
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000524 '--writeJsonSummaryPath', output_json_path])
525 expected_summary_dict = {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000526 "header" : EXPECTED_HEADER_CONTENTS,
rmistry2529f2e2014-08-22 04:46:30 -0700527 "image-base-gs-url" : None,
epogerb492c6f2014-08-14 07:32:49 -0700528 "descriptions" : None,
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000529 "actual-results" : {
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000530 "red.skp": {
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000531 # Manually verified these 6 images, all 256x256 tiles,
532 # consistent with a tiled version of the 640x400 red rect
533 # with black borders.
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000534 "tiled-images": [{
535 "checksumAlgorithm" : "bitmap-64bitMD5",
536 "checksumValue" : 5815827069051002745,
537 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700538 "filepath" :
539 "red_skp/bitmap-64bitMD5_5815827069051002745.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000540 }, {
541 "checksumAlgorithm" : "bitmap-64bitMD5",
542 "checksumValue" : 9323613075234140270,
543 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700544 "filepath" :
545 "red_skp/bitmap-64bitMD5_9323613075234140270.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000546 }, {
547 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700548 "checksumValue" : 15939355025996362179,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000549 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700550 "filepath" :
stephana7260d722014-09-05 13:21:42 -0700551 "red_skp/bitmap-64bitMD5_15939355025996362179.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000552 }, {
553 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700554 "checksumValue" : 649771916797529222,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000555 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700556 "filepath" :
stephana7260d722014-09-05 13:21:42 -0700557 "red_skp/bitmap-64bitMD5_649771916797529222.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000558 }, {
559 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700560 "checksumValue" : 8132820002266077288,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000561 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700562 "filepath" :
stephana7260d722014-09-05 13:21:42 -0700563 "red_skp/bitmap-64bitMD5_8132820002266077288.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000564 }, {
565 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700566 "checksumValue" : 2406160701181324581,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000567 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700568 "filepath" :
stephana7260d722014-09-05 13:21:42 -0700569 "red_skp/bitmap-64bitMD5_2406160701181324581.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000570 }],
571 },
572 "green.skp": {
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000573 # Manually verified these 6 images, all 256x256 tiles,
574 # consistent with a tiled version of the 640x400 green rect
575 # with black borders.
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000576 "tiled-images": [{
577 "checksumAlgorithm" : "bitmap-64bitMD5",
578 "checksumValue" : 12587324416545178013,
579 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700580 "filepath" :
581 "green_skp/bitmap-64bitMD5_12587324416545178013.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000582 }, {
583 "checksumAlgorithm" : "bitmap-64bitMD5",
584 "checksumValue" : 7624374914829746293,
585 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700586 "filepath" :
587 "green_skp/bitmap-64bitMD5_7624374914829746293.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000588 }, {
589 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700590 "checksumValue" : 11866144860997809880,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000591 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700592 "filepath" :
stephana7260d722014-09-05 13:21:42 -0700593 "green_skp/bitmap-64bitMD5_11866144860997809880.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000594 }, {
595 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700596 "checksumValue" : 3893392565127823822,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000597 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700598 "filepath" :
stephana7260d722014-09-05 13:21:42 -0700599 "green_skp/bitmap-64bitMD5_3893392565127823822.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000600 }, {
601 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700602 "checksumValue" : 2083084978343901738,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000603 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700604 "filepath" :
stephana7260d722014-09-05 13:21:42 -0700605 "green_skp/bitmap-64bitMD5_2083084978343901738.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000606 }, {
607 "checksumAlgorithm" : "bitmap-64bitMD5",
stephana7260d722014-09-05 13:21:42 -0700608 "checksumValue" : 89620927366502076,
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000609 "comparisonResult" : "no-comparison",
epoger66ed8dc2014-07-17 12:54:16 -0700610 "filepath" :
stephana7260d722014-09-05 13:21:42 -0700611 "green_skp/bitmap-64bitMD5_89620927366502076.png",
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000612 }],
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000613 }
614 }
615 }
616 self._assert_json_contents(output_json_path, expected_summary_dict)
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000617 self._assert_directory_contents(write_path_dir, ['red_skp', 'green_skp'])
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000618 self._assert_directory_contents(
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000619 os.path.join(write_path_dir, 'red_skp'),
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000620 ['bitmap-64bitMD5_5815827069051002745.png',
621 'bitmap-64bitMD5_9323613075234140270.png',
stephana7260d722014-09-05 13:21:42 -0700622 'bitmap-64bitMD5_15939355025996362179.png',
623 'bitmap-64bitMD5_649771916797529222.png',
624 'bitmap-64bitMD5_8132820002266077288.png',
625 'bitmap-64bitMD5_2406160701181324581.png'])
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000626 self._assert_directory_contents(
commit-bot@chromium.org3f045172014-05-15 15:10:48 +0000627 os.path.join(write_path_dir, 'green_skp'),
commit-bot@chromium.org24c568c2014-04-10 15:39:02 +0000628 ['bitmap-64bitMD5_12587324416545178013.png',
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000629 'bitmap-64bitMD5_7624374914829746293.png',
stephana7260d722014-09-05 13:21:42 -0700630 'bitmap-64bitMD5_11866144860997809880.png',
631 'bitmap-64bitMD5_3893392565127823822.png',
632 'bitmap-64bitMD5_2083084978343901738.png',
633 'bitmap-64bitMD5_89620927366502076.png'])
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000634
635 def _run_render_pictures(self, args):
epoger66ed8dc2014-07-17 12:54:16 -0700636 binary = find_run_binary.find_path_to_program('render_pictures')
637 return find_run_binary.run_command(
638 [binary, '--config', '8888'] + args)
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000639
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000640 def _create_expectations(self, missing_some_images=False,
epoger85b438d2014-08-21 23:21:32 -0700641 ignore_some_failures=False,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000642 rel_path='expectations.json'):
643 """Creates expectations JSON file within self._expectations_dir .
644
645 Args:
646 missing_some_images: (bool) whether to remove expectations for a subset
647 of the images
epoger85b438d2014-08-21 23:21:32 -0700648 ignore_some_failures: (bool) whether to ignore some failing tests
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000649 rel_path: (string) relative path within self._expectations_dir to write
650 the expectations into
651
652 Returns: full path to the expectations file created.
653 """
654 expectations_dict = {
655 "header" : EXPECTED_HEADER_CONTENTS,
epogerb492c6f2014-08-14 07:32:49 -0700656 "descriptions" : None,
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000657 "expected-results" : {
658 # red.skp: these should fail the comparison
659 "red.skp": {
660 "tiled-images": modified_list_of_dicts(
661 RED_TILES, {'checksumValue': 11111}),
662 "whole-image": modified_dict(
663 RED_WHOLEIMAGE, {'checksumValue': 22222}),
664 },
665 # green.skp: these should pass the comparison
666 "green.skp": {
667 "tiled-images": GREEN_TILES,
668 "whole-image": GREEN_WHOLEIMAGE,
669 }
670 }
671 }
672 if missing_some_images:
epoger85b438d2014-08-21 23:21:32 -0700673 red_subdict = expectations_dict['expected-results']['red.skp']
674 del red_subdict['whole-image']
675 del red_subdict['tiled-images'][-1]
676 elif ignore_some_failures:
677 red_subdict = expectations_dict['expected-results']['red.skp']
678 red_subdict['whole-image']['ignoreFailure'] = True
679 red_subdict['tiled-images'][-1]['ignoreFailure'] = True
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000680 path = os.path.join(self._expectations_dir, rel_path)
681 with open(path, 'w') as fh:
682 json.dump(expectations_dict, fh)
683 return path
684
commit-bot@chromium.orgf11943f2014-03-12 20:09:46 +0000685 def _generate_skps(self):
686 """Runs the skpmaker binary to generate files in self._input_skp_dir."""
687 self._run_skpmaker(
688 output_path=os.path.join(self._input_skp_dir, 'red.skp'), red=255)
689 self._run_skpmaker(
690 output_path=os.path.join(self._input_skp_dir, 'green.skp'), green=255)
691
692 def _run_skpmaker(self, output_path, red=0, green=0, blue=0,
693 width=640, height=400):
694 """Runs the skpmaker binary to generate SKP with known characteristics.
695
696 Args:
697 output_path: Filepath to write the SKP into.
698 red: Value of red color channel in image, 0-255.
699 green: Value of green color channel in image, 0-255.
700 blue: Value of blue color channel in image, 0-255.
701 width: Width of canvas to create.
702 height: Height of canvas to create.
703 """
epoger66ed8dc2014-07-17 12:54:16 -0700704 binary = find_run_binary.find_path_to_program('skpmaker')
705 return find_run_binary.run_command([
706 binary,
707 '--red', str(red),
708 '--green', str(green),
709 '--blue', str(blue),
710 '--width', str(width),
711 '--height', str(height),
712 '--writePath', str(output_path),
713 ])
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000714
commit-bot@chromium.orgf5e315c2014-03-19 17:26:07 +0000715 def _assert_directory_contents(self, dir_path, expected_filenames):
716 """Asserts that files found in a dir are identical to expected_filenames.
717
718 Args:
719 dir_path: Path to a directory on local disk.
720 expected_filenames: Set containing the expected filenames within the dir.
721
722 Raises:
723 AssertionError: contents of the directory are not identical to
724 expected_filenames.
725 """
726 self.assertEqual(set(os.listdir(dir_path)), set(expected_filenames))
727
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000728 def _assert_json_contents(self, json_path, expected_dict):
729 """Asserts that contents of a JSON file are identical to expected_dict.
730
731 Args:
732 json_path: Path to a JSON file.
733 expected_dict: Dictionary indicating the expected contents of the JSON
734 file.
735
736 Raises:
737 AssertionError: contents of the JSON file are not identical to
738 expected_dict.
739 """
commit-bot@chromium.org205ce482014-05-12 15:37:20 +0000740 prettyprinted_expected_dict = json.dumps(expected_dict, sort_keys=True,
741 indent=2)
742 with open(json_path, 'r') as fh:
743 prettyprinted_json_dict = json.dumps(json.load(fh), sort_keys=True,
744 indent=2)
745 self.assertMultiLineEqual(prettyprinted_expected_dict,
746 prettyprinted_json_dict)
commit-bot@chromium.org11f15622014-01-07 17:03:40 +0000747
748
749def main():
750 base_unittest.main(RenderPicturesTest)
751
752
753if __name__ == '__main__':
754 main()