You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2015/08/29 20:39:36 UTC

svn commit: r1700066 - in /openoffice/trunk/main/cppuhelper: prj/build.lst qa/ifcontainer/cppu_ifcontainer.cxx qa/ifcontainer/export.map qa/ifcontainer/main.cxx qa/ifcontainer/makefile.mk

Author: damjan
Date: Sat Aug 29 18:39:35 2015
New Revision: 1700066

URL: http://svn.apache.org/r1700066
Log:
#i125003# migrate main/cppuhelper/qa/ifcontainer from cppunit to Google Test
and run it on every build.


Added:
    openoffice/trunk/main/cppuhelper/qa/ifcontainer/main.cxx
Removed:
    openoffice/trunk/main/cppuhelper/qa/ifcontainer/export.map
Modified:
    openoffice/trunk/main/cppuhelper/prj/build.lst
    openoffice/trunk/main/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx
    openoffice/trunk/main/cppuhelper/qa/ifcontainer/makefile.mk

Modified: openoffice/trunk/main/cppuhelper/prj/build.lst
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/cppuhelper/prj/build.lst?rev=1700066&r1=1700065&r2=1700066&view=diff
==============================================================================
--- openoffice/trunk/main/cppuhelper/prj/build.lst (original)
+++ openoffice/trunk/main/cppuhelper/prj/build.lst Sat Aug 29 18:39:35 2015
@@ -3,4 +3,5 @@ ch	cppuhelper								usr1	-	all	ch_mkout
 ch	cppuhelper\inc							nmake	-	all	ch_include NULL
 ch	cppuhelper\source						nmake	-	all	ch_source ch_unotypes ch_include NULL
 ch	cppuhelper\unotypes						nmake	-	all	ch_unotypes NULL
+ch	cppuhelper\qa\ifcontainer					nmake	-	all	ch_qa_ifcontainer ch_source ch_include ch_unotypes NULL
 ch cppuhelper\qa\propertysetmixin nmake - all ch_qa_propertysetmixin ch_source NULL

Modified: openoffice/trunk/main/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx?rev=1700066&r1=1700065&r2=1700066&view=diff
==============================================================================
--- openoffice/trunk/main/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx (original)
+++ openoffice/trunk/main/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx Sat Aug 29 18:39:35 2015
@@ -21,13 +21,12 @@
 
 
 
-#include <testshl/simpleheader.hxx>
-
 #include "com/sun/star/lang/XEventListener.hpp"
 #include "cppuhelper/interfacecontainer.hxx"
 #include "cppuhelper/queryinterface.hxx"
 #include "cppuhelper/implbase1.hxx"
 #include "cppuhelper/propshlp.hxx"
+#include "gtest/gtest.h"
 
 using namespace com::sun::star;
 using namespace com::sun::star::uno;
