mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
tests: factorize UI related helpers
This commit is contained in:
committed by
Frans de Jonge
parent
480eb7e142
commit
f1b522acb9
@@ -30,6 +30,8 @@ files["spec/unit/*"].globals = {
|
|||||||
"package",
|
"package",
|
||||||
"disable_plugins",
|
"disable_plugins",
|
||||||
"load_plugin",
|
"load_plugin",
|
||||||
|
"fastforward_ui_events",
|
||||||
|
"screenshot",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- TODO: clean up and enforce max line width (631)
|
-- TODO: clean up and enforce max line width (631)
|
||||||
|
|||||||
@@ -75,3 +75,17 @@ function load_plugin(name)
|
|||||||
end
|
end
|
||||||
assert(false)
|
assert(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function fastforward_ui_events()
|
||||||
|
local UIManager = require("ui/uimanager")
|
||||||
|
-- Fast forward all scheduled tasks.
|
||||||
|
UIManager:shiftScheduledTasksBy(-1e9)
|
||||||
|
-- Fix hang when running tests with our docker base image SDL.
|
||||||
|
UIManager:setInputTimeout(0)
|
||||||
|
-- And run the UI manager's input loop once.
|
||||||
|
UIManager:handleInput()
|
||||||
|
end
|
||||||
|
|
||||||
|
function screenshot(screen, filename)
|
||||||
|
screen:shot(DataStorage:getDataDir() .. "/screenshots/" .. filename)
|
||||||
|
end
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ describe("ReaderBookmark module", function()
|
|||||||
Util.copyFile("spec/front/unit/data/sample.pdf", sample_pdf)
|
Util.copyFile("spec/front/unit/data/sample.pdf", sample_pdf)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function screenshot(filename)
|
|
||||||
Screen:shot(DataStorage:getDataDir() .. "/screenshots/" .. filename)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function highlight_text(readerui, pos0, pos1)
|
local function highlight_text(readerui, pos0, pos1)
|
||||||
readerui.highlight:onHold(nil, { pos = pos0 })
|
readerui.highlight:onHold(nil, { pos = pos0 })
|
||||||
readerui.highlight:onHoldPan(nil, { pos = pos1 })
|
readerui.highlight:onHoldPan(nil, { pos = pos1 })
|
||||||
@@ -79,13 +75,13 @@ describe("ReaderBookmark module", function()
|
|||||||
it("should show dogear after toggling non-bookmarked page", function()
|
it("should show dogear after toggling non-bookmarked page", function()
|
||||||
assert.falsy(readerui.view.dogear_visible)
|
assert.falsy(readerui.view.dogear_visible)
|
||||||
toggler_dogear(readerui)
|
toggler_dogear(readerui)
|
||||||
screenshot("reader_bookmark_dogear_epub.png")
|
screenshot(Screen, "reader_bookmark_dogear_epub.png")
|
||||||
assert.truthy(readerui.view.dogear_visible)
|
assert.truthy(readerui.view.dogear_visible)
|
||||||
end)
|
end)
|
||||||
it("should not show dogear after toggling bookmarked page", function()
|
it("should not show dogear after toggling bookmarked page", function()
|
||||||
assert.truthy(readerui.view.dogear_visible)
|
assert.truthy(readerui.view.dogear_visible)
|
||||||
toggler_dogear(readerui)
|
toggler_dogear(readerui)
|
||||||
screenshot("reader_bookmark_nodogear_epub.png")
|
screenshot(Screen, "reader_bookmark_nodogear_epub.png")
|
||||||
assert.falsy(readerui.view.dogear_visible)
|
assert.falsy(readerui.view.dogear_visible)
|
||||||
end)
|
end)
|
||||||
it("should sort bookmarks with ascending page numbers", function()
|
it("should sort bookmarks with ascending page numbers", function()
|
||||||
@@ -96,7 +92,7 @@ describe("ReaderBookmark module", function()
|
|||||||
end
|
end
|
||||||
readerui.bookmark:onShowBookmark()
|
readerui.bookmark:onShowBookmark()
|
||||||
show_bookmark_menu(readerui)
|
show_bookmark_menu(readerui)
|
||||||
screenshot("reader_bookmark_10marks_epub.png")
|
screenshot(Screen, "reader_bookmark_10marks_epub.png")
|
||||||
assert.are.same(10, #readerui.annotation.annotations)
|
assert.are.same(10, #readerui.annotation.annotations)
|
||||||
assert.are.same(15, readerui.document:getPageFromXPointer(readerui.annotation.annotations[4].page))
|
assert.are.same(15, readerui.document:getPageFromXPointer(readerui.annotation.annotations[4].page))
|
||||||
end)
|
end)
|
||||||
@@ -108,7 +104,7 @@ describe("ReaderBookmark module", function()
|
|||||||
end
|
end
|
||||||
readerui.bookmark:onShowBookmark()
|
readerui.bookmark:onShowBookmark()
|
||||||
show_bookmark_menu(readerui)
|
show_bookmark_menu(readerui)
|
||||||
screenshot("reader_bookmark_5marks_epub.png")
|
screenshot(Screen, "reader_bookmark_5marks_epub.png")
|
||||||
assert.are.same(5, #readerui.annotation.annotations)
|
assert.are.same(5, #readerui.annotation.annotations)
|
||||||
end)
|
end)
|
||||||
it("should add bookmark by highlighting", function()
|
it("should add bookmark by highlighting", function()
|
||||||
@@ -117,7 +113,7 @@ describe("ReaderBookmark module", function()
|
|||||||
Geom:new{ x = 260, y = 90 })
|
Geom:new{ x = 260, y = 90 })
|
||||||
readerui.bookmark:onShowBookmark()
|
readerui.bookmark:onShowBookmark()
|
||||||
show_bookmark_menu(readerui)
|
show_bookmark_menu(readerui)
|
||||||
screenshot("reader_bookmark_6marks_epub.png")
|
screenshot(Screen, "reader_bookmark_6marks_epub.png")
|
||||||
assert.are.same(6, #readerui.annotation.annotations)
|
assert.are.same(6, #readerui.annotation.annotations)
|
||||||
end)
|
end)
|
||||||
it("should get previous bookmark for certain page", function()
|
it("should get previous bookmark for certain page", function()
|
||||||
@@ -154,12 +150,12 @@ describe("ReaderBookmark module", function()
|
|||||||
end)
|
end)
|
||||||
it("should show dogear after toggling non-bookmarked page", function()
|
it("should show dogear after toggling non-bookmarked page", function()
|
||||||
toggler_dogear(readerui)
|
toggler_dogear(readerui)
|
||||||
screenshot("reader_bookmark_dogear_pdf.png")
|
screenshot(Screen, "reader_bookmark_dogear_pdf.png")
|
||||||
assert.truthy(readerui.view.dogear_visible)
|
assert.truthy(readerui.view.dogear_visible)
|
||||||
end)
|
end)
|
||||||
it("should not show dogear after toggling bookmarked page", function()
|
it("should not show dogear after toggling bookmarked page", function()
|
||||||
toggler_dogear(readerui)
|
toggler_dogear(readerui)
|
||||||
screenshot("reader_bookmark_nodogear_pdf.png")
|
screenshot(Screen, "reader_bookmark_nodogear_pdf.png")
|
||||||
assert.truthy(not readerui.view.dogear_visible)
|
assert.truthy(not readerui.view.dogear_visible)
|
||||||
end)
|
end)
|
||||||
it("should sort bookmarks with ascending page numbers", function()
|
it("should sort bookmarks with ascending page numbers", function()
|
||||||
@@ -170,7 +166,7 @@ describe("ReaderBookmark module", function()
|
|||||||
end
|
end
|
||||||
readerui.bookmark:onShowBookmark()
|
readerui.bookmark:onShowBookmark()
|
||||||
show_bookmark_menu(readerui)
|
show_bookmark_menu(readerui)
|
||||||
screenshot("reader_bookmark_10marks_pdf.png")
|
screenshot(Screen, "reader_bookmark_10marks_pdf.png")
|
||||||
assert.are.same(10, #readerui.annotation.annotations)
|
assert.are.same(10, #readerui.annotation.annotations)
|
||||||
assert.are.same(15, readerui.annotation.annotations[4].page)
|
assert.are.same(15, readerui.annotation.annotations[4].page)
|
||||||
end)
|
end)
|
||||||
@@ -182,14 +178,14 @@ describe("ReaderBookmark module", function()
|
|||||||
end
|
end
|
||||||
readerui.bookmark:onShowBookmark()
|
readerui.bookmark:onShowBookmark()
|
||||||
show_bookmark_menu(readerui)
|
show_bookmark_menu(readerui)
|
||||||
screenshot("reader_bookmark_5marks_pdf.png")
|
screenshot(Screen, "reader_bookmark_5marks_pdf.png")
|
||||||
assert.are.same(5, #readerui.annotation.annotations)
|
assert.are.same(5, #readerui.annotation.annotations)
|
||||||
end)
|
end)
|
||||||
it("should add bookmark by highlighting", function()
|
it("should add bookmark by highlighting", function()
|
||||||
highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
||||||
readerui.bookmark:onShowBookmark()
|
readerui.bookmark:onShowBookmark()
|
||||||
show_bookmark_menu(readerui)
|
show_bookmark_menu(readerui)
|
||||||
screenshot("reader_bookmark_6marks_pdf.png")
|
screenshot(Screen, "reader_bookmark_6marks_pdf.png")
|
||||||
assert.are.same(6, #readerui.annotation.annotations)
|
assert.are.same(6, #readerui.annotation.annotations)
|
||||||
end)
|
end)
|
||||||
it("should get previous bookmark for certain page", function()
|
it("should get previous bookmark for certain page", function()
|
||||||
|
|||||||
@@ -1,21 +1,16 @@
|
|||||||
describe("Readerdictionary module", function()
|
describe("Readerdictionary module", function()
|
||||||
local DataStorage, DocumentRegistry, ReaderUI, UIManager, Screen
|
local DocumentRegistry, ReaderUI, UIManager, Screen
|
||||||
|
|
||||||
setup(function()
|
setup(function()
|
||||||
require("commonrequire")
|
require("commonrequire")
|
||||||
disable_plugins()
|
disable_plugins()
|
||||||
load_plugin("japanese.koplugin")
|
load_plugin("japanese.koplugin")
|
||||||
DataStorage = require("datastorage")
|
|
||||||
DocumentRegistry = require("document/documentregistry")
|
DocumentRegistry = require("document/documentregistry")
|
||||||
ReaderUI = require("apps/reader/readerui")
|
ReaderUI = require("apps/reader/readerui")
|
||||||
UIManager = require("ui/uimanager")
|
UIManager = require("ui/uimanager")
|
||||||
Screen = require("device").screen
|
Screen = require("device").screen
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function screenshot(filename)
|
|
||||||
Screen:shot(DataStorage:getDataDir() .. "/screenshots/" .. filename)
|
|
||||||
end
|
|
||||||
|
|
||||||
local readerui, rolling, dictionary
|
local readerui, rolling, dictionary
|
||||||
setup(function()
|
setup(function()
|
||||||
local sample_epub = "spec/front/unit/data/leaves.epub"
|
local sample_epub = "spec/front/unit/data/leaves.epub"
|
||||||
@@ -42,7 +37,7 @@ describe("Readerdictionary module", function()
|
|||||||
ReaderUI.instance = readerui
|
ReaderUI.instance = readerui
|
||||||
end)
|
end)
|
||||||
UIManager:run()
|
UIManager:run()
|
||||||
screenshot("screenshots/reader_dictionary.png")
|
screenshot(Screen, "reader_dictionary.png")
|
||||||
end)
|
end)
|
||||||
it("should attempt to deinflect (Japanese) word on lookup", function()
|
it("should attempt to deinflect (Japanese) word on lookup", function()
|
||||||
UIManager:quit()
|
UIManager:quit()
|
||||||
@@ -72,6 +67,6 @@ describe("Readerdictionary module", function()
|
|||||||
ReaderUI.instance = readerui
|
ReaderUI.instance = readerui
|
||||||
end)
|
end)
|
||||||
UIManager:run()
|
UIManager:run()
|
||||||
screenshot("screenshots/reader_dictionary_japanese.png")
|
screenshot(Screen, "reader_dictionary_japanese.png")
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ describe("Readerhighlight module", function()
|
|||||||
require("ffi/util").copyFile("spec/front/unit/data/sample.pdf", sample_pdf)
|
require("ffi/util").copyFile("spec/front/unit/data/sample.pdf", sample_pdf)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function screenshot(filename)
|
|
||||||
Screen:shot(DataStorage:getDataDir() .. "/screenshots/" .. filename)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function highlight_single_word(readerui, pos0)
|
local function highlight_single_word(readerui, pos0)
|
||||||
local s = spy.on(readerui.languagesupport, "improveWordSelection")
|
local s = spy.on(readerui.languagesupport, "improveWordSelection")
|
||||||
|
|
||||||
@@ -112,7 +108,7 @@ describe("Readerhighlight module", function()
|
|||||||
end)
|
end)
|
||||||
it("should highlight single word", function()
|
it("should highlight single word", function()
|
||||||
highlight_single_word(readerui, Geom:new{ x = 400, y = 70 })
|
highlight_single_word(readerui, Geom:new{ x = 400, y = 70 })
|
||||||
screenshot("reader_highlight_single_word_epub.png")
|
screenshot(Screen, "reader_highlight_single_word_epub.png")
|
||||||
assert.spy(selection_spy).was_called()
|
assert.spy(selection_spy).was_called()
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
@@ -120,7 +116,7 @@ describe("Readerhighlight module", function()
|
|||||||
highlight_text(readerui,
|
highlight_text(readerui,
|
||||||
Geom:new{ x = 400, y = 110 },
|
Geom:new{ x = 400, y = 110 },
|
||||||
Geom:new{ x = 400, y = 170 })
|
Geom:new{ x = 400, y = 170 })
|
||||||
screenshot("reader_highlight_text_epub.png")
|
screenshot(Screen, "reader_highlight_text_epub.png")
|
||||||
assert.spy(selection_spy).was_called()
|
assert.spy(selection_spy).was_called()
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
@@ -129,7 +125,7 @@ describe("Readerhighlight module", function()
|
|||||||
Geom:new{ x = 130, y = 100 },
|
Geom:new{ x = 130, y = 100 },
|
||||||
Geom:new{ x = 350, y = 395 },
|
Geom:new{ x = 350, y = 395 },
|
||||||
Geom:new{ x = 80, y = 265 })
|
Geom:new{ x = 80, y = 265 })
|
||||||
screenshot("reader_tap_highlight_text_epub.png")
|
screenshot(Screen, "reader_tap_highlight_text_epub.png")
|
||||||
assert.spy(selection_spy).was_called()
|
assert.spy(selection_spy).was_called()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -163,16 +159,16 @@ describe("Readerhighlight module", function()
|
|||||||
Geom:new{ x = 260, y = 70 },
|
Geom:new{ x = 260, y = 70 },
|
||||||
Geom:new{ x = 260, y = 150 },
|
Geom:new{ x = 260, y = 150 },
|
||||||
Geom:new{ x = 280, y = 110 })
|
Geom:new{ x = 280, y = 110 })
|
||||||
screenshot("reader_tap_highlight_text_pdf.png")
|
screenshot(Screen, "reader_tap_highlight_text_pdf.png")
|
||||||
end)
|
end)
|
||||||
it("should highlight single word", function()
|
it("should highlight single word", function()
|
||||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||||
screenshot("reader_highlight_single_word_pdf.png")
|
screenshot(Screen, "reader_highlight_single_word_pdf.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
it("should highlight text", function()
|
it("should highlight text", function()
|
||||||
highlight_text(readerui, Geom:new{ x = 260, y = 170 }, Geom:new{ x = 260, y = 250 })
|
highlight_text(readerui, Geom:new{ x = 260, y = 170 }, Geom:new{ x = 260, y = 250 })
|
||||||
screenshot("reader_highlight_text_pdf.png")
|
screenshot(Screen, "reader_highlight_text_pdf.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -188,16 +184,16 @@ describe("Readerhighlight module", function()
|
|||||||
end)
|
end)
|
||||||
it("should respond to tap gesture", function()
|
it("should respond to tap gesture", function()
|
||||||
tap_highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 })
|
tap_highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 })
|
||||||
screenshot("reader_tap_highlight_text_pdf_scanned.png")
|
screenshot(Screen, "reader_tap_highlight_text_pdf_scanned.png")
|
||||||
end)
|
end)
|
||||||
it("should highlight single word", function()
|
it("should highlight single word", function()
|
||||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||||
screenshot("reader_highlight_single_word_pdf_scanned.png")
|
screenshot(Screen, "reader_highlight_single_word_pdf_scanned.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
it("should highlight text", function()
|
it("should highlight text", function()
|
||||||
highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
||||||
screenshot("reader_highlight_text_pdf_scanned.png")
|
screenshot(Screen, "reader_highlight_text_pdf_scanned.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -218,16 +214,16 @@ describe("Readerhighlight module", function()
|
|||||||
end)
|
end)
|
||||||
it("should response on tap gesture", function()
|
it("should response on tap gesture", function()
|
||||||
tap_highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 })
|
tap_highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 })
|
||||||
screenshot("reader_tap_highlight_text_pdf_reflowed.png")
|
screenshot(Screen, "reader_tap_highlight_text_pdf_reflowed.png")
|
||||||
end)
|
end)
|
||||||
it("should highlight single word", function()
|
it("should highlight single word", function()
|
||||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||||
screenshot("reader_highlight_single_word_pdf_reflowed.png")
|
screenshot(Screen, "reader_highlight_single_word_pdf_reflowed.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
it("should highlight text", function()
|
it("should highlight text", function()
|
||||||
highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
||||||
screenshot("reader_highlight_text_pdf_reflowed.png")
|
screenshot(Screen, "reader_highlight_text_pdf_reflowed.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -261,11 +257,11 @@ describe("Readerhighlight module", function()
|
|||||||
end)
|
end)
|
||||||
it("should highlight single word", function()
|
it("should highlight single word", function()
|
||||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||||
screenshot("reader_highlight_single_word_pdf_scroll.png")
|
screenshot(Screen, "reader_highlight_single_word_pdf_scroll.png")
|
||||||
end)
|
end)
|
||||||
it("should highlight text", function()
|
it("should highlight text", function()
|
||||||
highlight_text(readerui, Geom:new{ x = 260, y = 170 }, Geom:new{ x = 260, y = 250 })
|
highlight_text(readerui, Geom:new{ x = 260, y = 170 }, Geom:new{ x = 260, y = 250 })
|
||||||
screenshot("reader_highlight_text_pdf_scroll.png")
|
screenshot(Screen, "reader_highlight_text_pdf_scroll.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
it("should response on tap gesture", function()
|
it("should response on tap gesture", function()
|
||||||
@@ -273,7 +269,7 @@ describe("Readerhighlight module", function()
|
|||||||
Geom:new{ x = 260, y = 70 },
|
Geom:new{ x = 260, y = 70 },
|
||||||
Geom:new{ x = 260, y = 150 },
|
Geom:new{ x = 260, y = 150 },
|
||||||
Geom:new{ x = 280, y = 110 })
|
Geom:new{ x = 280, y = 110 })
|
||||||
screenshot("reader_tap_highlight_text_pdf_scroll.png")
|
screenshot(Screen, "reader_tap_highlight_text_pdf_scroll.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -290,17 +286,17 @@ describe("Readerhighlight module", function()
|
|||||||
end)
|
end)
|
||||||
it("should highlight single word", function()
|
it("should highlight single word", function()
|
||||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||||
screenshot("reader_highlight_single_word_pdf_scanned_scroll.png")
|
screenshot(Screen, "reader_highlight_single_word_pdf_scanned_scroll.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
it("should highlight text", function()
|
it("should highlight text", function()
|
||||||
highlight_text(readerui, Geom:new{x = 192, y = 186}, Geom:new{x = 280, y = 186})
|
highlight_text(readerui, Geom:new{x = 192, y = 186}, Geom:new{x = 280, y = 186})
|
||||||
screenshot("reader_highlight_text_pdf_scanned_scroll.png")
|
screenshot(Screen, "reader_highlight_text_pdf_scanned_scroll.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
it("should response on tap gesture", function()
|
it("should response on tap gesture", function()
|
||||||
tap_highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 })
|
tap_highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 })
|
||||||
screenshot("reader_tap_highlight_text_pdf_scanned_scroll.png")
|
screenshot(Screen, "reader_tap_highlight_text_pdf_scanned_scroll.png")
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
describe("for reflowed page", function()
|
describe("for reflowed page", function()
|
||||||
@@ -320,17 +316,17 @@ describe("Readerhighlight module", function()
|
|||||||
end)
|
end)
|
||||||
it("should highlight single word", function()
|
it("should highlight single word", function()
|
||||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||||
screenshot("reader_highlight_single_word_pdf_reflowed_scroll.png")
|
screenshot(Screen, "reader_highlight_single_word_pdf_reflowed_scroll.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
it("should highlight text", function()
|
it("should highlight text", function()
|
||||||
highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
||||||
screenshot("reader_highlight_text_pdf_reflowed_scroll.png")
|
screenshot(Screen, "reader_highlight_text_pdf_reflowed_scroll.png")
|
||||||
assert.truthy(#readerui.annotation.annotations == 1)
|
assert.truthy(#readerui.annotation.annotations == 1)
|
||||||
end)
|
end)
|
||||||
it("should response on tap gesture", function()
|
it("should response on tap gesture", function()
|
||||||
tap_highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 })
|
tap_highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 })
|
||||||
screenshot("reader_tap_highlight_text_pdf_reflowed_scroll.png")
|
screenshot(Screen, "reader_tap_highlight_text_pdf_reflowed_scroll.png")
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
describe("ReaderLink module", function()
|
describe("ReaderLink module", function()
|
||||||
local DocumentRegistry, ReaderUI, UIManager, sample_epub, sample_pdf, Event, Screen
|
local DocumentRegistry, ReaderUI, sample_epub, sample_pdf, Event, Screen
|
||||||
|
|
||||||
setup(function()
|
setup(function()
|
||||||
require("commonrequire")
|
require("commonrequire")
|
||||||
@@ -8,7 +8,6 @@ describe("ReaderLink module", function()
|
|||||||
DocumentRegistry = require("document/documentregistry")
|
DocumentRegistry = require("document/documentregistry")
|
||||||
Event = require("ui/event")
|
Event = require("ui/event")
|
||||||
ReaderUI = require("apps/reader/readerui")
|
ReaderUI = require("apps/reader/readerui")
|
||||||
UIManager = require("ui/uimanager")
|
|
||||||
Screen = require("device").screen
|
Screen = require("device").screen
|
||||||
sample_epub = "spec/front/unit/data/leaves.epub"
|
sample_epub = "spec/front/unit/data/leaves.epub"
|
||||||
sample_pdf = "spec/front/unit/data/paper.pdf"
|
sample_pdf = "spec/front/unit/data/paper.pdf"
|
||||||
@@ -16,18 +15,10 @@ describe("ReaderLink module", function()
|
|||||||
|
|
||||||
local readerui
|
local readerui
|
||||||
|
|
||||||
local function fastforward_ui_events()
|
|
||||||
-- Fast forward all scheduled tasks.
|
|
||||||
UIManager:shiftScheduledTasksBy(-1e9)
|
|
||||||
UIManager:run()
|
|
||||||
end
|
|
||||||
|
|
||||||
after_each(function()
|
after_each(function()
|
||||||
readerui:closeDocument()
|
readerui:closeDocument()
|
||||||
readerui:onClose()
|
readerui:onClose()
|
||||||
readerui = nil
|
readerui = nil
|
||||||
UIManager:quit()
|
|
||||||
UIManager._exit_code = nil
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe("with epub", function()
|
describe("with epub", function()
|
||||||
|
|||||||
Reference in New Issue
Block a user