mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
readerpaging(fix): handle edge cases where paging pan will crash the reader
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
describe("Readerpaging module", function()
|
||||
local sample_pdf = "spec/front/unit/data/sample.pdf"
|
||||
local readerui, UIManager, Event
|
||||
local readerui, UIManager, Event, DocumentRegistry, ReaderUI
|
||||
local paging
|
||||
|
||||
setup(function()
|
||||
require("commonrequire")
|
||||
UIManager = require("ui/uimanager")
|
||||
Event = require("ui/event")
|
||||
DocumentRegistry = require("document/documentregistry")
|
||||
ReaderUI = require("apps/reader/readerui")
|
||||
end)
|
||||
|
||||
describe("Page mode", function()
|
||||
setup(function()
|
||||
readerui = require("apps/reader/readerui"):new{
|
||||
document = require("document/documentregistry"):openDocument(sample_pdf),
|
||||
readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_pdf),
|
||||
}
|
||||
paging = readerui.paging
|
||||
end)
|
||||
@@ -43,8 +45,8 @@ describe("Readerpaging module", function()
|
||||
purgeDir(DocSettings:getSidecarDir(sample_pdf))
|
||||
os.remove(DocSettings:getHistoryPath(sample_pdf))
|
||||
|
||||
readerui = require("apps/reader/readerui"):new{
|
||||
document = require("document/documentregistry"):openDocument(sample_pdf),
|
||||
readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_pdf),
|
||||
}
|
||||
paging = readerui.paging
|
||||
end)
|
||||
@@ -68,5 +70,25 @@ describe("Readerpaging module", function()
|
||||
readerui.onEndOfBook = nil
|
||||
UIManager:quit()
|
||||
end)
|
||||
|
||||
it("should scroll withtout crash backward on the first page", function()
|
||||
local sample_djvu = "spec/front/unit/data/djvu3spec.djvu"
|
||||
local tmp_readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_djvu),
|
||||
}
|
||||
tmp_readerui.paging:onScrollPanRel(-100)
|
||||
end)
|
||||
|
||||
it("should scroll withtout crash forward on the last page", function()
|
||||
local sample_djvu = "spec/front/unit/data/djvu3spec.djvu"
|
||||
local tmp_readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_djvu),
|
||||
}
|
||||
local paging = tmp_readerui.paging
|
||||
paging:onGotoPage(tmp_readerui.document:getPageCount())
|
||||
paging:onScrollPanRel(120)
|
||||
paging:onScrollPanRel(-1)
|
||||
paging:onScrollPanRel(120)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user