summaryrefslogtreecommitdiff
path: root/testing/tools/pngdiffer.py
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-04-09 13:37:02 -0700
committerTom Sepez <tsepez@chromium.org>2015-04-09 13:37:02 -0700
commit30762ceda9db949550de6785b36dbe0d89c6d9d2 (patch)
tree6212fb0d3f1b70e2f25d0014066f4d3804f3f6e3 /testing/tools/pngdiffer.py
parent06e015f33248e4453259c8cebc414e9601638a6d (diff)
downloadpdfium-30762ceda9db949550de6785b36dbe0d89c6d9d2.tar.xz
Merge to XFA: testing utility combo patch
This pulls in the following CLs from master: Review URL: https://codereview.chromium.org/1072613003 Review URL: https://codereview.chromium.org/1058463004 Review URL: https://codereview.chromium.org/1057983003 Review URL: https://codereview.chromium.org/1036073002 Review URL: https://codereview.chromium.org/1031203003 Review URL: https://codereview.chromium.org/1029193002 Review URL: https://codereview.chromium.org/1016613004 Review URL: https://codereview.chromium.org/1026903002 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1062163003
Diffstat (limited to 'testing/tools/pngdiffer.py')
-rwxr-xr-xtesting/tools/pngdiffer.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/testing/tools/pngdiffer.py b/testing/tools/pngdiffer.py
new file mode 100755
index 0000000000..7a7e8ddbc6
--- /dev/null
+++ b/testing/tools/pngdiffer.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# Copyright 2015 The PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import subprocess
+import sys
+
+class PNGDiffer():
+ ACTUAL_TEMPLATE = '.pdf.%d.png'
+ EXPECTED_TEMPLATE = '_expected' + ACTUAL_TEMPLATE
+ PLATFORM_EXPECTED_TEMPLATE = '_expected_%s' + ACTUAL_TEMPLATE
+
+ def __init__(self, finder):
+ self.pdfium_diff_path = finder.ExecutablePath('pdfium_diff')
+ self.os_name = finder.os_name
+
+ 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)
+ i = 0
+ try:
+ 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):
+ if i == 0:
+ print "WARNING: no expected results files for " + input_filename
+ break
+ print "Checking " + actual_path
+ sys.stdout.flush()
+ subprocess.check_call(
+ [self.pdfium_diff_path, expected_path, actual_path])
+ i += 1
+ except subprocess.CalledProcessError as e:
+ print "FAILURE: " + input_filename + "; " + str(e)
+ return True
+ return False