[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - sd/qa
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sat May 30 11:17:02 UTC 2020
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 11c596a628c757022c404c9c533b7a274c810e5f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat May 30 13:10:04 2020 +0200
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sat May 30 13:10:04 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
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index 6469eba789fe..a0feaae81912 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: [" << long(r.Top()) << ", " << long(r.Left()) << "]"
+ << "S: [" << long(r.GetWidth()) << ", " << long(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);
More information about the Libreoffice-commits
mailing list