mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
various test/coverage optimization
This commit is contained in:
4
Makefile
4
Makefile
@@ -99,7 +99,7 @@ $(INSTALL_DIR)/koreader/.luacov:
|
|||||||
|
|
||||||
testfront: $(INSTALL_DIR)/koreader/.busted
|
testfront: $(INSTALL_DIR)/koreader/.busted
|
||||||
# sdr files may have unexpected impact on unit testing
|
# 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) \
|
cd $(INSTALL_DIR)/koreader && ./luajit $(shell which busted) \
|
||||||
--sort-files \
|
--sort-files \
|
||||||
--no-auto-insulate \
|
--no-auto-insulate \
|
||||||
@@ -110,8 +110,10 @@ test:
|
|||||||
$(MAKE) testfront
|
$(MAKE) testfront
|
||||||
|
|
||||||
coverage: $(INSTALL_DIR)/koreader/.luacov
|
coverage: $(INSTALL_DIR)/koreader/.luacov
|
||||||
|
-rm -rf $(INSTALL_DIR)/koreader/luacov.*.out
|
||||||
cd $(INSTALL_DIR)/koreader && \
|
cd $(INSTALL_DIR)/koreader && \
|
||||||
./luajit $(shell which busted) -o verbose_print \
|
./luajit $(shell which busted) -o verbose_print \
|
||||||
|
--sort-files \
|
||||||
--no-auto-insulate \
|
--no-auto-insulate \
|
||||||
--coverage --exclude-tags=nocov
|
--coverage --exclude-tags=nocov
|
||||||
# coverage report summary
|
# 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 \
|
sudo apt-get install build-essential git patch wget unzip \
|
||||||
gettext autoconf cmake libtool nasm luarocks \
|
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:
|
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/
|
[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
|
[l10n-readme]:https://github.com/koreader/koreader/blob/master/l10n/README.md
|
||||||
[koreader-transifex]:https://www.transifex.com/projects/p/koreader/
|
[koreader-transifex]:https://www.transifex.com/projects/p/koreader/
|
||||||
[coverage-badge]:https://coveralls.io/repos/koreader/koreader/badge.svg
|
[coverage-badge]:https://coveralls.io/repos/github/koreader/koreader/badge.svg?branch=master
|
||||||
[coverage-link]:https://coveralls.io/r/koreader/koreader
|
[coverage-link]:https://coveralls.io/github/koreader/koreader?branch=master
|
||||||
[licence-badge]:http://img.shields.io/badge/licence-AGPL-brightgreen.svg
|
[licence-badge]:http://img.shields.io/badge/licence-AGPL-brightgreen.svg
|
||||||
[gitter-badge]:https://badges.gitter.im/Join%20Chat.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
|
[gitter-link]:https://gitter.im/koreader/koreader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
||||||
|
|||||||
2
base
2
base
Submodule base updated: a575672469...cacbaeaeb7
@@ -7,16 +7,25 @@ describe("Koptinterface module", function()
|
|||||||
Cache = require("cache")
|
Cache = require("cache")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local sample_pdf = "spec/front/unit/data/tall.pdf"
|
local tall_pdf = "spec/front/unit/data/tall.pdf"
|
||||||
local doc
|
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()
|
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()
|
Cache:clear()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
doc:close()
|
doc:close()
|
||||||
|
complex_doc:close()
|
||||||
|
paper_doc:close()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("should get auto bbox", function()
|
it("should get auto bbox", function()
|
||||||
@@ -56,7 +65,6 @@ describe("Koptinterface module", function()
|
|||||||
doc.configurable.text_wrap = 1
|
doc.configurable.text_wrap = 1
|
||||||
local kc = Koptinterface:getCachedContext(doc, 1)
|
local kc = Koptinterface:getCachedContext(doc, 1)
|
||||||
assert.truthy(kc)
|
assert.truthy(kc)
|
||||||
doc.configurable.text_wrap = 0
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("should hint reflowed page in background", function()
|
it("should hint reflowed page in background", function()
|
||||||
@@ -65,7 +73,6 @@ describe("Koptinterface module", function()
|
|||||||
-- and wait for reflowing to complete
|
-- and wait for reflowing to complete
|
||||||
local kc = Koptinterface:getCachedContext(doc, 1)
|
local kc = Koptinterface:getCachedContext(doc, 1)
|
||||||
assert.truthy(kc)
|
assert.truthy(kc)
|
||||||
doc.configurable.text_wrap = 0
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("should get native text boxes", function()
|
it("should get native text boxes", function()
|
||||||
@@ -75,12 +82,69 @@ describe("Koptinterface module", function()
|
|||||||
assert.truthy(lines_in_native_page == 60)
|
assert.truthy(lines_in_native_page == 60)
|
||||||
end)
|
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()
|
it("should get reflow text boxes", function()
|
||||||
doc.configurable.text_wrap = 1
|
doc.configurable.text_wrap = 1
|
||||||
local kc = Koptinterface:getCachedContext(doc, 1)
|
local kc = Koptinterface:getCachedContext(doc, 1)
|
||||||
local boxes = Koptinterface:getReflowedTextBoxes(doc, 1)
|
local boxes = Koptinterface:getReflowedTextBoxes(doc, 1)
|
||||||
local lines_in_reflowed_page = #boxes
|
local lines_in_reflowed_page = #boxes
|
||||||
assert.truthy(lines_in_reflowed_page > 60)
|
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)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ describe("ReaderLink module", function()
|
|||||||
ReaderUI = require("apps/reader/readerui")
|
ReaderUI = require("apps/reader/readerui")
|
||||||
UIManager = require("ui/uimanager")
|
UIManager = require("ui/uimanager")
|
||||||
sample_epub = "spec/front/unit/data/leaves.epub"
|
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)
|
end)
|
||||||
|
|
||||||
it("should jump to links in epub", function()
|
it("should jump to links in epub", function()
|
||||||
|
|||||||
2
test
2
test
Submodule test updated: 851fbdd77f...86eeb0b43d
Reference in New Issue
Block a user