sd/qa/unit/sdmodeltestbase.hxx | 16 ++++++++++++++++ sd/qa/unit/tiledrendering/CallbackRecorder.hxx | 3 +++ sd/qa/unit/tiledrendering/LOKitSearchTest.cxx | 18 +++++++++++++----- 3 files changed, 32 insertions(+), 5 deletions(-)
New commits: commit 4dcc48f37248a1eb45188739de961689e7873f3c Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 30 13:10:04 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Jun 3 13:27:18 2020 +0200 sd: improve the test for LOKit search in PDF graphic Record how many times we het the search result back, so we can be sure that the search happend and don't just read the old values. Assert the search result selection rectangles and text selection rectangles. Add tools:Rectangle support for CPPUnit into sdmodeltestbase.hxx Change-Id: I0b22d2d2f66abdc0dd0d5ac13a1bfebaa470749a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95383 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 6469eba789fe..08f66de864f1 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -483,6 +483,22 @@ template<> struct assertion_traits<Color> } }; +template<> struct assertion_traits<tools::Rectangle> +{ + static bool equal( const tools::Rectangle& r1, const tools::Rectangle& r2 ) + { + return r1 == r2; + } + + static std::string toString( const tools::Rectangle& r) + { + OStringStream ost; + ost << "Rect P: [" << r.Top() << ", " << r.Left() << "] " + "S: [" << r.GetWidth() << ", " << r.GetHeight() << "]"; + return ost.str(); + } +}; + CPPUNIT_NS_END #endif diff --git a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx index fc5117cce6dc..7e6c8a42d07d 100644 --- a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx +++ b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx @@ -51,6 +51,7 @@ struct CallbackRecorder , m_nPart(0) , m_nSelectionBeforeSearchResult(0) , m_nSelectionAfterSearchResult(0) + , m_nSearchResultCount(0) { } @@ -62,6 +63,7 @@ struct CallbackRecorder std::vector<int> m_aSearchResultPart; int m_nSelectionBeforeSearchResult; int m_nSelectionAfterSearchResult; + int m_nSearchResultCount; /// For document size changed callback. osl::Condition m_aDocumentSizeCondition; @@ -115,6 +117,7 @@ struct CallbackRecorder break; case LOK_CALLBACK_SEARCH_RESULT_SELECTION: { + m_nSearchResultCount++; m_aSearchResultSelection.clear(); m_aSearchResultPart.clear(); boost::property_tree::ptree aTree; diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx index 33257f12d4ab..8d8b11e43fa1 100644 --- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx +++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx @@ -292,21 +292,29 @@ void LOKitSearchTest::testSearchInPDF() CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, pVectorGraphicData->getVectorGraphicDataType()); + // Search lcl_search("ABC"); CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound); + CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount); CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); + CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"), + mpCallbackRecorder->m_aSearchResultSelection[0]); + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)), + mpCallbackRecorder->m_aSelection[0]); - CPPUNIT_ASSERT_EQUAL(long(3763), mpCallbackRecorder->m_aSelection[0].Left()); - CPPUNIT_ASSERT_EQUAL(long(1331), mpCallbackRecorder->m_aSelection[0].Top()); - CPPUNIT_ASSERT_EQUAL(long(1433), mpCallbackRecorder->m_aSelection[0].GetWidth()); - CPPUNIT_ASSERT_EQUAL(long(484), mpCallbackRecorder->m_aSelection[0].GetHeight()); - + // Search again - same result lcl_search("ABC"); + CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound); + CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount); CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); + CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"), + mpCallbackRecorder->m_aSearchResultSelection[0]); + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)), + mpCallbackRecorder->m_aSelection[0]); } CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits