2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00
koreader/spec/unit/cache_spec.lua

51 lines
1.5 KiB
Lua
Raw Normal View History

2014-05-30 15:20:55 +00:00
describe("Cache module", function()
local DocumentRegistry, Cache
2016-04-19 06:50:36 +00:00
local doc
local max_page = 1
setup(function()
require("commonrequire")
DocumentRegistry = require("document/documentregistry")
Cache = require("cache")
local sample_pdf = "spec/front/unit/data/sample.pdf"
doc = DocumentRegistry:openDocument(sample_pdf)
end)
2014-05-30 15:20:55 +00:00
it("should clear cache", function()
Cache:clear()
end)
2016-04-19 06:50:36 +00:00
2014-05-30 15:20:55 +00:00
it("should serialize blitbuffer", function()
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)
Cache:serialize()
end
Cache:clear()
end)
2016-04-19 06:50:36 +00:00
2014-05-30 15:20:55 +00:00
it("should deserialize blitbuffer", function()
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
Cache:clear()
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
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)
Cache:serialize()
end
Cache: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()
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
Cache:clear()
end)
end)