Chromium Code Reviews| Index: tools/tests/render_pictures_test.py |
| diff --git a/tools/tests/render_pictures_test.py b/tools/tests/render_pictures_test.py |
| index 3ebed93578dea700bf03748f78928b78d5ee1892..510b2494a5d6b1b5dc83e522e7528f50e309d701 100755 |
| --- a/tools/tests/render_pictures_test.py |
| +++ b/tools/tests/render_pictures_test.py |
| @@ -26,6 +26,92 @@ EXPECTED_HEADER_CONTENTS = { |
| "revision" : 1, |
| } |
| +# Manually verified: 640x400 red rectangle with black border |
| +RED_WHOLEIMAGE = { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 11092453015575919668, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "red_skp.png", |
| +} |
| + |
| +# Manually verified: 640x400 green rectangle with black border |
| +GREEN_WHOLEIMAGE = { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 8891695120562235492, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "green_skp.png", |
| +} |
| + |
| +# Manually verified these 6 images, all 256x256 tiles, |
| +# consistent with a tiled version of the 640x400 red rect |
| +# with black borders. |
| +RED_TILES = [{ |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 5815827069051002745, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "red_skp-tile0.png", |
| +},{ |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 9323613075234140270, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "red_skp-tile1.png", |
| +}, { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 16670399404877552232, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "red_skp-tile2.png", |
| +}, { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 2507897274083364964, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "red_skp-tile3.png", |
| +}, { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 7325267995523877959, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "red_skp-tile4.png", |
| +}, { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 2181381724594493116, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "red_skp-tile5.png", |
| +}] |
| + |
| +# Manually verified these 6 images, all 256x256 tiles, |
| +# consistent with a tiled version of the 640x400 green rect |
| +# with black borders. |
| +GREEN_TILES = [{ |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 12587324416545178013, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "green_skp-tile0.png", |
| +}, { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 7624374914829746293, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "green_skp-tile1.png", |
| +}, { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 5686489729535631913, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "green_skp-tile2.png", |
| +}, { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 7980646035555096146, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "green_skp-tile3.png", |
| +}, { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 17817086664365875131, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "green_skp-tile4.png", |
| +}, { |
| + "checksumAlgorithm" : "bitmap-64bitMD5", |
| + "checksumValue" : 10673669813016809363, |
| + "comparisonResult" : "no-comparison", |
| + "filepath" : "green_skp-tile5.png", |
| +}] |
| + |
| class RenderPicturesTest(base_unittest.TestCase): |
| @@ -39,13 +125,19 @@ class RenderPicturesTest(base_unittest.TestCase): |
| shutil.rmtree(self._temp_dir) |
| def test_tiled_whole_image(self): |
| - """Run render_pictures with tiles and --writeWholeImage flag.""" |
| + """Run render_pictures with tiles and --writeWholeImage flag. |
| + |
| + TODO(epoger): This test generates undesired results! The JSON summary |
|
epoger
2014/04/24 20:51:20
This behavior CHANGED with this CL, but it was alr
|
| + includes both whole-image and tiled-images (as it should), but only |
| + whole-images are written out to disk. |
| + |
| + TODO(epoger): I noticed that when this is run without --writePath being |
|
scroggo
2014/04/24 21:15:08
Are there bugs for these TODOs? Should they be ref
epoger
2014/04/25 15:26:43
Now they do, and they are. Good idea, thanks.
|
| + specified, this test writes red_skp.png and green_skp.png to the current |
| + directory. We should fix that... if --writePath is not specified, this |
| + probably shouldn't write out red_skp.png and green_skp.png at all! |
| + """ |
| output_json_path = os.path.join(self._temp_dir, 'output.json') |
| self._generate_skps() |
| - # TODO(epoger): I noticed that when this is run without --writePath being |
| - # specified, this test writes red_skp.png and green_skp.png to the current |
| - # directory. We should fix that... if --writePath is not specified, this |
| - # probably shouldn't write out red_skp.png and green_skp.png at all! |
| self._run_render_pictures(['-r', self._input_skp_dir, |
| '--bbh', 'grid', '256', '256', |
| '--mode', 'tile', '256', '256', |
| @@ -56,26 +148,18 @@ class RenderPicturesTest(base_unittest.TestCase): |
| "header" : EXPECTED_HEADER_CONTENTS, |
| "actual-results" : { |
| "red.skp": { |
| - # Manually verified: 640x400 red rectangle with black border |
| - "whole-image": { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 11092453015575919668, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "red_skp.png", |
| - }, |
| + "tiled-images": RED_TILES, |
| + "whole-image": RED_WHOLEIMAGE, |
| }, |
| "green.skp": { |
| - # Manually verified: 640x400 green rectangle with black border |
| - "whole-image": { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 8891695120562235492, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "green_skp.png", |
| - }, |
| + "tiled-images": GREEN_TILES, |
| + "whole-image": GREEN_WHOLEIMAGE, |
| } |
| } |
| } |
| self._assert_json_contents(output_json_path, expected_summary_dict) |
| + # The disk contents are not what they should be--we should see all the |
|
scroggo
2014/04/24 21:15:08
I suppose this goes with the TODO above?
epoger
2014/04/25 15:26:43
Yes. Removed this redundant comment.
|
| + # tile images written out, too. |
| self._assert_directory_contents( |
| self._temp_dir, ['red_skp.png', 'green_skp.png', 'output.json']) |
| @@ -86,28 +170,14 @@ class RenderPicturesTest(base_unittest.TestCase): |
| self._run_render_pictures(['-r', self._input_skp_dir, |
| '--writePath', self._temp_dir, |
| '--writeJsonSummaryPath', output_json_path]) |
| - # TODO(epoger): These expectations are the same as for above unittest. |
| - # Define the expectations once, and share them. |
| expected_summary_dict = { |
| "header" : EXPECTED_HEADER_CONTENTS, |
| "actual-results" : { |
| "red.skp": { |
| - # Manually verified: 640x400 red rectangle with black border |
| - "whole-image": { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 11092453015575919668, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "red_skp.png", |
| - }, |
| + "whole-image": RED_WHOLEIMAGE, |
| }, |
| "green.skp": { |
| - # Manually verified: 640x400 green rectangle with black border |
| - "whole-image": { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 8891695120562235492, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "green_skp.png", |
| - }, |
| + "whole-image": GREEN_WHOLEIMAGE, |
| } |
| } |
| } |
| @@ -157,36 +227,44 @@ class RenderPicturesTest(base_unittest.TestCase): |
| ['bitmap-64bitMD5_8891695120562235492.png']) |
| def test_untiled_validate(self): |
| - """Same as test_untiled, but with --validate. |
| - |
| - TODO(epoger): This test generates undesired results! The call |
| - to render_pictures should succeed, and generate the same output as |
| - test_untiled. |
| - See https://code.google.com/p/skia/issues/detail?id=2044 ('render_pictures: |
|
scroggo
2014/04/24 21:15:08
I'm glad to know that using the flag "validate" no
epoger
2014/04/25 15:26:43
Probably so.
This code really should have had uni
|
| - --validate fails') |
| - """ |
| + """Same as test_untiled, but with --validate.""" |
| output_json_path = os.path.join(self._temp_dir, 'output.json') |
| self._generate_skps() |
| - with self.assertRaises(Exception): |
| - self._run_render_pictures(['-r', self._input_skp_dir, |
| - '--validate', |
| - '--writePath', self._temp_dir, |
| - '--writeJsonSummaryPath', output_json_path]) |
| + self._run_render_pictures(['-r', self._input_skp_dir, |
| + '--validate', |
| + '--writePath', self._temp_dir, |
| + '--writeJsonSummaryPath', output_json_path]) |
| + expected_summary_dict = { |
| + "header" : EXPECTED_HEADER_CONTENTS, |
| + "actual-results" : { |
| + "red.skp": { |
| + "whole-image": RED_WHOLEIMAGE, |
| + }, |
| + "green.skp": { |
| + "whole-image": GREEN_WHOLEIMAGE, |
| + } |
| + } |
| + } |
| + self._assert_json_contents(output_json_path, expected_summary_dict) |
| + self._assert_directory_contents( |
| + self._temp_dir, ['red_skp.png', 'green_skp.png', 'output.json']) |
| def test_untiled_without_writePath(self): |
| - """Same as test_untiled, but without --writePath. |
| - |
| - TODO(epoger): This test generates undesired results! |
| - See https://code.google.com/p/skia/issues/detail?id=2043 ('render_pictures: |
| - --writeJsonSummaryPath fails unless --writePath is specified') |
| - """ |
| + """Same as test_untiled, but without --writePath.""" |
| output_json_path = os.path.join(self._temp_dir, 'output.json') |
| self._generate_skps() |
| self._run_render_pictures(['-r', self._input_skp_dir, |
| '--writeJsonSummaryPath', output_json_path]) |
| expected_summary_dict = { |
| "header" : EXPECTED_HEADER_CONTENTS, |
| - "actual-results" : None, |
| + "actual-results" : { |
| + "red.skp": { |
| + "whole-image": RED_WHOLEIMAGE, |
| + }, |
| + "green.skp": { |
| + "whole-image": GREEN_WHOLEIMAGE, |
| + } |
| + } |
| } |
| self._assert_json_contents(output_json_path, expected_summary_dict) |
| @@ -203,76 +281,10 @@ class RenderPicturesTest(base_unittest.TestCase): |
| "header" : EXPECTED_HEADER_CONTENTS, |
| "actual-results" : { |
| "red.skp": { |
| - # Manually verified these 6 images, all 256x256 tiles, |
| - # consistent with a tiled version of the 640x400 red rect |
| - # with black borders. |
| - "tiled-images": [{ |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 5815827069051002745, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "red_skp-tile0.png", |
| - }, { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 9323613075234140270, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "red_skp-tile1.png", |
| - }, { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 16670399404877552232, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "red_skp-tile2.png", |
| - }, { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 2507897274083364964, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "red_skp-tile3.png", |
| - }, { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 7325267995523877959, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "red_skp-tile4.png", |
| - }, { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 2181381724594493116, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "red_skp-tile5.png", |
| - }], |
| + "tiled-images": RED_TILES, |
| }, |
| "green.skp": { |
| - # Manually verified these 6 images, all 256x256 tiles, |
| - # consistent with a tiled version of the 640x400 green rect |
| - # with black borders. |
| - "tiled-images": [{ |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 12587324416545178013, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "green_skp-tile0.png", |
| - }, { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 7624374914829746293, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "green_skp-tile1.png", |
| - }, { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 5686489729535631913, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "green_skp-tile2.png", |
| - }, { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 7980646035555096146, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "green_skp-tile3.png", |
| - }, { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 17817086664365875131, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "green_skp-tile4.png", |
| - }, { |
| - "checksumAlgorithm" : "bitmap-64bitMD5", |
| - "checksumValue" : 10673669813016809363, |
| - "comparisonResult" : "no-comparison", |
| - "filepath" : "green_skp-tile5.png", |
| - }], |
| + "tiled-images": GREEN_TILES, |
| } |
| } |
| } |