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

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

Issue 397103003: combine base_unittest.py modules from gm and tools (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: everything but pylint cleanup Created 6 years, 5 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 """
11 11
12 # System-level imports 12 # System-level imports
13 import copy 13 import copy
14 import json 14 import json
15 import os 15 import os
16 import shutil 16 import shutil
17 import tempfile 17 import tempfile
18 18
19 # Must fix up PYTHONPATH before importing from within Skia
20 import fix_pythonpath # pylint: disable=W0611
21
19 # Imports from within Skia 22 # Imports from within Skia
20 import base_unittest 23 import base_unittest
24 import find_run_binary
21 25
22 # Maximum length of text diffs to show when tests fail 26 # Maximum length of text diffs to show when tests fail
23 MAX_DIFF_LENGTH = 30000 27 MAX_DIFF_LENGTH = 30000
24 28
25 EXPECTED_HEADER_CONTENTS = { 29 EXPECTED_HEADER_CONTENTS = {
26 "type" : "ChecksummedImages", 30 "type" : "ChecksummedImages",
27 "revision" : 1, 31 "revision" : 1,
28 } 32 }
29 33
30 # Manually verified: 640x400 red rectangle with black border 34 # Manually verified: 640x400 red rectangle with black border
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 self._assert_directory_contents( 550 self._assert_directory_contents(
547 os.path.join(write_path_dir, 'green_skp'), 551 os.path.join(write_path_dir, 'green_skp'),
548 ['bitmap-64bitMD5_12587324416545178013.png', 552 ['bitmap-64bitMD5_12587324416545178013.png',
549 'bitmap-64bitMD5_7624374914829746293.png', 553 'bitmap-64bitMD5_7624374914829746293.png',
550 'bitmap-64bitMD5_5686489729535631913.png', 554 'bitmap-64bitMD5_5686489729535631913.png',
551 'bitmap-64bitMD5_7980646035555096146.png', 555 'bitmap-64bitMD5_7980646035555096146.png',
552 'bitmap-64bitMD5_17817086664365875131.png', 556 'bitmap-64bitMD5_17817086664365875131.png',
553 'bitmap-64bitMD5_10673669813016809363.png']) 557 'bitmap-64bitMD5_10673669813016809363.png'])
554 558
555 def _run_render_pictures(self, args): 559 def _run_render_pictures(self, args):
556 binary = self.find_path_to_program('render_pictures') 560 binary = find_run_binary.find_path_to_program('render_pictures')
557 return self.run_command([binary, 561 return find_run_binary.run_command(
558 '--config', '8888', 562 [binary, '--config', '8888'] + args)
559 ] + args)
560 563
561 def _create_expectations(self, missing_some_images=False, 564 def _create_expectations(self, missing_some_images=False,
562 rel_path='expectations.json'): 565 rel_path='expectations.json'):
563 """Creates expectations JSON file within self._expectations_dir . 566 """Creates expectations JSON file within self._expectations_dir .
564 567
565 Args: 568 Args:
566 missing_some_images: (bool) whether to remove expectations for a subset 569 missing_some_images: (bool) whether to remove expectations for a subset
567 of the images 570 of the images
568 rel_path: (string) relative path within self._expectations_dir to write 571 rel_path: (string) relative path within self._expectations_dir to write
569 the expectations into 572 the expectations into
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 """Runs the skpmaker binary to generate SKP with known characteristics. 610 """Runs the skpmaker binary to generate SKP with known characteristics.
608 611
609 Args: 612 Args:
610 output_path: Filepath to write the SKP into. 613 output_path: Filepath to write the SKP into.
611 red: Value of red color channel in image, 0-255. 614 red: Value of red color channel in image, 0-255.
612 green: Value of green color channel in image, 0-255. 615 green: Value of green color channel in image, 0-255.
613 blue: Value of blue color channel in image, 0-255. 616 blue: Value of blue color channel in image, 0-255.
614 width: Width of canvas to create. 617 width: Width of canvas to create.
615 height: Height of canvas to create. 618 height: Height of canvas to create.
616 """ 619 """
617 binary = self.find_path_to_program('skpmaker') 620 binary = find_run_binary.find_path_to_program('skpmaker')
618 return self.run_command([binary, 621 return find_run_binary.run_command([
619 '--red', str(red), 622 binary,
620 '--green', str(green), 623 '--red', str(red),
621 '--blue', str(blue), 624 '--green', str(green),
622 '--width', str(width), 625 '--blue', str(blue),
623 '--height', str(height), 626 '--width', str(width),
624 '--writePath', str(output_path), 627 '--height', str(height),
625 ]) 628 '--writePath', str(output_path),
629 ])
626 630
627 def _assert_directory_contents(self, dir_path, expected_filenames): 631 def _assert_directory_contents(self, dir_path, expected_filenames):
628 """Asserts that files found in a dir are identical to expected_filenames. 632 """Asserts that files found in a dir are identical to expected_filenames.
629 633
630 Args: 634 Args:
631 dir_path: Path to a directory on local disk. 635 dir_path: Path to a directory on local disk.
632 expected_filenames: Set containing the expected filenames within the dir. 636 expected_filenames: Set containing the expected filenames within the dir.
633 637
634 Raises: 638 Raises:
635 AssertionError: contents of the directory are not identical to 639 AssertionError: contents of the directory are not identical to
(...skipping 21 matching lines...) Expand all
657 self.assertMultiLineEqual(prettyprinted_expected_dict, 661 self.assertMultiLineEqual(prettyprinted_expected_dict,
658 prettyprinted_json_dict) 662 prettyprinted_json_dict)
659 663
660 664
661 def main(): 665 def main():
662 base_unittest.main(RenderPicturesTest) 666 base_unittest.main(RenderPicturesTest)
663 667
664 668
665 if __name__ == '__main__': 669 if __name__ == '__main__':
666 main() 670 main()
OLDNEW
« gm/rebaseline_server/base_unittest.py ('K') | « tools/tests/fix_pythonpath.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698