|
|
@ -12,7 +12,8 @@ describe("Readerhighlight module", function()
|
|
|
|
UIManager = require("ui/uimanager")
|
|
|
|
UIManager = require("ui/uimanager")
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
local function highlight_single_word(readerui, pos0)
|
|
|
|
local function highlight_single_word(pos0)
|
|
|
|
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
local s = spy.on(readerui.languagesupport, "improveWordSelection")
|
|
|
|
local s = spy.on(readerui.languagesupport, "improveWordSelection")
|
|
|
|
|
|
|
|
|
|
|
|
readerui.highlight:onHold(nil, { pos = pos0 })
|
|
|
|
readerui.highlight:onHold(nil, { pos = pos0 })
|
|
|
@ -28,13 +29,12 @@ describe("Readerhighlight module", function()
|
|
|
|
UIManager:scheduleIn(1, function()
|
|
|
|
UIManager:scheduleIn(1, function()
|
|
|
|
UIManager:close(readerui.dictionary.dict_window)
|
|
|
|
UIManager:close(readerui.dictionary.dict_window)
|
|
|
|
UIManager:close(readerui)
|
|
|
|
UIManager:close(readerui)
|
|
|
|
-- We haven't torn it down yet
|
|
|
|
|
|
|
|
ReaderUI.instance = readerui
|
|
|
|
|
|
|
|
UIManager:quit()
|
|
|
|
UIManager:quit()
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
UIManager:run()
|
|
|
|
UIManager:run()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local function highlight_text(readerui, pos0, pos1)
|
|
|
|
local function highlight_text(pos0, pos1)
|
|
|
|
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
readerui.highlight:onHold(nil, { pos = pos0 })
|
|
|
|
readerui.highlight:onHold(nil, { pos = pos0 })
|
|
|
|
readerui.highlight:onHoldPan(nil, { pos = pos1 })
|
|
|
|
readerui.highlight:onHoldPan(nil, { pos = pos1 })
|
|
|
|
local next_slot
|
|
|
|
local next_slot
|
|
|
@ -54,13 +54,16 @@ describe("Readerhighlight module", function()
|
|
|
|
UIManager:scheduleIn(1, function()
|
|
|
|
UIManager:scheduleIn(1, function()
|
|
|
|
UIManager:close(readerui.highlight.highlight_dialog)
|
|
|
|
UIManager:close(readerui.highlight.highlight_dialog)
|
|
|
|
UIManager:close(readerui)
|
|
|
|
UIManager:close(readerui)
|
|
|
|
-- We haven't torn it down yet
|
|
|
|
|
|
|
|
ReaderUI.instance = readerui
|
|
|
|
|
|
|
|
UIManager:quit()
|
|
|
|
UIManager:quit()
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
UIManager:run()
|
|
|
|
UIManager:run()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local function tap_highlight_text(readerui, pos0, pos1, pos2)
|
|
|
|
local function tap_highlight_text(pos0, pos1, pos2)
|
|
|
|
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
|
|
|
|
-- Check the actual call chain, instead of relying on the actual internal highlight_dialog object directly...
|
|
|
|
|
|
|
|
-- Besides being less nutty, this will work for overlapping highlights...
|
|
|
|
|
|
|
|
local s = spy.on(readerui.highlight, "showChooseHighlightDialog")
|
|
|
|
|
|
|
|
|
|
|
|
readerui.highlight:onHold(nil, { pos = pos0 })
|
|
|
|
readerui.highlight:onHold(nil, { pos = pos0 })
|
|
|
|
readerui.highlight:onHoldPan(nil, { pos = pos1 })
|
|
|
|
readerui.highlight:onHoldPan(nil, { pos = pos1 })
|
|
|
|
readerui.highlight:onHoldRelease()
|
|
|
|
readerui.highlight:onHoldRelease()
|
|
|
@ -68,12 +71,15 @@ describe("Readerhighlight module", function()
|
|
|
|
readerui.highlight:clear()
|
|
|
|
readerui.highlight:clear()
|
|
|
|
UIManager:close(readerui.highlight.highlight_dialog)
|
|
|
|
UIManager:close(readerui.highlight.highlight_dialog)
|
|
|
|
readerui.highlight:onTap(nil, { pos = pos2 })
|
|
|
|
readerui.highlight:onTap(nil, { pos = pos2 })
|
|
|
|
assert.truthy(readerui.highlight.edit_highlight_dialog)
|
|
|
|
if not readerui.highlight.edit_highlight_dialog then
|
|
|
|
|
|
|
|
-- Take an up-to-date screenshot if this step failed, it's probably because we found overlapping HLs
|
|
|
|
|
|
|
|
UIManager:forceRePaint()
|
|
|
|
|
|
|
|
Screen:shot("screenshots/tap_highlight_text_overlapping_highlights.png")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
assert.spy(s).was_called()
|
|
|
|
UIManager:nextTick(function()
|
|
|
|
UIManager:nextTick(function()
|
|
|
|
UIManager:close(readerui.highlight.edit_highlight_dialog)
|
|
|
|
UIManager:close(readerui.highlight.edit_highlight_dialog)
|
|
|
|
UIManager:close(readerui)
|
|
|
|
UIManager:close(readerui)
|
|
|
|
-- We haven't torn it down yet
|
|
|
|
|
|
|
|
ReaderUI.instance = readerui
|
|
|
|
|
|
|
|
UIManager:quit()
|
|
|
|
UIManager:quit()
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
UIManager:run()
|
|
|
|
UIManager:run()
|
|
|
@ -81,23 +87,18 @@ describe("Readerhighlight module", function()
|
|
|
|
|
|
|
|
|
|
|
|
describe("highlight for EPUB documents", function()
|
|
|
|
describe("highlight for EPUB documents", function()
|
|
|
|
local page = 10
|
|
|
|
local page = 10
|
|
|
|
local readerui, selection_spy
|
|
|
|
before_each(function()
|
|
|
|
setup(function()
|
|
|
|
UIManager:quit()
|
|
|
|
|
|
|
|
|
|
|
|
local sample_epub = "spec/front/unit/data/juliet.epub"
|
|
|
|
local sample_epub = "spec/front/unit/data/juliet.epub"
|
|
|
|
readerui = ReaderUI:new{
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
document = DocumentRegistry:openDocument(sample_epub),
|
|
|
|
document = DocumentRegistry:openDocument(sample_epub),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
selection_spy = spy.on(readerui.languagesupport, "improveWordSelection")
|
|
|
|
local selection_spy = spy.on(readerui.languagesupport, "improveWordSelection")
|
|
|
|
end)
|
|
|
|
|
|
|
|
teardown(function()
|
|
|
|
|
|
|
|
readerui:closeDocument()
|
|
|
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
|
|
|
|
UIManager:quit()
|
|
|
|
|
|
|
|
readerui.rolling:onGotoPage(page)
|
|
|
|
|
|
|
|
UIManager:show(readerui)
|
|
|
|
UIManager:show(readerui)
|
|
|
|
|
|
|
|
readerui.rolling:onGotoPage(page)
|
|
|
|
selection_spy:clear()
|
|
|
|
selection_spy:clear()
|
|
|
|
--- @fixme HACK: Mock UIManager:run x and y for readerui.dimen
|
|
|
|
--- @fixme HACK: Mock UIManager:run x and y for readerui.dimen
|
|
|
|
--- @todo Refactor readerview's dimen handling so we can get rid of
|
|
|
|
--- @todo Refactor readerview's dimen handling so we can get rid of
|
|
|
@ -105,25 +106,38 @@ describe("Readerhighlight module", function()
|
|
|
|
readerui:paintTo(Screen.bb, 0, 0)
|
|
|
|
readerui:paintTo(Screen.bb, 0, 0)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
after_each(function()
|
|
|
|
after_each(function()
|
|
|
|
readerui.highlight:clear()
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if readerui then
|
|
|
|
|
|
|
|
readerui.highlight:clear()
|
|
|
|
|
|
|
|
readerui:closeDocument()
|
|
|
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should highlight single word", function()
|
|
|
|
it("should highlight single word", function()
|
|
|
|
highlight_single_word(readerui, Geom:new{ x = 400, y = 70 })
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
|
|
|
|
local selection_spy = spy.on(readerui.languagesupport, "improveWordSelection")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
highlight_single_word(Geom:new{ x = 400, y = 70 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_epub.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_epub.png")
|
|
|
|
assert.spy(selection_spy).was_called()
|
|
|
|
assert.spy(selection_spy).was_called()
|
|
|
|
assert.truthy(readerui.view.highlight.saved[page])
|
|
|
|
assert.truthy(readerui.view.highlight.saved[page])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should highlight text", function()
|
|
|
|
it("should highlight text", function()
|
|
|
|
highlight_text(readerui,
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
Geom:new{ x = 400, y = 110 },
|
|
|
|
local selection_spy = spy.on(readerui.languagesupport, "improveWordSelection")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
highlight_text(Geom:new{ x = 400, y = 110 },
|
|
|
|
Geom:new{ x = 400, y = 170 })
|
|
|
|
Geom:new{ x = 400, y = 170 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_epub.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_epub.png")
|
|
|
|
assert.spy(selection_spy).was_called()
|
|
|
|
assert.spy(selection_spy).was_called()
|
|
|
|
assert.truthy(readerui.view.highlight.saved[page])
|
|
|
|
assert.truthy(readerui.view.highlight.saved[page])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should response on tap gesture", function()
|
|
|
|
it("should response on tap gesture", function()
|
|
|
|
tap_highlight_text(readerui,
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
Geom:new{ x = 130, y = 100 },
|
|
|
|
local selection_spy = spy.on(readerui.languagesupport, "improveWordSelection")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tap_highlight_text(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 })
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_epub.png")
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_epub.png")
|
|
|
@ -132,132 +146,160 @@ describe("Readerhighlight module", function()
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
describe("highlight for PDF documents in page mode", function()
|
|
|
|
describe("highlight for PDF documents in page mode", function()
|
|
|
|
local readerui
|
|
|
|
local sample_pdf = "spec/front/unit/data/sample.pdf"
|
|
|
|
setup(function()
|
|
|
|
|
|
|
|
local sample_pdf = "spec/front/unit/data/sample.pdf"
|
|
|
|
|
|
|
|
readerui = ReaderUI:new{
|
|
|
|
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
|
|
|
_testsuite = true,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("SetScrollMode", false))
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
teardown(function()
|
|
|
|
|
|
|
|
readerui:closeDocument()
|
|
|
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe("for scanned page with text layer", function()
|
|
|
|
describe("for scanned page with text layer", function()
|
|
|
|
before_each(function()
|
|
|
|
before_each(function()
|
|
|
|
UIManager:quit()
|
|
|
|
UIManager:quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("SetScrollMode", false))
|
|
|
|
|
|
|
|
|
|
|
|
UIManager:show(readerui)
|
|
|
|
UIManager:show(readerui)
|
|
|
|
readerui.paging:onGotoPage(10)
|
|
|
|
readerui.paging:onGotoPage(10)
|
|
|
|
|
|
|
|
-- We want up-to-date screenshots
|
|
|
|
|
|
|
|
readerui:paintTo(Screen.bb, 0, 0)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
after_each(function()
|
|
|
|
after_each(function()
|
|
|
|
readerui.highlight:clear()
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if readerui then
|
|
|
|
|
|
|
|
readerui.highlight:clear()
|
|
|
|
|
|
|
|
readerui:closeDocument()
|
|
|
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should response on tap gesture #nocov", function()
|
|
|
|
it("should response on tap gesture", function()
|
|
|
|
tap_highlight_text(readerui,
|
|
|
|
tap_highlight_text(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 })
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_pdf.png")
|
|
|
|
Screen:shot("screenshots/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(Geom:new{ x = 260, y = 70 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf.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(Geom:new{ x = 260, y = 170 }, Geom:new{ x = 260, y = 250 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf.png")
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
describe("for scanned page without text layer", function()
|
|
|
|
describe("for scanned page without text layer", function()
|
|
|
|
before_each(function()
|
|
|
|
before_each(function()
|
|
|
|
UIManager:quit()
|
|
|
|
UIManager:quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("SetScrollMode", false))
|
|
|
|
|
|
|
|
|
|
|
|
UIManager:show(readerui)
|
|
|
|
UIManager:show(readerui)
|
|
|
|
readerui.paging:onGotoPage(28)
|
|
|
|
readerui.paging:onGotoPage(28)
|
|
|
|
|
|
|
|
readerui:paintTo(Screen.bb, 0, 0)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
after_each(function()
|
|
|
|
after_each(function()
|
|
|
|
readerui.highlight:clear()
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if readerui then
|
|
|
|
|
|
|
|
readerui.highlight:clear()
|
|
|
|
|
|
|
|
readerui:closeDocument()
|
|
|
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should respond to tap gesture #nocov", 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(Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 250, y = 75 })
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_pdf_scanned.png")
|
|
|
|
Screen:shot("screenshots/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(Geom:new{ x = 260, y = 70 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf_scanned.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf_scanned.png")
|
|
|
|
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(Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf_scanned.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf_scanned.png")
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
describe("for reflowed page", function()
|
|
|
|
describe("for reflowed page", function()
|
|
|
|
before_each(function()
|
|
|
|
before_each(function()
|
|
|
|
UIManager:quit()
|
|
|
|
UIManager:quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("SetScrollMode", false))
|
|
|
|
readerui.document.configurable.text_wrap = 1
|
|
|
|
readerui.document.configurable.text_wrap = 1
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("ReflowUpdated"))
|
|
|
|
|
|
|
|
|
|
|
|
UIManager:show(readerui)
|
|
|
|
UIManager:show(readerui)
|
|
|
|
readerui.paging:onGotoPage(31)
|
|
|
|
readerui.paging:onGotoPage(31)
|
|
|
|
|
|
|
|
readerui:paintTo(Screen.bb, 0, 0)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
after_each(function()
|
|
|
|
after_each(function()
|
|
|
|
readerui.highlight:clear()
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
readerui.document.configurable.text_wrap = 0
|
|
|
|
|
|
|
|
UIManager:close(readerui) -- close to flush settings
|
|
|
|
if readerui then
|
|
|
|
-- We haven't torn it down yet
|
|
|
|
readerui.highlight:clear()
|
|
|
|
ReaderUI.instance = readerui
|
|
|
|
readerui.document.configurable.text_wrap = 0
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("ReflowUpdated"))
|
|
|
|
|
|
|
|
readerui:closeDocument()
|
|
|
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should response on tap gesture #nocov", 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(Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 250, y = 75 })
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_pdf_reflowed.png")
|
|
|
|
Screen:shot("screenshots/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(Geom:new{ x = 260, y = 70 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf_reflowed.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf_reflowed.png")
|
|
|
|
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(Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf_reflowed.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf_reflowed.png")
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
describe("highlight for PDF documents in scroll mode", function()
|
|
|
|
describe("highlight for PDF documents in scroll mode", function()
|
|
|
|
local readerui
|
|
|
|
local sample_pdf = "spec/front/unit/data/sample.pdf"
|
|
|
|
setup(function()
|
|
|
|
|
|
|
|
local sample_pdf = "spec/front/unit/data/sample.pdf"
|
|
|
|
|
|
|
|
readerui = ReaderUI:new{
|
|
|
|
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
|
|
|
_testsuite = true,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("SetScrollMode", true))
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
teardown(function()
|
|
|
|
|
|
|
|
readerui:closeDocument()
|
|
|
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe("for scanned page with text layer", function()
|
|
|
|
describe("for scanned page with text layer", function()
|
|
|
|
before_each(function()
|
|
|
|
before_each(function()
|
|
|
|
UIManager:quit()
|
|
|
|
UIManager:quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("SetScrollMode", true))
|
|
|
|
|
|
|
|
|
|
|
|
UIManager:show(readerui)
|
|
|
|
UIManager:show(readerui)
|
|
|
|
readerui.paging:onGotoPage(10)
|
|
|
|
readerui.paging:onGotoPage(10)
|
|
|
|
readerui.zooming:setZoomMode("contentwidth")
|
|
|
|
readerui.zooming:setZoomMode("contentwidth")
|
|
|
|
|
|
|
|
readerui:paintTo(Screen.bb, 0, 0)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
after_each(function()
|
|
|
|
after_each(function()
|
|
|
|
readerui.highlight:clear()
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if readerui then
|
|
|
|
|
|
|
|
readerui.highlight:clear()
|
|
|
|
|
|
|
|
readerui:closeDocument()
|
|
|
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
|
|
|
end
|
|
|
|
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(Geom:new{ x = 260, y = 70 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf_scroll.png")
|
|
|
|
Screen:shot("screenshots/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(Geom:new{ x = 260, y = 170 }, Geom:new{ x = 260, y = 250 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf_scroll.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf_scroll.png")
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should response on tap gesture", function()
|
|
|
|
it("should response on tap gesture", function()
|
|
|
|
tap_highlight_text(readerui,
|
|
|
|
tap_highlight_text(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 })
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_pdf_scroll.png")
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_pdf_scroll.png")
|
|
|
@ -266,50 +308,77 @@ describe("Readerhighlight module", function()
|
|
|
|
describe("for scanned page without text layer", function()
|
|
|
|
describe("for scanned page without text layer", function()
|
|
|
|
before_each(function()
|
|
|
|
before_each(function()
|
|
|
|
UIManager:quit()
|
|
|
|
UIManager:quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("SetScrollMode", true))
|
|
|
|
|
|
|
|
|
|
|
|
UIManager:show(readerui)
|
|
|
|
UIManager:show(readerui)
|
|
|
|
readerui.paging:onGotoPage(28)
|
|
|
|
readerui.paging:onGotoPage(28)
|
|
|
|
readerui.zooming:setZoomMode("contentwidth")
|
|
|
|
readerui.zooming:setZoomMode("contentwidth")
|
|
|
|
|
|
|
|
readerui:paintTo(Screen.bb, 0, 0)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
after_each(function()
|
|
|
|
after_each(function()
|
|
|
|
readerui.highlight:clear()
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if readerui then
|
|
|
|
|
|
|
|
readerui.highlight:clear()
|
|
|
|
|
|
|
|
readerui:closeDocument()
|
|
|
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
|
|
|
end
|
|
|
|
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(Geom:new{ x = 260, y = 70 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf_scanned_scroll.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf_scanned_scroll.png")
|
|
|
|
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(Geom:new{x = 192, y = 186}, Geom:new{x = 280, y = 186})
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf_scanned_scroll.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf_scanned_scroll.png")
|
|
|
|
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(Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 250, y = 75 })
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_pdf_scanned_scroll.png")
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_pdf_scanned_scroll.png")
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
describe("for reflowed page", function()
|
|
|
|
describe("for reflowed page", function()
|
|
|
|
before_each(function()
|
|
|
|
before_each(function()
|
|
|
|
UIManager:quit()
|
|
|
|
UIManager:quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local readerui = ReaderUI:new{
|
|
|
|
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
|
|
|
|
document = DocumentRegistry:openDocument(sample_pdf),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("SetScrollMode", true))
|
|
|
|
readerui.document.configurable.text_wrap = 1
|
|
|
|
readerui.document.configurable.text_wrap = 1
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("ReflowUpdated"))
|
|
|
|
|
|
|
|
|
|
|
|
UIManager:show(readerui)
|
|
|
|
UIManager:show(readerui)
|
|
|
|
readerui.paging:onGotoPage(31)
|
|
|
|
readerui.paging:onGotoPage(31)
|
|
|
|
|
|
|
|
readerui:paintTo(Screen.bb, 0, 0)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
after_each(function()
|
|
|
|
after_each(function()
|
|
|
|
readerui.highlight:clear()
|
|
|
|
local readerui = ReaderUI.instance
|
|
|
|
readerui.document.configurable.text_wrap = 0
|
|
|
|
|
|
|
|
UIManager:close(readerui) -- close to flush settings
|
|
|
|
if readerui then
|
|
|
|
-- We haven't torn it down yet
|
|
|
|
readerui.highlight:clear()
|
|
|
|
ReaderUI.instance = readerui
|
|
|
|
readerui.document.configurable.text_wrap = 0
|
|
|
|
|
|
|
|
readerui:handleEvent(Event:new("ReflowUpdated"))
|
|
|
|
|
|
|
|
readerui:closeDocument()
|
|
|
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
|
|
|
end
|
|
|
|
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(Geom:new{ x = 260, y = 70 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf_reflowed_scroll.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_single_word_pdf_reflowed_scroll.png")
|
|
|
|
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(Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 })
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf_reflowed_scroll.png")
|
|
|
|
Screen:shot("screenshots/reader_highlight_text_pdf_reflowed_scroll.png")
|
|
|
|
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(Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 250, y = 75 })
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_pdf_reflowed_scroll.png")
|
|
|
|
Screen:shot("screenshots/reader_tap_highlight_text_pdf_reflowed_scroll.png")
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|