2014-05-30 15:20:55 +00:00
|
|
|
describe("Cache module", function()
|
2021-05-04 21:13:24 +00:00
|
|
|
local DocumentRegistry, DocCache
|
2016-04-19 06:50:36 +00:00
|
|
|
local doc
|
|
|
|
local max_page = 1
|
|
|
|
setup(function()
|
|
|
|
require("commonrequire")
|
|
|
|
DocumentRegistry = require("document/documentregistry")
|
2021-05-04 21:13:24 +00:00
|
|
|
DocCache = require("document/doccache")
|
2016-04-19 06:50:36 +00:00
|
|
|
|
|
|
|
local sample_pdf = "spec/front/unit/data/sample.pdf"
|
|
|
|
doc = DocumentRegistry:openDocument(sample_pdf)
|
|
|
|
end)
|
2020-12-19 04:32:23 +00:00
|
|
|
teardown(function()
|
|
|
|
doc:close()
|
|
|
|
end)
|
2016-04-19 06:50:36 +00:00
|
|
|
|
2014-05-30 15:20:55 +00:00
|
|
|
it("should clear cache", function()
|
2021-05-04 21:13:24 +00:00
|
|
|
DocCache:clear()
|
2014-05-30 15:20:55 +00:00
|
|
|
end)
|
2016-04-19 06:50:36 +00:00
|
|
|
|
2014-05-30 15:20:55 +00:00
|
|
|
it("should serialize blitbuffer", function()
|
2014-10-06 13:31:04 +00:00
|
|
|
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
2014-05-30 15:20:55 +00:00
|
|
|
doc:renderPage(pageno, nil, 1, 0, 1.0, 0)
|
2021-05-04 21:13:24 +00:00
|
|
|
DocCache:serialize()
|
2014-05-30 15:20:55 +00:00
|
|
|
end
|
2021-05-04 21:13:24 +00:00
|
|
|
DocCache:clear()
|
2014-05-30 15:20:55 +00:00
|
|
|
end)
|
2016-04-19 06:50:36 +00:00
|
|
|
|
2014-05-30 15:20:55 +00:00
|
|
|
it("should deserialize blitbuffer", function()
|
2014-10-06 13:31:04 +00:00
|
|
|
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
2014-05-30 15:20:55 +00:00
|
|
|
doc:hintPage(pageno, 1, 0, 1.0, 0)
|
|
|
|
end
|
2021-05-04 21:13:24 +00:00
|
|
|
DocCache:clear()
|
2014-05-30 15:20:55 +00:00
|
|
|
end)
|
2016-04-19 06:50:36 +00:00
|
|
|
|
2014-05-30 15:20:55 +00:00
|
|
|
it("should serialize koptcontext", function()
|
|
|
|
doc.configurable.text_wrap = 1
|
2014-10-06 13:31:04 +00:00
|
|
|
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
2014-05-30 15:20:55 +00:00
|
|
|
doc:renderPage(pageno, nil, 1, 0, 1.0, 0)
|
|
|
|
doc:getPageDimensions(pageno)
|
2021-05-04 21:13:24 +00:00
|
|
|
DocCache:serialize()
|
2014-05-30 15:20:55 +00:00
|
|
|
end
|
2021-05-04 21:13:24 +00:00
|
|
|
DocCache:clear()
|
2016-04-19 06:50:36 +00:00
|
|
|
doc.configurable.text_wrap = 0
|
2014-05-30 15:20:55 +00:00
|
|
|
end)
|
2016-04-19 06:50:36 +00:00
|
|
|
|
2014-05-30 15:20:55 +00:00
|
|
|
it("should deserialize koptcontext", function()
|
2014-10-06 13:31:04 +00:00
|
|
|
for pageno = 1, math.min(max_page, doc.info.number_of_pages) do
|
2014-05-30 15:20:55 +00:00
|
|
|
doc:renderPage(pageno, nil, 1, 0, 1.0, 0)
|
|
|
|
end
|
2021-05-04 21:13:24 +00:00
|
|
|
DocCache:clear()
|
2014-05-30 15:20:55 +00:00
|
|
|
end)
|
|
|
|
end)
|