openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1708667 - in /openoffice/trunk/main/unoxml/test: domtest.cxx makefile.mk
Date Wed, 14 Oct 2015 18:02:33 GMT
Author: damjan
Date: Wed Oct 14 18:02:32 2015
New Revision: 1708667

URL: http://svn.apache.org/viewvc?rev=1708667&view=rev
Log:
#i125003# migrate main/uno/test from cppunit to Google Test. Doesn't link due
to missing static libraries (pre-gbuild migration era?) but isn't run during the buid.


Modified:
    openoffice/trunk/main/unoxml/test/domtest.cxx
    openoffice/trunk/main/unoxml/test/makefile.mk

Modified: openoffice/trunk/main/unoxml/test/domtest.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/unoxml/test/domtest.cxx?rev=1708667&r1=1708666&r2=1708667&view=diff
==============================================================================
--- openoffice/trunk/main/unoxml/test/domtest.cxx (original)
+++ openoffice/trunk/main/unoxml/test/domtest.cxx Wed Oct 14 18:02:32 2015
@@ -23,7 +23,7 @@
 
 // autogenerated file with codegen.pl
 
-#include <testshl/simpleheader.hxx>
+#include "gtest/gtest.h"
 
 #include <rtl/ref.hxx>
 #include <osl/file.hxx>
@@ -38,6 +38,8 @@
 #include <com/sun/star/xml/sax/XSAXSerializable.hpp>
 #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
 
+#include <cstdlib>
+
 #include "../source/dom/documentbuilder.hxx"
 
 
@@ -173,15 +175,13 @@ struct TokenHandler
 {
     virtual ::sal_Int32 SAL_CALL getToken( const ::rtl::OUString& Identifier ) throw
(uno::RuntimeException)
     {
-        CPPUNIT_ASSERT_MESSAGE( "TokenHandler::getToken() unexpected call",
-                                false );
+        EXPECT_TRUE( false ) << "TokenHandler::getToken() unexpected call";
         return -1;
     }
 
     virtual ::rtl::OUString SAL_CALL getIdentifier( ::sal_Int32 Token ) throw (uno::RuntimeException)
     {
-        CPPUNIT_ASSERT_MESSAGE( "TokenHandler::getIdentifier() unexpected call",
-                                false );
+        EXPECT_TRUE( false ) << "TokenHandler::getIdentifier() unexpected call";
         return rtl::OUString();
     }
 
@@ -193,13 +193,12 @@ struct TokenHandler
 
     virtual uno::Sequence< ::sal_Int8 > SAL_CALL getUTF8Identifier( ::sal_Int32 Token
) throw (uno::RuntimeException)
     {
-        CPPUNIT_ASSERT_MESSAGE( "TokenHandler::getUTF8Identifier() unexpected call", 
-                                false );
+        EXPECT_TRUE( false) << "TokenHandler::getUTF8Identifier() unexpected call";
         return uno::Sequence<sal_Int8>();
     }
 };
 
-struct BasicTest : public CppUnit::TestFixture
+struct BasicTest : public ::testing::Test
 {
     rtl::Reference<CDocumentBuilder>    mxDomBuilder;
     rtl::Reference<ErrorHandler>        mxErrHandler;
@@ -208,7 +207,7 @@ struct BasicTest : public CppUnit::TestF
     rtl::Reference<SequenceInputStream> mxErrorInStream;
     rtl::Reference<SequenceInputStream> mxFatalInStream;
 
-    void setUp()
+    void SetUp()
     {
         // luckily, DOM builder doesn't use service fac, so we need
         // not bootstrap uno here
@@ -224,59 +223,45 @@ struct BasicTest : public CppUnit::TestF
                                                                   sizeof(fatalTestFile)/sizeof(*fatalTestFile)))
);
         mxDomBuilder->setErrorHandler(mxErrHandler.get());
     }
+};
+
+TEST_F(BasicTest, validInputTest)
+{
+    ASSERT_TRUE( mxDomBuilder->parse(
+        uno::Reference<io::XInputStream>(
+            mxValidInStream.get())).is() ) << "Valid input file did not result in XDocument
#1";
+    ASSERT_TRUE( mxErrHandler->noErrors() ) << "Valid input file resulted in parse
errors";
+}
 
