2016-02-22 01:46:19 +00:00
|
|
|
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")
|
2016-03-27 22:39:47 +00:00
|
|
|
paging:onGotoPage(readerui.document:getPageCount())
|
2016-02-22 01:46:19 +00:00
|
|
|
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()
|
2016-04-19 06:50:36 +00:00
|
|
|
local purgeDir = require("ffi/util").purgeDir
|
|
|
|
local DocSettings = require("docsettings")
|
|
|
|
purgeDir(DocSettings:getSidecarDir(sample_pdf))
|
|
|
|
os.remove(DocSettings:getHistoryPath(sample_pdf))
|
|
|
|
|
2016-02-22 01:46:19 +00:00
|
|
|
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()
|
2016-03-27 22:39:47 +00:00
|
|
|
paging:onGotoPage(readerui.document:getPageCount())
|
2016-02-22 01:46:19 +00:00
|
|
|
readerui.zooming:setZoomMode("pageheight")
|
2016-03-27 22:39:47 +00:00
|
|
|
readerui.view:onSetScrollMode(true)
|
2016-02-22 01:46:19 +00:00
|
|
|
local called = false
|
|
|
|
readerui.onEndOfBook = function()
|
|
|
|
called = true
|
|
|
|
end
|
|
|
|
paging:onPagingRel(1)
|
|
|
|
assert.is.truthy(called)
|
|
|
|
readerui.onEndOfBook = nil
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|