From bf8d49ef1a7fac0190a1bfbbea704ca469e605fc Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 21 Jun 2011 13:40:21 -0700 Subject: [PATCH 1/5] Don't error out for FontFile3 descriptors. --- pdf.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pdf.js b/pdf.js index fff135816..cffb1c0fa 100644 --- a/pdf.js +++ b/pdf.js @@ -784,6 +784,9 @@ var Dict = (function() { get2: function(key1, key2) { return this.get(key1) || this.get(key2); }, + get3: function(key1, key2, key3) { + return this.get(key1) || this.get(key2) || this.get(key3); + }, has: function(key) { return key in this.map; }, @@ -2255,7 +2258,7 @@ var CanvasGraphics = (function() { assertWellFormed(IsName(fontName), "invalid font name"); fontName = fontName.name.replace("+", "_"); - var fontFile = descriptor.get2("FontFile", "FontFile2"); + var fontFile = descriptor.get3("FontFile", "FontFile2", "FontFile3"); if (!fontFile) error("FontFile not found for font: " + fontName); fontFile = xref.fetchIfRef(fontFile); From f7fb8e63489b4948ac04aef90ec3b64313da0375 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 21 Jun 2011 13:56:49 -0700 Subject: [PATCH 2/5] fix typo --- pdf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdf.js b/pdf.js index cffb1c0fa..52a65f1e3 100644 --- a/pdf.js +++ b/pdf.js @@ -2624,7 +2624,7 @@ var CanvasGraphics = (function() { setWordSpacing: function(spacing) { TODO("word spacing"); }, - setHSpacing: function(scale) { + setHScale: function(scale) { TODO("horizontal text scale"); }, setLeading: function(leading) { From 2dff6d818cedb2f482aa2060e4160b3e8130156a Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Tue, 21 Jun 2011 14:53:57 -0700 Subject: [PATCH 3/5] test-harness improvements --- test.py | 59 ++++++++++++++++++++++++++++++++++------------ test_manifest.json | 4 ++-- test_slave.html | 23 +++++++++++++++--- 3 files changed, 66 insertions(+), 20 deletions(-) diff --git a/test.py b/test.py index 46d30fef5..7c3c4048a 100644 --- a/test.py +++ b/test.py @@ -1,7 +1,10 @@ import json, os, sys, subprocess from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +from urlparse import urlparse ANAL = True +DEFAULT_MANIFEST_FILE = 'test_manifest.json' +REFDIR = 'ref' VERBOSE = False MIMEs = { @@ -34,8 +37,11 @@ class PDFTestHandler(BaseHTTPRequestHandler): BaseHTTPRequestHandler.log_request(code, size) def do_GET(self): + url = urlparse(self.path) + # Ignore query string + path, _ = url.path, url.query cwd = os.getcwd() - path = os.path.abspath(os.path.realpath(cwd + os.sep + self.path)) + path = os.path.abspath(os.path.realpath(cwd + os.sep + path)) cwd = os.path.abspath(cwd) prefix = os.path.commonprefix(( path, cwd )) _, ext = os.path.splitext(path) @@ -69,10 +75,10 @@ class PDFTestHandler(BaseHTTPRequestHandler): self.end_headers() result = json.loads(self.rfile.read(numBytes)) - browser = 'firefox4' - id, failure, round, page, snapshot = result['id'], result['failure'], result['round'], result['page'], result['snapshot'] + browser, id, failure, round, page, snapshot = result['browser'], result['id'], result['failure'], result['round'], result['page'], result['snapshot'] taskResults = State.taskResults[browser][id] - taskResults[round][page - 1] = Result(snapshot, failure) + taskResults[round].append(Result(snapshot, failure)) + assert len(taskResults[round]) == page if result['taskDone']: check(State.manifest[id], taskResults, browser) @@ -81,7 +87,7 @@ class PDFTestHandler(BaseHTTPRequestHandler): State.done = (0 == State.remaining) -def set_up(): +def set_up(manifestFile): # Only serve files from a pdf.js clone assert not ANAL or os.path.isfile('pdf.js') and os.path.isdir('.git') @@ -90,7 +96,7 @@ def set_up(): #'chrome12', 'chrome13', 'firefox5', 'firefox6','opera11' ): if os.access(b, os.R_OK | os.X_OK) ] - mf = open('test_manifest.json') + mf = open(manifestFile) manifestList = json.load(mf) mf.close() @@ -101,15 +107,16 @@ def set_up(): State.manifest[id] = item taskResults = [ ] for r in xrange(rounds): - taskResults.append([ None ] * 100) + taskResults.append([ ]) State.taskResults[b][id] = taskResults State.remaining = len(manifestList) for b in testBrowsers: print 'Launching', b + qs = 'browser='+ b +'&manifestFile='+ manifestFile subprocess.Popen(( os.path.abspath(os.path.realpath(b)), - 'http://localhost:8080/test_slave.html' )) + 'http://localhost:8080/test_slave.html?'+ qs)) def check(task, results, browser): @@ -129,7 +136,7 @@ def check(task, results, browser): return kind = task['type'] - if '==' == kind: + if 'eq' == kind: checkEq(task, results, browser) elif 'fbf' == kind: checkFBF(task, results, browser) @@ -140,8 +147,26 @@ def check(task, results, browser): def checkEq(task, results, browser): - print ' !!! [TODO: == tests] !!!' - print 'TEST-PASS | == test', task['id'], '| in', browser + pfx = os.path.join(REFDIR, sys.platform, browser, task['id']) + results = results[0] + + passed = True + for page in xrange(len(results)): + ref = None + try: + path = os.path.join(pfx, str(page + 1)) + f = open(path) + ref = f.read() + f.close() + except IOError, ioe: + continue + + snapshot = results[page] + if ref != snapshot: + print 'TEST-UNEXPECTED-FAIL | eq', task['id'], '| in', browser, '| rendering of page', page + 1, '!= reference rendering' + passed = False + if passed: + print 'TEST-PASS | eq test', task['id'], '| in', browser printed = [False] @@ -150,13 +175,16 @@ def checkFBF(task, results, browser): round0, round1 = results[0], results[1] assert len(round0) == len(round1) + passed = True for page in xrange(len(round1)): r0Page, r1Page = round0[page], round1[page] if r0Page is None: break if r0Page.snapshot != r1Page.snapshot: print 'TEST-UNEXPECTED-FAIL | forward-back-forward test', task['id'], '| in', browser, '| first rendering of page', page + 1, '!= second' - print 'TEST-PASS | forward-back-forward test', task['id'], '| in', browser + passed = False + if passed: + print 'TEST-PASS | forward-back-forward test', task['id'], '| in', browser def checkLoad(task, results, browser): @@ -165,11 +193,12 @@ def checkLoad(task, results, browser): print 'TEST-PASS | load test', task['id'], '| in', browser -def main(): - set_up() +def main(args): + manifestFile = args[0] if len(args) == 1 else DEFAULT_MANIFEST_FILE + set_up(manifestFile) server = HTTPServer(('127.0.0.1', 8080), PDFTestHandler) while not State.done: server.handle_request() if __name__ == '__main__': - main() + main(sys.argv[1:]) diff --git a/test_manifest.json b/test_manifest.json index 2f45a026c..e31b8b2b4 100644 --- a/test_manifest.json +++ b/test_manifest.json @@ -1,8 +1,8 @@ [ - { "id": "tracemonkey-==", + { "id": "tracemonkey-eq", "file": "tests/tracemonkey.pdf", "rounds": 1, - "type": "==" + "type": "eq" }, { "id": "tracemonkey-fbf", "file": "tests/tracemonkey.pdf", diff --git a/test_slave.html b/test_slave.html index c560d90d0..cff9b3f7d 100644 --- a/test_slave.html +++ b/test_slave.html @@ -5,9 +5,24 @@