-    void validInputTest()
-    {        
-        CPPUNIT_ASSERT_MESSAGE( "Valid input file did not result in XDocument #1", 
-                                mxDomBuilder->parse(
-                                    uno::Reference<io::XInputStream>(
-                                        mxValidInStream.get())).is() );
-        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", 
-                                mxDomBuilder->parse(
-                                    uno::Reference<io::XInputStream>(
-                                        mxWarningInStream.get())).is() );
-        CPPUNIT_ASSERT_MESSAGE( "No parse warnings in unclean input file", 
-                                mxErrHandler->mnWarnCount && !mxErrHandler->mnErrCount
&& !mxErrHandler->mnFatalCount );
-    }
-
-    void errorInputTest()
-    {        
-        CPPUNIT_ASSERT_MESSAGE( "Valid input file did not result in XDocument #3", 
-                                mxDomBuilder->parse(
-                                    uno::Reference<io::XInputStream>(
-                                        mxErrorInStream.get())).is() );
-        CPPUNIT_ASSERT_MESSAGE( "No parse errors in unclean input file", 
-                                !mxErrHandler->mnWarnCount && mxErrHandler->mnErrCount
&& !mxErrHandler->mnFatalCount );
-    }
-
-    void fatalInputTest()
-    {        
-        CPPUNIT_ASSERT_MESSAGE( "Broken input file resulted in XDocument", 
-                                !mxDomBuilder->parse(
-                                    uno::Reference<io::XInputStream>(
-                                        mxFatalInStream.get())).is() );
-        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_SUITE_END();
+TEST_F(BasicTest, warningInputTest)
+{
+    ASSERT_TRUE( mxDomBuilder->parse(
+        uno::Reference<io::XInputStream>(
+            mxWarningInStream.get())).is() ) << "Valid input file did not result in
XDocument #2";
+    ASSERT_TRUE( mxErrHandler->mnWarnCount && !mxErrHandler->mnErrCount &&
!mxErrHandler->mnFatalCount )
+        << "No parse warnings in unclean input file";
+}
+
+TEST_F(BasicTest, errorInputTest)
+{
+    ASSERT_TRUE( mxDomBuilder->parse(
+        uno::Reference<io::XInputStream>(
+            mxErrorInStream.get())).is() ) << "Valid input file did not result in XDocument
#3";
+    ASSERT_TRUE( !mxErrHandler->mnWarnCount && mxErrHandler->mnErrCount &&
!mxErrHandler->mnFatalCount )
+        << "No parse errors in unclean input file";
+}
+
+TEST_F(BasicTest, fatalInputTest)
+{
+    ASSERT_TRUE( !mxDomBuilder->parse(
+        uno::Reference<io::XInputStream>(
+            mxFatalInStream.get())).is() ) << "Broken input file resulted in XDocument";
+    ASSERT_TRUE( !mxErrHandler->mnWarnCount && !mxErrHandler->mnErrCount &&
mxErrHandler->mnFatalCount )
+        << "No fatal parse errors in unclean input file";
 };
 
-struct SerializerTest : public CppUnit::TestFixture
+
+struct SerializerTest : public ::testing::Test
 {
     SerializerTest() : mbUnoInitialized(false) {}
 
@@ -289,13 +274,13 @@ struct SerializerTest : public CppUnit::
     uno::Sequence< beans::Pair< rtl::OUString, sal_Int32 > > maRegisteredNamespaces;
     bool                                                     mbUnoInitialized;
 
-    void setUp()
+    void SetUp()
     {
         // need working typelib, bootstrap UNO now
         if( !mbUnoInitialized )
         {
-            const char* pArgs( getForwardString() );
-            CPPUNIT_ASSERT_MESSAGE("Test file parameter", pArgs);
+            const char* pArgs( getenv("UNOXML_DOMTEST_FORWARD") );
+            ASSERT_TRUE(pArgs) << "Test file parameter";
 
             const rtl::OUString sBaseDir=rtl::OUString::createFromAscii(pArgs);
 
@@ -303,18 +288,17 @@ struct SerializerTest : public CppUnit::
             try
             {
                 ::rtl::OUString aIniUrl;
-                CPPUNIT_ASSERT_MESSAGE( 
-                    "Converting ini file to URL",
+                ASSERT_TRUE(
                     osl_getFileURLFromSystemPath( 
                         (sBaseDir+rtl::OUString::createFromAscii("unoxml_unittest_test.ini")).pData,

-                        &aIniUrl.pData ) == osl_File_E_None );
+                        &aIniUrl.pData ) == osl_File_E_None ) << "Converting ini
file to URL";
 
                 mxCtx = ::cppu::defaultBootstrap_InitialComponentContext(aIniUrl);
-                CPPUNIT_ASSERT_MESSAGE("Getting component context", mxCtx.is());
+                ASSERT_TRUE(mxCtx.is()) << "Getting component context";
             }
             catch( uno::Exception& )
             {
-                CPPUNIT_ASSERT_MESSAGE("Bootstrapping UNO", false);
+                ASSERT_TRUE(false) << "Bootstrapping UNO";
             }
 
             mbUnoInitialized = true;
@@ -344,52 +328,36 @@ struct SerializerTest : public CppUnit::
                     "http://www.w3.org/1999/xlink") ),
             2*xml::sax::FastToken::NAMESPACE);
     }
