summaryrefslogtreecommitdiffstats
path: root/sd
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-05-30 13:10:04 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-07-30 15:07:28 +0200
commita081f9d0cbbc003479c650fcad2e2415b2893403 (patch)
tree64a576fb7bb44e800a97ce945daae45817b04c5a /sd
parentvcl: add search start position support for VectorGraphicSearch (diff)
downloadcore-a081f9d0cbbc003479c650fcad2e2415b2893403.tar.gz
core-a081f9d0cbbc003479c650fcad2e2415b2893403.zip
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 <quikee@gmail.com> (cherry picked from commit 4dcc48f37248a1eb45188739de961689e7873f3c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95931 Tested-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 60ec74e442aebe1d80b1416ec1405fffc06ab4ae)
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/sdmodeltestbase.hxx16
-rw-r--r--sd/qa/unit/tiledrendering/CallbackRecorder.hxx3
-rw-r--r--sd/qa/unit/tiledrendering/LOKitSearchTest.cxx18
3 files changed, 32 insertions, 5 deletions
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index b8231922e4cb..ad8defc88fe4 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -485,6 +485,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);