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

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

Issue 251103004: Revert of fix contents of render_pictures JSON summary (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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 """
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 21 # Maximum length of text diffs to show when tests fail
22 MAX_DIFF_LENGTH = 30000 22 MAX_DIFF_LENGTH = 30000
23 23
24 EXPECTED_HEADER_CONTENTS = { 24 EXPECTED_HEADER_CONTENTS = {
25 "type" : "ChecksummedImages", 25 "type" : "ChecksummedImages",
26 "revision" : 1, 26 "revision" : 1,
27 } 27 }
28 28
29 # Manually verified: 640x400 red rectangle with black border
30 RED_WHOLEIMAGE = {
31 "checksumAlgorithm" : "bitmap-64bitMD5",
32 "checksumValue" : 11092453015575919668,
33 "comparisonResult" : "no-comparison",
34 "filepath" : "red_skp.png",
35 }
36
37 # Manually verified: 640x400 green rectangle with black border
38 GREEN_WHOLEIMAGE = {
39 "checksumAlgorithm" : "bitmap-64bitMD5",
40 "checksumValue" : 8891695120562235492,
41 "comparisonResult" : "no-comparison",
42 "filepath" : "green_skp.png",
43 }
44
45 # Manually verified these 6 images, all 256x256 tiles,
46 # consistent with a tiled version of the 640x400 red rect
47 # with black borders.
48 RED_TILES = [{
49 "checksumAlgorithm" : "bitmap-64bitMD5",
50 "checksumValue" : 5815827069051002745,
51 "comparisonResult" : "no-comparison",
52 "filepath" : "red_skp-tile0.png",
53 },{
54 "checksumAlgorithm" : "bitmap-64bitMD5",
55 "checksumValue" : 9323613075234140270,
56 "comparisonResult" : "no-comparison",
57 "filepath" : "red_skp-tile1.png",
58 }, {
59 "checksumAlgorithm" : "bitmap-64bitMD5",
60 "checksumValue" : 16670399404877552232,
61 "comparisonResult" : "no-comparison",
62 "filepath" : "red_skp-tile2.png",
63 }, {
64 "checksumAlgorithm" : "bitmap-64bitMD5",
65 "checksumValue" : 2507897274083364964,
66 "comparisonResult" : "no-comparison",
67 "filepath" : "red_skp-tile3.png",
68 }, {
69 "checksumAlgorithm" : "bitmap-64bitMD5",
70 "checksumValue" : 7325267995523877959,
71 "comparisonResult" : "no-comparison",
72 "filepath" : "red_skp-tile4.png",
73 }, {
74 "checksumAlgorithm" : "bitmap-64bitMD5",
75 "checksumValue" : 2181381724594493116,
76 "comparisonResult" : "no-comparison",
77 "filepath" : "red_skp-tile5.png",
78 }]
79
80 # Manually verified these 6 images, all 256x256 tiles,
81 # consistent with a tiled version of the 640x400 green rect
82 # with black borders.
83 GREEN_TILES = [{
84 "checksumAlgorithm" : "bitmap-64bitMD5",
85 "checksumValue" : 12587324416545178013,
86 "comparisonResult" : "no-comparison",
87 "filepath" : "green_skp-tile0.png",
88 }, {
89 "checksumAlgorithm" : "bitmap-64bitMD5",
90 "checksumValue" : 7624374914829746293,
91 "comparisonResult" : "no-comparison",
92 "filepath" : "green_skp-tile1.png",
93 }, {
94 "checksumAlgorithm" : "bitmap-64bitMD5",
95 "checksumValue" : 5686489729535631913,
96 "comparisonResult" : "no-comparison",
97 "filepath" : "green_skp-tile2.png",
98 }, {
99 "checksumAlgorithm" : "bitmap-64bitMD5",
100 "checksumValue" : 7980646035555096146,
101 "comparisonResult" : "no-comparison",
102 "filepath" : "green_skp-tile3.png",
103 }, {
104 "checksumAlgorithm" : "bitmap-64bitMD5",
105 "checksumValue" : 17817086664365875131,
106 "comparisonResult" : "no-comparison",
107 "filepath" : "green_skp-tile4.png",
108 }, {
109 "checksumAlgorithm" : "bitmap-64bitMD5",
110 "checksumValue" : 10673669813016809363,
111 "comparisonResult" : "no-comparison",
112 "filepath" : "green_skp-tile5.png",
113 }]
114
115 29
116 class RenderPicturesTest(base_unittest.TestCase): 30 class RenderPicturesTest(base_unittest.TestCase):
117 31
118 def setUp(self): 32 def setUp(self):
119 self._input_skp_dir = tempfile.mkdtemp() 33 self._input_skp_dir = tempfile.mkdtemp()
120 self._temp_dir = tempfile.mkdtemp() 34 self._temp_dir = tempfile.mkdtemp()
121 self.maxDiff = MAX_DIFF_LENGTH 35 self.maxDiff = MAX_DIFF_LENGTH
122 36
123 def tearDown(self): 37 def tearDown(self):
124 shutil.rmtree(self._input_skp_dir) 38 shutil.rmtree(self._input_skp_dir)
125 shutil.rmtree(self._temp_dir) 39 shutil.rmtree(self._temp_dir)
126 40
127 def test_tiled_whole_image(self): 41 def test_tiled_whole_image(self):
128 """Run render_pictures with tiles and --writeWholeImage flag. 42 """Run render_pictures with tiles and --writeWholeImage flag."""
129
130 TODO(epoger): This test generates undesired results! The JSON summary
131 includes both whole-image and tiled-images (as it should), but only
132 whole-images are written out to disk. See http://skbug.com/2463
133
134 TODO(epoger): I noticed that when this is run without --writePath being
135 specified, this test writes red_skp.png and green_skp.png to the current
136 directory. We should fix that... if --writePath is not specified, this
137 probably shouldn't write out red_skp.png and green_skp.png at all!
138 See http://skbug.com/2464
139 """
140 output_json_path = os.path.join(self._temp_dir, 'output.json') 43 output_json_path = os.path.join(self._temp_dir, 'output.json')
141 self._generate_skps() 44 self._generate_skps()
45 # TODO(epoger): I noticed that when this is run without --writePath being
46 # specified, this test writes red_skp.png and green_skp.png to the current
47 # directory. We should fix that... if --writePath is not specified, this
48 # probably shouldn't write out red_skp.png and green_skp.png at all!
142 self._run_render_pictures(['-r', self._input_skp_dir, 49 self._run_render_pictures(['-r', self._input_skp_dir,
143 '--bbh', 'grid', '256', '256', 50 '--bbh', 'grid', '256', '256',
144 '--mode', 'tile', '256', '256', 51 '--mode', 'tile', '256', '256',
145 '--writeJsonSummaryPath', output_json_path, 52 '--writeJsonSummaryPath', output_json_path,
146 '--writePath', self._temp_dir, 53 '--writePath', self._temp_dir,
147 '--writeWholeImage']) 54 '--writeWholeImage'])
148 expected_summary_dict = { 55 expected_summary_dict = {
149 "header" : EXPECTED_HEADER_CONTENTS, 56 "header" : EXPECTED_HEADER_CONTENTS,
150 "actual-results" : { 57 "actual-results" : {
151 "red.skp": { 58 "red.skp": {
152 "tiled-images": RED_TILES, 59 # Manually verified: 640x400 red rectangle with black border
153 "whole-image": RED_WHOLEIMAGE, 60 "whole-image": {
61 "checksumAlgorithm" : "bitmap-64bitMD5",
62 "checksumValue" : 11092453015575919668,
63 "comparisonResult" : "no-comparison",
64 "filepath" : "red_skp.png",
65 },
154 }, 66 },
155 "green.skp": { 67 "green.skp": {
156 "tiled-images": GREEN_TILES, 68 # Manually verified: 640x400 green rectangle with black border
157 "whole-image": GREEN_WHOLEIMAGE, 69 "whole-image": {
70 "checksumAlgorithm" : "bitmap-64bitMD5",
71 "checksumValue" : 8891695120562235492,
72 "comparisonResult" : "no-comparison",
73 "filepath" : "green_skp.png",
74 },
158 } 75 }
159 } 76 }
160 } 77 }
161 self._assert_json_contents(output_json_path, expected_summary_dict) 78 self._assert_json_contents(output_json_path, expected_summary_dict)
162 self._assert_directory_contents( 79 self._assert_directory_contents(
163 self._temp_dir, ['red_skp.png', 'green_skp.png', 'output.json']) 80 self._temp_dir, ['red_skp.png', 'green_skp.png', 'output.json'])
164 81
165 def test_untiled(self): 82 def test_untiled(self):
166 """Run without tiles.""" 83 """Run without tiles."""
167 output_json_path = os.path.join(self._temp_dir, 'output.json') 84 output_json_path = os.path.join(self._temp_dir, 'output.json')
168 self._generate_skps() 85 self._generate_skps()
169 self._run_render_pictures(['-r', self._input_skp_dir, 86 self._run_render_pictures(['-r', self._input_skp_dir,
170 '--writePath', self._temp_dir, 87 '--writePath', self._temp_dir,
171 '--writeJsonSummaryPath', output_json_path]) 88 '--writeJsonSummaryPath', output_json_path])
89 # TODO(epoger): These expectations are the same as for above unittest.
90 # Define the expectations once, and share them.
172 expected_summary_dict = { 91 expected_summary_dict = {
173 "header" : EXPECTED_HEADER_CONTENTS, 92 "header" : EXPECTED_HEADER_CONTENTS,
174 "actual-results" : { 93 "actual-results" : {
175 "red.skp": { 94 "red.skp": {
176 "whole-image": RED_WHOLEIMAGE, 95 # Manually verified: 640x400 red rectangle with black border
96 "whole-image": {
97 "checksumAlgorithm" : "bitmap-64bitMD5",
98 "checksumValue" : 11092453015575919668,
99 "comparisonResult" : "no-comparison",
100 "filepath" : "red_skp.png",
101 },
177 }, 102 },
178 "green.skp": { 103 "green.skp": {
179 "whole-image": GREEN_WHOLEIMAGE, 104 # Manually verified: 640x400 green rectangle with black border
105 "whole-image": {
106 "checksumAlgorithm" : "bitmap-64bitMD5",
107 "checksumValue" : 8891695120562235492,
108 "comparisonResult" : "no-comparison",
109 "filepath" : "green_skp.png",
110 },
180 } 111 }
181 } 112 }
182 } 113 }
183 self._assert_json_contents(output_json_path, expected_summary_dict) 114 self._assert_json_contents(output_json_path, expected_summary_dict)
184 self._assert_directory_contents( 115 self._assert_directory_contents(
185 self._temp_dir, ['red_skp.png', 'green_skp.png', 'output.json']) 116 self._temp_dir, ['red_skp.png', 'green_skp.png', 'output.json'])
186 117
187 def test_untiled_writeChecksumBasedFilenames(self): 118 def test_untiled_writeChecksumBasedFilenames(self):
188 """Same as test_untiled, but with --writeChecksumBasedFilenames.""" 119 """Same as test_untiled, but with --writeChecksumBasedFilenames."""
189 output_json_path = os.path.join(self._temp_dir, 'output.json') 120 output_json_path = os.path.join(self._temp_dir, 'output.json')
(...skipping 29 matching lines...) Expand all
219 self._assert_directory_contents(self._temp_dir, [ 150 self._assert_directory_contents(self._temp_dir, [
220 'red_skp', 'green_skp', 'output.json']) 151 'red_skp', 'green_skp', 'output.json'])
221 self._assert_directory_contents( 152 self._assert_directory_contents(
222 os.path.join(self._temp_dir, 'red_skp'), 153 os.path.join(self._temp_dir, 'red_skp'),
223 ['bitmap-64bitMD5_11092453015575919668.png']) 154 ['bitmap-64bitMD5_11092453015575919668.png'])
224 self._assert_directory_contents( 155 self._assert_directory_contents(
225 os.path.join(self._temp_dir, 'green_skp'), 156 os.path.join(self._temp_dir, 'green_skp'),
226 ['bitmap-64bitMD5_8891695120562235492.png']) 157 ['bitmap-64bitMD5_8891695120562235492.png'])
227 158
228 def test_untiled_validate(self): 159 def test_untiled_validate(self):
229 """Same as test_untiled, but with --validate.""" 160 """Same as test_untiled, but with --validate.
161
162 TODO(epoger): This test generates undesired results! The call
163 to render_pictures should succeed, and generate the same output as
164 test_untiled.
165 See https://code.google.com/p/skia/issues/detail?id=2044 ('render_pictures:
166 --validate fails')
167 """
230 output_json_path = os.path.join(self._temp_dir, 'output.json') 168 output_json_path = os.path.join(self._temp_dir, 'output.json')
231 self._generate_skps() 169 self._generate_skps()
232 self._run_render_pictures(['-r', self._input_skp_dir, 170 with self.assertRaises(Exception):
233 '--validate', 171 self._run_render_pictures(['-r', self._input_skp_dir,
234 '--writePath', self._temp_dir, 172 '--validate',
235 '--writeJsonSummaryPath', output_json_path]) 173 '--writePath', self._temp_dir,
236 expected_summary_dict = { 174 '--writeJsonSummaryPath', output_json_path])
237 "header" : EXPECTED_HEADER_CONTENTS,
238 "actual-results" : {
239 "red.skp": {
240 "whole-image": RED_WHOLEIMAGE,
241 },
242 "green.skp": {
243 "whole-image": GREEN_WHOLEIMAGE,
244 }
245 }
246 }
247 self._assert_json_contents(output_json_path, expected_summary_dict)
248 self._assert_directory_contents(
249 self._temp_dir, ['red_skp.png', 'green_skp.png', 'output.json'])
250 175
251 def test_untiled_without_writePath(self): 176 def test_untiled_without_writePath(self):
252 """Same as test_untiled, but without --writePath.""" 177 """Same as test_untiled, but without --writePath.
178
179 TODO(epoger): This test generates undesired results!
180 See https://code.google.com/p/skia/issues/detail?id=2043 ('render_pictures:
181 --writeJsonSummaryPath fails unless --writePath is specified')
182 """
253 output_json_path = os.path.join(self._temp_dir, 'output.json') 183 output_json_path = os.path.join(self._temp_dir, 'output.json')
254 self._generate_skps() 184 self._generate_skps()
255 self._run_render_pictures(['-r', self._input_skp_dir, 185 self._run_render_pictures(['-r', self._input_skp_dir,
256 '--writeJsonSummaryPath', output_json_path]) 186 '--writeJsonSummaryPath', output_json_path])
257 expected_summary_dict = { 187 expected_summary_dict = {
258 "header" : EXPECTED_HEADER_CONTENTS, 188 "header" : EXPECTED_HEADER_CONTENTS,
259 "actual-results" : { 189 "actual-results" : None,
260 "red.skp": {
261 "whole-image": RED_WHOLEIMAGE,
262 },
263 "green.skp": {
264 "whole-image": GREEN_WHOLEIMAGE,
265 }
266 }
267 } 190 }
268 self._assert_json_contents(output_json_path, expected_summary_dict) 191 self._assert_json_contents(output_json_path, expected_summary_dict)
269 192
270 def test_tiled(self): 193 def test_tiled(self):
271 """Generate individual tiles.""" 194 """Generate individual tiles."""
272 output_json_path = os.path.join(self._temp_dir, 'output.json') 195 output_json_path = os.path.join(self._temp_dir, 'output.json')
273 self._generate_skps() 196 self._generate_skps()
274 self._run_render_pictures(['-r', self._input_skp_dir, 197 self._run_render_pictures(['-r', self._input_skp_dir,
275 '--bbh', 'grid', '256', '256', 198 '--bbh', 'grid', '256', '256',
276 '--mode', 'tile', '256', '256', 199 '--mode', 'tile', '256', '256',
277 '--writePath', self._temp_dir, 200 '--writePath', self._temp_dir,
278 '--writeJsonSummaryPath', output_json_path]) 201 '--writeJsonSummaryPath', output_json_path])
279 expected_summary_dict = { 202 expected_summary_dict = {
280 "header" : EXPECTED_HEADER_CONTENTS, 203 "header" : EXPECTED_HEADER_CONTENTS,
281 "actual-results" : { 204 "actual-results" : {
282 "red.skp": { 205 "red.skp": {
283 "tiled-images": RED_TILES, 206 # Manually verified these 6 images, all 256x256 tiles,
207 # consistent with a tiled version of the 640x400 red rect
208 # with black borders.
209 "tiled-images": [{
210 "checksumAlgorithm" : "bitmap-64bitMD5",
211 "checksumValue" : 5815827069051002745,
212 "comparisonResult" : "no-comparison",
213 "filepath" : "red_skp-tile0.png",
214 }, {
215 "checksumAlgorithm" : "bitmap-64bitMD5",
216 "checksumValue" : 9323613075234140270,
217 "comparisonResult" : "no-comparison",
218 "filepath" : "red_skp-tile1.png",
219 }, {
220 "checksumAlgorithm" : "bitmap-64bitMD5",
221 "checksumValue" : 16670399404877552232,
222 "comparisonResult" : "no-comparison",
223 "filepath" : "red_skp-tile2.png",
224 }, {
225 "checksumAlgorithm" : "bitmap-64bitMD5",
226 "checksumValue" : 2507897274083364964,
227 "comparisonResult" : "no-comparison",
228 "filepath" : "red_skp-tile3.png",
229 }, {
230 "checksumAlgorithm" : "bitmap-64bitMD5",
231 "checksumValue" : 7325267995523877959,
232 "comparisonResult" : "no-comparison",
233 "filepath" : "red_skp-tile4.png",
234 }, {
235 "checksumAlgorithm" : "bitmap-64bitMD5",
236 "checksumValue" : 2181381724594493116,
237 "comparisonResult" : "no-comparison",
238 "filepath" : "red_skp-tile5.png",
239 }],
284 }, 240 },
285 "green.skp": { 241 "green.skp": {
286 "tiled-images": GREEN_TILES, 242 # Manually verified these 6 images, all 256x256 tiles,
243 # consistent with a tiled version of the 640x400 green rect
244 # with black borders.
245 "tiled-images": [{
246 "checksumAlgorithm" : "bitmap-64bitMD5",
247 "checksumValue" : 12587324416545178013,
248 "comparisonResult" : "no-comparison",
249 "filepath" : "green_skp-tile0.png",
250 }, {
251 "checksumAlgorithm" : "bitmap-64bitMD5",
252 "checksumValue" : 7624374914829746293,
253 "comparisonResult" : "no-comparison",
254 "filepath" : "green_skp-tile1.png",
255 }, {
256 "checksumAlgorithm" : "bitmap-64bitMD5",
257 "checksumValue" : 5686489729535631913,
258 "comparisonResult" : "no-comparison",
259 "filepath" : "green_skp-tile2.png",
260 }, {
261 "checksumAlgorithm" : "bitmap-64bitMD5",
262 "checksumValue" : 7980646035555096146,
263 "comparisonResult" : "no-comparison",
264 "filepath" : "green_skp-tile3.png",
265 }, {
266 "checksumAlgorithm" : "bitmap-64bitMD5",
267 "checksumValue" : 17817086664365875131,
268 "comparisonResult" : "no-comparison",
269 "filepath" : "green_skp-tile4.png",
270 }, {
271 "checksumAlgorithm" : "bitmap-64bitMD5",
272 "checksumValue" : 10673669813016809363,
273 "comparisonResult" : "no-comparison",
274 "filepath" : "green_skp-tile5.png",
275 }],
287 } 276 }
288 } 277 }
289 } 278 }
290 self._assert_json_contents(output_json_path, expected_summary_dict) 279 self._assert_json_contents(output_json_path, expected_summary_dict)
291 self._assert_directory_contents( 280 self._assert_directory_contents(
292 self._temp_dir, 281 self._temp_dir,
293 ['red_skp-tile0.png', 'red_skp-tile1.png', 'red_skp-tile2.png', 282 ['red_skp-tile0.png', 'red_skp-tile1.png', 'red_skp-tile2.png',
294 'red_skp-tile3.png', 'red_skp-tile4.png', 'red_skp-tile5.png', 283 'red_skp-tile3.png', 'red_skp-tile4.png', 'red_skp-tile5.png',
295 'green_skp-tile0.png', 'green_skp-tile1.png', 'green_skp-tile2.png', 284 'green_skp-tile0.png', 'green_skp-tile1.png', 'green_skp-tile2.png',
296 'green_skp-tile3.png', 'green_skp-tile4.png', 'green_skp-tile5.png', 285 'green_skp-tile3.png', 'green_skp-tile4.png', 'green_skp-tile5.png',
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 actual_dict = json.loads(file_contents) 458 actual_dict = json.loads(file_contents)
470 self.assertEqual(actual_dict, expected_dict) 459 self.assertEqual(actual_dict, expected_dict)
471 460
472 461
473 def main(): 462 def main():
474 base_unittest.main(RenderPicturesTest) 463 base_unittest.main(RenderPicturesTest)
475 464
476 465
477 if __name__ == '__main__': 466 if __name__ == '__main__':
478 main() 467 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