-
-    void serializerTest ()
-    {        
-        uno::Reference< xml::dom::XDocument > xDoc=
-            mxDomBuilder->parse(
-                uno::Reference<io::XInputStream>(
-                    mxInStream.get()));
-        CPPUNIT_ASSERT_MESSAGE( "Valid input file did not result in XDocument", 
-                                xDoc.is() );
-        CPPUNIT_ASSERT_MESSAGE( "Valid input file resulted in parse errors", 
-                                mxErrHandler->noErrors() );
-
-        uno::Reference< xml::sax::XSAXSerializable > xSaxSerializer(
-            xDoc, uno::UNO_QUERY);
-        CPPUNIT_ASSERT_MESSAGE( "XSAXSerializable not supported", 
-                                xSaxSerializer.is() );
-
-        uno::Reference< xml::sax::XFastSAXSerializable > xFastSaxSerializer(
-            xDoc, uno::UNO_QUERY);
-        CPPUNIT_ASSERT_MESSAGE( "XFastSAXSerializable not supported", 
-                                xSaxSerializer.is() );
-
-        xFastSaxSerializer->fastSerialize( mxHandler.get(), 
-                                           mxTokHandler.get(), 
-                                           uno::Sequence< beans::StringPair >(),
-                                           maRegisteredNamespaces );
-    }
-
-    // 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(SerializerTest);
-    CPPUNIT_TEST(serializerTest);
-    CPPUNIT_TEST_SUITE_END();
 };
 
-// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BasicTest, "BasicTest");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(SerializerTest, "SerializerTest");
+TEST_F(SerializerTest, serializerTest)
+{
+    uno::Reference< xml::dom::XDocument > xDoc=
+        mxDomBuilder->parse(
+            uno::Reference<io::XInputStream>(
+                mxInStream.get()));
+    ASSERT_TRUE( xDoc.is() ) << "Valid input file did not result in XDocument";
+    ASSERT_TRUE( mxErrHandler->noErrors() ) << "Valid input file resulted in parse
errors";
+
+    uno::Reference< xml::sax::XSAXSerializable > xSaxSerializer(
+        xDoc, uno::UNO_QUERY);
+    ASSERT_TRUE( xSaxSerializer.is() ) << "XSAXSerializable not supported";
+
+    uno::Reference< xml::sax::XFastSAXSerializable > xFastSaxSerializer(
+        xDoc, uno::UNO_QUERY);
+    ASSERT_TRUE( xSaxSerializer.is() ) << "XFastSAXSerializable not supported";
+
+    xFastSaxSerializer->fastSerialize( mxHandler.get(),
+                                       mxTokHandler.get(),
+                                       uno::Sequence< beans::StringPair >(),
+                                       maRegisteredNamespaces );
 }
 
