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

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

Issue 202983003: add --writeChecksumBasedFilenames flag to render_pictures (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: pass SkString pointers to init Created 6 years, 9 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 | « tools/render_pictures_main.cpp ('k') | 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 """
(...skipping 19 matching lines...) Expand all
30 self.maxDiff = MAX_DIFF_LENGTH 30 self.maxDiff = MAX_DIFF_LENGTH
31 31
32 def tearDown(self): 32 def tearDown(self):
33 shutil.rmtree(self._input_skp_dir) 33 shutil.rmtree(self._input_skp_dir)
34 shutil.rmtree(self._temp_dir) 34 shutil.rmtree(self._temp_dir)
35 35
36 def test_tiled_whole_image(self): 36 def test_tiled_whole_image(self):
37 """Run render_pictures with tiles and --writeWholeImage flag.""" 37 """Run render_pictures with tiles and --writeWholeImage flag."""
38 output_json_path = os.path.join(self._temp_dir, 'output.json') 38 output_json_path = os.path.join(self._temp_dir, 'output.json')
39 self._generate_skps() 39 self._generate_skps()
40 # TODO(epoger): I noticed that when this is run without --writePath being
41 # specified, this test writes red.png and green.png to the current working
42 # directory. We should fix that... if --writePath is not specified, this
43 # probably shouldn't write out red.png and green.png at all!
40 self._run_render_pictures(['-r', self._input_skp_dir, 44 self._run_render_pictures(['-r', self._input_skp_dir,
41 '--bbh', 'grid', '256', '256', 45 '--bbh', 'grid', '256', '256',
42 '--mode', 'tile', '256', '256', 46 '--mode', 'tile', '256', '256',
43 '--writeJsonSummaryPath', output_json_path, 47 '--writeJsonSummaryPath', output_json_path,
48 '--writePath', self._temp_dir,
44 '--writeWholeImage']) 49 '--writeWholeImage'])
45 expected_summary_dict = { 50 expected_summary_dict = {
46 "actual-results" : { 51 "actual-results" : {
47 "no-comparison" : { 52 "no-comparison" : {
48 # Manually verified: 640x400 red rectangle with black border 53 # Manually verified: 640x400 red rectangle with black border
49 "red.png" : [ "bitmap-64bitMD5", 11092453015575919668 ], 54 "red.png" : [ "bitmap-64bitMD5", 11092453015575919668 ],
50 # Manually verified: 640x400 green rectangle with black border 55 # Manually verified: 640x400 green rectangle with black border
51 "green.png" : [ "bitmap-64bitMD5", 8891695120562235492 ], 56 "green.png" : [ "bitmap-64bitMD5", 8891695120562235492 ],
52 } 57 }
53 } 58 }
54 } 59 }
55 self._assert_json_contents(output_json_path, expected_summary_dict) 60 self._assert_json_contents(output_json_path, expected_summary_dict)
61 self._assert_directory_contents(
62 self._temp_dir, ['red.png', 'green.png', 'output.json'])
56 63
57 def test_untiled(self): 64 def test_untiled(self):
58 """Run without tiles.""" 65 """Run without tiles."""
59 output_json_path = os.path.join(self._temp_dir, 'output.json') 66 output_json_path = os.path.join(self._temp_dir, 'output.json')
60 self._generate_skps() 67 self._generate_skps()
61 self._run_render_pictures(['-r', self._input_skp_dir, 68 self._run_render_pictures(['-r', self._input_skp_dir,
62 '--writePath', self._temp_dir, 69 '--writePath', self._temp_dir,
63 '--writeJsonSummaryPath', output_json_path]) 70 '--writeJsonSummaryPath', output_json_path])
64 expected_summary_dict = { 71 expected_summary_dict = {
65 "actual-results" : { 72 "actual-results" : {
66 "no-comparison" : { 73 "no-comparison" : {
67 # Manually verified: 640x400 red rectangle with black border 74 # Manually verified: 640x400 red rectangle with black border
68 "red.png" : ["bitmap-64bitMD5", 11092453015575919668], 75 "red.png" : ["bitmap-64bitMD5", 11092453015575919668],
69 # Manually verified: 640x400 green rectangle with black border 76 # Manually verified: 640x400 green rectangle with black border
70 "green.png" : ["bitmap-64bitMD5", 8891695120562235492], 77 "green.png" : ["bitmap-64bitMD5", 8891695120562235492],
71 } 78 }
72 } 79 }
73 } 80 }
74 self._assert_json_contents(output_json_path, expected_summary_dict) 81 self._assert_json_contents(output_json_path, expected_summary_dict)
82 self._assert_directory_contents(
83 self._temp_dir, ['red.png', 'green.png', 'output.json'])
84
85 def test_untiled_writeChecksumBasedFilenames(self):
86 """Same as test_untiled, but with --writeChecksumBasedFilenames."""
87 output_json_path = os.path.join(self._temp_dir, 'output.json')
88 self._generate_skps()
89 self._run_render_pictures(['-r', self._input_skp_dir,
90 '--writeChecksumBasedFilenames',
91 '--writePath', self._temp_dir,
92 '--writeJsonSummaryPath', output_json_path])
93 expected_summary_dict = {
94 "actual-results" : {
95 "no-comparison" : {
96 # Manually verified: 640x400 red rectangle with black border
97 "red.png" : ["bitmap-64bitMD5", 11092453015575919668],
98 # Manually verified: 640x400 green rectangle with black border
99 "green.png" : ["bitmap-64bitMD5", 8891695120562235492],
100 }
101 }
102 }
103 self._assert_json_contents(output_json_path, expected_summary_dict)
104 self._assert_directory_contents(
105 self._temp_dir, ['bitmap-64bitMD5_11092453015575919668.png',
106 'bitmap-64bitMD5_8891695120562235492.png',
107 'output.json'])
75 108
76 def test_untiled_validate(self): 109 def test_untiled_validate(self):
77 """Same as test_untiled, but with --validate. 110 """Same as test_untiled, but with --validate.
78 111
79 TODO(epoger): This test generates undesired results! The call 112 TODO(epoger): This test generates undesired results! The call
80 to render_pictures should succeed, and generate the same output as 113 to render_pictures should succeed, and generate the same output as
81 test_untiled. 114 test_untiled.
82 See https://code.google.com/p/skia/issues/detail?id=2044 ('render_pictures: 115 See https://code.google.com/p/skia/issues/detail?id=2044 ('render_pictures:
83 --validate fails') 116 --validate fails')
84 """ 117 """
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 "green0.png" : ["bitmap-64bitMD5", 12587324416545178013], 168 "green0.png" : ["bitmap-64bitMD5", 12587324416545178013],
136 "green1.png" : ["bitmap-64bitMD5", 7624374914829746293], 169 "green1.png" : ["bitmap-64bitMD5", 7624374914829746293],
137 "green2.png" : ["bitmap-64bitMD5", 5686489729535631913], 170 "green2.png" : ["bitmap-64bitMD5", 5686489729535631913],
138 "green3.png" : ["bitmap-64bitMD5", 7980646035555096146], 171 "green3.png" : ["bitmap-64bitMD5", 7980646035555096146],
139 "green4.png" : ["bitmap-64bitMD5", 17817086664365875131], 172 "green4.png" : ["bitmap-64bitMD5", 17817086664365875131],
140 "green5.png" : ["bitmap-64bitMD5", 10673669813016809363], 173 "green5.png" : ["bitmap-64bitMD5", 10673669813016809363],
141 } 174 }
142 } 175 }
143 } 176 }
144 self._assert_json_contents(output_json_path, expected_summary_dict) 177 self._assert_json_contents(output_json_path, expected_summary_dict)
178 self._assert_directory_contents(
179 self._temp_dir,
180 ['red0.png', 'red1.png', 'red2.png', 'red3.png', 'red4.png', 'red5.png',
181 'green0.png', 'green1.png', 'green2.png', 'green3.png', 'green4.png',
182 'green5.png', 'output.json'])
183
184 def test_tiled_writeChecksumBasedFilenames(self):
185 """Same as test_tiled, but with --writeChecksumBasedFilenames."""
186 output_json_path = os.path.join(self._temp_dir, 'output.json')
187 self._generate_skps()
188 self._run_render_pictures(['-r', self._input_skp_dir,
189 '--bbh', 'grid', '256', '256',
190 '--mode', 'tile', '256', '256',
191 '--writeChecksumBasedFilenames',
192 '--writePath', self._temp_dir,
193 '--writeJsonSummaryPath', output_json_path])
194 expected_summary_dict = {
195 "actual-results" : {
196 "no-comparison" : {
197 # Manually verified these 6 images, all 256x256 tiles,
198 # consistent with a tiled version of the 640x400 red rect
199 # with black borders.
200 "red0.png" : ["bitmap-64bitMD5", 5815827069051002745],
201 "red1.png" : ["bitmap-64bitMD5", 9323613075234140270],
202 "red2.png" : ["bitmap-64bitMD5", 16670399404877552232],
203 "red3.png" : ["bitmap-64bitMD5", 2507897274083364964],
204 "red4.png" : ["bitmap-64bitMD5", 7325267995523877959],
205 "red5.png" : ["bitmap-64bitMD5", 2181381724594493116],
206 # Manually verified these 6 images, all 256x256 tiles,
207 # consistent with a tiled version of the 640x400 green rect
208 # with black borders.
209 "green0.png" : ["bitmap-64bitMD5", 12587324416545178013],
210 "green1.png" : ["bitmap-64bitMD5", 7624374914829746293],
211 "green2.png" : ["bitmap-64bitMD5", 5686489729535631913],
212 "green3.png" : ["bitmap-64bitMD5", 7980646035555096146],
213 "green4.png" : ["bitmap-64bitMD5", 17817086664365875131],
214 "green5.png" : ["bitmap-64bitMD5", 10673669813016809363],
215 }
216 }
217 }
218 self._assert_json_contents(output_json_path, expected_summary_dict)
219 self._assert_directory_contents(
220 self._temp_dir,
221 ['bitmap-64bitMD5_5815827069051002745.png',
222 'bitmap-64bitMD5_9323613075234140270.png',
223 'bitmap-64bitMD5_16670399404877552232.png',
224 'bitmap-64bitMD5_2507897274083364964.png',
225 'bitmap-64bitMD5_7325267995523877959.png',
226 'bitmap-64bitMD5_2181381724594493116.png',
227 'bitmap-64bitMD5_12587324416545178013.png',
228 'bitmap-64bitMD5_7624374914829746293.png',
229 'bitmap-64bitMD5_5686489729535631913.png',
230 'bitmap-64bitMD5_7980646035555096146.png',
231 'bitmap-64bitMD5_17817086664365875131.png',
232 'bitmap-64bitMD5_10673669813016809363.png',
233 'output.json'])
145 234
146 def _run_render_pictures(self, args): 235 def _run_render_pictures(self, args):
147 binary = self.find_path_to_program('render_pictures') 236 binary = self.find_path_to_program('render_pictures')
148 return self.run_command([binary, 237 return self.run_command([binary,
149 '--clone', '1', 238 '--clone', '1',
150 '--config', '8888', 239 '--config', '8888',
151 ] + args) 240 ] + args)
152 241
153 def _generate_skps(self): 242 def _generate_skps(self):
154 """Runs the skpmaker binary to generate files in self._input_skp_dir.""" 243 """Runs the skpmaker binary to generate files in self._input_skp_dir."""
(...skipping 17 matching lines...) Expand all
172 binary = self.find_path_to_program('skpmaker') 261 binary = self.find_path_to_program('skpmaker')
173 return self.run_command([binary, 262 return self.run_command([binary,
174 '--red', str(red), 263 '--red', str(red),
175 '--green', str(green), 264 '--green', str(green),
176 '--blue', str(blue), 265 '--blue', str(blue),
177 '--width', str(width), 266 '--width', str(width),
178 '--height', str(height), 267 '--height', str(height),
179 '--writePath', str(output_path), 268 '--writePath', str(output_path),
180 ]) 269 ])
181 270
271 def _assert_directory_contents(self, dir_path, expected_filenames):
272 """Asserts that files found in a dir are identical to expected_filenames.
273
274 Args:
275 dir_path: Path to a directory on local disk.
276 expected_filenames: Set containing the expected filenames within the dir.
277
278 Raises:
279 AssertionError: contents of the directory are not identical to
280 expected_filenames.
281 """
282 self.assertEqual(set(os.listdir(dir_path)), set(expected_filenames))
283
284
182 def _assert_json_contents(self, json_path, expected_dict): 285 def _assert_json_contents(self, json_path, expected_dict):
183 """Asserts that contents of a JSON file are identical to expected_dict. 286 """Asserts that contents of a JSON file are identical to expected_dict.
184 287
185 Args: 288 Args:
186 json_path: Path to a JSON file. 289 json_path: Path to a JSON file.
187 expected_dict: Dictionary indicating the expected contents of the JSON 290 expected_dict: Dictionary indicating the expected contents of the JSON
188 file. 291 file.
189 292
190 Raises: 293 Raises:
191 AssertionError: contents of the JSON file are not identical to 294 AssertionError: contents of the JSON file are not identical to
192 expected_dict. 295 expected_dict.
193 """ 296 """
194 file_contents = open(json_path, 'r').read() 297 file_contents = open(json_path, 'r').read()
195 actual_dict = json.loads(file_contents) 298 actual_dict = json.loads(file_contents)
196 self.assertEqual(actual_dict, expected_dict) 299 self.assertEqual(actual_dict, expected_dict)
197 300
198 301
199 def main(): 302 def main():
200 base_unittest.main(RenderPicturesTest) 303 base_unittest.main(RenderPicturesTest)
201 304
202 305
203 if __name__ == '__main__': 306 if __name__ == '__main__':
204 main() 307 main()
OLDNEW
« no previous file with comments | « tools/render_pictures_main.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698