2015-05-05 06:42:14 +00:00
|
|
|
describe.skip("PDF Recognition", function() {
|
2015-03-08 19:59:53 +00:00
|
|
|
Components.utils.import("resource://gre/modules/FileUtils.jsm");
|
|
|
|
|
|
|
|
var win;
|
|
|
|
before(function() {
|
|
|
|
this.timeout(60000);
|
2015-03-09 21:06:01 +00:00
|
|
|
// Load Zotero pane, install PDF tools, and load the
|
|
|
|
// translators
|
2015-04-13 07:27:51 +00:00
|
|
|
return Zotero.Promise.all([loadZoteroPane().then(function(w) {
|
2015-03-08 19:59:53 +00:00
|
|
|
win = w;
|
2015-03-09 21:06:01 +00:00
|
|
|
}), installPDFTools()]);
|
2015-03-08 19:59:53 +00:00
|
|
|
});
|
2015-03-08 22:40:29 +00:00
|
|
|
afterEach(function() {
|
|
|
|
for(let win of getWindows("chrome://zotero/content/pdfProgress.xul")) {
|
|
|
|
win.close();
|
|
|
|
}
|
|
|
|
});
|
2015-03-08 19:59:53 +00:00
|
|
|
after(function() {
|
|
|
|
win.close();
|
|
|
|
});
|
|
|
|
|
2015-05-23 08:25:47 +00:00
|
|
|
it("should recognize a PDF with a DOI", function* () {
|
2015-03-08 19:59:53 +00:00
|
|
|
this.timeout(30000);
|
|
|
|
// Import the PDF
|
|
|
|
var testdir = getTestDataDirectory();
|
|
|
|
testdir.append("recognizePDF_test_DOI.pdf");
|
2015-05-23 08:25:47 +00:00
|
|
|
var id = yield Zotero.Attachments.importFromFile({
|
|
|
|
file: testdir
|
|
|
|
});
|
2015-03-08 19:59:53 +00:00
|
|
|
|
|
|
|
// Recognize the PDF
|
|
|
|
win.ZoteroPane.selectItem(id);
|
|
|
|
win.Zotero_RecognizePDF.recognizeSelected();
|
|
|
|
|
|
|
|
return waitForItemEvent("add").then(function(ids) {
|
|
|
|
var item = Zotero.Items.get(ids[0]);
|
|
|
|
assert.equal(item.getField("title"), "Shaping the Research Agenda");
|
|
|
|
assert.equal(item.getField("libraryCatalog"), "CrossRef");
|
|
|
|
});
|
|
|
|
});
|
2015-03-08 20:20:57 +00:00
|
|
|
|
2015-05-23 08:25:47 +00:00
|
|
|
it("should recognize a PDF without a DOI", function* () {
|
2015-03-31 04:52:38 +00:00
|
|
|
if (Zotero.noUserInput) this.skip(); // CAPTCHAs make this fail
|
|
|
|
|
2015-03-08 20:20:57 +00:00
|
|
|
this.timeout(30000);
|
|
|
|
// Import the PDF
|
|
|
|
var testdir = getTestDataDirectory();
|
|
|
|
testdir.append("recognizePDF_test_GS.pdf");
|
2015-05-23 08:25:47 +00:00
|
|
|
var id = yield Zotero.Attachments.importFromFile({
|
|
|
|
file: testdir
|
|
|
|
});
|
2015-03-08 20:20:57 +00:00
|
|
|
|
|
|
|
// Recognize the PDF
|
|
|
|
win.ZoteroPane.selectItem(id);
|
|
|
|
win.Zotero_RecognizePDF.recognizeSelected();
|
|
|
|
|
|
|
|
return waitForItemEvent("add").then(function(ids) {
|
|
|
|
var item = Zotero.Items.get(ids[0]);
|
|
|
|
assert.equal(item.getField("title"), "Scaling study of an improved fermion action on quenched lattices");
|
|
|
|
assert.equal(item.getField("libraryCatalog"), "Google Scholar");
|
|
|
|
});
|
|
|
|
});
|
2015-03-08 19:59:53 +00:00
|
|
|
});
|