| 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 compare_rendered_pictures.py | 9 Test compare_rendered_pictures.py |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 import subprocess | 23 import subprocess |
| 24 | 24 |
| 25 # Must fix up PYTHONPATH before importing from within Skia | 25 # Must fix up PYTHONPATH before importing from within Skia |
| 26 import fix_pythonpath # pylint: disable=W0611 | 26 import fix_pythonpath # pylint: disable=W0611 |
| 27 | 27 |
| 28 # Imports from within Skia | 28 # Imports from within Skia |
| 29 import base_unittest | 29 import base_unittest |
| 30 import compare_rendered_pictures | 30 import compare_rendered_pictures |
| 31 import find_run_binary | 31 import find_run_binary |
| 32 import gm_json | 32 import gm_json |
| 33 import imagediffdb |
| 33 import results | 34 import results |
| 34 | 35 |
| 35 | 36 |
| 36 class CompareRenderedPicturesTest(base_unittest.TestCase): | 37 class CompareRenderedPicturesTest(base_unittest.TestCase): |
| 37 | 38 |
| 38 def test_endToEnd(self): | 39 def test_endToEnd(self): |
| 39 """Generate two sets of SKPs, run render_pictures over both, and compare | 40 """Generate two sets of SKPs, run render_pictures over both, and compare |
| 40 the results.""" | 41 the results.""" |
| 42 actuals_label = 'before_patch' |
| 43 expectations_label = 'after_patch' |
| 41 self._generate_skps_and_run_render_pictures( | 44 self._generate_skps_and_run_render_pictures( |
| 42 subdir='before_patch', skpdict={ | 45 subdir=actuals_label, skpdict={ |
| 43 'changed.skp': 200, | 46 'changed.skp': 200, |
| 44 'unchanged.skp': 100, | 47 'unchanged.skp': 100, |
| 45 'only-in-before.skp': 128, | 48 'only-in-before.skp': 128, |
| 46 }) | 49 }) |
| 47 self._generate_skps_and_run_render_pictures( | 50 self._generate_skps_and_run_render_pictures( |
| 48 subdir='after_patch', skpdict={ | 51 subdir=expectations_label, skpdict={ |
| 49 'changed.skp': 201, | 52 'changed.skp': 201, |
| 50 'unchanged.skp': 100, | 53 'unchanged.skp': 100, |
| 51 'only-in-after.skp': 128, | 54 'only-in-after.skp': 128, |
| 52 }) | 55 }) |
| 53 | 56 |
| 54 results_obj = compare_rendered_pictures.RenderedPicturesComparisons( | 57 results_obj = compare_rendered_pictures.RenderedPicturesComparisons( |
| 55 actuals_root=self.temp_dir, | 58 actuals_dirs=[os.path.join(self.temp_dir, actuals_label)], |
| 56 subdirs=('before_patch', 'after_patch'), | 59 expectations_dirs=[os.path.join(self.temp_dir, expectations_label)], |
| 57 generated_images_root=self.temp_dir, | 60 image_diff_db=imagediffdb.ImageDiffDB(self.temp_dir), |
| 58 diff_base_url='/static/generated-images') | 61 image_base_gs_url='gs://fakebucket/fake/path', |
| 62 diff_base_url='/static/generated-images', |
| 63 actuals_label=actuals_label, expectations_label=expectations_label) |
| 59 results_obj.get_timestamp = mock_get_timestamp | 64 results_obj.get_timestamp = mock_get_timestamp |
| 60 | 65 |
| 61 gm_json.WriteToFile( | 66 gm_json.WriteToFile( |
| 62 results_obj.get_packaged_results_of_type( | 67 results_obj.get_packaged_results_of_type( |
| 63 results.KEY__HEADER__RESULTS_ALL), | 68 results.KEY__HEADER__RESULTS_ALL), |
| 64 os.path.join(self.output_dir_actual, 'compare_rendered_pictures.json')) | 69 os.path.join(self.output_dir_actual, 'compare_rendered_pictures.json')) |
| 65 | 70 |
| 66 def _generate_skps_and_run_render_pictures(self, subdir, skpdict): | 71 def _generate_skps_and_run_render_pictures(self, subdir, skpdict): |
| 67 """Generate SKPs and run render_pictures on them. | 72 """Generate SKPs and run render_pictures on them. |
| 68 | 73 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 """Mock version of BaseComparisons.get_timestamp() for testing.""" | 119 """Mock version of BaseComparisons.get_timestamp() for testing.""" |
| 115 return 12345678 | 120 return 12345678 |
| 116 | 121 |
| 117 | 122 |
| 118 def main(): | 123 def main(): |
| 119 base_unittest.main(CompareRenderedPicturesTest) | 124 base_unittest.main(CompareRenderedPicturesTest) |
| 120 | 125 |
| 121 | 126 |
| 122 if __name__ == '__main__': | 127 if __name__ == '__main__': |
| 123 main() | 128 main() |
| OLD | NEW |