diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-01-11 21:39:16 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-01-12 08:11:44 +0100 |
commit | ac025a464086c73c564024f484fd181c97138bd9 (patch) | |
tree | d7477f4f58b90094d4add27f594ab15fbeddb035 /sw/qa/extras | |
parent | dc35df15c5d125ff0caf82e9e7c99695d7cd7dfc (diff) |
CppunitTest_sw_odfexport: rework to avoid preTest()
See commit a226cec52e536c46e03f57a5f1f7931abbeb0cdd
(CppunitTest_sw_rtfimport: convert one testcase to use
CPPUNIT_TEST_FIXTURE(), 2019-11-05) for motivation.
Change-Id: Ie7187c7a843a191475688a4a6390514199c6a1c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128298
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/odfexport/odfexport.cxx | 71 |
1 files changed, 31 insertions, 40 deletions
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index d3fe6465b4d4..d7aef384764e 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -51,6 +51,7 @@ #include <svl/PasswordHelper.hxx> #include <comphelper/sequenceashashmap.hxx> #include <vcl/filter/PDFiumLibrary.hxx> +#include <comphelper/scopeguard.hxx> #include <docufld.hxx> // for SwHiddenTextField::ParseIfFieldDefinition() method call #include <unoprnms.hxx> @@ -80,47 +81,24 @@ public: { return true; } - - virtual std::unique_ptr<Resetter> preTest(const char* pFilename) override - { - if (pFilename == std::string_view("fdo58949.docx")) - { - std::unique_ptr<Resetter> pResetter(new Resetter( - [] () { - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(true, pBatch); - return pBatch->commit(); - })); - - std::shared_ptr<comphelper::ConfigurationChanges> pBatch(comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(false, pBatch); - pBatch->commit(); - return pResetter; - } - if (pFilename == std::string_view("2_MathType3.docx")) - { - std::unique_ptr<Resetter> pResetter(new Resetter( - [this] () { - mpFilter = "writer8"; - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Cache::Writer::OLE_Objects::set(20, pBatch); - return pBatch->commit(); - })); - mpFilter = "OpenDocument Text Flat XML"; // doesn't happen with ODF package - std::shared_ptr<comphelper::ConfigurationChanges> pBatch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Common::Cache::Writer::OLE_Objects::set(1, pBatch); - pBatch->commit(); - return pResetter; - } - return nullptr; - } }; -DECLARE_ODFEXPORT_TEST(testMathObjectFlatExport, "2_MathType3.docx") -{ +CPPUNIT_TEST_FIXTURE(Test, testMathObjectFlatExport) +{ + comphelper::ScopeGuard g([this]() { + mpFilter = "writer8"; + std::shared_ptr<comphelper::ConfigurationChanges> pBatch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Cache::Writer::OLE_Objects::set(20, pBatch); + return pBatch->commit(); + }); + mpFilter = "OpenDocument Text Flat XML"; // doesn't happen with ODF package + std::shared_ptr<comphelper::ConfigurationChanges> pBatch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Cache::Writer::OLE_Objects::set(1, pBatch); + pBatch->commit(); + loadAndReload("2_MathType3.docx"); + uno::Reference<util::XModifiable> xModifiable(mxComponent, uno::UNO_QUERY); CPPUNIT_ASSERT(!xModifiable->isModified()); // see preTest(), set the OLE cache to 1 for this test @@ -901,8 +879,21 @@ DECLARE_ODFEXPORT_TEST(testTdf115815, "tdf115815.odt") CPPUNIT_ASSERT_EQUAL(OUString("Lorem "), sTextBeforeAnnotation); } -DECLARE_ODFEXPORT_TEST(testFdo58949, "fdo58949.docx") +CPPUNIT_TEST_FIXTURE(Test, testFdo58949) { + comphelper::ScopeGuard g([]() { + std::shared_ptr<comphelper::ConfigurationChanges> pBatch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(true, pBatch); + pBatch->commit(); + }); + + std::shared_ptr<comphelper::ConfigurationChanges> pBatch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(false, pBatch); + pBatch->commit(); + loadAndReload("fdo58949.docx"); + /* * The problem was that the exporter didn't insert "Obj102" to the * resulting zip file. No idea how to check for "broken" (missing OLE data |