New PDF recognizer

This commit is contained in:
Martynas Bagdonas 2018-01-20 10:45:00 +02:00
parent ce0dd5cc5e
commit 991a50d090
12 changed files with 735 additions and 989 deletions

View file

@ -16,7 +16,7 @@ describe("PDF Recognition", function() {
});
afterEach(function() {
for(let win of getWindows("chrome://zotero/content/pdfProgress.xul")) {
for(let win of getWindows("chrome://zotero/content/recognizePDFDialog.xul")) {
win.close();
}
});
@ -27,34 +27,7 @@ describe("PDF Recognition", function() {
}
});
it("should recognize a PDF with a DOI within a collection", function* () {
this.timeout(30000);
// Import the PDF
var testdir = getTestDataDirectory();
testdir.append("recognizePDF_test_DOI.pdf");
var col = yield createDataObject('collection');
yield waitForItemsLoad(win);
var attachment = yield Zotero.Attachments.importFromFile({
file: testdir,
collections: [col.id]
});
// Recognize the PDF
win.Zotero_RecognizePDF.recognizeSelected();
var ids = yield waitForItemEvent("add");
yield waitForNotifierEvent('add', 'collection-item')
var item = Zotero.Items.get(ids[0]);
assert.equal(item.getField("title"), "Shaping the Research Agenda");
assert.equal(item.getField("libraryCatalog"), "CrossRef");
assert.equal(attachment.parentID, item.id);
assert.isTrue(col.hasItem(item.id));
});
it("should recognize a PDF without a DOI", function* () {
it("should recognize a PDF", function* () {
this.timeout(30000);
// Import the PDF
var testdir = getTestDataDirectory();
@ -64,19 +37,18 @@ describe("PDF Recognition", function() {
});
// Recognize the PDF
win.Zotero_RecognizePDF.recognizeSelected();
win.ZoteroPane.recognizeSelected();
var addedIDs = yield waitForItemEvent("add");
var modifiedIDs = yield waitForItemEvent("modify");
assert.lengthOf(addedIDs, 1);
var item = Zotero.Items.get(addedIDs[0]);
assert.equal(item.getField("title"), "Scaling study of an improved fermion action on quenched lattices");
assert.equal(item.getField("libraryCatalog"), "Google Scholar");
assert.lengthOf(modifiedIDs, 2);
yield Zotero.Promise.delay(0);
var progressWindow = getWindows("chrome://zotero/content/pdfProgress.xul")[0];
var progressWindow = getWindows("chrome://zotero/content/recognizePDFDialog.xul")[0];
assert.equal(
progressWindow.document.getElementById("label").value,
Zotero.getString("recognizePDF.complete.label")