mirror of https://github.com/koreader/koreader
Merge pull request #1667 from chrox/fixes_for_stable_release
add support for password protected zip/cbz documentspull/1671/head v2015.10.08-nightly
commit
d93f8a743b
@ -1 +1 @@
|
||||
Subproject commit d0bed73cd630aa7f304cd7447eea8abfd3500aec
|
||||
Subproject commit 05b04b0a20c3cc9c9969537f805e378a530c079a
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"policy_groups": [
|
||||
"networking"
|
||||
],
|
||||
"read_path": [
|
||||
"@{HOME}/",
|
||||
"/media/*/*/[Dd][Oo][Cc][Uu][Mm][Ee][Nn][Tt][Ss]/",
|
||||
"@{PROC}/*/mounts",
|
||||
"/dev/disk/by-label/"
|
||||
],
|
||||
"write_path": [
|
||||
"@{HOME}/"
|
||||
],
|
||||
"policy_version": 1.2
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
require("commonrequire")
|
||||
local DocumentRegistry = require("document/documentregistry")
|
||||
local Koptinterface = require("document/koptinterface")
|
||||
local Cache = require("cache")
|
||||
local DEBUG = require("dbg")
|
||||
DEBUG:turnOn()
|
||||
|
||||
describe("Koptinterface module", function()
|
||||
local sample_pdf = "spec/front/unit/data/tall.pdf"
|
||||
local doc
|
||||
|
||||
before_each(function()
|
||||
doc = DocumentRegistry:openDocument(sample_pdf)
|
||||
Cache:clear()
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
doc:close()
|
||||
end)
|
||||
|
||||
it("should get auto bbox", function()
|
||||
local auto_bbox = Koptinterface:getAutoBBox(doc, 1)
|
||||
assertAlmostEquals(22, auto_bbox.x0, 0.5)
|
||||
assertAlmostEquals(38, auto_bbox.y0, 0.5)
|
||||
assertAlmostEquals(548, auto_bbox.x1, 0.5)
|
||||
assertAlmostEquals(1387, auto_bbox.y1, 0.5)
|
||||
end)
|
||||
|
||||
it("should get semi auto bbox", function()
|
||||
local semiauto_bbox = Koptinterface:getSemiAutoBBox(doc, 1)
|
||||
local page_bbox = doc:getPageBBox(1)
|
||||
doc.bbox[1] = {
|
||||
x0 = page_bbox.x0 + 10,
|
||||
y0 = page_bbox.y0 + 10,
|
||||
x1 = page_bbox.x1 - 10,
|
||||
y1 = page_bbox.y1 - 10,
|
||||
}
|
||||
|
||||
local bbox = Koptinterface:getSemiAutoBBox(doc, 1)
|
||||
assertNotAlmostEquals(semiauto_bbox.x0, bbox.x0, 0.5)
|
||||
assertNotAlmostEquals(semiauto_bbox.y0, bbox.y0, 0.5)
|
||||
assertNotAlmostEquals(semiauto_bbox.x1, bbox.x1, 0.5)
|
||||
assertNotAlmostEquals(semiauto_bbox.y1, bbox.y1, 0.5)
|
||||
end)
|
||||
|
||||
it("should render optimized page to de-watermark", function()
|
||||
local page_dimen = doc:getPageDimensions(1, 1.0, 0)
|
||||
local tile = Koptinterface:renderOptimizedPage(doc, 1, nil,
|
||||
1.0, 0, 0)
|
||||
assert.truthy(tile)
|
||||
assert.are.same(page_dimen, tile.excerpt)
|
||||
end)
|
||||
|
||||
it("should reflow page in foreground", function()
|
||||
doc.configurable.text_wrap = 1
|
||||
local kc = Koptinterface:getCachedContext(doc, 1)
|
||||
assert.truthy(kc)
|
||||
end)
|
||||
|
||||
it("should hint reflowed page in background", function()
|
||||
doc.configurable.text_wrap = 1
|
||||
Koptinterface:hintReflowedPage(doc, 1, 1.0, 0, 1.0, 0)
|
||||
-- and wait for reflowing to complete
|
||||
local kc = Koptinterface:getCachedContext(doc, 1)
|
||||
assert.truthy(kc)
|
||||
end)
|
||||
|
||||
it("should get native text boxes", function()
|
||||
local kc = Koptinterface:getCachedContext(doc, 1)
|
||||
local boxes = Koptinterface:getNativeTextBoxes(doc, 1)
|
||||
local lines_in_native_page = #boxes
|
||||
assert.truthy(lines_in_native_page == 60)
|
||||
end)
|
||||
|
||||
it("should get reflow text boxes", function()
|
||||
doc.configurable.text_wrap = 1
|
||||
local kc = Koptinterface:getCachedContext(doc, 1)
|
||||
local boxes = Koptinterface:getReflowedTextBoxes(doc, 1)
|
||||
local lines_in_reflowed_page = #boxes
|
||||
assert.truthy(lines_in_reflowed_page > 60)
|
||||
end)
|
||||
|
||||
end)
|
@ -0,0 +1,22 @@
|
||||
-- from Mashape/kong/spec/busted-print.lua
|
||||
local ansicolors = require 'ansicolors'
|
||||
|
||||
return function(options)
|
||||
local handler = require 'busted.outputHandlers.utfTerminal'(options)
|
||||
|
||||
handler.fileStart = function(file)
|
||||
io.write('\n' .. ansicolors('%{cyan}' .. file.name) .. ':')
|
||||
end
|
||||
|
||||
handler.testStart = function(element, parent, status, debug)
|
||||
io.write('\n ' .. handler.getFullName(element) .. ' ... ')
|
||||
io.flush()
|
||||
end
|
||||
|
||||
local busted = require 'busted'
|
||||
|
||||
busted.subscribe({ 'file', 'start' }, handler.fileStart)
|
||||
busted.subscribe({ 'test', 'start' }, handler.testStart)
|
||||
|
||||
return handler
|
||||
end
|
Loading…
Reference in New Issue