@@ -57,79 +56,12 @@ public:
 
 namespace cppu_ifcontainer
 {
-    class IfTest : public CppUnit::TestFixture
+    class IfTest : public ::testing::Test
     {
+    protected:
         osl::Mutex m_aGuard;
         static const int nTests = 10;
     public:
-        void testCreateDispose()
-        {
-            ContainerStats aStats;
-            cppu::OInterfaceContainerHelper *pContainer;
-
-            pContainer = new cppu::OInterfaceContainerHelper(m_aGuard);
-
-            CPPUNIT_ASSERT_MESSAGE("Empty container not empty",
-                                   pContainer->getLength() == 0);
-
-            int i;
-            for (i = 0; i < nTests; i++)
-            {
-                Reference<XEventListener> xRef = new ContainerListener(&aStats);
-                int nNewLen = pContainer->addInterface(xRef);
-
-                CPPUNIT_ASSERT_MESSAGE("addition length mismatch",
-                                       nNewLen == i + 1);
-                CPPUNIT_ASSERT_MESSAGE("addition length mismatch",
-                                       pContainer->getLength() == i + 1);
-            }
-            CPPUNIT_ASSERT_MESSAGE("alive count mismatch",
-                                   aStats.m_nAlive == nTests);
-
-            EventObject aObj;
-            pContainer->disposeAndClear(aObj);
-
-            CPPUNIT_ASSERT_MESSAGE("dispose count mismatch",
-                                   aStats.m_nDisposed == nTests);
-            CPPUNIT_ASSERT_MESSAGE("leaked container left alive",
-                                   aStats.m_nAlive == 0);
-
-            delete pContainer;
-        }
-
-        void testEnumerate()
-        {
-            int i;
-            ContainerStats aStats;
-            cppu::OInterfaceContainerHelper *pContainer;
-            pContainer = new cppu::OInterfaceContainerHelper(m_aGuard);
-
-            std::vector< Reference< XEventListener > > aListeners;
-            for (i = 0; i < nTests; i++)
-            {
-                Reference<XEventListener> xRef = new ContainerListener(&aStats);
-                int nNewLen = pContainer->addInterface(xRef);
-                aListeners.push_back(xRef);
-            }
-            Sequence< Reference< XInterface > > aElements;
-            aElements = pContainer->getElements();
-
-            CPPUNIT_ASSERT_MESSAGE("query contents",
-                                   (int)aElements.getLength() == nTests);
-            if ((int)aElements.getLength() == nTests)
-            {
-                for (i = 0; i < nTests; i++)
-                {
-                    CPPUNIT_ASSERT_MESSAGE("mismatching elements",
-                                           aElements[i] == aListeners[i]);
-                }
-            }
-            pContainer->clear();
-
-            CPPUNIT_ASSERT_MESSAGE("non-empty container post clear",
-                                   pContainer->getLength() == 0);
-            delete pContainer;
-        }
 
         template < typename ContainerType, typename ContainedType >
         void doContainerTest(const ContainedType *pTypes)
@@ -155,11 +87,11 @@ namespace cppu_ifcontainer
 
                 pHelper = pContainer->getContainer(pTypes[i]);
 
-                CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != NULL);
+                ASSERT_TRUE(pHelper != NULL) << "no helper";
                 Sequence<Reference< XInterface > > aSeq = pHelper->getElements();
-                CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 2);
-                CPPUNIT_ASSERT_MESSAGE("match", aSeq[0] == xRefs[i*2]);
-                CPPUNIT_ASSERT_MESSAGE("match", aSeq[1] == xRefs[i*2+1]);
+                ASSERT_TRUE(aSeq.getLength() == 2) << "wrong num elements";
+                ASSERT_TRUE(aSeq[0] == xRefs[i*2]) << "match";
+                ASSERT_TRUE(aSeq[1] == xRefs[i*2+1]) << "match";
             }
 
             // remove every other interface
@@ -173,10 +105,10 @@ namespace cppu_ifcontainer
 
                 pHelper = pContainer->getContainer(pTypes[i]);
 
-                CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != NULL);
+                ASSERT_TRUE(pHelper != NULL) << "no helper";
                 Sequence<Reference< XInterface > > aSeq = pHelper->getElements();
-                CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 1);
-                CPPUNIT_ASSERT_MESSAGE("match", aSeq[0] == xRefs[i*2]);
+                ASSERT_TRUE(aSeq.getLength() == 1) << "wrong num elements";
+                ASSERT_TRUE(aSeq[0] == xRefs[i*2]) << "match";
             }
 
             // remove the 1st half of the rest
@@ -189,75 +121,124 @@ namespace cppu_ifcontainer
                 cppu::OInterfaceContainerHelper *pHelper;
 
                 pHelper = pContainer->getContainer(pTypes[i]);
-                CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != NULL);
+                ASSERT_TRUE(pHelper != NULL) << "no helper";
                 Sequence<Reference< XInterface > > aSeq = pHelper->getElements();
-                CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 0);
+                ASSERT_TRUE(aSeq.getLength() == 0) << "wrong num elements";
             }
 
             delete pContainer;
         }
+    };
 
