OLD | NEW |
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 Loading... |
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 "image-base-gs-url" : None, |
200 "descriptions" : None, | 201 "descriptions" : None, |
201 "actual-results" : { | 202 "actual-results" : { |
202 "red.skp": { | 203 "red.skp": { |
203 "tiled-images": RED_TILES, | 204 "tiled-images": RED_TILES, |
204 "whole-image": RED_WHOLEIMAGE, | 205 "whole-image": RED_WHOLEIMAGE, |
205 }, | 206 }, |
206 "green.skp": { | 207 "green.skp": { |
207 "tiled-images": GREEN_TILES, | 208 "tiled-images": GREEN_TILES, |
208 "whole-image": GREEN_WHOLEIMAGE, | 209 "whole-image": GREEN_WHOLEIMAGE, |
209 } | 210 } |
(...skipping 16 matching lines...) Expand all Loading... |
226 '--bbh', 'grid', '256', '256', | 227 '--bbh', 'grid', '256', '256', |
227 '--mode', 'tile', '256', '256', | 228 '--mode', 'tile', '256', '256', |
228 '--readJsonSummaryPath', expectations_path, | 229 '--readJsonSummaryPath', expectations_path, |
229 '--writeJsonSummaryPath', output_json_path, | 230 '--writeJsonSummaryPath', output_json_path, |
230 '--writePath', write_path_dir, | 231 '--writePath', write_path_dir, |
231 '--writeWholeImage']) | 232 '--writeWholeImage']) |
232 modified_red_tiles = copy.deepcopy(RED_TILES) | 233 modified_red_tiles = copy.deepcopy(RED_TILES) |
233 modified_red_tiles[5]['comparisonResult'] = 'failure-ignored' | 234 modified_red_tiles[5]['comparisonResult'] = 'failure-ignored' |
234 expected_summary_dict = { | 235 expected_summary_dict = { |
235 "header" : EXPECTED_HEADER_CONTENTS, | 236 "header" : EXPECTED_HEADER_CONTENTS, |
| 237 "image-base-gs-url" : None, |
236 "descriptions" : None, | 238 "descriptions" : None, |
237 "actual-results" : { | 239 "actual-results" : { |
238 "red.skp": { | 240 "red.skp": { |
239 "tiled-images": modified_red_tiles, | 241 "tiled-images": modified_red_tiles, |
240 "whole-image": modified_dict( | 242 "whole-image": modified_dict( |
241 RED_WHOLEIMAGE, {"comparisonResult" : "failure-ignored"}), | 243 RED_WHOLEIMAGE, {"comparisonResult" : "failure-ignored"}), |
242 }, | 244 }, |
243 "green.skp": { | 245 "green.skp": { |
244 "tiled-images": GREEN_TILES, | 246 "tiled-images": GREEN_TILES, |
245 "whole-image": GREEN_WHOLEIMAGE, | 247 "whole-image": GREEN_WHOLEIMAGE, |
(...skipping 17 matching lines...) Expand all Loading... |
263 '--bbh', 'grid', '256', '256', | 265 '--bbh', 'grid', '256', '256', |
264 '--mode', 'tile', '256', '256', | 266 '--mode', 'tile', '256', '256', |
265 '--readJsonSummaryPath', expectations_path, | 267 '--readJsonSummaryPath', expectations_path, |
266 '--writeJsonSummaryPath', output_json_path, | 268 '--writeJsonSummaryPath', output_json_path, |
267 '--writePath', write_path_dir, | 269 '--writePath', write_path_dir, |
268 '--writeWholeImage']) | 270 '--writeWholeImage']) |
269 modified_red_tiles = copy.deepcopy(RED_TILES) | 271 modified_red_tiles = copy.deepcopy(RED_TILES) |
270 modified_red_tiles[5]['comparisonResult'] = 'no-comparison' | 272 modified_red_tiles[5]['comparisonResult'] = 'no-comparison' |
271 expected_summary_dict = { | 273 expected_summary_dict = { |
272 "header" : EXPECTED_HEADER_CONTENTS, | 274 "header" : EXPECTED_HEADER_CONTENTS, |
| 275 "image-base-gs-url" : None, |
273 "descriptions" : None, | 276 "descriptions" : None, |
274 "actual-results" : { | 277 "actual-results" : { |
275 "red.skp": { | 278 "red.skp": { |
276 "tiled-images": modified_red_tiles, | 279 "tiled-images": modified_red_tiles, |
277 "whole-image": modified_dict( | 280 "whole-image": modified_dict( |
278 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), | 281 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), |
279 }, | 282 }, |
280 "green.skp": { | 283 "green.skp": { |
281 "tiled-images": GREEN_TILES, | 284 "tiled-images": GREEN_TILES, |
282 "whole-image": GREEN_WHOLEIMAGE, | 285 "whole-image": GREEN_WHOLEIMAGE, |
(...skipping 25 matching lines...) Expand all Loading... |
308 '--readJsonSummaryPath', expectations_path, | 311 '--readJsonSummaryPath', expectations_path, |
309 '--writePath', write_path_dir, | 312 '--writePath', write_path_dir, |
310 '--writeJsonSummaryPath', output_json_path, | 313 '--writeJsonSummaryPath', output_json_path, |
311 ] | 314 ] |
312 if additional_args: | 315 if additional_args: |
313 args.extend(additional_args) | 316 args.extend(additional_args) |
314 self._run_render_pictures(args) | 317 self._run_render_pictures(args) |
315 if expected_summary_dict == None: | 318 if expected_summary_dict == None: |
316 expected_summary_dict = { | 319 expected_summary_dict = { |
317 "header" : EXPECTED_HEADER_CONTENTS, | 320 "header" : EXPECTED_HEADER_CONTENTS, |
| 321 "image-base-gs-url" : None, |
318 "descriptions" : None, | 322 "descriptions" : None, |
319 "actual-results" : { | 323 "actual-results" : { |
320 "red.skp": { | 324 "red.skp": { |
321 "whole-image": RED_WHOLEIMAGE, | 325 "whole-image": RED_WHOLEIMAGE, |
322 }, | 326 }, |
323 "green.skp": { | 327 "green.skp": { |
324 "whole-image": GREEN_WHOLEIMAGE, | 328 "whole-image": GREEN_WHOLEIMAGE, |
325 } | 329 } |
326 } | 330 } |
327 } | 331 } |
328 self._assert_json_contents(output_json_path, expected_summary_dict) | 332 self._assert_json_contents(output_json_path, expected_summary_dict) |
329 self._assert_directory_contents( | 333 self._assert_directory_contents( |
330 write_path_dir, ['red_skp.png', 'green_skp.png']) | 334 write_path_dir, ['red_skp.png', 'green_skp.png']) |
331 | 335 |
332 def test_untiled(self): | 336 def test_untiled(self): |
333 """Basic test without tiles.""" | 337 """Basic test without tiles.""" |
334 self._test_untiled() | 338 self._test_untiled() |
335 | 339 |
336 def test_untiled_empty_expectations_file(self): | 340 def test_untiled_empty_expectations_file(self): |
337 """Same as test_untiled, but with an empty expectations file.""" | 341 """Same as test_untiled, but with an empty expectations file.""" |
338 expectations_path = os.path.join(self._expectations_dir, 'empty') | 342 expectations_path = os.path.join(self._expectations_dir, 'empty') |
339 with open(expectations_path, 'w'): | 343 with open(expectations_path, 'w'): |
340 pass | 344 pass |
341 expected_summary_dict = { | 345 expected_summary_dict = { |
342 "header" : EXPECTED_HEADER_CONTENTS, | 346 "header" : EXPECTED_HEADER_CONTENTS, |
| 347 "image-base-gs-url" : None, |
343 "descriptions" : None, | 348 "descriptions" : None, |
344 "actual-results" : { | 349 "actual-results" : { |
345 "red.skp": { | 350 "red.skp": { |
346 "whole-image": modified_dict( | 351 "whole-image": modified_dict( |
347 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), | 352 RED_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), |
348 }, | 353 }, |
349 "green.skp": { | 354 "green.skp": { |
350 "whole-image": modified_dict( | 355 "whole-image": modified_dict( |
351 GREEN_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), | 356 GREEN_WHOLEIMAGE, {"comparisonResult" : "no-comparison"}), |
352 } | 357 } |
(...skipping 10 matching lines...) Expand all Loading... |
363 self._generate_skps() | 368 self._generate_skps() |
364 self._run_render_pictures([ | 369 self._run_render_pictures([ |
365 '-r', self._input_skp_dir, | 370 '-r', self._input_skp_dir, |
366 '--descriptions', 'builder=builderName', 'renderMode=renderModeName', | 371 '--descriptions', 'builder=builderName', 'renderMode=renderModeName', |
367 '--writeChecksumBasedFilenames', | 372 '--writeChecksumBasedFilenames', |
368 '--writePath', write_path_dir, | 373 '--writePath', write_path_dir, |
369 '--writeJsonSummaryPath', output_json_path, | 374 '--writeJsonSummaryPath', output_json_path, |
370 ]) | 375 ]) |
371 expected_summary_dict = { | 376 expected_summary_dict = { |
372 "header" : EXPECTED_HEADER_CONTENTS, | 377 "header" : EXPECTED_HEADER_CONTENTS, |
| 378 "image-base-gs-url" : None, |
373 "descriptions" : { | 379 "descriptions" : { |
374 "builder": "builderName", | 380 "builder": "builderName", |
375 "renderMode": "renderModeName", | 381 "renderMode": "renderModeName", |
376 }, | 382 }, |
377 "actual-results" : { | 383 "actual-results" : { |
378 "red.skp": { | 384 "red.skp": { |
379 # Manually verified: 640x400 red rectangle with black border | 385 # Manually verified: 640x400 red rectangle with black border |
380 "whole-image": { | 386 "whole-image": { |
381 "checksumAlgorithm" : "bitmap-64bitMD5", | 387 "checksumAlgorithm" : "bitmap-64bitMD5", |
382 "checksumValue" : 11092453015575919668, | 388 "checksumValue" : 11092453015575919668, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 """Same as test_untiled, but without --writePath.""" | 420 """Same as test_untiled, but without --writePath.""" |
415 output_json_path = os.path.join(self._output_dir, 'actuals.json') | 421 output_json_path = os.path.join(self._output_dir, 'actuals.json') |
416 self._generate_skps() | 422 self._generate_skps() |
417 expectations_path = self._create_expectations() | 423 expectations_path = self._create_expectations() |
418 self._run_render_pictures([ | 424 self._run_render_pictures([ |
419 '-r', self._input_skp_dir, | 425 '-r', self._input_skp_dir, |
420 '--readJsonSummaryPath', expectations_path, | 426 '--readJsonSummaryPath', expectations_path, |
421 '--writeJsonSummaryPath', output_json_path]) | 427 '--writeJsonSummaryPath', output_json_path]) |
422 expected_summary_dict = { | 428 expected_summary_dict = { |
423 "header" : EXPECTED_HEADER_CONTENTS, | 429 "header" : EXPECTED_HEADER_CONTENTS, |
| 430 "image-base-gs-url" : None, |
424 "descriptions" : None, | 431 "descriptions" : None, |
425 "actual-results" : { | 432 "actual-results" : { |
426 "red.skp": { | 433 "red.skp": { |
427 "whole-image": RED_WHOLEIMAGE, | 434 "whole-image": RED_WHOLEIMAGE, |
428 }, | 435 }, |
429 "green.skp": { | 436 "green.skp": { |
430 "whole-image": GREEN_WHOLEIMAGE, | 437 "whole-image": GREEN_WHOLEIMAGE, |
431 } | 438 } |
432 } | 439 } |
433 } | 440 } |
434 self._assert_json_contents(output_json_path, expected_summary_dict) | 441 self._assert_json_contents(output_json_path, expected_summary_dict) |
435 | 442 |
436 def test_tiled(self): | 443 def test_tiled(self): |
437 """Generate individual tiles.""" | 444 """Generate individual tiles.""" |
438 output_json_path = os.path.join(self._output_dir, 'actuals.json') | 445 output_json_path = os.path.join(self._output_dir, 'actuals.json') |
439 write_path_dir = self.create_empty_dir( | 446 write_path_dir = self.create_empty_dir( |
440 path=os.path.join(self._output_dir, 'writePath')) | 447 path=os.path.join(self._output_dir, 'writePath')) |
441 self._generate_skps() | 448 self._generate_skps() |
442 expectations_path = self._create_expectations() | 449 expectations_path = self._create_expectations() |
443 self._run_render_pictures([ | 450 self._run_render_pictures([ |
444 '-r', self._input_skp_dir, | 451 '-r', self._input_skp_dir, |
445 '--bbh', 'grid', '256', '256', | 452 '--bbh', 'grid', '256', '256', |
446 '--mode', 'tile', '256', '256', | 453 '--mode', 'tile', '256', '256', |
447 '--readJsonSummaryPath', expectations_path, | 454 '--readJsonSummaryPath', expectations_path, |
448 '--writePath', write_path_dir, | 455 '--writePath', write_path_dir, |
449 '--writeJsonSummaryPath', output_json_path]) | 456 '--writeJsonSummaryPath', output_json_path]) |
450 expected_summary_dict = { | 457 expected_summary_dict = { |
451 "header" : EXPECTED_HEADER_CONTENTS, | 458 "header" : EXPECTED_HEADER_CONTENTS, |
| 459 "image-base-gs-url" : None, |
452 "descriptions" : None, | 460 "descriptions" : None, |
453 "actual-results" : { | 461 "actual-results" : { |
454 "red.skp": { | 462 "red.skp": { |
455 "tiled-images": RED_TILES, | 463 "tiled-images": RED_TILES, |
456 }, | 464 }, |
457 "green.skp": { | 465 "green.skp": { |
458 "tiled-images": GREEN_TILES, | 466 "tiled-images": GREEN_TILES, |
459 } | 467 } |
460 } | 468 } |
461 } | 469 } |
(...skipping 15 matching lines...) Expand all Loading... |
477 expectations_path = self._create_expectations() | 485 expectations_path = self._create_expectations() |
478 self._run_render_pictures([ | 486 self._run_render_pictures([ |
479 '-r', self._input_skp_dir, | 487 '-r', self._input_skp_dir, |
480 '--bbh', 'grid', '256', '256', | 488 '--bbh', 'grid', '256', '256', |
481 '--mode', 'tile', '256', '256', | 489 '--mode', 'tile', '256', '256', |
482 '--readJsonSummaryPath', expectations_path, | 490 '--readJsonSummaryPath', expectations_path, |
483 '--mismatchPath', mismatch_path_dir, | 491 '--mismatchPath', mismatch_path_dir, |
484 '--writeJsonSummaryPath', output_json_path]) | 492 '--writeJsonSummaryPath', output_json_path]) |
485 expected_summary_dict = { | 493 expected_summary_dict = { |
486 "header" : EXPECTED_HEADER_CONTENTS, | 494 "header" : EXPECTED_HEADER_CONTENTS, |
| 495 "image-base-gs-url" : None, |
487 "descriptions" : None, | 496 "descriptions" : None, |
488 "actual-results" : { | 497 "actual-results" : { |
489 "red.skp": { | 498 "red.skp": { |
490 "tiled-images": RED_TILES, | 499 "tiled-images": RED_TILES, |
491 }, | 500 }, |
492 "green.skp": { | 501 "green.skp": { |
493 "tiled-images": GREEN_TILES, | 502 "tiled-images": GREEN_TILES, |
494 } | 503 } |
495 } | 504 } |
496 } | 505 } |
(...skipping 11 matching lines...) Expand all Loading... |
508 path=os.path.join(self._output_dir, 'writePath')) | 517 path=os.path.join(self._output_dir, 'writePath')) |
509 self._generate_skps() | 518 self._generate_skps() |
510 self._run_render_pictures(['-r', self._input_skp_dir, | 519 self._run_render_pictures(['-r', self._input_skp_dir, |
511 '--bbh', 'grid', '256', '256', | 520 '--bbh', 'grid', '256', '256', |
512 '--mode', 'tile', '256', '256', | 521 '--mode', 'tile', '256', '256', |
513 '--writeChecksumBasedFilenames', | 522 '--writeChecksumBasedFilenames', |
514 '--writePath', write_path_dir, | 523 '--writePath', write_path_dir, |
515 '--writeJsonSummaryPath', output_json_path]) | 524 '--writeJsonSummaryPath', output_json_path]) |
516 expected_summary_dict = { | 525 expected_summary_dict = { |
517 "header" : EXPECTED_HEADER_CONTENTS, | 526 "header" : EXPECTED_HEADER_CONTENTS, |
| 527 "image-base-gs-url" : None, |
518 "descriptions" : None, | 528 "descriptions" : None, |
519 "actual-results" : { | 529 "actual-results" : { |
520 "red.skp": { | 530 "red.skp": { |
521 # Manually verified these 6 images, all 256x256 tiles, | 531 # Manually verified these 6 images, all 256x256 tiles, |
522 # consistent with a tiled version of the 640x400 red rect | 532 # consistent with a tiled version of the 640x400 red rect |
523 # with black borders. | 533 # with black borders. |
524 "tiled-images": [{ | 534 "tiled-images": [{ |
525 "checksumAlgorithm" : "bitmap-64bitMD5", | 535 "checksumAlgorithm" : "bitmap-64bitMD5", |
526 "checksumValue" : 5815827069051002745, | 536 "checksumValue" : 5815827069051002745, |
527 "comparisonResult" : "no-comparison", | 537 "comparisonResult" : "no-comparison", |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 self.assertMultiLineEqual(prettyprinted_expected_dict, | 745 self.assertMultiLineEqual(prettyprinted_expected_dict, |
736 prettyprinted_json_dict) | 746 prettyprinted_json_dict) |
737 | 747 |
738 | 748 |
739 def main(): | 749 def main(): |
740 base_unittest.main(RenderPicturesTest) | 750 base_unittest.main(RenderPicturesTest) |
741 | 751 |
742 | 752 |
743 if __name__ == '__main__': | 753 if __name__ == '__main__': |
744 main() | 754 main() |
OLD | NEW |