readerrolling(fix): do not emit PageUpdate event until document is ready

This commit is contained in:
Qingping Hou
2016-10-04 10:38:32 -07:00
parent c998120a78
commit abbb72b6d3
4 changed files with 32 additions and 11 deletions

View File

@@ -182,4 +182,20 @@ describe("Readerrolling module", function()
end
end)
end)
describe("test initialization", function()
it("should emit PageUpdate event after book is rendered", function()
local ReaderView = require("apps/reader/modules/readerview")
local saved_handler = ReaderView.onPageUpdate
ReaderView.onPageUpdate = function(_self)
assert.are.same(7, _self.ui.document:getPageCount())
end
local test_book = "spec/front/unit/data/sample.txt"
require("docsettings"):open(test_book):purge()
ReaderUI:new{
document = DocumentRegistry:openDocument(test_book),
}
ReaderView.onPageUpdate = saved_handler
end)
end)
end)