4 Copyright 2014 Google Inc.
6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file.
9 Test the render_pictures binary.
12 # System-level imports
19 # Must fix up PYTHONPATH before importing from within Skia
20 import fix_pythonpath # pylint: disable=W0611
22 # Imports from within Skia
24 import find_run_binary
26 # Maximum length of text diffs to show when tests fail
27 MAX_DIFF_LENGTH = 30000
29 EXPECTED_HEADER_CONTENTS = {
30 "type" : "ChecksummedImages",
34 # Manually verified: 640x400 red rectangle with black border
35 # Standard expectations will be set up in such a way that this image fails
38 "checksumAlgorithm" : "bitmap-64bitMD5",
39 "checksumValue" : 2853310525600416231,
40 "comparisonResult" : "failed",
41 "filepath" : "red_skp.png",
44 # Manually verified: 640x400 green rectangle with black border
45 # Standard expectations will be set up in such a way that this image passes
48 "checksumAlgorithm" : "bitmap-64bitMD5",
49 "checksumValue" : 11143979097452425335,
50 "comparisonResult" : "succeeded",
51 "filepath" : "green_skp.png",
54 # Manually verified these 6 images, all 256x256 tiles,
55 # consistent with a tiled version of the 640x400 red rect
57 # Standard expectations will be set up in such a way that these images fail
60 "checksumAlgorithm" : "bitmap-64bitMD5",
61 "checksumValue" : 5815827069051002745,
62 "comparisonResult" : "failed",
63 "filepath" : "red_skp-tile0.png",
65 "checksumAlgorithm" : "bitmap-64bitMD5",
66 "checksumValue" : 9323613075234140270,
67 "comparisonResult" : "failed",
68 "filepath" : "red_skp-tile1.png",
70 "checksumAlgorithm" : "bitmap-64bitMD5",
71 "checksumValue" : 15939355025996362179,
72 "comparisonResult" : "failed",
73 "filepath" : "red_skp-tile2.png",
75 "checksumAlgorithm" : "bitmap-64bitMD5",
76 "checksumValue" : 649771916797529222,
77 "comparisonResult" : "failed",
78 "filepath" : "red_skp-tile3.png",
80 "checksumAlgorithm" : "bitmap-64bitMD5",
81 "checksumValue" : 8132820002266077288,
82 "comparisonResult" : "failed",
83 "filepath" : "red_skp-tile4.png",
85 "checksumAlgorithm" : "bitmap-64bitMD5",
86 "checksumValue" : 2406160701181324581,
87 "comparisonResult" : "failed",
88 "filepath" : "red_skp-tile5.png",
91 # Manually verified these 6 images, all 256x256 tiles,
92 # consistent with a tiled version of the 640x400 green rect
94 # Standard expectations will be set up in such a way that these images pass
97 "checksumAlgorithm" : "bitmap-64bitMD5",
98 "checksumValue" : 12587324416545178013,
99 "comparisonResult" : "succeeded",
100 "filepath" : "green_skp-tile0.png",
102 "checksumAlgorithm" : "bitmap-64bitMD5",
103 "checksumValue" : 7624374914829746293,
104 "comparisonResult" : "succeeded",
105 "filepath" : "green_skp-tile1.png",
107 "checksumAlgorithm" : "bitmap-64bitMD5",
108 "checksumValue" : 11866144860997809880,
109 "comparisonResult" : "succeeded",
110 "filepath" : "green_skp-tile2.png",
112 "checksumAlgorithm" : "bitmap-64bitMD5",
113 "checksumValue" : 3893392565127823822,
114 "comparisonResult" : "succeeded",
115 "filepath" : "green_skp-tile3.png",
117 "checksumAlgorithm" : "bitmap-64bitMD5",
118 "checksumValue" : 2083084978343901738,
119 "comparisonResult" : "succeeded",
120 "filepath" : "green_skp-tile4.png",
122 "checksumAlgorithm" : "bitmap-64bitMD5",
123 "checksumValue" : 89620927366502076,
124 "comparisonResult" : "succeeded",
125 "filepath" : "green_skp-tile5.png",
129 def modified_dict(input_dict, modification_dict):
130 """Returns a dict, with some modifications applied to it.
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
136 output_dict = input_dict.copy()
137 output_dict.update(modification_dict)
141 def modified_list_of_dicts(input_list, modification_dict):
142 """Returns a list of dicts, with some modifications applied to each dict.
145 input_list: a list of dictionaries; these dicts will be copied, not
147 modification_dict: a set of key/value pairs to overwrite in each dict
151 for input_dict in input_list:
152 output_dict = modified_dict(input_dict, modification_dict)
153 output_list.append(output_dict)
157 class RenderPicturesTest(base_unittest.TestCase):
160 self.maxDiff = MAX_DIFF_LENGTH
161 self._expectations_dir = tempfile.mkdtemp()
162 self._input_skp_dir = tempfile.mkdtemp()
163 # All output of render_pictures binary will go into this directory.
164 self._output_dir = tempfile.mkdtemp()
167 shutil.rmtree(self._expectations_dir)
168 shutil.rmtree(self._input_skp_dir)
169 shutil.rmtree(self._output_dir)
171 def test_tiled_whole_image(self):
172 """Run render_pictures with tiles and --writeWholeImage flag.
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
177 Once I fix that, I should add a similar test that exercises mismatchPath.
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
185 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'))
188 self._generate_skps()
189 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,
196 '--writePath', write_path_dir,
197 '--writeWholeImage'])
198 expected_summary_dict = {
199 "header" : EXPECTED_HEADER_CONTENTS,
200 "image-base-gs-url" : None,
201 "descriptions" : None,
204 "tiled-images": RED_TILES,
205 "whole-image": RED_WHOLEIMAGE,
208 "tiled-images": GREEN_TILES,
209 "whole-image": GREEN_WHOLEIMAGE,
213 self._assert_json_contents(output_json_path, expected_summary_dict)
214 self._assert_directory_contents(
215 write_path_dir, ['red_skp.png', 'green_skp.png'])
217 def test_ignore_some_failures(self):
218 """test_tiled_whole_image, but ignoring some failed tests.
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,
237 "image-base-gs-url" : None,
238 "descriptions" : None,
241 "tiled-images": modified_red_tiles,
242 "whole-image": modified_dict(
243 RED_WHOLEIMAGE, {"comparisonResult" : "failure-ignored"}),
246 "tiled-images": GREEN_TILES,
247 "whole-image": GREEN_WHOLEIMAGE,
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'])
255 def test_missing_tile_and_whole_image(self):
256 """test_tiled_whole_image, but missing expectations for some images.
258 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'))
261 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,
269 '--writePath', write_path_dir,
270 '--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,
275 "image-base-gs-url" : None,
276 "descriptions" : None,
279 "tiled-images": modified_red_tiles,
280 "whole-image": modified_dict(
281 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}),
284 "tiled-images": GREEN_TILES,
285 "whole-image": GREEN_WHOLEIMAGE,
289 self._assert_json_contents(output_json_path, expected_summary_dict)
291 def _test_untiled(self, expectations_path=None, expected_summary_dict=None,
292 additional_args=None):
293 """Base for multiple tests without tiles.
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
303 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'))
306 self._generate_skps()
307 if expectations_path == None:
308 expectations_path = self._create_expectations()
310 '-r', self._input_skp_dir,
311 '--readJsonSummaryPath', expectations_path,
312 '--writePath', write_path_dir,
313 '--writeJsonSummaryPath', output_json_path,
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,
321 "image-base-gs-url" : None,
322 "descriptions" : None,
325 "whole-image": RED_WHOLEIMAGE,
328 "whole-image": GREEN_WHOLEIMAGE,
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'])
336 def test_untiled(self):
337 """Basic test without tiles."""
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')
343 with open(expectations_path, 'w'):
345 expected_summary_dict = {
346 "header" : EXPECTED_HEADER_CONTENTS,
347 "image-base-gs-url" : None,
348 "descriptions" : None,
351 "whole-image": modified_dict(
352 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}),
355 "whole-image": modified_dict(
356 GREEN_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}),
360 self._test_untiled(expectations_path=expectations_path,
361 expected_summary_dict=expected_summary_dict)
363 def test_untiled_writeChecksumBasedFilenames(self):
364 """Same as test_untiled, but with --writeChecksumBasedFilenames."""
365 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'))
368 self._generate_skps()
369 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,
376 expected_summary_dict = {
377 "header" : EXPECTED_HEADER_CONTENTS,
378 "image-base-gs-url" : None,
380 "builder": "builderName",
381 "renderMode": "renderModeName",
385 # Manually verified: 640x400 red rectangle with black border
387 "checksumAlgorithm" : "bitmap-64bitMD5",
388 "checksumValue" : 2853310525600416231,
389 "comparisonResult" : "no-comparison",
391 "red_skp/bitmap-64bitMD5_2853310525600416231.png",
395 # Manually verified: 640x400 green rectangle with black border
397 "checksumAlgorithm" : "bitmap-64bitMD5",
398 "checksumValue" : 11143979097452425335,
399 "comparisonResult" : "no-comparison",
401 "green_skp/bitmap-64bitMD5_11143979097452425335.png",
406 self._assert_json_contents(output_json_path, expected_summary_dict)
407 self._assert_directory_contents(write_path_dir, ['red_skp', 'green_skp'])
408 self._assert_directory_contents(
409 os.path.join(write_path_dir, 'red_skp'),
410 ['bitmap-64bitMD5_2853310525600416231.png'])
411 self._assert_directory_contents(
412 os.path.join(write_path_dir, 'green_skp'),
413 ['bitmap-64bitMD5_11143979097452425335.png'])
415 def test_untiled_validate(self):
416 """Same as test_untiled, but with --validate."""
417 self._test_untiled(additional_args=['--validate'])
419 def test_untiled_without_writePath(self):
420 """Same as test_untiled, but without --writePath."""
421 output_json_path = os.path.join(self._output_dir, 'actuals.json')
422 self._generate_skps()
423 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])
428 expected_summary_dict = {
429 "header" : EXPECTED_HEADER_CONTENTS,
430 "image-base-gs-url" : None,
431 "descriptions" : None,
434 "whole-image": RED_WHOLEIMAGE,
437 "whole-image": GREEN_WHOLEIMAGE,
441 self._assert_json_contents(output_json_path, expected_summary_dict)
443 def test_tiled(self):
444 """Generate individual tiles."""
445 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'))
448 self._generate_skps()
449 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,
455 '--writePath', write_path_dir,
456 '--writeJsonSummaryPath', output_json_path])
457 expected_summary_dict = {
458 "header" : EXPECTED_HEADER_CONTENTS,
459 "image-base-gs-url" : None,
460 "descriptions" : None,
463 "tiled-images": RED_TILES,
466 "tiled-images": GREEN_TILES,
470 self._assert_json_contents(output_json_path, expected_summary_dict)
471 self._assert_directory_contents(
473 ['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',
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,
495 "image-base-gs-url" : None,
496 "descriptions" : None,
499 "tiled-images": RED_TILES,
502 "tiled-images": GREEN_TILES,
506 self._assert_json_contents(output_json_path, expected_summary_dict)
507 self._assert_directory_contents(
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',
513 def test_tiled_writeChecksumBasedFilenames(self):
514 """Same as test_tiled, but with --writeChecksumBasedFilenames."""
515 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'))
518 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',
523 '--writePath', write_path_dir,
524 '--writeJsonSummaryPath', output_json_path])
525 expected_summary_dict = {
526 "header" : EXPECTED_HEADER_CONTENTS,
527 "image-base-gs-url" : None,
528 "descriptions" : None,
531 # Manually verified these 6 images, all 256x256 tiles,
532 # consistent with a tiled version of the 640x400 red rect
533 # with black borders.
535 "checksumAlgorithm" : "bitmap-64bitMD5",
536 "checksumValue" : 5815827069051002745,
537 "comparisonResult" : "no-comparison",
539 "red_skp/bitmap-64bitMD5_5815827069051002745.png",
541 "checksumAlgorithm" : "bitmap-64bitMD5",
542 "checksumValue" : 9323613075234140270,
543 "comparisonResult" : "no-comparison",
545 "red_skp/bitmap-64bitMD5_9323613075234140270.png",
547 "checksumAlgorithm" : "bitmap-64bitMD5",
548 "checksumValue" : 15939355025996362179,
549 "comparisonResult" : "no-comparison",
551 "red_skp/bitmap-64bitMD5_15939355025996362179.png",
553 "checksumAlgorithm" : "bitmap-64bitMD5",
554 "checksumValue" : 649771916797529222,
555 "comparisonResult" : "no-comparison",
557 "red_skp/bitmap-64bitMD5_649771916797529222.png",
559 "checksumAlgorithm" : "bitmap-64bitMD5",
560 "checksumValue" : 8132820002266077288,
561 "comparisonResult" : "no-comparison",
563 "red_skp/bitmap-64bitMD5_8132820002266077288.png",
565 "checksumAlgorithm" : "bitmap-64bitMD5",
566 "checksumValue" : 2406160701181324581,
567 "comparisonResult" : "no-comparison",
569 "red_skp/bitmap-64bitMD5_2406160701181324581.png",
573 # Manually verified these 6 images, all 256x256 tiles,
574 # consistent with a tiled version of the 640x400 green rect
575 # with black borders.
577 "checksumAlgorithm" : "bitmap-64bitMD5",
578 "checksumValue" : 12587324416545178013,
579 "comparisonResult" : "no-comparison",
581 "green_skp/bitmap-64bitMD5_12587324416545178013.png",
583 "checksumAlgorithm" : "bitmap-64bitMD5",
584 "checksumValue" : 7624374914829746293,
585 "comparisonResult" : "no-comparison",
587 "green_skp/bitmap-64bitMD5_7624374914829746293.png",
589 "checksumAlgorithm" : "bitmap-64bitMD5",
590 "checksumValue" : 11866144860997809880,
591 "comparisonResult" : "no-comparison",
593 "green_skp/bitmap-64bitMD5_11866144860997809880.png",
595 "checksumAlgorithm" : "bitmap-64bitMD5",
596 "checksumValue" : 3893392565127823822,
597 "comparisonResult" : "no-comparison",
599 "green_skp/bitmap-64bitMD5_3893392565127823822.png",
601 "checksumAlgorithm" : "bitmap-64bitMD5",
602 "checksumValue" : 2083084978343901738,
603 "comparisonResult" : "no-comparison",
605 "green_skp/bitmap-64bitMD5_2083084978343901738.png",
607 "checksumAlgorithm" : "bitmap-64bitMD5",
608 "checksumValue" : 89620927366502076,
609 "comparisonResult" : "no-comparison",
611 "green_skp/bitmap-64bitMD5_89620927366502076.png",
616 self._assert_json_contents(output_json_path, expected_summary_dict)
617 self._assert_directory_contents(write_path_dir, ['red_skp', 'green_skp'])
618 self._assert_directory_contents(
619 os.path.join(write_path_dir, 'red_skp'),
620 ['bitmap-64bitMD5_5815827069051002745.png',
621 'bitmap-64bitMD5_9323613075234140270.png',
622 'bitmap-64bitMD5_15939355025996362179.png',
623 'bitmap-64bitMD5_649771916797529222.png',
624 'bitmap-64bitMD5_8132820002266077288.png',
625 'bitmap-64bitMD5_2406160701181324581.png'])
626 self._assert_directory_contents(
627 os.path.join(write_path_dir, 'green_skp'),
628 ['bitmap-64bitMD5_12587324416545178013.png',
629 'bitmap-64bitMD5_7624374914829746293.png',
630 'bitmap-64bitMD5_11866144860997809880.png',
631 'bitmap-64bitMD5_3893392565127823822.png',
632 'bitmap-64bitMD5_2083084978343901738.png',
633 'bitmap-64bitMD5_89620927366502076.png'])
635 def _run_render_pictures(self, args):
636 binary = find_run_binary.find_path_to_program('render_pictures')
637 return find_run_binary.run_command(
638 [binary, '--config', '8888'] + args)
640 def _create_expectations(self, missing_some_images=False,
641 ignore_some_failures=False,
642 rel_path='expectations.json'):
643 """Creates expectations JSON file within self._expectations_dir .
646 missing_some_images: (bool) whether to remove expectations for a subset
648 ignore_some_failures: (bool) whether to ignore some failing tests
649 rel_path: (string) relative path within self._expectations_dir to write
650 the expectations into
652 Returns: full path to the expectations file created.
654 expectations_dict = {
655 "header" : EXPECTED_HEADER_CONTENTS,
656 "descriptions" : None,
657 "expected-results" : {
658 # red.skp: these should fail the comparison
660 "tiled-images": modified_list_of_dicts(
661 RED_TILES, {'checksumValue': 11111}),
662 "whole-image": modified_dict(
663 RED_WHOLEIMAGE, {'checksumValue': 22222}),
665 # green.skp: these should pass the comparison
667 "tiled-images": GREEN_TILES,
668 "whole-image": GREEN_WHOLEIMAGE,
672 if missing_some_images:
673 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
680 path = os.path.join(self._expectations_dir, rel_path)
681 with open(path, 'w') as fh:
682 json.dump(expectations_dict, fh)
685 def _generate_skps(self):
686 """Runs the skpmaker binary to generate files in self._input_skp_dir."""
688 output_path=os.path.join(self._input_skp_dir, 'red.skp'), red=255)
690 output_path=os.path.join(self._input_skp_dir, 'green.skp'), green=255)
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.
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.
704 binary = find_run_binary.find_path_to_program('skpmaker')
705 return find_run_binary.run_command([
708 '--green', str(green),
710 '--width', str(width),
711 '--height', str(height),
712 '--writePath', str(output_path),
715 def _assert_directory_contents(self, dir_path, expected_filenames):
716 """Asserts that files found in a dir are identical to expected_filenames.
719 dir_path: Path to a directory on local disk.
720 expected_filenames: Set containing the expected filenames within the dir.
723 AssertionError: contents of the directory are not identical to
726 self.assertEqual(set(os.listdir(dir_path)), set(expected_filenames))
728 def _assert_json_contents(self, json_path, expected_dict):
729 """Asserts that contents of a JSON file are identical to expected_dict.
732 json_path: Path to a JSON file.
733 expected_dict: Dictionary indicating the expected contents of the JSON
737 AssertionError: contents of the JSON file are not identical to
740 prettyprinted_expected_dict = json.dumps(expected_dict, sort_keys=True,
742 with open(json_path, 'r') as fh:
743 prettyprinted_json_dict = json.dumps(json.load(fh), sort_keys=True,
745 self.assertMultiLineEqual(prettyprinted_expected_dict,
746 prettyprinted_json_dict)
750 base_unittest.main(RenderPicturesTest)
753 if __name__ == '__main__':