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
@@ -18,10 +18,6 @@ describe("Readerhighlight module", function()
|
||||
require("ffi/util").copyFile("spec/front/unit/data/sample.pdf", sample_pdf)
|
||||
end)
|
||||
|
||||
local function screenshot(filename)
|
||||
Screen:shot(DataStorage:getDataDir() .. "/screenshots/" .. filename)
|
||||
end
|
||||
|
||||
local function highlight_single_word(readerui, pos0)
|
||||
local s = spy.on(readerui.languagesupport, "improveWordSelection")
|
||||
|
||||
@@ -112,7 +108,7 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
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.truthy(#readerui.annotation.annotations == 1)
|
||||
end)
|
||||
@@ -120,7 +116,7 @@ describe("Readerhighlight module", function()
|
||||
highlight_text(readerui,
|
||||
Geom:new{ x = 400, y = 110 },
|
||||
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.truthy(#readerui.annotation.annotations == 1)
|
||||
end)
|
||||
@@ -129,7 +125,7 @@ describe("Readerhighlight module", function()
|
||||
Geom:new{ x = 130, y = 100 },
|
||||
Geom:new{ x = 350, y = 395 },
|
||||
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()
|
||||
end)
|
||||
end)
|
||||
@@ -163,16 +159,16 @@ describe("Readerhighlight module", function()
|
||||
Geom:new{ x = 260, y = 70 },
|
||||
Geom:new{ x = 260, y = 150 },
|
||||
Geom:new{ x = 280, y = 110 })
|
||||
screenshot("reader_tap_highlight_text_pdf.png")
|
||||
screenshot(Screen, "reader_tap_highlight_text_pdf.png")
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
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)
|
||||
end)
|
||||
it("should highlight text", function()
|
||||
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)
|
||||
end)
|
||||
end)
|
||||
@@ -188,16 +184,16 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
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 })
|
||||
screenshot("reader_tap_highlight_text_pdf_scanned.png")
|
||||
screenshot(Screen, "reader_tap_highlight_text_pdf_scanned.png")
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
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)
|
||||
end)
|
||||
it("should highlight text", function()
|
||||
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)
|
||||
end)
|
||||
end)
|
||||
@@ -218,16 +214,16 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
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 })
|
||||
screenshot("reader_tap_highlight_text_pdf_reflowed.png")
|
||||
screenshot(Screen, "reader_tap_highlight_text_pdf_reflowed.png")
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
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)
|
||||
end)
|
||||
it("should highlight text", function()
|
||||
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)
|
||||
end)
|
||||
end)
|
||||
@@ -261,11 +257,11 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
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)
|
||||
it("should highlight text", function()
|
||||
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)
|
||||
end)
|
||||
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 = 150 },
|
||||
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)
|
||||
end)
|
||||
end)
|
||||
@@ -290,17 +286,17 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
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)
|
||||
end)
|
||||
it("should highlight text", function()
|
||||
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)
|
||||
end)
|
||||
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 })
|
||||
screenshot("reader_tap_highlight_text_pdf_scanned_scroll.png")
|
||||
screenshot(Screen, "reader_tap_highlight_text_pdf_scanned_scroll.png")
|
||||
end)
|
||||
end)
|
||||
describe("for reflowed page", function()
|
||||
@@ -320,17 +316,17 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
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)
|
||||
end)
|
||||
it("should highlight text", function()
|
||||
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)
|
||||
end)
|
||||
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 })
|
||||
screenshot("reader_tap_highlight_text_pdf_reflowed_scroll.png")
|
||||
screenshot(Screen, "reader_tap_highlight_text_pdf_reflowed_scroll.png")
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user