Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1190)

Side by Side Diff: tools/tests/render_pictures_test.py

Issue 139383004: render_pictures: adjust unittests to show specific failures (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 """ 3 """
4 Copyright 2014 Google Inc. 4 Copyright 2014 Google Inc.
5 5
6 Use of this source code is governed by a BSD-style license that can be 6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file. 7 found in the LICENSE file.
8 8
9 Test the render_pictures binary. 9 Test the render_pictures binary.
10 """ 10 """
11 11
12 # System-level imports 12 # System-level imports
13 import json 13 import json
14 import os 14 import os
15 import shutil 15 import shutil
16 import tempfile 16 import tempfile
17 17
18 # Imports from within Skia 18 # Imports from within Skia
19 import base_unittest 19 import base_unittest
20 20
21 # Maximum length of text diffs to show when tests fail
22 MAX_DIFF_LENGTH = 30000
23
21 24
22 class RenderPicturesTest(base_unittest.TestCase): 25 class RenderPicturesTest(base_unittest.TestCase):
23 26
24 def setUp(self): 27 def setUp(self):
25 self._temp_dir = tempfile.mkdtemp() 28 self._temp_dir = tempfile.mkdtemp()
29 self.maxDiff = MAX_DIFF_LENGTH
26 30
27 def tearDown(self): 31 def tearDown(self):
28 shutil.rmtree(self._temp_dir) 32 shutil.rmtree(self._temp_dir)
29 33
30 def test_tiled_whole_image_no_comparison(self): 34 def test_tiled_whole_image_no_comparison(self):
31 """Run render_pictures with tiles and --writeWholeImage flag.""" 35 """Run render_pictures with tiles and --writeWholeImage flag."""
32 input_skp_path = os.path.join(self._temp_dir, 'input.skp') 36 input_skp_path = os.path.join(self._temp_dir, 'input.skp')
33 output_json_path = os.path.join(self._temp_dir, 'output.json') 37 output_json_path = os.path.join(self._temp_dir, 'output.json')
34 self._run_skpmaker(['--writePath', input_skp_path]) 38 self._run_skpmaker(['--writePath', input_skp_path])
35 self._run_render_pictures(['-r', input_skp_path, 39 self._run_render_pictures(['-r', input_skp_path,
36 '--bbh', 'grid', '256', '256', 40 '--bbh', 'grid', '256', '256',
37 '--mode', 'tile', '256', '256', 41 '--mode', 'tile', '256', '256',
38 '--writeJsonSummaryPath', output_json_path, 42 '--writeJsonSummaryPath', output_json_path,
39 '--writeWholeImage']) 43 '--writeWholeImage'])
40 expected_summary_dict = { 44 expected_summary_dict = {
41 "actual-results" : { 45 "actual-results" : {
42 "no-comparison" : { 46 "no-comparison" : {
43 # Manually verified: 640x400 red image with black border 47 # Manually verified: 640x400 red rectangle with black border
44 "input.png" : [ "bitmap-64bitMD5", 11092453015575919668 ] 48 "input.png" : [ "bitmap-64bitMD5", 11092453015575919668 ]
45 } 49 }
46 } 50 }
47 } 51 }
48 self._assert_json_contents(output_json_path, expected_summary_dict) 52 self._assert_json_contents(output_json_path, expected_summary_dict)
49 53
50 def test_tiled_no_comparison(self): 54 def test_untiled_no_comparison(self):
51 """Generate individual tiles. 55 """Run without tiles."""
52
53 TODO(epoger): The results of this test are currently broken!
54 The summary should contain a list of tiles, but for some reason, it is
55 empty."""
56 input_skp_path = os.path.join(self._temp_dir, 'input.skp') 56 input_skp_path = os.path.join(self._temp_dir, 'input.skp')
57 output_json_path = os.path.join(self._temp_dir, 'output.json') 57 output_json_path = os.path.join(self._temp_dir, 'output.json')
58 self._run_skpmaker(['--writePath', input_skp_path]) 58 self._run_skpmaker(['--writePath', input_skp_path])
59 self._run_render_pictures(['-r', input_skp_path, 59 self._run_render_pictures(['-r', input_skp_path,
60 '--bbh', 'grid', '256', '256', 60 '--writePath', self._temp_dir,
61 '--mode', 'tile', '256', '256',
62 '--writeJsonSummaryPath', output_json_path]) 61 '--writeJsonSummaryPath', output_json_path])
63 expected_summary_dict = { 62 expected_summary_dict = {
64 "actual-results" : { 63 "actual-results" : {
65 "no-comparison" : None 64 "no-comparison" : {
65 # Manually verified: 640x400 red rectangle with black border
66 "input.png" : ["bitmap-64bitMD5", 11092453015575919668],
66 } 67 }
67 } 68 }
69 }
68 self._assert_json_contents(output_json_path, expected_summary_dict) 70 self._assert_json_contents(output_json_path, expected_summary_dict)
69 71
70 def test_untiled_no_comparison(self): 72 def test_validate(self):
71 """Run without tiles. 73 """Same as test_untiled_no_comparison, but with --validate.
72 74
73 TODO(epoger): The results of this test are currently broken! 75 TODO(epoger): This test generates undesired results! The call
74 The summary should contain a single image, but for some reason, it is 76 to render_pictures should succeed, and generate the same output as
75 empty.""" 77 test_untiled_no_comparison.
78 See https://code.google.com/p/skia/issues/detail?id=2044 ('render_pictures:
79 --validate fails')
80 """
81 input_skp_path = os.path.join(self._temp_dir, 'input.skp')
82 output_json_path = os.path.join(self._temp_dir, 'output.json')
83 self._run_skpmaker(['--writePath', input_skp_path])
84 with self.assertRaises(Exception):
85 self._run_render_pictures(['-r', input_skp_path,
86 '--validate',
87 '--writePath', self._temp_dir,
88 '--writeJsonSummaryPath', output_json_path])
89
90 def test_without_writePath(self):
91 """Same as test_untiled_no_comparison, but without --writePath.
92
93 TODO(epoger): This test generates undesired results!
94 See https://code.google.com/p/skia/issues/detail?id=2043 ('render_pictures:
95 --writeJsonSummaryPath fails unless --writePath is specified')
96 """
76 input_skp_path = os.path.join(self._temp_dir, 'input.skp') 97 input_skp_path = os.path.join(self._temp_dir, 'input.skp')
77 output_json_path = os.path.join(self._temp_dir, 'output.json') 98 output_json_path = os.path.join(self._temp_dir, 'output.json')
78 self._run_skpmaker(['--writePath', input_skp_path]) 99 self._run_skpmaker(['--writePath', input_skp_path])
79 self._run_render_pictures(['-r', input_skp_path, 100 self._run_render_pictures(['-r', input_skp_path,
80 '--writeJsonSummaryPath', output_json_path]) 101 '--writeJsonSummaryPath', output_json_path])
81 expected_summary_dict = { 102 expected_summary_dict = {
82 "actual-results" : { 103 "actual-results" : {
83 "no-comparison" : None 104 "no-comparison" : None,
105 }
106 }
107 self._assert_json_contents(output_json_path, expected_summary_dict)
108
109 def test_tiled_no_comparison(self):
110 """Generate individual tiles."""
111 input_skp_path = os.path.join(self._temp_dir, 'input.skp')
112 output_json_path = os.path.join(self._temp_dir, 'output.json')
113 self._run_skpmaker(['--writePath', input_skp_path])
114 self._run_render_pictures(['-r', input_skp_path,
115 '--bbh', 'grid', '256', '256',
116 '--mode', 'tile', '256', '256',
117 '--writePath', self._temp_dir,
118 '--writeJsonSummaryPath', output_json_path])
119 expected_summary_dict = {
120 "actual-results" : {
121 "no-comparison" : {
122 # Manually verified these 6 images, all 256x256 tiles,
123 # consistent with a tiled version of the 640x400 red rect
124 # with black borders.
125 "input0.png" : ["bitmap-64bitMD5", 5815827069051002745],
126 "input1.png" : ["bitmap-64bitMD5", 9323613075234140270],
127 "input2.png" : ["bitmap-64bitMD5", 16670399404877552232],
128 "input3.png" : ["bitmap-64bitMD5", 2507897274083364964],
129 "input4.png" : ["bitmap-64bitMD5", 7325267995523877959],
130 "input5.png" : ["bitmap-64bitMD5", 2181381724594493116],
84 } 131 }
85 } 132 }
133 }
86 self._assert_json_contents(output_json_path, expected_summary_dict) 134 self._assert_json_contents(output_json_path, expected_summary_dict)
87 135
88 def _run_render_pictures(self, args): 136 def _run_render_pictures(self, args):
89 binary = self.find_path_to_program('render_pictures') 137 binary = self.find_path_to_program('render_pictures')
90 return self.run_command([binary, 138 return self.run_command([binary,
91 '--clone', '1', 139 '--clone', '1',
92 '--config', '8888', 140 '--config', '8888',
93 '--validate'
94 ] + args) 141 ] + args)
95 142
96 def _run_skpmaker(self, args): 143 def _run_skpmaker(self, args):
97 binary = self.find_path_to_program('skpmaker') 144 binary = self.find_path_to_program('skpmaker')
98 return self.run_command([binary, 145 return self.run_command([binary,
99 '--red', '255', 146 '--red', '255',
100 '--green', '0', 147 '--green', '0',
101 '--blue', '0', 148 '--blue', '0',
102 '--width', '640', 149 '--width', '640',
103 '--height', '400', 150 '--height', '400',
(...skipping 15 matching lines...) Expand all
119 actual_dict = json.loads(file_contents) 166 actual_dict = json.loads(file_contents)
120 self.assertEqual(actual_dict, expected_dict) 167 self.assertEqual(actual_dict, expected_dict)
121 168
122 169
123 def main(): 170 def main():
124 base_unittest.main(RenderPicturesTest) 171 base_unittest.main(RenderPicturesTest)
125 172
126 173
127 if __name__ == '__main__': 174 if __name__ == '__main__':
128 main() 175 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698