sd/qa/unit/SVGExportTests.cxx | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)
New commits: commit 185f3117e8090f796dd437899bcf02c024e6af72 Author: Marco Cecchetti <marco.cecche...@collabora.com> AuthorDate: Wed Feb 17 23:46:23 2021 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Mon Feb 22 12:15:53 2021 +0100 filter: svg: unit test for placeholder locale We set the language to it-IT and check that the exported placeholder text is still <number> instead of <numero> Change-Id: I7ec7e25e53075da38cb87d81e9f8268b37121bfe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111115 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> 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 <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <comphelper/processfactory.hxx> +#include <unotools/syslocaleoptions.hxx> +#include <vcl/svapp.hxx> +#include <vcl/settings.hxx> #include <boost/preprocessor/stringize.hpp> @@ -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<void ()> m_Func; + + public: + Resetter(std::function<void ()> const& rFunc) + : m_Func(rFunc) + { + } + ~Resetter() + { + try + { + m_Func(); + } + catch (...) // has to be reliable + { + CPPUNIT_FAIL("resetter failed with exception"); + } + } + }; + uno::Reference<lang::XComponent> mxComponent; utl::TempFile maTempFile; @@ -279,6 +305,37 @@ public: CPPUNIT_ASSERT_EQUAL_MESSAGE("The href attribute for <use> 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-name>"); + // 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 ), "<number>"); + } + 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(); }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits