unoxml/CppunitTest_unoxml_domtest.mk |   47 ++++++++++
 unoxml/Module_unoxml.mk              |    4 
 unoxml/test/domtest.cxx              |  150 ++++++++++++-----------------------
 3 files changed, 103 insertions(+), 98 deletions(-)

New commits:
commit dbbd89efdeaa44421d1f2ad774c342009d881d9b
Author: Tobias Madl <tobias.madl....@gmail.com>
Date:   Tue Sep 23 11:43:14 2014 +0000

    fdo#39625 Make existing CppUnit tests work
    
    As in the ticket description, this test is now working, but
    some parts of it are still commented out, because they are waiting
    for a fix of another bug (Bug 84237). Once it is fixed, it should
    be possible to just uncomment them, and then they should work.
    
    Change-Id: I73d1cc7391080e357c08cb3442616e2901070c1f
    Signed-off-by: Stephan Bergmann <sberg...@redhat.com> (with minor 
amendments)

diff --git a/unoxml/CppunitTest_unoxml_domtest.mk 
b/unoxml/CppunitTest_unoxml_domtest.mk
new file mode 100644
index 0000000..b12fd1e
--- /dev/null
+++ b/unoxml/CppunitTest_unoxml_domtest.mk
@@ -0,0 +1,47 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,unoxml_domtest))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,unoxml_domtest, \
+    unoxml/test/domtest \
+))
+
+$(eval $(call gb_CppunitTest_use_api,unoxml_domtest,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_components,unoxml_domtest,\
+    configmgr/source/configmgr \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+    sfx2/util/sfx \
+    ucb/source/core/ucb1 \
+    ucb/source/ucp/file/ucpfile1 \
+    unoxml/source/service/unoxml \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,unoxml_domtest, \
+    boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,unoxml_domtest, \
+    comphelper \
+    cppu \
+    cppuhelper \
+    sal \
+    test \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,unoxml_domtest))
+$(eval $(call gb_CppunitTest_use_ure,unoxml_domtest))
+$(eval $(call gb_CppunitTest_use_vcl,unoxml_domtest))
+
+# vim: set noet sw=4 ts=4:
diff --git a/unoxml/Module_unoxml.mk b/unoxml/Module_unoxml.mk
index 53cf589..bb06953 100644
--- a/unoxml/Module_unoxml.mk
+++ b/unoxml/Module_unoxml.mk
@@ -24,6 +24,10 @@ $(eval $(call gb_Module_add_targets,unoxml,\
     Library_unordf \
 ))
 
