2015-05-23 22:03:25 +00:00
|
|
|
describe("Zotero.Fulltext", function () {
|
|
|
|
describe("#downloadPDFTool()", function () {
|
|
|
|
it("should install the PDF tools", function* () {
|
|
|
|
var version = "3.04";
|
|
|
|
var dataDir = Zotero.getZoteroDirectory().path;
|
2015-05-26 08:44:02 +00:00
|
|
|
var execFileName = Zotero.Fulltext.pdfInfoFileName;
|
2015-05-23 22:03:25 +00:00
|
|
|
var execPath = OS.Path.join(dataDir, execFileName);
|
|
|
|
var versionFileName = execFileName + '.version';
|
|
|
|
var versionPath = OS.Path.join(dataDir, versionFileName);
|
|
|
|
var scriptExt = Zotero.isWin ? 'vbs' : 'sh';
|
|
|
|
var scriptPath = OS.Path.join(dataDir, 'pdfinfo.' + scriptExt);
|
|
|
|
var scriptContents = yield Zotero.File.getContentsFromURLAsync(
|
|
|
|
'resource://zotero/redirect.' + scriptExt
|
|
|
|
);
|
2015-06-01 03:07:24 +00:00
|
|
|
var cacheExecPath = OS.Path.join(
|
|
|
|
getTestDataDirectory().path, "pdf", version, execFileName
|
|
|
|
);
|
2015-05-23 22:03:25 +00:00
|
|
|
|
|
|
|
// Delete existing files
|
|
|
|
try {
|
|
|
|
yield OS.File.remove(execPath);
|
|
|
|
}
|
|
|
|
catch (e) {}
|
|
|
|
try {
|
|
|
|
yield OS.File.remove(versionPath);
|
|
|
|
}
|
|
|
|
catch (e) {}
|
|
|
|
try {
|
|
|
|
yield OS.File.remove(scriptPath);
|
|
|
|
}
|
|
|
|
catch (e) {}
|
|
|
|
|
|
|
|
yield Zotero.Fulltext.downloadPDFTool('info', version);
|
|
|
|
|
|
|
|
assert.ok(Zotero.Fulltext.pdfInfoIsRegistered());
|
|
|
|
assert.equal(
|
2015-06-01 03:07:24 +00:00
|
|
|
(yield Zotero.File.getBinaryContentsAsync(cacheExecPath)),
|
|
|
|
(yield Zotero.File.getBinaryContentsAsync(execPath))
|
2015-05-23 22:03:25 +00:00
|
|
|
);
|
|
|
|
assert.equal((yield OS.File.stat(execPath)).unixMode, 0o755);
|
|
|
|
assert.equal(
|
|
|
|
(yield Zotero.File.getContentsAsync(versionPath)),
|
|
|
|
version
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
(yield Zotero.File.getContentsAsync(scriptPath)),
|
|
|
|
scriptContents
|
|
|
|
);
|
|
|
|
assert.equal((yield OS.File.stat(scriptPath)).unixMode, 0o755);
|
|
|
|
|
2015-06-01 03:07:24 +00:00
|
|
|
yield Zotero.Fulltext.uninstallPDFTools();
|
|
|
|
assert.isFalse(Zotero.Fulltext.pdfInfoIsRegistered());
|
2015-05-23 22:03:25 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|