diff options
Diffstat (limited to 'testing/tools')
-rwxr-xr-x | testing/tools/fixup_pdf_template.py | 8 | ||||
-rw-r--r-- | testing/tools/test_runner.py | 12 |
2 files changed, 16 insertions, 4 deletions
diff --git a/testing/tools/fixup_pdf_template.py b/testing/tools/fixup_pdf_template.py index bee7a3d002..0f536785c1 100755 --- a/testing/tools/fixup_pdf_template.py +++ b/testing/tools/fixup_pdf_template.py @@ -30,11 +30,15 @@ import os import re import sys +SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__)) + + class StreamLenState: START = 1 FIND_STREAM = 2 FIND_ENDSTREAM = 3 + class TemplateProcessor: HEADER_TOKEN = '{{header}}' HEADER_REPLACEMENT = '%PDF-1.7\n%\xa0\xf2\xa4\xf4' @@ -45,7 +49,7 @@ class TemplateProcessor: XREF_REPLACEMENT_N = '%010d %05d n \n' XREF_REPLACEMENT_F = '0000000000 65535 f \n' # XREF rows must be exactly 20 bytes - space required. - assert(len(XREF_REPLACEMENT_F) == 20) + assert len(XREF_REPLACEMENT_F) == 20 TRAILER_TOKEN = '{{trailer}}' TRAILER_REPLACEMENT = 'trailer <<\n /Root 1 0 R\n /Size %d\n>>' @@ -230,7 +234,7 @@ class TemplateProcessor: def preprocess_line(self, line): if self.STREAMLEN_TOKEN in line: - assert(self.streamlen_state == StreamLenState.START) + assert self.streamlen_state == StreamLenState.START self.streamlen_state = StreamLenState.FIND_STREAM self.streamlens.append(0) return diff --git a/testing/tools/test_runner.py b/testing/tools/test_runner.py index 3fa1c79e04..3737969fb2 100644 --- a/testing/tools/test_runner.py +++ b/testing/tools/test_runner.py @@ -51,6 +51,8 @@ class TestRunner: # tests and outputfiles is a list tuples: # (path_to_image, md5_hash_of_pixelbuffer) def GenerateAndTest(self, input_filename, source_dir): + use_ahem = 'use_ahem' in source_dir + input_root, _ = os.path.splitext(input_filename) expected_txt_path = os.path.join(source_dir, input_root + '_expected.txt') @@ -76,7 +78,7 @@ class TestRunner: if os.path.exists(expected_txt_path): raised_exception = self.TestText(input_root, expected_txt_path, pdf_path) else: - raised_exception, results = self.TestPixel(input_root, pdf_path) + raised_exception, results = self.TestPixel(input_root, pdf_path, use_ahem) if raised_exception is not None: print 'FAILURE: %s; %s' % (input_filename, raised_exception) @@ -136,10 +138,15 @@ class TestRunner: cmd = [sys.executable, self.text_diff_path, expected_txt_path, txt_path] return common.RunCommand(cmd) - def TestPixel(self, input_root, pdf_path): + def TestPixel(self, input_root, pdf_path, use_ahem): cmd_to_run = [self.pdfium_test_path, '--send-events', '--png', '--md5'] + if self.oneshot_renderer: cmd_to_run.append('--render-oneshot') + + if use_ahem: + cmd_to_run.append('--font-dir=%s' % self.font_dir) + cmd_to_run.append(pdf_path) return common.RunCommandExtractHashedFiles(cmd_to_run) @@ -219,6 +226,7 @@ class TestRunner: finder = common.DirectoryFinder(self.options.build_dir) self.fixup_path = finder.ScriptPath('fixup_pdf_template.py') self.text_diff_path = finder.ScriptPath('text_diff.py') + self.font_dir = os.path.join(finder.TestingDir(), 'resources', 'fonts') self.source_dir = finder.TestingDir() if self.test_dir != 'corpus': |