actually wait for fonts to be loaded, and write out a log of failed eq comparisons
This commit is contained in:
parent
5585c6a5fe
commit
4ae16721fa
25
test.py
25
test.py
@ -9,6 +9,7 @@ def prompt(question):
|
||||
|
||||
ANAL = True
|
||||
DEFAULT_MANIFEST_FILE = 'test_manifest.json'
|
||||
EQLOG_FILE = 'eq.log'
|
||||
REFDIR = 'ref'
|
||||
TMPDIR = 'tmp'
|
||||
VERBOSE = False
|
||||
@ -35,6 +36,7 @@ class State:
|
||||
numEqNoSnapshot = 0
|
||||
numFBFFailures = 0
|
||||
numLoadFailures = 0
|
||||
eqLog = None
|
||||
|
||||
class Result:
|
||||
def __init__(self, snapshot, failure):
|
||||
@ -190,6 +192,7 @@ def check(task, results, browser):
|
||||
def checkEq(task, results, browser):
|
||||
pfx = os.path.join(REFDIR, sys.platform, browser, task['id'])
|
||||
results = results[0]
|
||||
taskId = task['id']
|
||||
|
||||
passed = True
|
||||
for page in xrange(len(results)):
|
||||
@ -208,7 +211,21 @@ def checkEq(task, results, browser):
|
||||
|
||||
eq = (ref == snapshot)
|
||||
if not eq:
|
||||
print 'TEST-UNEXPECTED-FAIL | eq', task['id'], '| in', browser, '| rendering of page', page + 1, '!= reference rendering'
|
||||
print 'TEST-UNEXPECTED-FAIL | eq', taskId, '| in', browser, '| rendering of page', page + 1, '!= reference rendering'
|
||||
# XXX need to dump this always, somehow, when we have
|
||||
# the reference repository
|
||||
if State.masterMode:
|
||||
if not State.eqLog:
|
||||
State.eqLog = open(EQLOG_FILE, 'w')
|
||||
eqLog = State.eqLog
|
||||
|
||||
# NB: this follows the format of Mozilla reftest
|
||||
# output so that we can reuse its reftest-analyzer
|
||||
# script
|
||||
print >>eqLog, 'REFTEST TEST-UNEXPECTED-FAIL |', browser +'-'+ taskId +'-page'+ str(page + 1), '| image comparison (==)'
|
||||
print >>eqLog, 'REFTEST IMAGE 1 (TEST):', snapshot
|
||||
print >>eqLog, 'REFTEST IMAGE 2 (REFERENCE):', ref
|
||||
|
||||
passed = False
|
||||
State.numEqFailures += 1
|
||||
|
||||
@ -292,6 +309,12 @@ def main(args):
|
||||
masterMode = (args[0] == '-m')
|
||||
manifestFile = args[0] if not masterMode else manifestFile
|
||||
|
||||
|
||||
|
||||
masterMode = True
|
||||
|
||||
|
||||
|
||||
setUp(manifestFile, masterMode)
|
||||
|
||||
server = HTTPServer(('127.0.0.1', 8080), PDFTestHandler)
|
||||
|
@ -1,6 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>pdf.js test slave</title>
|
||||
<style type="text/css"></style>
|
||||
<script type="text/javascript" src="pdf.js"></script>
|
||||
<script type="text/javascript" src="fonts.js"></script>
|
||||
<script type="text/javascript" src="glyphlist.js"></script>
|
||||
@ -31,7 +32,7 @@ function load() {
|
||||
stdout = document.getElementById("stdout");
|
||||
|
||||
log("Harness thinks this browser is '"+ browser +"'\n");
|
||||
log("Fetching manifest ...");
|
||||
log("Fetching manifest "+ manifestFile +"...");
|
||||
|
||||
var r = new XMLHttpRequest();
|
||||
r.open("GET", manifestFile, false);
|
||||
@ -81,38 +82,69 @@ function nextPage() {
|
||||
}
|
||||
|
||||
failure = '';
|
||||
log(" drawing page "+ currentTask.pageNum +"...");
|
||||
log(" loading page "+ currentTask.pageNum +"... ");
|
||||
|
||||
var ctx = canvas.getContext("2d");
|
||||
clear(ctx);
|
||||
|
||||
var fonts = [];
|
||||
var fontsReady = true;
|
||||
var gfx = new CanvasGraphics(ctx);
|
||||
try {
|
||||
currentPage = pdfDoc.getPage(currentTask.pageNum);
|
||||
currentPage.compile(gfx, fonts);
|
||||
|
||||
// Inspect fonts and translate the missing ones
|
||||
var count = fonts.length;
|
||||
for (var i = 0; i < count; ++i) {
|
||||
var font = fonts[i];
|
||||
if (Fonts[font.name]) {
|
||||
fontsReady = fontsReady && !Fonts[font.name].loading;
|
||||
continue;
|
||||
}
|
||||
new Font(font.name, font.file, font.properties);
|
||||
fontsReady = false;
|
||||
}
|
||||
} catch(e) {
|
||||
failure = 'compile: '+ e.toString();
|
||||
}
|
||||
|
||||
// TODO load fonts
|
||||
setTimeout(function() {
|
||||
if (!failure) {
|
||||
try {
|
||||
currentPage.display(gfx);
|
||||
} catch(e) {
|
||||
failure = 'render: '+ e.toString();
|
||||
}
|
||||
var checkFontsLoadedIntervalTimer = null;
|
||||
function checkFontsLoaded() {
|
||||
for (var i = 0; i < count; i++) {
|
||||
if (Fonts[font.name].loading) {
|
||||
return;
|
||||
}
|
||||
currentTask.taskDone = (currentTask.pageNum == pdfDoc.numPages
|
||||
&& (1 + currentTask.round) == currentTask.rounds);
|
||||
sendTaskResult(canvas.toDataURL("image/png"));
|
||||
log("done"+ (failure ? " (failed!)" : "") +"\n");
|
||||
}
|
||||
window.clearInterval(checkFontsLoadedIntervalTimer);
|
||||
|
||||
++currentTask.pageNum, nextPage();
|
||||
},
|
||||
0
|
||||
);
|
||||
snapshotCurrentPage(gfx);
|
||||
}
|
||||
|
||||
if (failure || fontsReady) {
|
||||
snapshotCurrentPage(gfx);
|
||||
} else {
|
||||
checkFontsLoadedIntervalTimer = setInterval(checkFontsLoaded, 10);
|
||||
}
|
||||
}
|
||||
|
||||
function snapshotCurrentPage(gfx) {
|
||||
log("done, snapshotting... ");
|
||||
|
||||
if (!failure) {
|
||||
try {
|
||||
currentPage.display(gfx);
|
||||
} catch(e) {
|
||||
failure = 'render: '+ e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
currentTask.taskDone = (currentTask.pageNum == pdfDoc.numPages
|
||||
&& (1 + currentTask.round) == currentTask.rounds);
|
||||
sendTaskResult(canvas.toDataURL("image/png"));
|
||||
log("done"+ (failure ? " (failed!)" : "") +"\n");
|
||||
|
||||
++currentTask.pageNum, nextPage();
|
||||
}
|
||||
|
||||
function done() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user