From 37eedddce7a18ad21aea9a87e44c385886f9ec4a Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:15:20 +0300 Subject: [PATCH] Update readerhighlight_spec.lua --- spec/unit/readerhighlight_spec.lua | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/spec/unit/readerhighlight_spec.lua b/spec/unit/readerhighlight_spec.lua index ae1ff4432..c83b9fb42 100644 --- a/spec/unit/readerhighlight_spec.lua +++ b/spec/unit/readerhighlight_spec.lua @@ -17,7 +17,7 @@ describe("Readerhighlight module", function() readerui.highlight:onHold(nil, { pos = pos0 }) readerui.highlight:onHoldRelease() - readerui.highlight:onHighlight() + readerui.highlight:saveHighlight() assert.spy(s).was_called() assert.spy(s).was_called_with(match.is_ref(readerui.languagesupport), @@ -50,7 +50,7 @@ describe("Readerhighlight module", function() assert.truthy(readerui.highlight.highlight_dialog) assert.truthy(UIManager._window_stack[next_slot].widget == readerui.highlight.highlight_dialog) - readerui.highlight:onHighlight() + readerui.highlight:saveHighlight() UIManager:scheduleIn(1, function() UIManager:close(readerui.highlight.highlight_dialog) UIManager:close(readerui) @@ -64,7 +64,7 @@ describe("Readerhighlight module", function() readerui.highlight:onHold(nil, { pos = pos0 }) readerui.highlight:onHoldPan(nil, { pos = pos1 }) readerui.highlight:onHoldRelease() - readerui.highlight:onHighlight() + readerui.highlight:saveHighlight() readerui.highlight:clear() UIManager:close(readerui.highlight.highlight_dialog) readerui.highlight:onTap(nil, { pos = pos2 }) @@ -111,7 +111,7 @@ describe("Readerhighlight module", function() highlight_single_word(readerui, Geom:new{ x = 400, y = 70 }) Screen:shot("screenshots/reader_highlight_single_word_epub.png") assert.spy(selection_spy).was_called() - assert.truthy(readerui.view.highlight.saved[page]) + assert.truthy(#readerui.annotation.annotations == 1) end) it("should highlight text", function() highlight_text(readerui, @@ -119,7 +119,7 @@ describe("Readerhighlight module", function() Geom:new{ x = 400, y = 170 }) Screen:shot("screenshots/reader_highlight_text_epub.png") assert.spy(selection_spy).was_called() - assert.truthy(readerui.view.highlight.saved[page]) + assert.truthy(#readerui.annotation.annotations == 1) end) it("should response on tap gesture", function() tap_highlight_text(readerui, @@ -165,10 +165,12 @@ describe("Readerhighlight module", function() 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") + 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") + assert.truthy(#readerui.annotation.annotations == 1) end) end) describe("for scanned page without text layer", function() @@ -187,10 +189,12 @@ describe("Readerhighlight module", function() 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") + 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") + assert.truthy(#readerui.annotation.annotations == 1) end) end) describe("for reflowed page", function() @@ -214,10 +218,12 @@ describe("Readerhighlight module", function() 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") + 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") + assert.truthy(#readerui.annotation.annotations == 1) end) end) end) @@ -255,6 +261,7 @@ describe("Readerhighlight module", function() 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") + assert.truthy(#readerui.annotation.annotations == 1) end) it("should response on tap gesture", function() tap_highlight_text(readerui, @@ -262,6 +269,7 @@ describe("Readerhighlight module", function() Geom:new{ x = 260, y = 150 }, Geom:new{ x = 280, y = 110 }) Screen:shot("screenshots/reader_tap_highlight_text_pdf_scroll.png") + assert.truthy(#readerui.annotation.annotations == 1) end) end) describe("for scanned page without text layer", function() @@ -277,10 +285,12 @@ describe("Readerhighlight module", function() 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") + 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") + 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 }) @@ -304,10 +314,12 @@ describe("Readerhighlight module", function() 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") + 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") + 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 })