-        void testOMultiTypeInterfaceContainerHelper()
+    TEST_F(IfTest, testCreateDispose)
+    {
+        ContainerStats aStats;
+        cppu::OInterfaceContainerHelper *pContainer;
+
+        pContainer = new cppu::OInterfaceContainerHelper(m_aGuard);
+
+        ASSERT_TRUE(pContainer->getLength() == 0) << "Empty container not empty";
+
+        int i;
+        for (i = 0; i < nTests; i++)
         {
-            uno::Type pTypes[nTests] =
-            {
-                ::cppu::UnoType< bool >::get(),
-                ::cppu::UnoType< float >::get(),
-                ::cppu::UnoType< double >::get(),
-                ::cppu::UnoType< ::sal_uInt64 >::get(),
-                ::cppu::UnoType< ::sal_Int64 >::get(),
-                ::cppu::UnoType< ::sal_uInt32 >::get(),
-                ::cppu::UnoType< ::sal_Int32 >::get(),
-                ::cppu::UnoType< ::sal_Int16 >::get(),
-                ::cppu::UnoType< ::rtl::OUString >::get(),
-                ::cppu::UnoType< ::sal_Int8 >::get()
-            };
-            doContainerTest< cppu::OMultiTypeInterfaceContainerHelper,
-                uno::Type> (pTypes);
+            Reference<XEventListener> xRef = new ContainerListener(&aStats);
+            int nNewLen = pContainer->addInterface(xRef);
+
+            ASSERT_TRUE(nNewLen == i + 1) << "addition length mismatch";
+            ASSERT_TRUE(pContainer->getLength() == i + 1) << "addition length mismatch";
+        }
+        ASSERT_TRUE(aStats.m_nAlive == nTests) << "alive count mismatch";
+
+        EventObject aObj;
+        pContainer->disposeAndClear(aObj);
+
+        ASSERT_TRUE(aStats.m_nDisposed == nTests) << "dispose count mismatch";
+        ASSERT_TRUE(aStats.m_nAlive == 0) << "leaked container left alive";
+
+        delete pContainer;
+    }
+
+    TEST_F(IfTest, testEnumerate)
+    {
+        int i;
+        ContainerStats aStats;
+        cppu::OInterfaceContainerHelper *pContainer;
+        pContainer = new cppu::OInterfaceContainerHelper(m_aGuard);
+
+        std::vector< Reference< XEventListener > > aListeners;
+        for (i = 0; i < nTests; i++)
+        {
+            Reference<XEventListener> xRef = new ContainerListener(&aStats);
+            int nNewLen = pContainer->addInterface(xRef);
+            aListeners.push_back(xRef);
         }
+        Sequence< Reference< XInterface > > aElements;
+        aElements = pContainer->getElements();
 
-        void testOMultiTypeInterfaceContainerHelperInt32()
+        ASSERT_TRUE((int)aElements.getLength() == nTests) << "query contents";
+        if ((int)aElements.getLength() == nTests)
         {
-            sal_Int32 pTypes[nTests] =
+            for (i = 0; i < nTests; i++)
             {
-                0,
-                -1,
-                1,
-                256,
-                1024,
-                3,
-                7,
-                8,
-                9,
-                10
-            };
-            doContainerTest< cppu::OMultiTypeInterfaceContainerHelperInt32, sal_Int32> (pTypes);
+                ASSERT_TRUE(aElements[i] == aListeners[i]) << "mismatching elements";
+            }
         }
+        pContainer->clear();
+
+        ASSERT_TRUE(pContainer->getLength() == 0) << "non-empty container post clear";
+        delete pContainer;
+    }
 
-        void testOMultiTypeInterfaceContainerHelperVar()
+    TEST_F(IfTest, testOMultiTypeInterfaceContainerHelper)
+    {
+        uno::Type pTypes[nTests] =
         {
-            typedef ::cppu::OMultiTypeInterfaceContainerHelperVar<
-                const char*, rtl::CStringHash, rtl::CStringEqual> StrContainer;
+            ::cppu::UnoType< bool >::get(),
+            ::cppu::UnoType< float >::get(),
+            ::cppu::UnoType< double >::get(),
+            ::cppu::UnoType< ::sal_uInt64 >::get(),
+            ::cppu::UnoType< ::sal_Int64 >::get(),
+            ::cppu::UnoType< ::sal_uInt32 >::get(),
+            ::cppu::UnoType< ::sal_Int32 >::get(),
+            ::cppu::UnoType< ::sal_Int16 >::get(),
+            ::cppu::UnoType< ::rtl::OUString >::get(),
+            ::cppu::UnoType< ::sal_Int8 >::get()
+        };
+        doContainerTest< cppu::OMultiTypeInterfaceContainerHelper,
+            uno::Type> (pTypes);
+    }
 
