summaryrefslogtreecommitdiff
path: root/sw/qa/extras/indexing
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-07-09 19:36:58 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-08-10 07:54:06 +0200
commitea1818b8ba34378b777b8706069d28fade2cc924 (patch)
treed2f7d506e3f84502b93533fe560de1bfa5009572 /sw/qa/extras/indexing
parentfc4c0747e97bb997cc37263b3e86b07dab21fe25 (diff)
indexing: add support for SdrObjects in SearchResultLocator
Also add (node) "type" parameter because we need to differentiate between Writer nodes and SdrObject nodes. Change-Id: I590695ae71781f64c22bdd7e1df01d69e3376e67 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118671 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw/qa/extras/indexing')
-rw-r--r--sw/qa/extras/indexing/SearchResultLocatorTest.cxx50
1 files changed, 39 insertions, 11 deletions
diff --git a/sw/qa/extras/indexing/SearchResultLocatorTest.cxx b/sw/qa/extras/indexing/SearchResultLocatorTest.cxx
index 9b8474911fbd..99f33422a065 100644
--- a/sw/qa/extras/indexing/SearchResultLocatorTest.cxx
+++ b/sw/qa/extras/indexing/SearchResultLocatorTest.cxx
@@ -17,27 +17,24 @@
namespace
{
-#if !defined MACOSX
constexpr OUStringLiteral DATA_DIRECTORY = u"sw/qa/extras/indexing/data/";
-#endif
}
class SearchResultLocatorTest : public SwModelTestBase
{
private:
-#if !defined MACOSX
SwDoc* createDoc(const char* pName = nullptr);
-#endif
public:
void testSearchResultLocator();
+ void testSearchResultLocatorForSdrObjects();
CPPUNIT_TEST_SUITE(SearchResultLocatorTest);
CPPUNIT_TEST(testSearchResultLocator);
+ CPPUNIT_TEST(testSearchResultLocatorForSdrObjects);
CPPUNIT_TEST_SUITE_END();
};
-#if !defined MACOSX
SwDoc* SearchResultLocatorTest::createDoc(const char* pName)
{
if (!pName)
@@ -49,25 +46,27 @@ SwDoc* SearchResultLocatorTest::createDoc(const char* pName)
CPPUNIT_ASSERT(pTextDoc);
return pTextDoc->GetDocShell()->GetDoc();
}
-#endif
void SearchResultLocatorTest::testSearchResultLocator()
{
-#if !defined(_WIN32) && !defined(MACOSX)
if (!IsDefaultDPI())
return;
SwDoc* pDoc = createDoc("IndexingExport_VariousParagraphs.odt");
CPPUNIT_ASSERT(pDoc);
- sw::SearchResultLocator aLocator(pDoc);
- sw::SearchIndexData aData;
+ sw::search::SearchResultLocator aLocator(pDoc);
+ sw::search::SearchIndexData aData;
+ aData.eType = sw::search::NodeType::WriterNode;
aData.nNodeIndex = 14;
- sw::LocationResult aResult = aLocator.find(aData);
+ sw::search::LocationResult aResult = aLocator.find(aData);
CPPUNIT_ASSERT_EQUAL(size_t(1), aResult.maRectangles.size());
- auto aRectangle = aResult.maRectangles[0];
+ // skip asserting exact values for macOS and Windows because of
+ // inconsistent results
+#if !defined(_WIN32) && !defined(MACOSX)
+ auto aRectangle = aResult.maRectangles[0];
CPPUNIT_ASSERT_DOUBLES_EQUAL(1418.0, aRectangle.getMinX(), 1e-4);
CPPUNIT_ASSERT_DOUBLES_EQUAL(4444.0, aRectangle.getMinY(), 1e-4);
@@ -76,6 +75,35 @@ void SearchResultLocatorTest::testSearchResultLocator()
#endif
}
+void SearchResultLocatorTest::testSearchResultLocatorForSdrObjects()
+{
+ if (!IsDefaultDPI())
+ return;
+
+ SwDoc* pDoc = createDoc("IndexingExport_Shapes.odt");
+ CPPUNIT_ASSERT(pDoc);
+
+ sw::search::SearchResultLocator aLocator(pDoc);
+ sw::search::SearchIndexData aData;
+ aData.eType = sw::search::NodeType::SdrObject;
+ aData.aObjectName = u"Circle";
+ aData.nNodeIndex = 1;
+
+ sw::search::LocationResult aResult = aLocator.find(aData);
+ CPPUNIT_ASSERT_EQUAL(size_t(1), aResult.maRectangles.size());
+
+ // skip asserting exact values for macOS and Windows because of
+ // inconsistent results
+#if !defined(_WIN32) && !defined(MACOSX)
+ auto aRectangle = aResult.maRectangles[0];
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1478.0, aRectangle.getMinX(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3223.0, aRectangle.getMinY(), 1e-4);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2059.0, aRectangle.getWidth(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2059.0, aRectangle.getHeight(), 1e-4);
+#endif
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SearchResultLocatorTest);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */