diff options
author | Lei Zhang <thestig@chromium.org> | 2015-09-09 13:05:42 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-09-09 13:05:42 -0700 |
commit | 77aaf96a165272ab52916c04b5ec69e4f2fd13de (patch) | |
tree | 13780e258aaacc1dd55784d16cc16d5557866d90 /testing/tools/pngdiffer.py | |
parent | 396e872d872b760813036b7e7dd8bb68a8b61598 (diff) | |
download | pdfium-77aaf96a165272ab52916c04b5ec69e4f2fd13de.tar.xz |
Merge to XFA: Remove existing generated images before running a test.
TBR=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1314443007 .
(cherry picked from commit 8ead9036aab18d45498e310866210dfff20da188)
Review URL: https://codereview.chromium.org/1331643004 .
Diffstat (limited to 'testing/tools/pngdiffer.py')
-rwxr-xr-x | testing/tools/pngdiffer.py | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/testing/tools/pngdiffer.py b/testing/tools/pngdiffer.py index 7a7e8ddbc6..35eaaa437a 100755 --- a/testing/tools/pngdiffer.py +++ b/testing/tools/pngdiffer.py @@ -16,14 +16,33 @@ class PNGDiffer(): self.pdfium_diff_path = finder.ExecutablePath('pdfium_diff') self.os_name = finder.os_name + def GetActualFiles(self, input_filename, source_dir, working_dir): + actual_paths = [] + template_paths = self._GetTemplatePaths( + input_filename, source_dir, working_dir) + actual_path_template = template_paths[0]; + expected_path_template = template_paths[1] + platform_expected_path_template = template_paths[2] + i = 0 + while True: + actual_path = actual_path_template % i + expected_path = expected_path_template % i + platform_expected_path = ( + platform_expected_path_template % (self.os_name, i)) + if os.path.exists(platform_expected_path): + expected_path = platform_expected_path + elif not os.path.exists(expected_path): + break + actual_paths.append(actual_path) + i += 1 + return actual_paths + def HasDifferences(self, input_filename, source_dir, working_dir): - input_root, _ = os.path.splitext(input_filename) - actual_path_template = os.path.join( - working_dir, input_root + self.ACTUAL_TEMPLATE) - expected_path_template = os.path.join( - source_dir, input_root + self.EXPECTED_TEMPLATE) - platform_expected_path_template = os.path.join( - source_dir, input_root + self.PLATFORM_EXPECTED_TEMPLATE) + template_paths = self._GetTemplatePaths( + input_filename, source_dir, working_dir) + actual_path_template = template_paths[0]; + expected_path_template = template_paths[1] + platform_expected_path_template = template_paths[2] i = 0 try: while True: @@ -46,3 +65,12 @@ class PNGDiffer(): print "FAILURE: " + input_filename + "; " + str(e) return True return False + + def _GetTemplatePaths(self, input_filename, source_dir, working_dir): + input_root, _ = os.path.splitext(input_filename) + actual_path = os.path.join(working_dir, input_root + self.ACTUAL_TEMPLATE) + expected_path = os.path.join( + source_dir, input_root + self.EXPECTED_TEMPLATE) + platform_expected_path = os.path.join( + source_dir, input_root + self.PLATFORM_EXPECTED_TEMPLATE) + return (actual_path, expected_path, platform_expected_path) |