diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2023-07-18 19:54:33 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2023-07-19 11:55:18 +0200 |
commit | a85cb997bc84a26196d8852bd0d546db1de3b761 (patch) | |
tree | 2108eae07df9e5a112dc5220d0437aa8a2794a1f | |
parent | b68a6d6ce18a611873c166e72a97930812bfbbc0 (diff) |
CppunitTest_sw_htmlexport: rework to avoid preTest()
Which means no magic happens just because a test document is called
charborder.odt.
Change-Id: I8eda9d1cdc905a6041369321469cbf34c375da83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154597
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 81 |
1 files changed, 40 insertions, 41 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index f58105b55d4b..ebeab5963eda 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -44,6 +44,7 @@ #include <vcl/dibtools.hxx> #include <o3tl/string_view.hxx> #include <editeng/brushitem.hxx> +#include <comphelper/scopeguard.hxx> #include <swmodule.hxx> #include <swdll.hxx> @@ -201,22 +202,6 @@ public: rStream.WriteOString("}"); rStream.Seek(0); } - -private: - virtual std::unique_ptr<Resetter> preTest(const char* filename) override - { - if (filename == std::string_view("charborder.odt")) - { - // FIXME if padding-top gets exported as inches, not cms, we get rounding errors. - SwGlobals::ensure(); // make sure that SW_MOD() is not 0 - SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false)); - std::unique_ptr<Resetter> pResetter( - new Resetter([ pPref, eUnit = pPref->GetMetric() ]() { pPref->SetMetric(eUnit); })); - pPref->SetMetric(FieldUnit::CM); - return pResetter; - } - return nullptr; - } }; #define DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(TestName, filename) \ @@ -347,35 +332,49 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testFdo86857, "fdo86857.html") CPPUNIT_ASSERT_EQUAL(Color(0x66ffff), getProperty<Color>(xCell, "BackColor")); } -DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testCharacterBorder, "charborder.odt") +CPPUNIT_TEST_FIXTURE(HtmlExportTest, testCharacterBorder) { - CPPUNIT_ASSERT_EQUAL(1, getPages()); + // FIXME if padding-top gets exported as inches, not cms, we get rounding errors. + SwGlobals::ensure(); // make sure that SW_MOD() is not 0 + SwMasterUsrPref* pPref = const_cast<SwMasterUsrPref*>(SW_MOD()->GetUsrPref(false)); + FieldUnit eUnit = pPref->GetMetric(); + pPref->SetMetric(FieldUnit::CM); + comphelper::ScopeGuard g([pPref, eUnit]() { pPref->SetMetric(eUnit); }); - uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 1), uno::UNO_QUERY); - // Different Border - { - CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0x6666FF, 12, 12, 12, 3, 37), - getProperty<table::BorderLine2>(xRun, "CharTopBorder")); - CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF9900, 0, 99, 0, 2, 99), - getProperty<table::BorderLine2>(xRun, "CharLeftBorder")); - CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF0000, 0, 169, 0, 1, 169), - getProperty<table::BorderLine2>(xRun, "CharBottomBorder")); - CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0x0000FF, 0, 169, 0, 0, 169), - getProperty<table::BorderLine2>(xRun, "CharRightBorder")); - } + auto verify = [this]() { + CPPUNIT_ASSERT_EQUAL(1, getPages()); - // Different Padding - { - CPPUNIT_ASSERT_EQUAL(sal_Int32(450), getProperty<sal_Int32>(xRun, "CharTopBorderDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(550), - getProperty<sal_Int32>(xRun, "CharLeftBorderDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(150), - getProperty<sal_Int32>(xRun, "CharBottomBorderDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(250), - getProperty<sal_Int32>(xRun, "CharRightBorderDistance")); - } + uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 1), uno::UNO_QUERY); + // Different Border + { + CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0x6666FF, 12, 12, 12, 3, 37), + getProperty<table::BorderLine2>(xRun, "CharTopBorder")); + CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF9900, 0, 99, 0, 2, 99), + getProperty<table::BorderLine2>(xRun, "CharLeftBorder")); + CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF0000, 0, 169, 0, 1, 169), + getProperty<table::BorderLine2>(xRun, "CharBottomBorder")); + CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0x0000FF, 0, 169, 0, 0, 169), + getProperty<table::BorderLine2>(xRun, "CharRightBorder")); + } + + // Different Padding + { + CPPUNIT_ASSERT_EQUAL(sal_Int32(450), + getProperty<sal_Int32>(xRun, "CharTopBorderDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(550), + getProperty<sal_Int32>(xRun, "CharLeftBorderDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(150), + getProperty<sal_Int32>(xRun, "CharBottomBorderDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(250), + getProperty<sal_Int32>(xRun, "CharRightBorderDistance")); + } - // No shadow + // No shadow + }; + createSwDoc("charborder.odt"); + verify(); + saveAndReload(mpFilter); + verify(); } #define DECLARE_HTMLEXPORT_TEST(TestName, filename) \ |