diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-02-07 07:56:42 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-02-07 08:53:53 +0100 |
commit | 398996d877112f88dcfb175af9edc15c38d3a020 (patch) | |
tree | 41d054d564bc0a932b0cc0819fba629c27fcd587 /sw | |
parent | c869fb5ea2fa1dbbfa7c17754aeac48ed7f77cc4 (diff) |
CppunitTest_sw_ooxmllinks: avoid DECLARE_LINKS_EXPORT_TEST completely
No need go via Writer-specific macros.
Change-Id: Ic738ff318f94181b093fd948dcf38057b6c7e189
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163067
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmllinks.cxx | 81 | ||||
-rw-r--r-- | sw/qa/inc/swmodeltestbase.hxx | 7 | ||||
-rw-r--r-- | sw/qa/unit/swmodeltestbase.cxx | 12 |
3 files changed, 37 insertions, 63 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx index d58952cb6b5f..e309a066fa92 100644 --- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx @@ -15,42 +15,10 @@ // This file contains tests to check relative/absolute hyperlinks handling -#define USE_TEMP_DIR true -#define DONT_MODIFY_LINK false - +// decide if output link should be converted to absolute #define USE_ABSOLUTE true #define USE_RELATIVE false -// bAbsolute - decide if output link should be converted to absolute -// bUseTempDir - decide if link should be modified to be placed in temp dir - for testing relative links -#define DECLARE_LINKS_EXPORT_TEST(TestName, FileName, bAbsolute, bUseTempDir) \ - class TestName : public Test \ - { \ - protected: \ - virtual void postLoad(const char*) override \ - { \ - if (!bUseTempDir) \ - return; \ - \ - UseTempDir(); \ - } \ - \ - public: \ - CPPUNIT_TEST_SUITE(TestName); \ - CPPUNIT_TEST(Import_Export_Import); \ - CPPUNIT_TEST_SUITE_END(); \ - void Import_Export_Import() \ - { \ - auto xChanges = comphelper::ConfigurationChanges::create(); \ - officecfg::Office::Common::Save::URL::FileSystem::set(!bAbsolute, xChanges); \ - xChanges->commit(); \ - executeLoadReloadVerify(FileName); \ - } \ - void verify() override; \ - }; \ - CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \ - void TestName::verify() - class Test : public SwModelTestBase { public: @@ -66,6 +34,7 @@ public: xChanges->commit(); } + // link should be modified to be placed in temp dir - for testing relative links void UseTempDir() { uno::Reference<text::XTextRange> xParagraph = getParagraph(1); @@ -159,9 +128,12 @@ CPPUNIT_TEST_FIXTURE(Test, testRelativeToRelativeExport) "Target"_ostr, "relative.docx"); } -DECLARE_LINKS_EXPORT_TEST(testRelativeToAbsoluteExport, "relative-link.docx", USE_ABSOLUTE, - DONT_MODIFY_LINK) +CPPUNIT_TEST_FIXTURE(Test, testRelativeToAbsoluteExport) { + SetAbsolute(USE_ABSOLUTE); + createSwDoc("relative-link.docx"); + // Don't modify link. + saveAndReload(mpFilter); xmlDocUniquePtr pXmlDoc = parseExport("word/_rels/document.xml.rels"); OUString sTarget @@ -170,18 +142,24 @@ DECLARE_LINKS_EXPORT_TEST(testRelativeToAbsoluteExport, "relative-link.docx", US CPPUNIT_ASSERT(sTarget.endsWith("relative.docx")); } -DECLARE_LINKS_EXPORT_TEST(testAbsoluteToRelativeExport, "absolute-link.docx", USE_RELATIVE, - USE_TEMP_DIR) +CPPUNIT_TEST_FIXTURE(Test, testAbsoluteToRelativeExport) { + SetAbsolute(USE_RELATIVE); + createSwDoc("absolute-link.docx"); + UseTempDir(); + saveAndReload(mpFilter); xmlDocUniquePtr pXmlDoc = parseExport("word/_rels/document.xml.rels"); assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[2]"_ostr, "Target"_ostr, "test.docx"); } -DECLARE_LINKS_EXPORT_TEST(testAbsoluteToAbsoluteExport, "absolute-link.docx", USE_ABSOLUTE, - DONT_MODIFY_LINK) +CPPUNIT_TEST_FIXTURE(Test, testAbsoluteToAbsoluteExport) { + SetAbsolute(USE_ABSOLUTE); + createSwDoc("absolute-link.docx"); + // Don't modify link. + saveAndReload(mpFilter); xmlDocUniquePtr pXmlDoc = parseExport("word/_rels/document.xml.rels"); OUString sTarget @@ -190,33 +168,48 @@ DECLARE_LINKS_EXPORT_TEST(testAbsoluteToAbsoluteExport, "absolute-link.docx", US CPPUNIT_ASSERT(sTarget.endsWith("test.docx")); } -DECLARE_LINKS_EXPORT_TEST(testTdf123627_export, "tdf123627.docx", USE_RELATIVE, USE_TEMP_DIR) +CPPUNIT_TEST_FIXTURE(Test, testTdf123627_export) { + SetAbsolute(USE_RELATIVE); + createSwDoc("tdf123627.docx"); + UseTempDir(); + saveAndReload(mpFilter); xmlDocUniquePtr pXmlDoc = parseExport("word/_rels/document.xml.rels"); assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[@TargetMode='External']"_ostr, "Target"_ostr, "test.docx"); } -DECLARE_LINKS_EXPORT_TEST(testTdf126590_export, "tdf126590.docx", USE_ABSOLUTE, DONT_MODIFY_LINK) +CPPUNIT_TEST_FIXTURE(Test, testTdf126590_export) { + SetAbsolute(USE_ABSOLUTE); + createSwDoc("tdf126590.docx"); + // Don't modify link. + saveAndReload(mpFilter); xmlDocUniquePtr pXmlDoc = parseExport("word/_rels/document.xml.rels"); // in the original file: Target="file:///C:\TEMP\test.docx" => invalid file URI assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[@TargetMode='External']"_ostr, "Target"_ostr, "file:///C:/TEMP/test.docx"); } -DECLARE_LINKS_EXPORT_TEST(testTdf126768_export, "tdf126768.docx", USE_ABSOLUTE, DONT_MODIFY_LINK) +CPPUNIT_TEST_FIXTURE(Test, testTdf126768_export) { + SetAbsolute(USE_ABSOLUTE); + createSwDoc("tdf126768.docx"); + // Don't modify link. + saveAndReload(mpFilter); xmlDocUniquePtr pXmlDoc = parseExport("word/_rels/document.xml.rels"); // in the original file: "file:///C:\\TEMP\\test.docx" => invalid file URI assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[@TargetMode='External']"_ostr, "Target"_ostr, "file:///C:/TEMP/test.docx"); } -DECLARE_LINKS_EXPORT_TEST(testNon_ascii_link_export, "non_ascii_link.docx", USE_ABSOLUTE, - DONT_MODIFY_LINK) +CPPUNIT_TEST_FIXTURE(Test, testNon_ascii_link_export) { + SetAbsolute(USE_ABSOLUTE); + createSwDoc("non_ascii_link.docx"); + // Don't modify link. + saveAndReload(mpFilter); xmlDocUniquePtr pXmlDoc = parseExport("word/_rels/document.xml.rels"); assertXPath(pXmlDoc, "/rels:Relationships/rels:Relationship[@TargetMode='External']"_ostr, diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx index f837661bed10..bd87666a19eb 100644 --- a/sw/qa/inc/swmodeltestbase.hxx +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -113,13 +113,6 @@ protected: /** * Helper func used by each unit test to test the 'export' code. - * (Loads the requested file, save it to temp file, load the - * temp file and then calls 'verify' method) - */ - void executeLoadReloadVerify(const char* filename, const char* pPassword = nullptr); - - /** - * Helper func used by each unit test to test the 'export' code. * (Loads the requested file for document base (this represents * the initial document condition), exports with the desired * export filter and then calls 'verify' method) diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx index 125370b145de..f84b3ef15b05 100644 --- a/sw/qa/unit/swmodeltestbase.cxx +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -75,18 +75,6 @@ void SwModelTestBase::executeLoadVerifyReloadVerify(const char* filename, const maTempFile.EnableKillingFile(); } -void SwModelTestBase::executeLoadReloadVerify(const char* filename, const char* pPassword) -{ - maTempFile.EnableKillingFile(false); - header(); - loadURL(createFileURL(OUString::createFromAscii(filename)), pPassword); - postLoad(filename); - saveAndReload(mpFilter, pPassword); - verify(); - finish(); - maTempFile.EnableKillingFile(); -} - void SwModelTestBase::executeImportExport(const char* filename, const char* pPassword) { maTempFile.EnableKillingFile(false); |