-            const char *pTypes[nTests] =
-            {
-                "this_is", "such", "fun", "writing", "unit", "tests", "when", "it", "works", "anyway"
-            };
-            doContainerTest< StrContainer, const char *> (pTypes);
-        }
+    TEST_F(IfTest, testOMultiTypeInterfaceContainerHelperInt32)
+    {
+        sal_Int32 pTypes[nTests] =
+        {
+            0,
+            -1,
+            1,
+            256,
+            1024,
+            3,
+            7,
+            8,
+            9,
+            10
+        };
+        doContainerTest< cppu::OMultiTypeInterfaceContainerHelperInt32, sal_Int32> (pTypes);
+    }
 
-        // Automatic registration code
-        CPPUNIT_TEST_SUITE(IfTest);
-        CPPUNIT_TEST(testCreateDispose);
-        CPPUNIT_TEST(testEnumerate);
-        CPPUNIT_TEST(testOMultiTypeInterfaceContainerHelper);
-        CPPUNIT_TEST(testOMultiTypeInterfaceContainerHelperVar);
-        CPPUNIT_TEST(testOMultiTypeInterfaceContainerHelperInt32);
-        CPPUNIT_TEST_SUITE_END();
-    };
-} // namespace cppu_ifcontainer
+    TEST_F(IfTest, testOMultiTypeInterfaceContainerHelperVar)
+    {
+        typedef ::cppu::OMultiTypeInterfaceContainerHelperVar<
+            const char*, rtl::CStringHash, rtl::CStringEqual> StrContainer;
 
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(cppu_ifcontainer::IfTest,
-                                      "cppu_ifcontainer");
+        const char *pTypes[nTests] =
+        {
+            "this_is", "such", "fun", "writing", "unit", "tests", "when", "it", "works", "anyway"
+        };
+        doContainerTest< StrContainer, const char *> (pTypes);
+    }
+
+
+} // namespace cppu_ifcontainer
 
-NOADDITIONAL;

Added: openoffice/trunk/main/cppuhelper/qa/ifcontainer/main.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/cppuhelper/qa/ifcontainer/main.cxx?rev=1700066&view=auto
==============================================================================
--- openoffice/trunk/main/cppuhelper/qa/ifcontainer/main.cxx (added)
+++ openoffice/trunk/main/cppuhelper/qa/ifcontainer/main.cxx Sat Aug 29 18:39:35 2015
@@ -0,0 +1,28 @@
+/**************************************************************
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *************************************************************/
+
+#include "gtest/gtest.h"
+
+int main(int argc, char **argv)
+{
+    ::testing::InitGoogleTest(&argc, argv);
+    return RUN_ALL_TESTS();
+}

Modified: openoffice/trunk/main/cppuhelper/qa/ifcontainer/makefile.mk
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/cppuhelper/qa/ifcontainer/makefile.mk?rev=1700066&r1=1700065&r2=1700066&view=diff
==============================================================================
--- openoffice/trunk/main/cppuhelper/qa/ifcontainer/makefile.mk (original)
+++ openoffice/trunk/main/cppuhelper/qa/ifcontainer/makefile.mk Sat Aug 29 18:39:35 2015
@@ -31,27 +31,31 @@ ENABLE_EXCEPTIONS=TRUE
 
 .INCLUDE :  settings.mk
 
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
+.IF "$(ENABLE_UNIT_TESTS)" != "YES"
+all:
+	@echo unit tests are disabled. Nothing to do.
+
+.ELSE
 
 # BEGIN ----------------------------------------------------------------
 # auto generated Target:joblist by codegen.pl
-SHL1OBJS=  \
-	$(SLO)$/cppu_ifcontainer.obj
-SHL1TARGET= cppu_ifcontainer
-SHL1STDLIBS=\
+APP1OBJS=  \
+	$(SLO)$/cppu_ifcontainer.obj \
+	$(SLO)$/main.obj
+APP1TARGET= cppu_ifcontainer
+APP1STDLIBS=\
     $(CPPUHELPERLIB) \
     $(SALLIB) \
     $(CPPULIB) \
     $(TESTSHL2LIB)\
-    $(CPPUNITLIB)
-SHL1IMPLIB= i$(SHL1TARGET)
-DEF1NAME    =$(SHL1TARGET)
-SHL1VERSIONMAP= export.map
+    $(GTESTLIB)
+APP1RPATH = NONE
+APP1TEST = enabled
 # auto generated Target:joblist
 # END ------------------------------------------------------------------
 
 # --- Targets ------------------------------------------------------
 
 .INCLUDE :  target.mk
-.INCLUDE : _cppunit.mk
 
+.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"