|
|
|
@ -8,6 +8,22 @@ local purgeDir = require("ffi/util").purgeDir
|
|
|
|
|
local Screen = require("device").screen
|
|
|
|
|
|
|
|
|
|
describe("Readerfooter module", function()
|
|
|
|
|
before_each(function()
|
|
|
|
|
G_reader_settings:saveSetting("footer", {
|
|
|
|
|
disabled = false,
|
|
|
|
|
all_at_once = true,
|
|
|
|
|
progress_bar = true,
|
|
|
|
|
toc_markers = true,
|
|
|
|
|
battery = true,
|
|
|
|
|
time = true,
|
|
|
|
|
page_progress = true,
|
|
|
|
|
pages_left = true,
|
|
|
|
|
percentage = true,
|
|
|
|
|
book_time_to_read = true,
|
|
|
|
|
chapter_time_to_read = true,
|
|
|
|
|
})
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("should setup footer for epub without error", function()
|
|
|
|
|
local sample_epub = "spec/front/unit/data/juliet.epub"
|
|
|
|
|
purgeDir(DocSettings:getSidecarDir(sample_epub))
|
|
|
|
@ -16,8 +32,6 @@ describe("Readerfooter module", function()
|
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_epub),
|
|
|
|
|
}
|
|
|
|
|
readerui.view.footer.settings.page_progress = true
|
|
|
|
|
readerui.view.footer.settings.all_at_once = true
|
|
|
|
|
readerui.view.footer:updateFooter()
|
|
|
|
|
timeinfo = readerui.view.footer:getTimeInfo()
|
|
|
|
|
-- stats has not been initialized here, so we get na TB and TC
|
|
|
|
@ -33,8 +47,6 @@ describe("Readerfooter module", function()
|
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
}
|
|
|
|
|
readerui.view.footer.settings.page_progress = true
|
|
|
|
|
readerui.view.footer.settings.all_at_once = true
|
|
|
|
|
readerui.view.footer:updateFooter()
|
|
|
|
|
timeinfo = readerui.view.footer:getTimeInfo()
|
|
|
|
|
assert.are.same('B:0% | '..timeinfo..' | 1 / 2 | => 1 | R:50% | TB: na | TC: na',
|
|
|
|
@ -50,8 +62,6 @@ describe("Readerfooter module", function()
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
}
|
|
|
|
|
local footer = readerui.view.footer
|
|
|
|
|
footer.settings.page_progress = true
|
|
|
|
|
footer.settings.all_at_once = true
|
|
|
|
|
footer:resetLayout()
|
|
|
|
|
footer:updateFooter()
|
|
|
|
|
timeinfo = readerui.view.footer:getTimeInfo()
|
|
|
|
@ -92,15 +102,22 @@ describe("Readerfooter module", function()
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
}
|
|
|
|
|
local footer = readerui.view.footer
|
|
|
|
|
footer.settings.page_progress = true
|
|
|
|
|
footer.settings.all_at_once = true
|
|
|
|
|
footer:resetLayout()
|
|
|
|
|
assert.are.same(529, footer.progress_bar.width)
|
|
|
|
|
local horizontal_margin = Screen:scaleBySize(10)*2
|
|
|
|
|
footer:updateFooter()
|
|
|
|
|
assert.is.same(357, footer.text_width)
|
|
|
|
|
assert.is.same(600, footer.progress_bar.width
|
|
|
|
|
+ footer.text_width
|
|
|
|
|
+ horizontal_margin)
|
|
|
|
|
assert.is.same(223, footer.progress_bar.width)
|
|
|
|
|
|
|
|
|
|
local old_screen_getwidth = Screen.getWidth
|
|
|
|
|
Screen.getWidth = function() return 900 end
|
|
|
|
|
footer:resetLayout()
|
|
|
|
|
assert.are.same(829, footer.progress_bar.width)
|
|
|
|
|
assert.is.same(357, footer.text_width)
|
|
|
|
|
assert.is.same(900, footer.progress_bar.width
|
|
|
|
|
+ footer.text_width
|
|
|
|
|
+ horizontal_margin)
|
|
|
|
|
assert.is.same(523, footer.progress_bar.width)
|
|
|
|
|
Screen.getWidth = old_screen_getwidth
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
@ -113,8 +130,6 @@ describe("Readerfooter module", function()
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_epub),
|
|
|
|
|
}
|
|
|
|
|
local footer = readerui.view.footer
|
|
|
|
|
footer.settings.page_progress = true
|
|
|
|
|
footer.settings.all_at_once = true
|
|
|
|
|
readerui.view.document.info.number_of_pages = 5000
|
|
|
|
|
footer:onPageUpdate(1)
|
|
|
|
|
assert.are.same(207, footer.progress_bar.width)
|
|
|
|
@ -133,6 +148,10 @@ describe("Readerfooter module", function()
|
|
|
|
|
UIManager:quit()
|
|
|
|
|
|
|
|
|
|
assert.are.same({}, UIManager._task_queue)
|
|
|
|
|
G_reader_settings:saveSetting("footer", {
|
|
|
|
|
page_progress = true,
|
|
|
|
|
auto_refresh_time = true,
|
|
|
|
|
})
|
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_epub),
|
|
|
|
|
}
|
|
|
|
@ -154,4 +173,29 @@ describe("Readerfooter module", function()
|
|
|
|
|
end
|
|
|
|
|
assert.is.same(0, found)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("should not schedule auto refresh time task if footer is disabled", function()
|
|
|
|
|
local sample_epub = "spec/front/unit/data/juliet.epub"
|
|
|
|
|
purgeDir(DocSettings:getSidecarDir(sample_epub))
|
|
|
|
|
os.remove(DocSettings:getHistoryPath(sample_epub))
|
|
|
|
|
UIManager:quit()
|
|
|
|
|
|
|
|
|
|
assert.are.same({}, UIManager._task_queue)
|
|
|
|
|
G_reader_settings:saveSetting("footer", {
|
|
|
|
|
disabled = true,
|
|
|
|
|
page_progress = true,
|
|
|
|
|
auto_refresh_time = true,
|
|
|
|
|
})
|
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_epub),
|
|
|
|
|
}
|
|
|
|
|
local footer = readerui.view.footer
|
|
|
|
|
local found = 0
|
|
|
|
|
for _,task in ipairs(UIManager._task_queue) do
|
|
|
|
|
if task.action == footer.autoRefreshTime then
|
|
|
|
|
found = found + 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
assert.is.same(0, found)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|