|
|
|
@ -51,18 +51,57 @@ describe("Readerrolling module", function()
|
|
|
|
|
assert.are.same(toc:getPreviousChapter(i, 0), rolling.current_page)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
it("should emit EndOfBook event at the end", function()
|
|
|
|
|
rolling:onGotoPage(readerui.document:getPageCount())
|
|
|
|
|
it("should emit EndOfBook event at the end of sample epub", function()
|
|
|
|
|
local called = false
|
|
|
|
|
readerui.onEndOfBook = function()
|
|
|
|
|
called = true
|
|
|
|
|
end
|
|
|
|
|
-- check beginning of the book
|
|
|
|
|
rolling:onGotoPage(1)
|
|
|
|
|
assert.is.falsy(called)
|
|
|
|
|
rolling:onGotoViewRel(-1)
|
|
|
|
|
rolling:onGotoViewRel(-1)
|
|
|
|
|
assert.is.falsy(called)
|
|
|
|
|
-- check end of the book
|
|
|
|
|
rolling:onGotoPage(readerui.document:getPageCount())
|
|
|
|
|
assert.is.falsy(called)
|
|
|
|
|
rolling:onGotoViewRel(1)
|
|
|
|
|
assert.is.truthy(called)
|
|
|
|
|
rolling:onGotoViewRel(1)
|
|
|
|
|
assert.is.truthy(called)
|
|
|
|
|
readerui.onEndOfBook = nil
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("should emit EndOfBook event at the end sample txt", function()
|
|
|
|
|
local sample_txt = "spec/front/unit/data/sample.txt"
|
|
|
|
|
local txt_readerui = ReaderUI:new{
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_txt),
|
|
|
|
|
}
|
|
|
|
|
local called = false
|
|
|
|
|
txt_readerui.onEndOfBook = function()
|
|
|
|
|
called = true
|
|
|
|
|
end
|
|
|
|
|
local txt_rolling = txt_readerui.rolling
|
|
|
|
|
-- check beginning of the book
|
|
|
|
|
txt_rolling:onGotoPage(1)
|
|
|
|
|
assert.is.falsy(called)
|
|
|
|
|
txt_rolling:onGotoViewRel(-1)
|
|
|
|
|
txt_rolling:onGotoViewRel(-1)
|
|
|
|
|
assert.is.falsy(called)
|
|
|
|
|
-- not at the end of the book
|
|
|
|
|
txt_rolling:onGotoPage(3)
|
|
|
|
|
assert.is.falsy(called)
|
|
|
|
|
txt_rolling:onGotoViewRel(1)
|
|
|
|
|
assert.is.falsy(called)
|
|
|
|
|
-- at the end of the book
|
|
|
|
|
txt_rolling:onGotoPage(txt_readerui.document:getPageCount())
|
|
|
|
|
assert.is.falsy(called)
|
|
|
|
|
txt_rolling:onGotoViewRel(1)
|
|
|
|
|
assert.is.truthy(called)
|
|
|
|
|
readerui.onEndOfBook = nil
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
describe("test in landscape screen mode", function()
|
|
|
|
|
it("should go to landscape screen mode", function()
|
|
|
|
|
readerui:handleEvent(Event:new("ChangeScreenMode", "landscape"))
|
|
|
|
@ -110,6 +149,7 @@ describe("Readerrolling module", function()
|
|
|
|
|
readerui.onEndOfBook = nil
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
describe("switching screen mode should not change current page number", function()
|
|
|
|
|
it("for portrait-landscape-portrait switching", function()
|
|
|
|
|
for i = 80, 100, 10 do
|
|
|
|
|