From c3147c668cb454d3762515313ea7bbdc38af146b Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Wed, 15 Jan 2014 20:35:54 +0000 Subject: [PATCH] render_pictures: adjust unittests to show specific failures BUG=skia:2043,skia:2044 R=rmistry@google.com Author: epoger@google.com Review URL: https://codereview.chromium.org/139383004 git-svn-id: http://skia.googlecode.com/svn/trunk@13100 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tools/tests/render_pictures_test.py | 81 +++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 17 deletions(-) diff --git a/tools/tests/render_pictures_test.py b/tools/tests/render_pictures_test.py index 33c1e6a..608df9f 100755 --- a/tools/tests/render_pictures_test.py +++ b/tools/tests/render_pictures_test.py @@ -18,11 +18,15 @@ import tempfile # Imports from within Skia import base_unittest +# Maximum length of text diffs to show when tests fail +MAX_DIFF_LENGTH = 30000 + class RenderPicturesTest(base_unittest.TestCase): def setUp(self): self._temp_dir = tempfile.mkdtemp() + self.maxDiff = MAX_DIFF_LENGTH def tearDown(self): shutil.rmtree(self._temp_dir) @@ -40,49 +44,93 @@ class RenderPicturesTest(base_unittest.TestCase): expected_summary_dict = { "actual-results" : { "no-comparison" : { - # Manually verified: 640x400 red image with black border + # Manually verified: 640x400 red rectangle with black border "input.png" : [ "bitmap-64bitMD5", 11092453015575919668 ] } } } self._assert_json_contents(output_json_path, expected_summary_dict) - def test_tiled_no_comparison(self): - """Generate individual tiles. - - TODO(epoger): The results of this test are currently broken! - The summary should contain a list of tiles, but for some reason, it is - empty.""" + def test_untiled_no_comparison(self): + """Run without tiles.""" input_skp_path = os.path.join(self._temp_dir, 'input.skp') output_json_path = os.path.join(self._temp_dir, 'output.json') self._run_skpmaker(['--writePath', input_skp_path]) self._run_render_pictures(['-r', input_skp_path, - '--bbh', 'grid', '256', '256', - '--mode', 'tile', '256', '256', + '--writePath', self._temp_dir, '--writeJsonSummaryPath', output_json_path]) expected_summary_dict = { "actual-results" : { - "no-comparison" : None + "no-comparison" : { + # Manually verified: 640x400 red rectangle with black border + "input.png" : ["bitmap-64bitMD5", 11092453015575919668], } } + } self._assert_json_contents(output_json_path, expected_summary_dict) - def test_untiled_no_comparison(self): - """Run without tiles. + def test_validate(self): + """Same as test_untiled_no_comparison, 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_no_comparison. + See https://code.google.com/p/skia/issues/detail?id=2044 ('render_pictures: + --validate fails') + """ + input_skp_path = os.path.join(self._temp_dir, 'input.skp') + output_json_path = os.path.join(self._temp_dir, 'output.json') + self._run_skpmaker(['--writePath', input_skp_path]) + with self.assertRaises(Exception): + self._run_render_pictures(['-r', input_skp_path, + '--validate', + '--writePath', self._temp_dir, + '--writeJsonSummaryPath', output_json_path]) + + def test_without_writePath(self): + """Same as test_untiled_no_comparison, 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') + """ + input_skp_path = os.path.join(self._temp_dir, 'input.skp') + output_json_path = os.path.join(self._temp_dir, 'output.json') + self._run_skpmaker(['--writePath', input_skp_path]) + self._run_render_pictures(['-r', input_skp_path, + '--writeJsonSummaryPath', output_json_path]) + expected_summary_dict = { + "actual-results" : { + "no-comparison" : None, + } + } + self._assert_json_contents(output_json_path, expected_summary_dict) - TODO(epoger): The results of this test are currently broken! - The summary should contain a single image, but for some reason, it is - empty.""" + def test_tiled_no_comparison(self): + """Generate individual tiles.""" input_skp_path = os.path.join(self._temp_dir, 'input.skp') output_json_path = os.path.join(self._temp_dir, 'output.json') self._run_skpmaker(['--writePath', input_skp_path]) self._run_render_pictures(['-r', input_skp_path, + '--bbh', 'grid', '256', '256', + '--mode', 'tile', '256', '256', + '--writePath', self._temp_dir, '--writeJsonSummaryPath', output_json_path]) expected_summary_dict = { "actual-results" : { - "no-comparison" : None + "no-comparison" : { + # Manually verified these 6 images, all 256x256 tiles, + # consistent with a tiled version of the 640x400 red rect + # with black borders. + "input0.png" : ["bitmap-64bitMD5", 5815827069051002745], + "input1.png" : ["bitmap-64bitMD5", 9323613075234140270], + "input2.png" : ["bitmap-64bitMD5", 16670399404877552232], + "input3.png" : ["bitmap-64bitMD5", 2507897274083364964], + "input4.png" : ["bitmap-64bitMD5", 7325267995523877959], + "input5.png" : ["bitmap-64bitMD5", 2181381724594493116], } } + } self._assert_json_contents(output_json_path, expected_summary_dict) def _run_render_pictures(self, args): @@ -90,7 +138,6 @@ class RenderPicturesTest(base_unittest.TestCase): return self.run_command([binary, '--clone', '1', '--config', '8888', - '--validate' ] + args) def _run_skpmaker(self, args): -- 2.7.4