[Libreoffice-commits] core.git: filter/source sd/qa

Marco Cecchetti marco.cecchetti at collabora.com
Sat Nov 28 15:09:52 PST 2015


 filter/source/svg/svgwriter.cxx |    8 +++-
 sd/qa/unit/SVGExportTests.cxx   |   77 +++++++++++++++++++++++++++++++++-------
 2 files changed, 70 insertions(+), 15 deletions(-)

New commits:
commit 50506421f29d09fa4c44c46c3d60208a64a1c450
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Mon Nov 9 17:50:33 2015 +0100

    tdf#95356: unit test about text decorations for svg export
    
    1) Fixed the trailing space issue in text decoration attribute value.
    
    2) Changed the SVG export suite in order to make it more reusable for
    other tests.
    
    3) Added a unit test for testing that text decorations are exported
    correctly.
    
    Change-Id: I2bd71974242a0007726fbdd5ef5637a9ec62fd47
    Reviewed-on: https://gerrit.libreoffice.org/19870
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 14981f5..ceb2dec 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -806,13 +806,17 @@ void SVGTextWriter::addFontAttributes( bool bIsTextContainer )
             if( eCurFontUnderline != eParFontUnderline )
             {
                 if( eCurFontUnderline != UNDERLINE_NONE )
-                    sTextDecoration = "underline ";
+                    sTextDecoration = "underline";
                 bIsDecorationChanged = true;
             }
             if( eCurFontStrikeout != eParFontStrikeout )
             {
                 if( eCurFontStrikeout != STRIKEOUT_NONE )
-                    sTextDecoration += "line-through ";
+                {
+                    if( !sTextDecoration.isEmpty() )
+                        sTextDecoration += " ";
+                    sTextDecoration += "line-through";
+                }
                 bIsDecorationChanged = true;
             }
 
diff --git a/sd/qa/unit/SVGExportTests.cxx b/sd/qa/unit/SVGExportTests.cxx
index 8dbbbc9..cd4259c 100644
--- a/sd/qa/unit/SVGExportTests.cxx
+++ b/sd/qa/unit/SVGExportTests.cxx
@@ -16,13 +16,52 @@
 #include <comphelper/processfactory.hxx>
 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
 
+#include <boost/preprocessor/stringize.hpp>
+
+#define MAKE_PATH_STRING( path ) BOOST_PP_STRINGIZE( path )
+#define SVG_SVG  *[name()='svg']
+#define SVG_G *[name()='g']
+#define SVG_TEXT *[name()='text']
+#define SVG_TSPAN *[name()='tspan']
+
 using namespace css;
 
-class SdSVGFilterTest : public SdModelTestBase, public XmlTestTools
+class SdSVGFilterTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
 {
     uno::Reference<lang::XComponent> mxComponent;
     utl::TempFile maTempFile;
 
+protected:
+    virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override
+    {
+        xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("svg"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"));
+    }
+
+    void load(const char* pDir, const char* pName)
+    {
+        return loadURL(getURLFromSrc(pDir) + OUString::createFromAscii(pName), pName);
+    }
+
+    void loadURL(OUString const& rURL, const char* pName)
+    {
+        if (mxComponent.is())
+            mxComponent->dispose();
+        // Output name early, so in the case of a hang, the name of the hanging input file is visible.
+        if (pName)
+            std::cout << pName << ",";
+        mxComponent = loadFromDesktop(rURL);
+        CPPUNIT_ASSERT(mxComponent.is());
+    }
+
+    void save()
+    {
+        uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+        utl::MediaDescriptor aMediaDescriptor;
+        OUString aFilterName("impress_svg_Export");
+        aMediaDescriptor["FilterName"] <<= aFilterName;
+        xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+    }
+
 public:
     SdSVGFilterTest()
     {
@@ -31,7 +70,7 @@ public:
 
     virtual void setUp() override
     {
-        SdModelTestBase::setUp();
+        test::BootstrapFixture::setUp();
 
         mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
     }
@@ -41,23 +80,35 @@ public:
         if (mxComponent.is())
             mxComponent->dispose();
 
-        SdModelTestBase::tearDown();
+        test::BootstrapFixture::tearDown();
+    }
+
+    void executeExport(const char* pName)
+    {
+        load( "/sd/qa/unit/data/odp/", pName );
+        save();
     }
 
     void testSVGExportTextDecorations()
     {
-        mxComponent = loadFromDesktop(getURLFromSrc("/sd/qa/unit/data/odp/svg-export-text-decorations.odp"));
-        CPPUNIT_ASSERT(mxComponent.is());
+        executeExport( "svg-export-text-decorations.odp" );
 
-        uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
-        utl::MediaDescriptor aMediaDescriptor;
-        OUString aFilterName("impress_svg_Export");
-        aMediaDescriptor["FilterName"] <<= aFilterName;
-        xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
-        xmlDocPtr pXmlDoc = parseXml(maTempFile);
-        CPPUNIT_ASSERT(pXmlDoc);
+        xmlDocPtr svgDoc = parseXml(maTempFile);
+        CPPUNIT_ASSERT(svgDoc);
+
+        svgDoc->name = reinterpret_cast<char *>(xmlStrdup(reinterpret_cast<xmlChar const *>(OUStringToOString(maTempFile.GetURL(), RTL_TEXTENCODING_UTF8).getStr())));
+
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG ), 1);
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2] ), "class", "SlideGroup");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G ), "class", "Slide");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1] ), "class", "TitleText");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT ), "class", "TextShape");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT/SVG_TSPAN ), "class", "TextParagraph");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT/SVG_TSPAN ), "text-decoration", "underline");
 
-        // TODO use assertXPath() here.
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT ), "class", "TextShape");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT/SVG_TSPAN ), "class", "TextParagraph");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT/SVG_TSPAN ), "text-decoration", "line-through");
     }
 
     CPPUNIT_TEST_SUITE(SdSVGFilterTest);


More information about the Libreoffice-commits mailing list