diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-04 10:09:20 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-04 13:17:39 +0100 |
commit | 3a2e81d4da10cde111cc82c1378ca4a18cb4eff4 (patch) | |
tree | b5d5971f9c544de20c707f644e60e0cbe472e07f | |
parent | 5fdf20eac1e071e68d4eea7d9f15bd8b3e7046d1 (diff) |
CppunitTest_sw_indexingexport: remove duplicated method
Change-Id: Iffbcd8ae699e8d09933cd9ef3c51a9b1a9e6dd7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142268
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sw/qa/extras/indexing/IndexingExportTest.cxx | 41 | ||||
-rw-r--r-- | sw/qa/extras/indexing/SearchResultLocatorTest.cxx | 35 |
2 files changed, 23 insertions, 53 deletions
diff --git a/sw/qa/extras/indexing/IndexingExportTest.cxx b/sw/qa/extras/indexing/IndexingExportTest.cxx index 445e2008340a..c38f5f1bd413 100644 --- a/sw/qa/extras/indexing/IndexingExportTest.cxx +++ b/sw/qa/extras/indexing/IndexingExportTest.cxx @@ -13,17 +13,14 @@ #include <IndexingExport.hxx> -namespace -{ -constexpr OUStringLiteral DATA_DIRECTORY = u"sw/qa/extras/indexing/data/"; -} - class IndexingExportTest : public SwModelTestBase { -private: - SwDoc* createDoc(const char* pName = nullptr); - public: + IndexingExportTest() + : SwModelTestBase("/sw/qa/extras/indexing/data/") + { + } + void testIndexingExport_Paragraphs(); void testIndexingExport_Images(); void testIndexingExport_OLE(); @@ -45,21 +42,9 @@ public: CPPUNIT_TEST_SUITE_END(); }; -SwDoc* IndexingExportTest::createDoc(const char* pName) -{ - if (!pName) - loadURL("private:factory/swriter", nullptr); - else - load(DATA_DIRECTORY, pName); - - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - return pTextDoc->GetDocShell()->GetDoc(); -} - void IndexingExportTest::testIndexingExport_Paragraphs() { - SwDoc* pDoc = createDoc("IndexingExport_VariousParagraphs.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_VariousParagraphs.odt"); CPPUNIT_ASSERT(pDoc); SvMemoryStream aMemoryStream; @@ -94,7 +79,7 @@ void IndexingExportTest::testIndexingExport_Paragraphs() void IndexingExportTest::testIndexingExport_Images() { - SwDoc* pDoc = createDoc("IndexingExport_Images.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_Images.odt"); CPPUNIT_ASSERT(pDoc); SvMemoryStream aMemoryStream; @@ -116,7 +101,7 @@ void IndexingExportTest::testIndexingExport_Images() void IndexingExportTest::testIndexingExport_OLE() { - SwDoc* pDoc = createDoc("IndexingExport_OLE.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_OLE.odt"); CPPUNIT_ASSERT(pDoc); SvMemoryStream aMemoryStream; @@ -135,7 +120,7 @@ void IndexingExportTest::testIndexingExport_OLE() void IndexingExportTest::testIndexingExport_Shapes() { - SwDoc* pDoc = createDoc("IndexingExport_Shapes.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_Shapes.odt"); CPPUNIT_ASSERT(pDoc); SvMemoryStream aMemoryStream; @@ -174,7 +159,7 @@ void IndexingExportTest::testIndexingExport_Shapes() void IndexingExportTest::testIndexingExport_Tables() { - SwDoc* pDoc = createDoc("IndexingExport_Tables.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_Tables.odt"); CPPUNIT_ASSERT(pDoc); SvMemoryStream aMemoryStream; @@ -241,7 +226,7 @@ void IndexingExportTest::testIndexingExport_Tables() void IndexingExportTest::testIndexingExport_Sections() { - SwDoc* pDoc = createDoc("IndexingExport_Sections.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_Sections.odt"); CPPUNIT_ASSERT(pDoc); SvMemoryStream aMemoryStream; @@ -272,7 +257,7 @@ void IndexingExportTest::testIndexingExport_Sections() void IndexingExportTest::testIndexingExport_Fontwork() { - SwDoc* pDoc = createDoc("IndexingExport_Fontwork.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_Fontwork.odt"); CPPUNIT_ASSERT(pDoc); SvMemoryStream aMemoryStream; @@ -296,7 +281,7 @@ void IndexingExportTest::testIndexingExport_Fontwork() void IndexingExportTest::testIndexingExport_Header_Footer() { - SwDoc* pDoc = createDoc("IndexingExport_Header_Footer.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_Header_Footer.odt"); CPPUNIT_ASSERT(pDoc); SvMemoryStream aMemoryStream; diff --git a/sw/qa/extras/indexing/SearchResultLocatorTest.cxx b/sw/qa/extras/indexing/SearchResultLocatorTest.cxx index 98d4669da966..a4de60444c10 100644 --- a/sw/qa/extras/indexing/SearchResultLocatorTest.cxx +++ b/sw/qa/extras/indexing/SearchResultLocatorTest.cxx @@ -13,17 +13,14 @@ #include <SearchResultLocator.hxx> -namespace -{ -constexpr OUStringLiteral DATA_DIRECTORY = u"sw/qa/extras/indexing/data/"; -} - class SearchResultLocatorTest : public SwModelTestBase { -private: - SwDoc* createDoc(const char* pName = nullptr); - public: + SearchResultLocatorTest() + : SwModelTestBase("/sw/qa/extras/indexing/data/") + { + } + void testSearchResultLocator(); void testSearchResultLocatorUsingXmlPayload(); void testSearchResultLocatorUsingJsonPayload(); @@ -39,24 +36,12 @@ public: CPPUNIT_TEST_SUITE_END(); }; -SwDoc* SearchResultLocatorTest::createDoc(const char* pName) -{ - if (!pName) - loadURL("private:factory/swriter", nullptr); - else - load(DATA_DIRECTORY, pName); - - SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pTextDoc); - return pTextDoc->GetDocShell()->GetDoc(); -} - void SearchResultLocatorTest::testSearchResultLocator() { if (!IsDefaultDPI()) return; - SwDoc* pDoc = createDoc("IndexingExport_VariousParagraphs.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_VariousParagraphs.odt"); CPPUNIT_ASSERT(pDoc); sw::search::SearchResultLocator aLocator(pDoc); @@ -83,7 +68,7 @@ void SearchResultLocatorTest::testSearchResultLocatorUsingXmlPayload() if (!IsDefaultDPI()) return; - SwDoc* pDoc = createDoc("IndexingExport_VariousParagraphs.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_VariousParagraphs.odt"); CPPUNIT_ASSERT(pDoc); sw::search::SearchResultLocator aLocator(pDoc); @@ -111,7 +96,7 @@ void SearchResultLocatorTest::testSearchResultLocatorUsingJsonPayload() if (!IsDefaultDPI()) return; - SwDoc* pDoc = createDoc("IndexingExport_VariousParagraphs.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_VariousParagraphs.odt"); CPPUNIT_ASSERT(pDoc); sw::search::SearchResultLocator aLocator(pDoc); @@ -139,7 +124,7 @@ void SearchResultLocatorTest::testSearchResultLocatorForSdrObjects() if (!IsDefaultDPI()) return; - SwDoc* pDoc = createDoc("IndexingExport_Shapes.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_Shapes.odt"); CPPUNIT_ASSERT(pDoc); sw::search::SearchResultLocator aLocator(pDoc); @@ -166,7 +151,7 @@ void SearchResultLocatorTest::testSearchResultLocatorForSdrObjectsUsingJsonPaylo if (!IsDefaultDPI()) return; - SwDoc* pDoc = createDoc("IndexingExport_Shapes.odt"); + SwDoc* pDoc = createSwDoc(mpTestDocumentPath, "IndexingExport_Shapes.odt"); CPPUNIT_ASSERT(pDoc); sw::search::SearchResultLocator aLocator(pDoc); |