mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Bump crengine:
- Ensure text decoration (underline) is continued over word gaps
- Invalidate TOC page numbers on rendering change
- Ensure reproducible cache files when same rendering settings
- LVBlockWriteStream: workaround to exclude fatal error
- Use utf8proc for string uppercase/lowercase/capitalize
Bump base:
Thirdparty: adds utf8proc 2.3.0 (libutf8proc.so.2)
For use by crengine, for now mostly for more complete and
accurate text-transform: uppercase/lowercase/capitalize.
Also revert test tweak (in 27ddd6f) to workaround an issue with
cre cache that should be solved by this crengine bump.
102 lines
3.9 KiB
Lua
102 lines
3.9 KiB
Lua
describe("Readertoc module", function()
|
|
local DocumentRegistry, ReaderUI, DEBUG
|
|
local readerui, toc, toc_max_depth, title
|
|
|
|
setup(function()
|
|
require("commonrequire")
|
|
DocumentRegistry = require("document/documentregistry")
|
|
ReaderUI = require("apps/reader/readerui")
|
|
DEBUG = require("dbg")
|
|
|
|
local sample_epub = "spec/front/unit/data/juliet.epub"
|
|
readerui = ReaderUI:new{
|
|
document = DocumentRegistry:openDocument(sample_epub),
|
|
}
|
|
-- reset book to first page
|
|
readerui.rolling:onGotoPage(0)
|
|
toc = readerui.toc
|
|
end)
|
|
|
|
it("should get max toc depth", function()
|
|
toc_max_depth = toc:getMaxDepth()
|
|
assert.are.same(2, toc_max_depth)
|
|
end)
|
|
it("should get toc title from page", function()
|
|
title = toc:getTocTitleByPage(60)
|
|
DEBUG("toc", toc.toc)
|
|
assert.is.equal("SCENE V. A hall in Capulet's house.", title)
|
|
title = toc:getTocTitleByPage(187)
|
|
assert.is.equal("SCENE I. Friar Laurence's cell.", title)
|
|
end)
|
|
describe("getTocTicks API", function()
|
|
local ticks_level_0 = nil
|
|
it("should get ticks of level 0", function()
|
|
ticks_level_0 = toc:getTocTicks(0)
|
|
--DEBUG("ticks", ticks_level_0)
|
|
assert.are.same(28, #ticks_level_0)
|
|
end)
|
|
local ticks_level_1 = nil
|
|
it("should get ticks of level 1", function()
|
|
ticks_level_1 = toc:getTocTicks(1)
|
|
assert.are.same(7, #ticks_level_1)
|
|
end)
|
|
local ticks_level_2 = nil
|
|
it("should get ticks of level 2", function()
|
|
ticks_level_2 = toc:getTocTicks(2)
|
|
assert.are.same(26, #ticks_level_2)
|
|
end)
|
|
local ticks_level_m1 = nil
|
|
it("should get ticks of level -1", function()
|
|
ticks_level_m1 = toc:getTocTicks(-1)
|
|
assert.are.same(26, #ticks_level_m1)
|
|
end)
|
|
it("should get the same ticks of level -1 and level 2", function()
|
|
if toc_max_depth == 2 then
|
|
assert.are.same(ticks_level_2, ticks_level_m1)
|
|
end
|
|
end)
|
|
end)
|
|
it("should get page of next chapter", function()
|
|
assert.truthy(toc:getNextChapter(10, 0) > 10)
|
|
assert.truthy(toc:getNextChapter(100, 0) > 100)
|
|
assert.are.same(nil, toc:getNextChapter(290, 0))
|
|
end)
|
|
it("should get page of previous chapter", function()
|
|
assert.truthy(toc:getPreviousChapter(10, 0) < 10)
|
|
assert.truthy(toc:getPreviousChapter(100, 0) < 100)
|
|
assert.truthy(toc:getPreviousChapter(200, 0) < 200)
|
|
end)
|
|
it("should get page left of chapter", function()
|
|
assert.truthy(toc:getChapterPagesLeft(10, 0) > 10)
|
|
assert.truthy(toc:getChapterPagesLeft(97, 0) > 10)
|
|
assert.are.same(nil, toc:getChapterPagesLeft(290, 0))
|
|
end)
|
|
it("should get page done of chapter", function()
|
|
assert.truthy(toc:getChapterPagesDone(12, 0) < 5)
|
|
assert.truthy(toc:getChapterPagesDone(95, 0) < 5)
|
|
assert.truthy(toc:getChapterPagesDone(290, 0) > 10)
|
|
end)
|
|
describe("collasible TOC", function()
|
|
it("should collapse the secondary toc nodes by default", function()
|
|
toc:onShowToc()
|
|
assert.are.same(7, #toc.collapsed_toc)
|
|
end)
|
|
it("should not expand toc nodes that have no child nodes", function()
|
|
toc:expandToc(2)
|
|
assert.are.same(7, #toc.collapsed_toc)
|
|
end)
|
|
it("should expand toc nodes that have child nodes", function()
|
|
toc:expandToc(3)
|
|
assert.are.same(13, #toc.collapsed_toc)
|
|
toc:expandToc(18)
|
|
assert.are.same(18, #toc.collapsed_toc)
|
|
end)
|
|
it("should collapse toc nodes that have been expanded", function()
|
|
toc:collapseToc(3)
|
|
assert.are.same(12, #toc.collapsed_toc)
|
|
toc:collapseToc(18)
|
|
assert.are.same(7, #toc.collapsed_toc)
|
|
end)
|
|
end)
|
|
end)
|