diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-08-25 20:16:57 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-08-26 04:47:01 +0200 |
commit | 0b698aa6eb26d75ca4baf677a461aee095f69317 (patch) | |
tree | 74c45ae224b31919a97fc6e5f307df5a996c06ee /sw/qa/extras/indexing | |
parent | 0484630164275e2828f1420b055f05e94b8c73ee (diff) |
indexing: move xml parsing into SearchResultLocator
Let's keep unneeded complexity out of SwXTextDocument, so move
parsing into SearchResultLocator.
As a bonus we can now test parsing.
Change-Id: I944bfc43e6953523eee19b26b7f483aa401809aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121032
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.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sw/qa/extras/indexing/SearchResultLocatorTest.cxx b/sw/qa/extras/indexing/SearchResultLocatorTest.cxx index 99ee267e4e02..c740f982b2c3 100644 --- a/sw/qa/extras/indexing/SearchResultLocatorTest.cxx +++ b/sw/qa/extras/indexing/SearchResultLocatorTest.cxx @@ -27,10 +27,12 @@ private: public: void testSearchResultLocator(); + void testSearchResultLocatorUsingPayload(); void testSearchResultLocatorForSdrObjects(); CPPUNIT_TEST_SUITE(SearchResultLocatorTest); CPPUNIT_TEST(testSearchResultLocator); + CPPUNIT_TEST(testSearchResultLocatorUsingPayload); CPPUNIT_TEST(testSearchResultLocatorForSdrObjects); CPPUNIT_TEST_SUITE_END(); }; @@ -74,6 +76,34 @@ void SearchResultLocatorTest::testSearchResultLocator() #endif } +void SearchResultLocatorTest::testSearchResultLocatorUsingPayload() +{ + if (!IsDefaultDPI()) + return; + + SwDoc* pDoc = createDoc("IndexingExport_VariousParagraphs.odt"); + CPPUNIT_ASSERT(pDoc); + + sw::search::SearchResultLocator aLocator(pDoc); + OString payload = "<indexing>" + "<paragraph type=\"1\" index=\"14\" />" + "</indexing>"; + + sw::search::LocationResult aResult = aLocator.findForPayload(payload.getStr()); + 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(1418.0, aRectangle.getMinX(), 1e-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4444.0, aRectangle.getMinY(), 1e-4); + + CPPUNIT_ASSERT_DOUBLES_EQUAL(9638.0, aRectangle.getWidth(), 1e-4); + CPPUNIT_ASSERT_DOUBLES_EQUAL(276.0, aRectangle.getHeight(), 1e-4); +#endif +} + void SearchResultLocatorTest::testSearchResultLocatorForSdrObjects() { if (!IsDefaultDPI()) |