summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2021-02-17 23:46:23 +0100
committerAndras Timar <andras.timar@collabora.com>2021-02-22 12:15:53 +0100
commit185f3117e8090f796dd437899bcf02c024e6af72 (patch)
tree85b54fb02e05dad5ce21b4ab8af12ce59a86fd0c
parent3f62b71938530fd7e89800fb8fc14634b4fabb56 (diff)
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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--sd/qa/unit/SVGExportTests.cxx58
1 files changed, 58 insertions, 0 deletions
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();
};