+}
 
-// -----------------------------------------------------------------------------
-
-// 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;
 
+int main(int argc, char **argv)
+{
+    ::testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
+}

Modified: openoffice/trunk/main/unoxml/test/makefile.mk
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/unoxml/test/makefile.mk?rev=1708667&r1=1708666&r2=1708667&view=diff
==============================================================================
--- openoffice/trunk/main/unoxml/test/makefile.mk (original)
+++ openoffice/trunk/main/unoxml/test/makefile.mk Wed Oct 14 18:02:32 2015
@@ -25,7 +25,6 @@ PRJ=..
 
 PRJNAME=unoxml
 TARGET=tests
-TARGETTYPE=GUI
 
 ENABLE_EXCEPTIONS=TRUE
 
@@ -33,54 +32,56 @@ ENABLE_EXCEPTIONS=TRUE
 
 .INCLUDE :  settings.mk
 
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+	@echo unit tests are disabled. Nothing to do.
+ 
+.ELSE
 
 # --- Common ----------------------------------------------------------
 
 # BEGIN ----------------------------------------------------------------
 # auto generated Target:tests by codegen.pl
-SHL1OBJS=  \
-	$(SLO)$/domtest.obj
+APP1OBJS=  \
+	$(SLO)$/domtest.obj $(SLO)$/documentbuilder.obj
 
 # the following three libs are a bit of a hack: cannot link against
 # unoxml here, because not yet delivered (and does not export
 # ~anything). Need the functionality to test, so we're linking it in
 # statically. Need to keep this in sync with
 # source/services/makefile.mk
-SHL1LIBS= \
-    $(SLB)$/domimpl.lib \
-    $(SLB)$/xpathimpl.lib \
-    $(SLB)$/eventsimpl.lib
+#APP1LIBS= \
+    #$(SLB)$/domimpl.lib \
+    #$(SLB)$/xpathimpl.lib \
+    #$(SLB)$/eventsimpl.lib
 
-SHL1TARGET= tests
-SHL1STDLIBS= \
+APP1TARGET= tests
+APP1STDLIBS= \
     $(UCBHELPERLIB) \
     $(LIBXML2LIB) \
 	$(TOOLSLIB)	\
 	$(COMPHELPERLIB)	\
 	$(CPPUHELPERLIB)	\
-	$(CPPUNITLIB)	 \
+	$(GTESTLIB)	 \
         $(TESTSHL2LIB)    \
 	$(CPPULIB)	\
 	$(SAXLIB) \
 	$(SALLIB)\
-	$(EXPATASCII3RDLIB)
+	$(EXPATASCII3RDLIB) \
+	-lunoxml
 
-SHL1IMPLIB= i$(SHL1TARGET)
-
-DEF1NAME    =$(SHL1TARGET)
-SHL1VERSIONMAP = export.map
+APP1RPATH = NONE
+APP1TEST = disabled
 
 # END ------------------------------------------------------------------
 
 #------------------------------- All object files -------------------------------
 # do this here, so we get right dependencies
-SLOFILES=$(SHL1OBJS)
+SLOFILES=$(APP1OBJS)
 
 # --- Targets ------------------------------------------------------
 
 .INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
 
 # --- Fake uno bootstrap ------------------------
 
@@ -95,7 +96,11 @@ $(MISC)$/unoxml_unittest_succeeded : $(S
 		@echo ----------------------------------------------------------
 		@echo - start unit test on library $(SHL1TARGETN)
 		@echo ----------------------------------------------------------
-                $(TESTSHL2) -forward $(BIN)$/ -sf $(mktmp ) $(SHL1TARGETN)
+		$(COMMAND_ECHO) $(AUGMENT_LIBRARY_PATH_LOCAL) \
+		UNOXML_DOMTEST_FORWARD=$(BIN)$/ \
+		$(APP1TARGETN) --gtest_output="xml:$(BIN)/$(APP1TARGET)_result.xml"
 		$(TOUCH) $@
 
 ALLTAR : $(MISC)$/unoxml_unittest_succeeded
+
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"



Mime
View raw message