various test/coverage optimization

pull/2222/head
chrox 8 years ago
parent 7e4dc7a3fe
commit 001433e6bc

@ -99,7 +99,7 @@ $(INSTALL_DIR)/koreader/.luacov:
testfront: $(INSTALL_DIR)/koreader/.busted
# sdr files may have unexpected impact on unit testing
rm -rf spec/unit/data/*.sdr
-rm -rf spec/unit/data/*.sdr
cd $(INSTALL_DIR)/koreader && ./luajit $(shell which busted) \
--sort-files \
--no-auto-insulate \
@ -110,8 +110,10 @@ test:
$(MAKE) testfront
coverage: $(INSTALL_DIR)/koreader/.luacov
-rm -rf $(INSTALL_DIR)/koreader/luacov.*.out
cd $(INSTALL_DIR)/koreader && \
./luajit $(shell which busted) -o verbose_print \
--sort-files \
--no-auto-insulate \
--coverage --exclude-tags=nocov
# coverage report summary

@ -78,9 +78,8 @@ Users of Debian and Ubuntu can install the required packages using:
```
sudo apt-get install build-essential git patch wget unzip \
gettext autoconf cmake libtool nasm luarocks \
libssl-dev libffi-dev libsdl2-dev libc6-dev-i386 linux-libc-dev:i386
libssl-dev libffi-dev libsdl2-dev libc6-dev-i386 linux-libc-dev:i386 zlib1g:i386
```
Note that the `linux-libc-dev:i386` package is only necessary for x86_64 machines.
Cross compile toolchains are available for Ubuntu users through these commands:
```
@ -280,8 +279,8 @@ http://ccache.samba.org
[linux-vm]:http://www.howtogeek.com/howto/11287/how-to-run-ubuntu-in-windows-7-with-vmware-player/
[l10n-readme]:https://github.com/koreader/koreader/blob/master/l10n/README.md
[koreader-transifex]:https://www.transifex.com/projects/p/koreader/
[coverage-badge]:https://coveralls.io/repos/koreader/koreader/badge.svg
[coverage-link]:https://coveralls.io/r/koreader/koreader
[coverage-badge]:https://coveralls.io/repos/github/koreader/koreader/badge.svg?branch=master
[coverage-link]:https://coveralls.io/github/koreader/koreader?branch=master
[licence-badge]:http://img.shields.io/badge/licence-AGPL-brightgreen.svg
[gitter-badge]:https://badges.gitter.im/Join%20Chat.svg
[gitter-link]:https://gitter.im/koreader/koreader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

@ -1 +1 @@
Subproject commit a57567246963a561585b53bafed16584afa1703b
Subproject commit cacbaeaeb71645ba302deaba25f80db69ac5e82a

@ -7,16 +7,25 @@ describe("Koptinterface module", function()
Cache = require("cache")
end)
local sample_pdf = "spec/front/unit/data/tall.pdf"
local doc
local tall_pdf = "spec/front/unit/data/tall.pdf"
local complex_pdf = "spec/front/unit/data/sample.pdf"
local paper_pdf = "spec/front/unit/data/paper.pdf"
local doc, complex_doc, paper_doc
before_each(function()
doc = DocumentRegistry:openDocument(sample_pdf)
doc = DocumentRegistry:openDocument(tall_pdf)
complex_doc = DocumentRegistry:openDocument(complex_pdf)
paper_doc = DocumentRegistry:openDocument(paper_pdf)
doc.configurable.text_wrap = 0
complex_doc.configurable.text_wrap = 0
paper_doc.configurable.text_wrap = 0
Cache:clear()
end)
after_each(function()
doc:close()
complex_doc:close()
paper_doc:close()
end)
it("should get auto bbox", function()
@ -56,7 +65,6 @@ describe("Koptinterface module", function()
doc.configurable.text_wrap = 1
local kc = Koptinterface:getCachedContext(doc, 1)
assert.truthy(kc)
doc.configurable.text_wrap = 0
end)
it("should hint reflowed page in background", function()
@ -65,7 +73,6 @@ describe("Koptinterface module", function()
-- and wait for reflowing to complete
local kc = Koptinterface:getCachedContext(doc, 1)
assert.truthy(kc)
doc.configurable.text_wrap = 0
end)
it("should get native text boxes", function()
@ -75,12 +82,69 @@ describe("Koptinterface module", function()
assert.truthy(lines_in_native_page == 60)
end)
it("should get native text boxes from scratch", function()
local kc = Koptinterface:getCachedContext(doc, 1)
local boxes = Koptinterface:getNativeTextBoxesFromScratch(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)
doc.configurable.text_wrap = 0
end)
it("should get reflow text boxes from scratch", function()
doc.configurable.text_wrap = 1
local kc = Koptinterface:getCachedContext(doc, 1)
local boxes = Koptinterface:getReflowedTextBoxesFromScratch(doc, 1)
local lines_in_reflowed_page = #boxes
assert.truthy(lines_in_reflowed_page > 60)
end)
it("should get page block of a two-column page", function()
for i = 0.3, 0.6, 0.3 do
for j = 0.3, 0.6, 0.3 do
local block = Koptinterface:getPageBlock(complex_doc, 34, i, j)
assert.truthy(block.x1 - block.x0 < 0.5)
end
end
end)
it("should get word from native position", function()
local word_boxes = Koptinterface:getWordFromPosition(complex_doc, {
page = 19, x = 400, y = 530,
})
assert.is.same("previous", word_boxes.word)
end)
it("should get word from reflow position", function()
complex_doc.configurable.text_wrap = 1
local kc = Koptinterface:getCachedContext(complex_doc, 19)
local word_boxes = Koptinterface:getWordFromPosition(complex_doc, {
page = 19, x = 320, y = 730,
})
assert.is.same("examples", word_boxes.word)
end)
it("should get link from native position", function()
local link = Koptinterface:getLinkFromPosition(paper_doc, 1, {
x = 140, y = 560,
})
assert.truthy(link)
assert.is.same(20, link.page)
require("dbg"):v("link", link)
end)
it("should get link from reflow position", function()
paper_doc.configurable.text_wrap = 1
local link = Koptinterface:getLinkFromPosition(paper_doc, 1, {
x = 500, y = 480,
})
assert.truthy(link)
assert.is.same(20, link.page)
end)
end)

@ -8,7 +8,7 @@ describe("ReaderLink module", function()
ReaderUI = require("apps/reader/readerui")
UIManager = require("ui/uimanager")
sample_epub = "spec/front/unit/data/leaves.epub"
sample_pdf = "spec/front/unit/data/Adaptively.Scaling.The.Metropolis.Algorithm.Using.Expected.Squared.Jumped.Distance.pdf"
sample_pdf = "spec/front/unit/data/paper.pdf"
end)
it("should jump to links in epub", function()

@ -1 +1 @@
Subproject commit 851fbdd77fc5d8fff6c932d16fd45ab110170ef1
Subproject commit 86eeb0b43d8998d402d203a1ae42d00dbed58037
Loading…
Cancel
Save