2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/spec/unit/readerpaging_spec.lua
2016-04-19 00:01:28 -07:00

56 lines
1.9 KiB
Lua

describe("Readerpaging module", function()
local sample_pdf = "spec/front/unit/data/sample.pdf"
local readerui
local paging
setup(function() require("commonrequire") end)
describe("Page mode", function()
setup(function()
readerui = require("apps/reader/readerui"):new{
document = require("document/documentregistry"):openDocument(sample_pdf),
}
paging = readerui.paging
end)
it("should emit EndOfBook event at the end", function()
readerui.zooming:setZoomMode("pageheight")
paging:onGotoPage(readerui.document:getPageCount())
local called = false
readerui.onEndOfBook = function()
called = true
end
paging:onPagingRel(1)
assert.is.truthy(called)
readerui.onEndOfBook = nil
end)
end)
describe("Scroll mode", function()
setup(function()
local purgeDir = require("ffi/util").purgeDir
local DocSettings = require("docsettings")
purgeDir(DocSettings:getSidecarDir(sample_pdf))
os.remove(DocSettings:getHistoryPath(sample_pdf))
readerui = require("apps/reader/readerui"):new{
document = require("document/documentregistry"):openDocument(sample_pdf),
}
paging = readerui.paging
end)
it("should emit EndOfBook event at the end", function()
paging:onGotoPage(readerui.document:getPageCount())
readerui.zooming:setZoomMode("pageheight")
readerui.view:onSetScrollMode(true)
local called = false
readerui.onEndOfBook = function()
called = true
end
paging:onPagingRel(1)
assert.is.truthy(called)
readerui.onEndOfBook = nil
end)
end)
end)