+$(eval $(call gb_Module_add_slowcheck_targets,unoxml,\
+    CppunitTest_unoxml_domtest \
+))
+
 ifneq ($(OOO_JUNIT_JAR),)
 $(eval $(call gb_Module_add_subsequentcheck_targets,unoxml,\
     JunitTest_unoxml_complex \
diff --git a/unoxml/test/domtest.cxx b/unoxml/test/domtest.cxx
index 5d49922..07d1738 100644
--- a/unoxml/test/domtest.cxx
+++ b/unoxml/test/domtest.cxx
@@ -17,28 +17,34 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-// autogenerated file with codegen.pl
-
-#include <testshl/simpleheader.hxx>
-
 #include <rtl/ref.hxx>
+#include <rtl/byteseq.hxx>
 #include <osl/file.hxx>
 #include <osl/process.h>
 #include <comphelper/seqstream.hxx>
 #include <comphelper/sequence.hxx>
+#include <comphelper/processfactory.hxx>
 #include <cppuhelper/compbase1.hxx>
 #include <cppuhelper/bootstrap.hxx>
 #include <cppuhelper/basemutex.hxx>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <unotest/macros_test.hxx>
+#include <test/bootstrapfixture.hxx>
 
+#include <com/sun/star/xml/dom/DocumentBuilder.hpp>
 #include <com/sun/star/xml/sax/FastToken.hpp>
 #include <com/sun/star/xml/sax/XSAXSerializable.hpp>
 #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
-
 #include "../source/dom/documentbuilder.hxx"
 
 using namespace ::DOM;
 using namespace ::comphelper;
 using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using css::xml::dom::XDocumentBuilder;
+using css::xml::dom::DocumentBuilder;
 
 namespace
 {
@@ -96,17 +102,17 @@ struct ErrorHandler
     ErrorHandler() : mnErrCount(0), mnFatalCount(0), mnWarnCount(0)
     {}
 
-    virtual void SAL_CALL error( const uno::Any& ) throw 
(xml::sax::SAXException, uno::RuntimeException)
+    virtual void SAL_CALL error( const uno::Any& ) throw 
(xml::sax::SAXException, uno::RuntimeException) SAL_OVERRIDE
     {
         ++mnErrCount;
     }
 
-    virtual void SAL_CALL fatalError( const uno::Any& ) throw 
(xml::sax::SAXException, uno::RuntimeException)
+    virtual void SAL_CALL fatalError( const uno::Any& ) throw 
(xml::sax::SAXException, uno::RuntimeException) SAL_OVERRIDE
     {
         ++mnFatalCount;
     }
 
-    virtual void SAL_CALL warning( const uno::Any& ) throw 
(xml::sax::SAXException, uno::RuntimeException)
+    virtual void SAL_CALL warning( const uno::Any& ) throw 
(xml::sax::SAXException, uno::RuntimeException) SAL_OVERRIDE
     {
         ++mnWarnCount;
     }
@@ -116,48 +122,48 @@ struct DocumentHandler
     : public ::cppu::WeakImplHelper1< xml::sax::XFastDocumentHandler >
 {
     // XFastContextHandler
-    virtual void SAL_CALL startFastElement( ::sal_Int32 Element, const 
uno::Reference< xml::sax::XFastAttributeList >& Attribs ) throw 
(xml::sax::SAXException, uno::RuntimeException)
+    virtual void SAL_CALL startFastElement( ::sal_Int32 Element, const 
uno::Reference< xml::sax::XFastAttributeList >& ) throw 
(xml::sax::SAXException, uno::RuntimeException) SAL_OVERRIDE
     {
         OSL_TRACE("Seen element: %c with namespace 0x%x",
                   Element & 0xFFFF, Element & 0xFFFF0000);
     }
 
-    virtual void SAL_CALL startUnknownElement( const OUString& Namespace, 
const OUString& Name, const uno::Reference< xml::sax::XFastAttributeList >& 
Attribs ) throw (xml::sax::SAXException, uno::RuntimeException)
+    virtual void SAL_CALL startUnknownElement( const OUString& , const 
OUString& , const uno::Reference< xml::sax::XFastAttributeList >& ) throw 
(xml::sax::SAXException, uno::RuntimeException) SAL_OVERRIDE
     {
     }
 
-    virtual void SAL_CALL endFastElement( ::sal_Int32 Element ) throw 
(xml::sax::SAXException, uno::RuntimeException)
+    virtual void SAL_CALL endFastElement( ::sal_Int32 ) throw 
(xml::sax::SAXException, uno::RuntimeException) SAL_OVERRIDE
     {
     }
 
-    virtual void SAL_CALL endUnknownElement( const OUString& Namespace, const 
OUString& Name ) throw (xml::sax::SAXException, uno::RuntimeException)
+    virtual void SAL_CALL endUnknownElement( const OUString&, const OUString& 
) throw (xml::sax::SAXException, uno::RuntimeException) SAL_OVERRIDE
     {
     }
 
-    virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL 
createFastChildContext( ::sal_Int32 Element, const uno::Reference< 
xml::sax::XFastAttributeList >& Attribs ) throw (xml::sax::SAXException, 
uno::RuntimeException)
+    virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL 
createFastChildContext( ::sal_Int32 , const uno::Reference< 
xml::sax::XFastAttributeList >& ) throw (xml::sax::SAXException, 
uno::RuntimeException) SAL_OVERRIDE
     {
         return this;
     }
 
-    virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL 
createUnknownChildContext( const OUString& Namespace, const OUString& Name, 
const uno::Reference< xml::sax::XFastAttributeList >& Attribs ) throw 
(xml::sax::SAXException, uno::RuntimeException)
+    virtual uno::Reference< xml::sax::XFastContextHandler > SAL_CALL 
createUnknownChildContext( const OUString& , const OUString& , const 
uno::Reference< xml::sax::XFastAttributeList >& ) throw 
(xml::sax::SAXException, uno::RuntimeException) SAL_OVERRIDE
     {
         return this;
     }
 
-    virtual void SAL_CALL characters( const OUString& aChars ) throw 
(xml::sax::SAXException, uno::RuntimeException)
+    virtual void SAL_CALL characters( const OUString& ) throw 
(xml::sax::SAXException, uno::RuntimeException) SAL_OVERRIDE
     {
     }
 
     // XFastDocumentHandler
-    virtual void SAL_CALL startDocument(  ) throw (xml::sax::SAXException, 
uno::RuntimeException)
+    virtual void SAL_CALL startDocument(  ) throw (xml::sax::SAXException, 
uno::RuntimeException) SAL_OVERRIDE
     {
     }
 
-    virtual void SAL_CALL endDocument(  ) throw (xml::sax::SAXException, 
uno::RuntimeException)
+    virtual void SAL_CALL endDocument(  ) throw (xml::sax::SAXException, 
uno::RuntimeException) SAL_OVERRIDE
     {
     }
 
-    virtual void SAL_CALL setDocumentLocator( const uno::Reference< 
xml::sax::XLocator >& xLocator ) throw (xml::sax::SAXException, 
uno::RuntimeException)
+    virtual void SAL_CALL setDocumentLocator( const uno::Reference< 
xml::sax::XLocator >& ) throw (xml::sax::SAXException, uno::RuntimeException) 
SAL_OVERRIDE
     {
     }
 };
@@ -165,27 +171,13 @@ struct DocumentHandler
 struct TokenHandler
     : public ::cppu::WeakImplHelper1< xml::sax::XFastTokenHandler >
 {
-    virtual ::sal_Int32 SAL_CALL getToken( const OUString& Identifier ) throw 
(uno::RuntimeException)
-    {
-        CPPUNIT_ASSERT_MESSAGE( "TokenHandler::getToken() unexpected call",
-                                false );
-        return -1;
-    }
-
-    virtual OUString SAL_CALL getIdentifier( ::sal_Int32 Token ) throw 
(uno::RuntimeException)
-    {
-        CPPUNIT_ASSERT_MESSAGE( "TokenHandler::getIdentifier() unexpected 
call",
-                                false );
-        return OUString();
-    }
-
-    virtual ::sal_Int32 SAL_CALL getTokenFromUTF8( const uno::Sequence< 
::sal_Int8 >& Identifier ) throw (uno::RuntimeException)
+    virtual ::sal_Int32 SAL_CALL getTokenFromUTF8( const uno::Sequence< 
::sal_Int8 >& Identifier ) throw (uno::RuntimeException) SAL_OVERRIDE
     {
         OSL_TRACE("getTokenFromUTF8() %s", (const 
char*)Identifier.getConstArray());
         return Identifier.getLength() ? Identifier[0] : 0;
     }
 
-    virtual uno::Sequence< ::sal_Int8 > SAL_CALL getUTF8Identifier( 
::sal_Int32 Token ) throw (uno::RuntimeException)
+    virtual uno::Sequence< ::sal_Int8 > SAL_CALL getUTF8Identifier( 
::sal_Int32 ) throw (uno::RuntimeException) SAL_OVERRIDE
     {
         CPPUNIT_ASSERT_MESSAGE( "TokenHandler::getUTF8Identifier() unexpected 
call",
                                 false );
@@ -193,29 +185,26 @@ struct TokenHandler
     }
 };
 
-struct BasicTest : public CppUnit::TestFixture
+struct BasicTest : public test::BootstrapFixture
 {
-    rtl::Reference<CDocumentBuilder>    mxDomBuilder;
+    uno::Reference<XDocumentBuilder>    mxDomBuilder;
     rtl::Reference<ErrorHandler>        mxErrHandler;
     rtl::Reference<SequenceInputStream> mxValidInStream;
     rtl::Reference<SequenceInputStream> mxWarningInStream;
     rtl::Reference<SequenceInputStream> mxErrorInStream;
     rtl::Reference<SequenceInputStream> mxFatalInStream;
 
-    void setUp()
+    virtual void setUp() SAL_OVERRIDE
     {
-        // luckily, DOM builder doesn't use service fac, so we need
-        // not bootstrap uno here
+        test::BootstrapFixture::setUp();
+
         mxErrHandler.set( new ErrorHandler() );
-        mxDomBuilder.set( new CDocumentBuilder(Reference< XMultiServiceFactory 
>() ));
-        mxValidInStream.set( new 
SequenceInputStream(ByteSequence((sal_Int8*)validTestFile,
-                                                                  
SAL_N_ELEMENTS(validTestFile))) );
-        mxWarningInStream.set( new 
SequenceInputStream(ByteSequence((sal_Int8*)warningTestFile,
-                                                                    
SAL_N_ELEMENTS(warningTestFile))) );
-        mxErrorInStream.set( new 
SequenceInputStream(ByteSequence((sal_Int8*)errorTestFile,
-                                                                  
SAL_N_ELEMENTS(errorTestFile))) );
-        mxFatalInStream.set( new 
SequenceInputStream(ByteSequence((sal_Int8*)fatalTestFile,
-                                                                  
SAL_N_ELEMENTS(fatalTestFile))) );
+        uno::Reference<XDocumentBuilder> xDB( 
getMultiServiceFactory()->createInstance(OUString("com.sun.star.xml.dom.DocumentBuilder")),
 uno::UNO_QUERY_THROW );
+        mxDomBuilder.set( xDB );
+        mxValidInStream.set( new 
SequenceInputStream(css::uno::Sequence<sal_Int8>((sal_Int8*)validTestFile, 
SAL_N_ELEMENTS(validTestFile))) );
+        mxWarningInStream.set( new 
SequenceInputStream(css::uno::Sequence<sal_Int8>((sal_Int8*)warningTestFile, 
SAL_N_ELEMENTS(warningTestFile))) );
+        mxErrorInStream.set( new 
SequenceInputStream(css::uno::Sequence<sal_Int8>((sal_Int8*)errorTestFile, 
SAL_N_ELEMENTS(errorTestFile))) );
+        mxFatalInStream.set( new 
SequenceInputStream(css::uno::Sequence<sal_Int8>((sal_Int8*)fatalTestFile, 
SAL_N_ELEMENTS(fatalTestFile))) );
         mxDomBuilder->setErrorHandler(mxErrHandler.get());
     }
 
@@ -228,7 +217,7 @@ struct BasicTest : public CppUnit::TestFixture
         CPPUNIT_ASSERT_MESSAGE( "Valid input file resulted in parse errors",
                                 mxErrHandler->noErrors() );
     }
-
+/*
     void warningInputTest()
     {
         CPPUNIT_ASSERT_MESSAGE( "Valid input file did not result in XDocument 
#2",
@@ -258,71 +247,36 @@ struct BasicTest : public CppUnit::TestFixture
         CPPUNIT_ASSERT_MESSAGE( "No fatal parse errors in unclean input file",
                                 !mxErrHandler->mnWarnCount && 
!mxErrHandler->mnErrCount && mxErrHandler->mnFatalCount );
     };
-
+*/
     // Change the following lines only, if you add, remove or rename
     // member functions of the current class,
     // because these macros are need by auto register mechanism.
     CPPUNIT_TEST_SUITE(BasicTest);
     CPPUNIT_TEST(validInputTest);
-    CPPUNIT_TEST(warningInputTest);
-    CPPUNIT_TEST(errorInputTest);
-    CPPUNIT_TEST(fatalInputTest);
+    //CPPUNIT_TEST(warningInputTest);
+    //CPPUNIT_TEST(errorInputTest);
+    //CPPUNIT_TEST(fatalInputTest);
     CPPUNIT_TEST_SUITE_END();
 };
 
-struct SerializerTest : public CppUnit::TestFixture
+struct SerializerTest : public test::BootstrapFixture
 {
-    SerializerTest() : mbUnoInitialized(false) {}
-
-    uno::Reference<uno::XComponentContext>                   mxCtx;
-    rtl::Reference<CDocumentBuilder>                         mxDomBuilder;
+    uno::Reference<XDocumentBuilder>                         mxDomBuilder;
     rtl::Reference<ErrorHandler>                             mxErrHandler;
     rtl::Reference<SequenceInputStream>                      mxInStream;
     rtl::Reference<DocumentHandler>                          mxHandler;
     rtl::Reference<TokenHandler>                             mxTokHandler;
     uno::Sequence< beans::Pair< OUString, sal_Int32 > > maRegisteredNamespaces;
-    bool                                                     mbUnoInitialized;
 
-    void setUp()
+    void setUp() SAL_OVERRIDE
     {
-        // need working typelib, bootstrap UNO now
-        if( !mbUnoInitialized )
-        {
-            const char* pArgs( getForwardString() );
-            CPPUNIT_ASSERT_MESSAGE("Test file parameter", pArgs);
-
-            const OUString sBaseDir=OUString::createFromAscii(pArgs);
-
-            // bootstrap UNO
-            try
-            {
-                OUString aIniUrl;
-                CPPUNIT_ASSERT_MESSAGE(
-                    "Converting ini file to URL",
-                    osl_getFileURLFromSystemPath(
-                        (sBaseDir+rtl::"unoxml_unittest_test.ini").pData,
-                        &aIniUrl.pData ) == osl_File_E_None );
-
-                mxCtx = 
::cppu::defaultBootstrap_InitialComponentContext(aIniUrl);
-                CPPUNIT_ASSERT_MESSAGE("Getting component context", 
mxCtx.is());
-            }
-            catch( uno::Exception& )
-            {
-                CPPUNIT_ASSERT_MESSAGE("Bootstrapping UNO", false);
-            }
-
-            mbUnoInitialized = true;
-        }
+        test::BootstrapFixture::setUp();
 
         mxErrHandler.set( new ErrorHandler() );
-        mxDomBuilder.set( new CDocumentBuilder(
-                              uno::Reference< lang::XMultiServiceFactory >(
-                                  mxCtx->getServiceManager(),
-                                  uno::UNO_QUERY )));
-        mxInStream.set( new 
SequenceInputStream(ByteSequence((sal_Int8*)validTestFile,
-                                                             
SAL_N_ELEMENTS(validTestFile))) );
+        uno::Reference<XDocumentBuilder> xDB( 
getMultiServiceFactory()->createInstance(OUString("com.sun.star.xml.dom.DocumentBuilder")),
 uno::UNO_QUERY_THROW );
+        mxDomBuilder.set( xDB );
+        mxInStream.set( new 
SequenceInputStream(css::uno::Sequence<sal_Int8>((sal_Int8*)validTestFile, 
SAL_N_ELEMENTS(validTestFile))) );
         mxDomBuilder->setErrorHandler(mxErrHandler.get());
-
         mxHandler.set( new DocumentHandler() );
         mxTokHandler.set( new TokenHandler() );
 
@@ -371,12 +325,12 @@ struct SerializerTest : public CppUnit::TestFixture
     CPPUNIT_TEST_SUITE_END();
 };
 
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BasicTest, "BasicTest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(SerializerTest, "SerializerTest");
+CPPUNIT_TEST_SUITE_REGISTRATION(BasicTest);
+CPPUNIT_TEST_SUITE_REGISTRATION(SerializerTest);
 }
 
 // this macro creates an empty function, which will called by the 
RegisterAllFunctions()
 // to let the user the possibility to also register some functions by hand.
-NOADDITIONAL;
+CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to