mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
fix: read stats crashes pdf/djvu documents
This commit is contained in:
2
base
2
base
Submodule base updated: 9ba8cb68aa...9a2503bacc
@@ -230,7 +230,12 @@ function ReaderFooter:getProgressPercentage()
|
||||
end
|
||||
|
||||
function ReaderFooter:getBookTimeToRead()
|
||||
local current_page = self.view.document:getCurrentPage()
|
||||
local current_page
|
||||
if self.view.document.info.has_pages then
|
||||
current_page = self.ui.paging.current_page
|
||||
else
|
||||
current_page = self.view.document:getCurrentPage()
|
||||
end
|
||||
return self:getDataFromStatistics("TB: ", self.pages - current_page)
|
||||
end
|
||||
|
||||
|
||||
30
spec/unit/readerfooter_spec.lua
Normal file
30
spec/unit/readerfooter_spec.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
require("commonrequire")
|
||||
local DocumentRegistry = require("document/documentregistry")
|
||||
local ReaderUI = require("apps/reader/readerui")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
describe("Readerfooter module", function()
|
||||
it("should setup footer for epub without error", function()
|
||||
local sample_epub = "spec/front/unit/data/juliet.epub"
|
||||
local readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_epub),
|
||||
}
|
||||
readerui.view.footer.settings.all_at_once = true
|
||||
readerui.view.footer:updateFooterPage()
|
||||
timeinfo = readerui.view.footer:getTimeInfo()
|
||||
assert.are.same('B:0% | '..timeinfo..' | => 0 | R:100% | TB: 00:00 | TC: 00:00',
|
||||
readerui.view.footer.progress_text.text)
|
||||
end)
|
||||
|
||||
it("should setup footer for pdf without error", function()
|
||||
local sample_pdf = "spec/front/unit/data/2col.pdf"
|
||||
local readerui = ReaderUI:new{
|
||||
document = DocumentRegistry:openDocument(sample_pdf),
|
||||
}
|
||||
readerui.view.footer.settings.all_at_once = true
|
||||
readerui.view.footer:updateFooterPage()
|
||||
timeinfo = readerui.view.footer:getTimeInfo()
|
||||
assert.are.same('B:0% | '..timeinfo..' | => 1 | R:50% | TB: na | TC: na',
|
||||
readerui.view.footer.progress_text.text)
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user