mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
tests: improve frontend testsuite isolation
This commit is contained in:
committed by
Frans de Jonge
parent
8005275388
commit
8c839d9ead
@@ -17,6 +17,10 @@ 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")
|
||||
|
||||
@@ -107,7 +111,7 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
highlight_single_word(readerui, Geom:new{ x = 400, y = 70 })
|
||||
Screen:shot("screenshots/reader_highlight_single_word_epub.png")
|
||||
screenshot("reader_highlight_single_word_epub.png")
|
||||
assert.spy(selection_spy).was_called()
|
||||
assert.truthy(#readerui.annotation.annotations == 1)
|
||||
end)
|
||||
@@ -115,7 +119,7 @@ describe("Readerhighlight module", function()
|
||||
highlight_text(readerui,
|
||||
Geom:new{ x = 400, y = 110 },
|
||||
Geom:new{ x = 400, y = 170 })
|
||||
Screen:shot("screenshots/reader_highlight_text_epub.png")
|
||||
screenshot("reader_highlight_text_epub.png")
|
||||
assert.spy(selection_spy).was_called()
|
||||
assert.truthy(#readerui.annotation.annotations == 1)
|
||||
end)
|
||||
@@ -124,7 +128,7 @@ describe("Readerhighlight module", function()
|
||||
Geom:new{ x = 130, y = 100 },
|
||||
Geom:new{ x = 350, y = 395 },
|
||||
Geom:new{ x = 80, y = 265 })
|
||||
Screen:shot("screenshots/reader_tap_highlight_text_epub.png")
|
||||
screenshot("reader_tap_highlight_text_epub.png")
|
||||
assert.spy(selection_spy).was_called()
|
||||
end)
|
||||
end)
|
||||
@@ -158,16 +162,16 @@ describe("Readerhighlight module", function()
|
||||
Geom:new{ x = 260, y = 70 },
|
||||
Geom:new{ x = 260, y = 150 },
|
||||
Geom:new{ x = 280, y = 110 })
|
||||
Screen:shot("screenshots/reader_tap_highlight_text_pdf.png")
|
||||
screenshot("reader_tap_highlight_text_pdf.png")
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||
Screen:shot("screenshots/reader_highlight_single_word_pdf.png")
|
||||
screenshot("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 })
|
||||
Screen:shot("screenshots/reader_highlight_text_pdf.png")
|
||||
screenshot("reader_highlight_text_pdf.png")
|
||||
assert.truthy(#readerui.annotation.annotations == 1)
|
||||
end)
|
||||
end)
|
||||
@@ -183,16 +187,16 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
it("should respond to tap gesture #nocov", function()
|
||||
tap_highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 })
|
||||
Screen:shot("screenshots/reader_tap_highlight_text_pdf_scanned.png")
|
||||
screenshot("reader_tap_highlight_text_pdf_scanned.png")
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||
Screen:shot("screenshots/reader_highlight_single_word_pdf_scanned.png")
|
||||
screenshot("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 })
|
||||
Screen:shot("screenshots/reader_highlight_text_pdf_scanned.png")
|
||||
screenshot("reader_highlight_text_pdf_scanned.png")
|
||||
assert.truthy(#readerui.annotation.annotations == 1)
|
||||
end)
|
||||
end)
|
||||
@@ -213,16 +217,16 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
it("should response on tap gesture #nocov", function()
|
||||
tap_highlight_text(readerui, Geom:new{ x = 260, y = 70 }, Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 })
|
||||
Screen:shot("screenshots/reader_tap_highlight_text_pdf_reflowed.png")
|
||||
screenshot("reader_tap_highlight_text_pdf_reflowed.png")
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||
Screen:shot("screenshots/reader_highlight_single_word_pdf_reflowed.png")
|
||||
screenshot("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 })
|
||||
Screen:shot("screenshots/reader_highlight_text_pdf_reflowed.png")
|
||||
screenshot("reader_highlight_text_pdf_reflowed.png")
|
||||
assert.truthy(#readerui.annotation.annotations == 1)
|
||||
end)
|
||||
end)
|
||||
@@ -256,11 +260,11 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||
Screen:shot("screenshots/reader_highlight_single_word_pdf_scroll.png")
|
||||
screenshot("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 })
|
||||
Screen:shot("screenshots/reader_highlight_text_pdf_scroll.png")
|
||||
screenshot("reader_highlight_text_pdf_scroll.png")
|
||||
assert.truthy(#readerui.annotation.annotations == 1)
|
||||
end)
|
||||
it("should response on tap gesture", function()
|
||||
@@ -268,7 +272,7 @@ describe("Readerhighlight module", function()
|
||||
Geom:new{ x = 260, y = 70 },
|
||||
Geom:new{ x = 260, y = 150 },
|
||||
Geom:new{ x = 280, y = 110 })
|
||||
Screen:shot("screenshots/reader_tap_highlight_text_pdf_scroll.png")
|
||||
screenshot("reader_tap_highlight_text_pdf_scroll.png")
|
||||
assert.truthy(#readerui.annotation.annotations == 1)
|
||||
end)
|
||||
end)
|
||||
@@ -285,17 +289,17 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||
Screen:shot("screenshots/reader_highlight_single_word_pdf_scanned_scroll.png")
|
||||
screenshot("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})
|
||||
Screen:shot("screenshots/reader_highlight_text_pdf_scanned_scroll.png")
|
||||
screenshot("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 })
|
||||
Screen:shot("screenshots/reader_tap_highlight_text_pdf_scanned_scroll.png")
|
||||
screenshot("reader_tap_highlight_text_pdf_scanned_scroll.png")
|
||||
end)
|
||||
end)
|
||||
describe("for reflowed page", function()
|
||||
@@ -315,17 +319,17 @@ describe("Readerhighlight module", function()
|
||||
end)
|
||||
it("should highlight single word", function()
|
||||
highlight_single_word(readerui, Geom:new{ x = 260, y = 70 })
|
||||
Screen:shot("screenshots/reader_highlight_single_word_pdf_reflowed_scroll.png")
|
||||
screenshot("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 })
|
||||
Screen:shot("screenshots/reader_highlight_text_pdf_reflowed_scroll.png")
|
||||
screenshot("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 })
|
||||
Screen:shot("screenshots/reader_tap_highlight_text_pdf_reflowed_scroll.png")
|
||||
screenshot("reader_tap_highlight_text_pdf_reflowed_scroll.png")
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user