[feat] DocumentRegistry: add getProviders() and preferred by weight (#3651)
This is step one toward "open with".
References https://github.com/koreader/koreader/issues/3345
* Fix up some mimetypes
* Add XHTML to supported filetypes
* Add a few image files to MuPDF
* ".bmp",
* ".gif",
* ".hdp",
* ".j2k",
* ".jp2",
* ".jpeg",
* ".jpg",
* ".jpx",
* ".jxr",
* ".pam",
* ".pbm",
* ".pgm",
* ".png",
* ".pnm",
* ".ppm",
* ".tif",
* ".tiff",
* ".wdp",
2018-01-31 19:49:21 +00:00
|
|
|
describe("document registry module", function()
|
2018-02-02 20:21:52 +00:00
|
|
|
local DocSettings, DocumentRegistry
|
[feat] DocumentRegistry: add getProviders() and preferred by weight (#3651)
This is step one toward "open with".
References https://github.com/koreader/koreader/issues/3345
* Fix up some mimetypes
* Add XHTML to supported filetypes
* Add a few image files to MuPDF
* ".bmp",
* ".gif",
* ".hdp",
* ".j2k",
* ".jp2",
* ".jpeg",
* ".jpg",
* ".jpx",
* ".jxr",
* ".pam",
* ".pbm",
* ".pgm",
* ".png",
* ".pnm",
* ".ppm",
* ".tif",
* ".tiff",
* ".wdp",
2018-01-31 19:49:21 +00:00
|
|
|
|
|
|
|
setup(function()
|
|
|
|
require("commonrequire")
|
2018-02-02 20:21:52 +00:00
|
|
|
DocSettings = require("docsettings")
|
[feat] DocumentRegistry: add getProviders() and preferred by weight (#3651)
This is step one toward "open with".
References https://github.com/koreader/koreader/issues/3345
* Fix up some mimetypes
* Add XHTML to supported filetypes
* Add a few image files to MuPDF
* ".bmp",
* ".gif",
* ".hdp",
* ".j2k",
* ".jp2",
* ".jpeg",
* ".jpg",
* ".jpx",
* ".jxr",
* ".pam",
* ".pbm",
* ".pgm",
* ".png",
* ".pnm",
* ".ppm",
* ".tif",
* ".tiff",
* ".wdp",
2018-01-31 19:49:21 +00:00
|
|
|
DocumentRegistry = require("document/documentregistry")
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("should get preferred rendering engine", function()
|
2018-02-02 20:21:52 +00:00
|
|
|
assert.is_equal("crengine",
|
|
|
|
DocumentRegistry:getProvider("bla.epub").provider)
|
|
|
|
assert.is_equal("mupdf",
|
|
|
|
DocumentRegistry:getProvider("bla.pdf").provider)
|
[feat] DocumentRegistry: add getProviders() and preferred by weight (#3651)
This is step one toward "open with".
References https://github.com/koreader/koreader/issues/3345
* Fix up some mimetypes
* Add XHTML to supported filetypes
* Add a few image files to MuPDF
* ".bmp",
* ".gif",
* ".hdp",
* ".j2k",
* ".jp2",
* ".jpeg",
* ".jpg",
* ".jpx",
* ".jxr",
* ".pam",
* ".pbm",
* ".pgm",
* ".png",
* ".pnm",
* ".ppm",
* ".tif",
* ".tiff",
* ".wdp",
2018-01-31 19:49:21 +00:00
|
|
|
end)
|
|
|
|
|
|
|
|
it("should return all supported rendering engines", function()
|
|
|
|
local providers = DocumentRegistry:getProviders("bla.epub")
|
2018-02-10 17:36:18 +00:00
|
|
|
assert.is_equal("crengine",
|
|
|
|
providers[1].provider.provider)
|
|
|
|
assert.is_equal("mupdf",
|
|
|
|
providers[2].provider.provider)
|
[feat] DocumentRegistry: add getProviders() and preferred by weight (#3651)
This is step one toward "open with".
References https://github.com/koreader/koreader/issues/3345
* Fix up some mimetypes
* Add XHTML to supported filetypes
* Add a few image files to MuPDF
* ".bmp",
* ".gif",
* ".hdp",
* ".j2k",
* ".jp2",
* ".jpeg",
* ".jpg",
* ".jpx",
* ".jxr",
* ".pam",
* ".pbm",
* ".pgm",
* ".png",
* ".pnm",
* ".ppm",
* ".tif",
* ".tiff",
* ".wdp",
2018-01-31 19:49:21 +00:00
|
|
|
end)
|
2018-02-02 20:21:52 +00:00
|
|
|
|
|
|
|
it("should set per-document setting for rendering engine", function()
|
|
|
|
local path = "../../foo.epub"
|
|
|
|
local pdf_provider = DocumentRegistry:getProvider("bla.pdf")
|
|
|
|
DocumentRegistry:setProvider(path, pdf_provider, false)
|
|
|
|
|
|
|
|
local provider = DocumentRegistry:getProvider(path)
|
|
|
|
|
|
|
|
assert.is_equal("mupdf", provider.provider)
|
|
|
|
|
|
|
|
local docsettings = DocSettings:open(path)
|
|
|
|
docsettings:purge()
|
|
|
|
end)
|
|
|
|
it("should set global setting for rendering engine", function()
|
|
|
|
local path = "../../foo.fb2"
|
|
|
|
local pdf_provider = DocumentRegistry:getProvider("bla.pdf")
|
|
|
|
DocumentRegistry:setProvider(path, pdf_provider, true)
|
|
|
|
|
|
|
|
local provider = DocumentRegistry:getProvider(path)
|
|
|
|
|
|
|
|
assert.is_equal("mupdf", provider.provider)
|
|
|
|
|
|
|
|
G_reader_settings:delSetting("provider")
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("should return per-document setting for rendering engine", function()
|
|
|
|
local path = "../../foofoo.epub"
|
|
|
|
local docsettings = DocSettings:open(path)
|
|
|
|
docsettings:saveSetting("provider", "mupdf")
|
|
|
|
docsettings:flush()
|
|
|
|
|
|
|
|
local provider = DocumentRegistry:getProvider(path)
|
|
|
|
|
|
|
|
assert.is_equal("mupdf", provider.provider)
|
|
|
|
|
|
|
|
docsettings:purge()
|
|
|
|
end)
|
|
|
|
it("should return global setting for rendering engine", function()
|
|
|
|
local path = "../../foofoo.fb2"
|
|
|
|
local provider_setting = {}
|
|
|
|
provider_setting.fb2 = "mupdf"
|
|
|
|
G_reader_settings:saveSetting("provider", provider_setting)
|
|
|
|
|
|
|
|
local provider = DocumentRegistry:getProvider(path)
|
|
|
|
|
|
|
|
assert.is_equal("mupdf", provider.provider)
|
|
|
|
|
|
|
|
G_reader_settings:delSetting("provider")
|
|
|
|
end)
|
[feat] DocumentRegistry: add getProviders() and preferred by weight (#3651)
This is step one toward "open with".
References https://github.com/koreader/koreader/issues/3345
* Fix up some mimetypes
* Add XHTML to supported filetypes
* Add a few image files to MuPDF
* ".bmp",
* ".gif",
* ".hdp",
* ".j2k",
* ".jp2",
* ".jpeg",
* ".jpg",
* ".jpx",
* ".jxr",
* ".pam",
* ".pbm",
* ".pgm",
* ".png",
* ".pnm",
* ".ppm",
* ".tif",
* ".tiff",
* ".wdp",
2018-01-31 19:49:21 +00:00
|
|
|
end)
|