]> git.parisson.com Git - pdf.js.git/commitdiff
add support for linking pdfs we can't/won't distribute
authorChris Jones <jones.chris.g@gmail.com>
Tue, 21 Jun 2011 22:14:42 +0000 (15:14 -0700)
committerChris Jones <jones.chris.g@gmail.com>
Tue, 21 Jun 2011 22:14:42 +0000 (15:14 -0700)
test.py
test_manifest.json
tests/pdf.pdf.link [new file with mode: 0644]

diff --git a/test.py b/test.py
index 7c3c4048a4df37a54ed3e41a3834228877c87d13..dae723b8a75da4d4a8d77a26008ddcb05e38cf20 100644 (file)
--- a/test.py
+++ b/test.py
@@ -1,4 +1,4 @@
-import json, os, sys, subprocess
+import json, os, sys, subprocess, urllib2
 from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
 from urlparse import urlparse
 
@@ -82,6 +82,8 @@ class PDFTestHandler(BaseHTTPRequestHandler):
 
         if result['taskDone']:
             check(State.manifest[id], taskResults, browser)
+            # Please oh please GC this ...
+            del State.taskResults[browser][id]
             State.remaining -= 1
 
         State.done = (0 == State.remaining)
@@ -100,6 +102,23 @@ def set_up(manifestFile):
     manifestList = json.load(mf)
     mf.close()
 
+    for item in manifestList:
+        f, isLink = item['file'], item.get('link', False)
+        if isLink and not os.access(f, os.R_OK):
+            linkFile = open(f +'.link')
+            link = linkFile.read()
+            linkFile.close()
+
+            sys.stdout.write('Downloading '+ link +' to '+ f +' ...')
+            sys.stdout.flush()
+            response = urllib2.urlopen(link)
+
+            out = open(f, 'w')
+            out.write(response.read())
+            out.close()
+
+            print 'done'
+
     for b in testBrowsers:
         State.taskResults[b] = { }
         for item in manifestList:
@@ -169,8 +188,6 @@ def checkEq(task, results, browser):
         print 'TEST-PASS | eq test', task['id'], '| in', browser
 
 
-printed = [False]
-
 def checkFBF(task, results, browser):
     round0, round1 = results[0], results[1]
     assert len(round0) == len(round1)
index e31b8b2b484dd8e8bcd5fa1f112b9eaa58ca3035..036b7aafc6778fda22e32f494483c82f315f4a98 100644 (file)
        "file": "tests/canvas.pdf",
        "rounds": 1,
        "type": "load"
+    },
+    {  "id": "pdfspec-load",
+       "file": "tests/pdf.pdf",
+       "link": true,
+       "rounds": 1,
+       "type": "load"
     }
 ]
diff --git a/tests/pdf.pdf.link b/tests/pdf.pdf.link
new file mode 100644 (file)
index 0000000..bbc2b3a
--- /dev/null
@@ -0,0 +1 @@
+http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf
\ No newline at end of file