From 185f3117e8090f796dd437899bcf02c024e6af72 Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Wed, 17 Feb 2021 23:46:23 +0100 Subject: filter: svg: unit test for placeholder locale We set the language to it-IT and check that the exported placeholder text is still instead of Change-Id: I7ec7e25e53075da38cb87d81e9f8268b37121bfe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111115 Tested-by: Jenkins CollaboraOffice Reviewed-by: Andras Timar --- sd/qa/unit/SVGExportTests.cxx | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/sd/qa/unit/SVGExportTests.cxx b/sd/qa/unit/SVGExportTests.cxx index 8401d85591a8..0b4cc8f52e6a 100644 --- a/sd/qa/unit/SVGExportTests.cxx +++ b/sd/qa/unit/SVGExportTests.cxx @@ -15,6 +15,9 @@ #include #include #include +#include +#include +#include #include @@ -66,6 +69,29 @@ static bool isValidTiledBackgroundId(const OUString& sId) class SdSVGFilterTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { + class Resetter + { + private: + std::function m_Func; + + public: + Resetter(std::function const& rFunc) + : m_Func(rFunc) + { + } + ~Resetter() + { + try + { + m_Func(); + } + catch (...) // has to be reliable + { + CPPUNIT_FAIL("resetter failed with exception"); + } + } + }; + uno::Reference mxComponent; utl::TempFile maTempFile; @@ -279,6 +305,37 @@ public: CPPUNIT_ASSERT_EQUAL_MESSAGE("The href attribute for does not match the tiled background id attribute: ", sBackgroundId, sRef); } + void testSVGPlaceholderLocale() + { + static const OUString aLangISO("it-IT"); + SvtSysLocaleOptions aSysLocaleOptions; + aSysLocaleOptions.SetLocaleConfigString(aLangISO); + aSysLocaleOptions.SetUILocaleConfigString(aLangISO); + + auto aSavedSettings = Application::GetSettings(); + Resetter aResetter([&]() { Application::SetSettings(aSavedSettings); }); + AllSettings aSettings(aSavedSettings); + aSettings.SetLanguageTag(aLangISO, true); + Application::SetSettings(aSettings); + + executeExport("text-fields.odp"); + + xmlDocPtr svgDoc = parseXml(maTempFile); + CPPUNIT_ASSERT(svgDoc); + + assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_DEFS[9]/SVG_G[2] ), "class", "Master_Slide"); + assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_DEFS[9]/SVG_G[2]/SVG_G[2] ), "class", "BackgroundObjects"); + + // Slide Name Field + assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_DEFS[9]/SVG_G[2]/SVG_G[2]/SVG_G[6] ), "class", "TextShape"); + assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_DEFS[9]/SVG_G[2]/SVG_G[2]/SVG_G[6]/SVG_G/SVG_TEXT/SVG_TSPAN/SVG_TSPAN/SVG_TSPAN ), "class", "PlaceholderText"); + assertXPathContent(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_DEFS[9]/SVG_G[2]/SVG_G[2]/SVG_G[6]/SVG_G/SVG_TEXT/SVG_TSPAN/SVG_TSPAN/SVG_TSPAN ), ""); + // Slide Number Field + assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_DEFS[9]/SVG_G[2]/SVG_G[2]/SVG_G[7] ), "class", "TextShape"); + assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_DEFS[9]/SVG_G[2]/SVG_G[2]/SVG_G[7]/SVG_G/SVG_TEXT/SVG_TSPAN/SVG_TSPAN/SVG_TSPAN ), "class", "PlaceholderText"); + assertXPathContent(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_DEFS[9]/SVG_G[2]/SVG_G[2]/SVG_G[7]/SVG_G/SVG_TEXT/SVG_TSPAN/SVG_TSPAN/SVG_TSPAN ), ""); + } + CPPUNIT_TEST_SUITE(SdSVGFilterTest); CPPUNIT_TEST(testSVGExportTextDecorations); CPPUNIT_TEST(testSVGExportJavascriptURL); @@ -286,6 +343,7 @@ public: CPPUNIT_TEST(testSVGExportTextFieldsInMasterPage); CPPUNIT_TEST(testSVGExportSlideBitmapBackground); CPPUNIT_TEST(testSVGExportSlideTileBitmapBackground); + CPPUNIT_TEST(testSVGPlaceholderLocale); CPPUNIT_TEST_SUITE_END(); }; -- cgit