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

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

Issue 466153006: add --descriptions flag to render_pictures tool (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 self._run_render_pictures([ 190 self._run_render_pictures([
191 '-r', self._input_skp_dir, 191 '-r', self._input_skp_dir,
192 '--bbh', 'grid', '256', '256', 192 '--bbh', 'grid', '256', '256',
193 '--mode', 'tile', '256', '256', 193 '--mode', 'tile', '256', '256',
194 '--readJsonSummaryPath', expectations_path, 194 '--readJsonSummaryPath', expectations_path,
195 '--writeJsonSummaryPath', output_json_path, 195 '--writeJsonSummaryPath', output_json_path,
196 '--writePath', write_path_dir, 196 '--writePath', write_path_dir,
197 '--writeWholeImage']) 197 '--writeWholeImage'])
198 expected_summary_dict = { 198 expected_summary_dict = {
199 "header" : EXPECTED_HEADER_CONTENTS, 199 "header" : EXPECTED_HEADER_CONTENTS,
200 "descriptions" : None,
200 "actual-results" : { 201 "actual-results" : {
201 "red.skp": { 202 "red.skp": {
202 "tiled-images": RED_TILES, 203 "tiled-images": RED_TILES,
203 "whole-image": RED_WHOLEIMAGE, 204 "whole-image": RED_WHOLEIMAGE,
204 }, 205 },
205 "green.skp": { 206 "green.skp": {
206 "tiled-images": GREEN_TILES, 207 "tiled-images": GREEN_TILES,
207 "whole-image": GREEN_WHOLEIMAGE, 208 "whole-image": GREEN_WHOLEIMAGE,
208 } 209 }
209 } 210 }
(...skipping 15 matching lines...) Expand all
225 '--bbh', 'grid', '256', '256', 226 '--bbh', 'grid', '256', '256',
226 '--mode', 'tile', '256', '256', 227 '--mode', 'tile', '256', '256',
227 '--readJsonSummaryPath', expectations_path, 228 '--readJsonSummaryPath', expectations_path,
228 '--writeJsonSummaryPath', output_json_path, 229 '--writeJsonSummaryPath', output_json_path,
229 '--writePath', write_path_dir, 230 '--writePath', write_path_dir,
230 '--writeWholeImage']) 231 '--writeWholeImage'])
231 modified_red_tiles = copy.deepcopy(RED_TILES) 232 modified_red_tiles = copy.deepcopy(RED_TILES)
232 modified_red_tiles[5]['comparisonResult'] = 'no-comparison' 233 modified_red_tiles[5]['comparisonResult'] = 'no-comparison'
233 expected_summary_dict = { 234 expected_summary_dict = {
234 "header" : EXPECTED_HEADER_CONTENTS, 235 "header" : EXPECTED_HEADER_CONTENTS,
236 "descriptions" : None,
235 "actual-results" : { 237 "actual-results" : {
236 "red.skp": { 238 "red.skp": {
237 "tiled-images": modified_red_tiles, 239 "tiled-images": modified_red_tiles,
238 "whole-image": modified_dict( 240 "whole-image": modified_dict(
239 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), 241 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}),
240 }, 242 },
241 "green.skp": { 243 "green.skp": {
242 "tiled-images": GREEN_TILES, 244 "tiled-images": GREEN_TILES,
243 "whole-image": GREEN_WHOLEIMAGE, 245 "whole-image": GREEN_WHOLEIMAGE,
244 } 246 }
(...skipping 24 matching lines...) Expand all
269 '--readJsonSummaryPath', expectations_path, 271 '--readJsonSummaryPath', expectations_path,
270 '--writePath', write_path_dir, 272 '--writePath', write_path_dir,
271 '--writeJsonSummaryPath', output_json_path, 273 '--writeJsonSummaryPath', output_json_path,
272 ] 274 ]
273 if additional_args: 275 if additional_args:
274 args.extend(additional_args) 276 args.extend(additional_args)
275 self._run_render_pictures(args) 277 self._run_render_pictures(args)
276 if expected_summary_dict == None: 278 if expected_summary_dict == None:
277 expected_summary_dict = { 279 expected_summary_dict = {
278 "header" : EXPECTED_HEADER_CONTENTS, 280 "header" : EXPECTED_HEADER_CONTENTS,
281 "descriptions" : None,
279 "actual-results" : { 282 "actual-results" : {
280 "red.skp": { 283 "red.skp": {
281 "whole-image": RED_WHOLEIMAGE, 284 "whole-image": RED_WHOLEIMAGE,
282 }, 285 },
283 "green.skp": { 286 "green.skp": {
284 "whole-image": GREEN_WHOLEIMAGE, 287 "whole-image": GREEN_WHOLEIMAGE,
285 } 288 }
286 } 289 }
287 } 290 }
288 self._assert_json_contents(output_json_path, expected_summary_dict) 291 self._assert_json_contents(output_json_path, expected_summary_dict)
289 self._assert_directory_contents( 292 self._assert_directory_contents(
290 write_path_dir, ['red_skp.png', 'green_skp.png']) 293 write_path_dir, ['red_skp.png', 'green_skp.png'])
291 294
292 def test_untiled(self): 295 def test_untiled(self):
293 """Basic test without tiles.""" 296 """Basic test without tiles."""
294 self._test_untiled() 297 self._test_untiled()
295 298
296 def test_untiled_empty_expectations_file(self): 299 def test_untiled_empty_expectations_file(self):
297 """Same as test_untiled, but with an empty expectations file.""" 300 """Same as test_untiled, but with an empty expectations file."""
298 expectations_path = os.path.join(self._expectations_dir, 'empty') 301 expectations_path = os.path.join(self._expectations_dir, 'empty')
299 with open(expectations_path, 'w'): 302 with open(expectations_path, 'w'):
300 pass 303 pass
301 expected_summary_dict = { 304 expected_summary_dict = {
302 "header" : EXPECTED_HEADER_CONTENTS, 305 "header" : EXPECTED_HEADER_CONTENTS,
306 "descriptions" : None,
303 "actual-results" : { 307 "actual-results" : {
304 "red.skp": { 308 "red.skp": {
305 "whole-image": modified_dict( 309 "whole-image": modified_dict(
306 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), 310 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}),
307 }, 311 },
308 "green.skp": { 312 "green.skp": {
309 "whole-image": modified_dict( 313 "whole-image": modified_dict(
310 GREEN_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), 314 GREEN_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}),
311 } 315 }
312 } 316 }
313 } 317 }
314 self._test_untiled(expectations_path=expectations_path, 318 self._test_untiled(expectations_path=expectations_path,
315 expected_summary_dict=expected_summary_dict) 319 expected_summary_dict=expected_summary_dict)
316 320
317 def test_untiled_writeChecksumBasedFilenames(self): 321 def test_untiled_writeChecksumBasedFilenames(self):
318 """Same as test_untiled, but with --writeChecksumBasedFilenames.""" 322 """Same as test_untiled, but with --writeChecksumBasedFilenames."""
319 output_json_path = os.path.join(self._output_dir, 'actuals.json') 323 output_json_path = os.path.join(self._output_dir, 'actuals.json')
320 write_path_dir = self.create_empty_dir( 324 write_path_dir = self.create_empty_dir(
321 path=os.path.join(self._output_dir, 'writePath')) 325 path=os.path.join(self._output_dir, 'writePath'))
322 self._generate_skps() 326 self._generate_skps()
323 self._run_render_pictures(['-r', self._input_skp_dir, 327 self._run_render_pictures([
324 '--writeChecksumBasedFilenames', 328 '-r', self._input_skp_dir,
325 '--writePath', write_path_dir, 329 '--descriptions', 'builder=builderName', 'renderMode=renderModeName',
326 '--writeJsonSummaryPath', output_json_path]) 330 '--writeChecksumBasedFilenames',
331 '--writePath', write_path_dir,
332 '--writeJsonSummaryPath', output_json_path,
333 ])
327 expected_summary_dict = { 334 expected_summary_dict = {
328 "header" : EXPECTED_HEADER_CONTENTS, 335 "header" : EXPECTED_HEADER_CONTENTS,
336 "descriptions" : {
337 "builder": "builderName",
338 "renderMode": "renderModeName",
339 },
329 "actual-results" : { 340 "actual-results" : {
330 "red.skp": { 341 "red.skp": {
331 # Manually verified: 640x400 red rectangle with black border 342 # Manually verified: 640x400 red rectangle with black border
332 "whole-image": { 343 "whole-image": {
333 "checksumAlgorithm" : "bitmap-64bitMD5", 344 "checksumAlgorithm" : "bitmap-64bitMD5",
334 "checksumValue" : 11092453015575919668, 345 "checksumValue" : 11092453015575919668,
335 "comparisonResult" : "no-comparison", 346 "comparisonResult" : "no-comparison",
336 "filepath" : 347 "filepath" :
337 "red_skp/bitmap-64bitMD5_11092453015575919668.png", 348 "red_skp/bitmap-64bitMD5_11092453015575919668.png",
338 }, 349 },
(...skipping 27 matching lines...) Expand all
366 """Same as test_untiled, but without --writePath.""" 377 """Same as test_untiled, but without --writePath."""
367 output_json_path = os.path.join(self._output_dir, 'actuals.json') 378 output_json_path = os.path.join(self._output_dir, 'actuals.json')
368 self._generate_skps() 379 self._generate_skps()
369 expectations_path = self._create_expectations() 380 expectations_path = self._create_expectations()
370 self._run_render_pictures([ 381 self._run_render_pictures([
371 '-r', self._input_skp_dir, 382 '-r', self._input_skp_dir,
372 '--readJsonSummaryPath', expectations_path, 383 '--readJsonSummaryPath', expectations_path,
373 '--writeJsonSummaryPath', output_json_path]) 384 '--writeJsonSummaryPath', output_json_path])
374 expected_summary_dict = { 385 expected_summary_dict = {
375 "header" : EXPECTED_HEADER_CONTENTS, 386 "header" : EXPECTED_HEADER_CONTENTS,
387 "descriptions" : None,
376 "actual-results" : { 388 "actual-results" : {
377 "red.skp": { 389 "red.skp": {
378 "whole-image": RED_WHOLEIMAGE, 390 "whole-image": RED_WHOLEIMAGE,
379 }, 391 },
380 "green.skp": { 392 "green.skp": {
381 "whole-image": GREEN_WHOLEIMAGE, 393 "whole-image": GREEN_WHOLEIMAGE,
382 } 394 }
383 } 395 }
384 } 396 }
385 self._assert_json_contents(output_json_path, expected_summary_dict) 397 self._assert_json_contents(output_json_path, expected_summary_dict)
386 398
387 def test_tiled(self): 399 def test_tiled(self):
388 """Generate individual tiles.""" 400 """Generate individual tiles."""
389 output_json_path = os.path.join(self._output_dir, 'actuals.json') 401 output_json_path = os.path.join(self._output_dir, 'actuals.json')
390 write_path_dir = self.create_empty_dir( 402 write_path_dir = self.create_empty_dir(
391 path=os.path.join(self._output_dir, 'writePath')) 403 path=os.path.join(self._output_dir, 'writePath'))
392 self._generate_skps() 404 self._generate_skps()
393 expectations_path = self._create_expectations() 405 expectations_path = self._create_expectations()
394 self._run_render_pictures([ 406 self._run_render_pictures([
395 '-r', self._input_skp_dir, 407 '-r', self._input_skp_dir,
396 '--bbh', 'grid', '256', '256', 408 '--bbh', 'grid', '256', '256',
397 '--mode', 'tile', '256', '256', 409 '--mode', 'tile', '256', '256',
398 '--readJsonSummaryPath', expectations_path, 410 '--readJsonSummaryPath', expectations_path,
399 '--writePath', write_path_dir, 411 '--writePath', write_path_dir,
400 '--writeJsonSummaryPath', output_json_path]) 412 '--writeJsonSummaryPath', output_json_path])
401 expected_summary_dict = { 413 expected_summary_dict = {
402 "header" : EXPECTED_HEADER_CONTENTS, 414 "header" : EXPECTED_HEADER_CONTENTS,
415 "descriptions" : None,
403 "actual-results" : { 416 "actual-results" : {
404 "red.skp": { 417 "red.skp": {
405 "tiled-images": RED_TILES, 418 "tiled-images": RED_TILES,
406 }, 419 },
407 "green.skp": { 420 "green.skp": {
408 "tiled-images": GREEN_TILES, 421 "tiled-images": GREEN_TILES,
409 } 422 }
410 } 423 }
411 } 424 }
412 self._assert_json_contents(output_json_path, expected_summary_dict) 425 self._assert_json_contents(output_json_path, expected_summary_dict)
(...skipping 14 matching lines...) Expand all
427 expectations_path = self._create_expectations() 440 expectations_path = self._create_expectations()
428 self._run_render_pictures([ 441 self._run_render_pictures([
429 '-r', self._input_skp_dir, 442 '-r', self._input_skp_dir,
430 '--bbh', 'grid', '256', '256', 443 '--bbh', 'grid', '256', '256',
431 '--mode', 'tile', '256', '256', 444 '--mode', 'tile', '256', '256',
432 '--readJsonSummaryPath', expectations_path, 445 '--readJsonSummaryPath', expectations_path,
433 '--mismatchPath', mismatch_path_dir, 446 '--mismatchPath', mismatch_path_dir,
434 '--writeJsonSummaryPath', output_json_path]) 447 '--writeJsonSummaryPath', output_json_path])
435 expected_summary_dict = { 448 expected_summary_dict = {
436 "header" : EXPECTED_HEADER_CONTENTS, 449 "header" : EXPECTED_HEADER_CONTENTS,
450 "descriptions" : None,
437 "actual-results" : { 451 "actual-results" : {
438 "red.skp": { 452 "red.skp": {
439 "tiled-images": RED_TILES, 453 "tiled-images": RED_TILES,
440 }, 454 },
441 "green.skp": { 455 "green.skp": {
442 "tiled-images": GREEN_TILES, 456 "tiled-images": GREEN_TILES,
443 } 457 }
444 } 458 }
445 } 459 }
446 self._assert_json_contents(output_json_path, expected_summary_dict) 460 self._assert_json_contents(output_json_path, expected_summary_dict)
(...skipping 10 matching lines...) Expand all
457 path=os.path.join(self._output_dir, 'writePath')) 471 path=os.path.join(self._output_dir, 'writePath'))
458 self._generate_skps() 472 self._generate_skps()
459 self._run_render_pictures(['-r', self._input_skp_dir, 473 self._run_render_pictures(['-r', self._input_skp_dir,
460 '--bbh', 'grid', '256', '256', 474 '--bbh', 'grid', '256', '256',
461 '--mode', 'tile', '256', '256', 475 '--mode', 'tile', '256', '256',
462 '--writeChecksumBasedFilenames', 476 '--writeChecksumBasedFilenames',
463 '--writePath', write_path_dir, 477 '--writePath', write_path_dir,
464 '--writeJsonSummaryPath', output_json_path]) 478 '--writeJsonSummaryPath', output_json_path])
465 expected_summary_dict = { 479 expected_summary_dict = {
466 "header" : EXPECTED_HEADER_CONTENTS, 480 "header" : EXPECTED_HEADER_CONTENTS,
481 "descriptions" : None,
467 "actual-results" : { 482 "actual-results" : {
468 "red.skp": { 483 "red.skp": {
469 # Manually verified these 6 images, all 256x256 tiles, 484 # Manually verified these 6 images, all 256x256 tiles,
470 # consistent with a tiled version of the 640x400 red rect 485 # consistent with a tiled version of the 640x400 red rect
471 # with black borders. 486 # with black borders.
472 "tiled-images": [{ 487 "tiled-images": [{
473 "checksumAlgorithm" : "bitmap-64bitMD5", 488 "checksumAlgorithm" : "bitmap-64bitMD5",
474 "checksumValue" : 5815827069051002745, 489 "checksumValue" : 5815827069051002745,
475 "comparisonResult" : "no-comparison", 490 "comparisonResult" : "no-comparison",
476 "filepath" : 491 "filepath" :
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 Args: 597 Args:
583 missing_some_images: (bool) whether to remove expectations for a subset 598 missing_some_images: (bool) whether to remove expectations for a subset
584 of the images 599 of the images
585 rel_path: (string) relative path within self._expectations_dir to write 600 rel_path: (string) relative path within self._expectations_dir to write
586 the expectations into 601 the expectations into
587 602
588 Returns: full path to the expectations file created. 603 Returns: full path to the expectations file created.
589 """ 604 """
590 expectations_dict = { 605 expectations_dict = {
591 "header" : EXPECTED_HEADER_CONTENTS, 606 "header" : EXPECTED_HEADER_CONTENTS,
607 "descriptions" : None,
592 "expected-results" : { 608 "expected-results" : {
593 # red.skp: these should fail the comparison 609 # red.skp: these should fail the comparison
594 "red.skp": { 610 "red.skp": {
595 "tiled-images": modified_list_of_dicts( 611 "tiled-images": modified_list_of_dicts(
596 RED_TILES, {'checksumValue': 11111}), 612 RED_TILES, {'checksumValue': 11111}),
597 "whole-image": modified_dict( 613 "whole-image": modified_dict(
598 RED_WHOLEIMAGE, {'checksumValue': 22222}), 614 RED_WHOLEIMAGE, {'checksumValue': 22222}),
599 }, 615 },
600 # green.skp: these should pass the comparison 616 # green.skp: these should pass the comparison
601 "green.skp": { 617 "green.skp": {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 self.assertMultiLineEqual(prettyprinted_expected_dict, 691 self.assertMultiLineEqual(prettyprinted_expected_dict,
676 prettyprinted_json_dict) 692 prettyprinted_json_dict)
677 693
678 694
679 def main(): 695 def main():
680 base_unittest.main(RenderPicturesTest) 696 base_unittest.main(RenderPicturesTest)
681 697
682 698
683 if __name__ == '__main__': 699 if __name__ == '__main__':
684 main() 700 main()
OLDNEW
« tools/render_pictures_main.cpp ('K') | « tools/render_pictures_main.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698