summaryrefslogtreecommitdiff
path: root/comphelper/qa
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-01-25 09:59:54 +0200
committerNoel Grandin <noel@peralex.com>2016-01-25 10:01:39 +0200
commit11cbce37f5817c506f6d13fdd2d578b7a5480fcf (patch)
treef7b7a84655b9f0c135affb70736ee00ae246b245 /comphelper/qa
parent3dc37e975ee79c4fd4215cb14a074f1fb5a35ca4 (diff)
cleanup OInterfaceContainer2 unit tests
remove unused code and actually hook up the tests in testifcontainer.cxx Change-Id: I9694ebe44f1e8eed3d72373d62424345f899c8e6
Diffstat (limited to 'comphelper/qa')
-rw-r--r--comphelper/qa/container/comphelper_ifcontainer.cxx68
-rw-r--r--comphelper/qa/container/testifcontainer.cxx51
2 files changed, 34 insertions, 85 deletions
diff --git a/comphelper/qa/container/comphelper_ifcontainer.cxx b/comphelper/qa/container/comphelper_ifcontainer.cxx
index ba9af495eaf0..733a7e056751 100644
--- a/comphelper/qa/container/comphelper_ifcontainer.cxx
+++ b/comphelper/qa/container/comphelper_ifcontainer.cxx
@@ -34,8 +34,6 @@ using namespace com::sun::star;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
-class ContainerListener;
-
struct ContainerStats {
int m_nAlive;
int m_nDisposed;
@@ -131,72 +129,6 @@ namespace comphelper_ifcontainer
delete pContainer;
}
- template < typename ContainerType, typename ContainedType >
- void doContainerTest(const ContainedType *pTypes)
- {
- ContainerStats aStats;
- ContainerType *pContainer;
- pContainer = new ContainerType(m_aGuard);
-
- int i;
- Reference<XEventListener> xRefs[nTests * 2];
-
- // add these interfaces
- for (i = 0; i < nTests * 2; i++)
- {
- xRefs[i] = new ContainerListener(&aStats);
- pContainer->addInterface(pTypes[i / 2], xRefs[i]);
- }
-
- // check it is all there
- for (i = 0; i < nTests; i++)
- {
- cppu::OInterfaceContainerHelper *pHelper;
-
- pHelper = pContainer->getContainer(pTypes[i]);
-
- CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != nullptr);
- 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]);
- }
-
- // remove every other interface
- for (i = 0; i < nTests; i++)
- pContainer->removeInterface(pTypes[i], xRefs[i*2+1]);
-
- // check it is half there
- for (i = 0; i < nTests; i++)
- {
- cppu::OInterfaceContainerHelper *pHelper;
-
- pHelper = pContainer->getContainer(pTypes[i]);
-
- CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != nullptr);
- Sequence<Reference< XInterface > > aSeq = pHelper->getElements();
- CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 1);
- CPPUNIT_ASSERT_MESSAGE("match", aSeq[0] == xRefs[i*2]);
- }
-
- // remove the 1st half of the rest
- for (i = 0; i < nTests / 2; i++)
- pContainer->removeInterface(pTypes[i], xRefs[i*2]);
-
- // check it is half there
- for (i = 0; i < nTests / 2; i++)
- {
- cppu::OInterfaceContainerHelper *pHelper;
-
- pHelper = pContainer->getContainer(pTypes[i]);
- CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != nullptr);
- Sequence<Reference< XInterface > > aSeq = pHelper->getElements();
- CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 0);
- }
-
- delete pContainer;
- }
-
// Automatic registration code
CPPUNIT_TEST_SUITE(IfTest);
CPPUNIT_TEST(testCreateDispose);
diff --git a/comphelper/qa/container/testifcontainer.cxx b/comphelper/qa/container/testifcontainer.cxx
index 12ec7e39adf7..85e06c218ddf 100644
--- a/comphelper/qa/container/testifcontainer.cxx
+++ b/comphelper/qa/container/testifcontainer.cxx
@@ -17,21 +17,34 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+#include "cppunit/plugin/TestPlugIn.h"
#include <osl/mutex.hxx>
-
-#include <cppuhelper/interfacecontainer.hxx>
+#include <comphelper/interfacecontainer2.hxx>
#include <cppuhelper/implbase1.hxx>
-
#include <com/sun/star/beans/XVetoableChangeListener.hpp>
-using namespace ::cppu;
using namespace ::osl;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
+namespace
+{
-class TestListener : public WeakImplHelper1< XVetoableChangeListener >
+class TestInterfaceContainer2: public CppUnit::TestFixture
+{
+public:
+ void test1();
+
+ CPPUNIT_TEST_SUITE(TestInterfaceContainer2);
+ CPPUNIT_TEST(test1);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+class TestListener : public cppu::WeakImplHelper1< XVetoableChangeListener >
{
public:
// Methods
@@ -47,12 +60,12 @@ public:
}
};
-void test_interfacecontainer()
+void TestInterfaceContainer2::test1()
{
Mutex mutex;
{
- OInterfaceContainerHelper helper( mutex );
+ comphelper::OInterfaceContainerHelper2 helper( mutex );
Reference< XVetoableChangeListener > r1 = new TestListener();
Reference< XVetoableChangeListener > r2 = new TestListener();
@@ -66,7 +79,7 @@ void test_interfacecontainer()
}
{
- OInterfaceContainerHelper helper( mutex );
+ comphelper::OInterfaceContainerHelper2 helper( mutex );
Reference< XVetoableChangeListener > r1 = new TestListener();
Reference< XVetoableChangeListener > r2 = new TestListener();
@@ -76,7 +89,7 @@ void test_interfacecontainer()
helper.addInterface( r2 );
helper.addInterface( r3 );
- OInterfaceIteratorHelper iterator( helper );
+ comphelper::OInterfaceIteratorHelper2 iterator( helper );
while( iterator.hasMoreElements() )
static_cast<XVetoableChangeListener*>(iterator.next())->vetoableChange( PropertyChangeEvent() );
@@ -85,7 +98,7 @@ void test_interfacecontainer()
}
{
- OInterfaceContainerHelper helper( mutex );
+ comphelper::OInterfaceContainerHelper2 helper( mutex );
Reference< XVetoableChangeListener > r1 = new TestListener();
Reference< XVetoableChangeListener > r2 = new TestListener();
@@ -95,7 +108,7 @@ void test_interfacecontainer()
helper.addInterface( r2 );
helper.addInterface( r3 );
- OInterfaceIteratorHelper iterator( helper );
+ comphelper::OInterfaceIteratorHelper2 iterator( helper );
static_cast<XVetoableChangeListener*>(iterator.next())->vetoableChange( PropertyChangeEvent() );
iterator.remove();
@@ -104,12 +117,12 @@ void test_interfacecontainer()
static_cast<XVetoableChangeListener*>(iterator.next())->vetoableChange( PropertyChangeEvent() );
iterator.remove();
- OSL_ASSERT( helper.getLength() == 0 );
+ CPPUNIT_ASSERT( helper.getLength() == 0 );
helper.disposeAndClear( EventObject() );
}
{
- OInterfaceContainerHelper helper( mutex );
+ comphelper::OInterfaceContainerHelper2 helper( mutex );
Reference< XVetoableChangeListener > r1 = new TestListener();
Reference< XVetoableChangeListener > r2 = new TestListener();
@@ -120,7 +133,7 @@ void test_interfacecontainer()
helper.addInterface( r3 );
{
- OInterfaceIteratorHelper iterator( helper );
+ comphelper::OInterfaceIteratorHelper2 iterator( helper );
while( iterator.hasMoreElements() )
{
Reference< XVetoableChangeListener > r = static_cast<XVetoableChangeListener*>(iterator.next());
@@ -128,13 +141,13 @@ void test_interfacecontainer()
iterator.remove();
}
}
- OSL_ASSERT( helper.getLength() == 2 );
+ CPPUNIT_ASSERT( helper.getLength() == 2 );
{
- OInterfaceIteratorHelper iterator( helper );
+ comphelper::OInterfaceIteratorHelper2 iterator( helper );
while( iterator.hasMoreElements() )
{
Reference< XVetoableChangeListener > r = static_cast<XVetoableChangeListener*>(iterator.next());
- OSL_ASSERT( r != r1 && ( r == r2 || r == r3 ) );
+ CPPUNIT_ASSERT( r != r1 && ( r == r2 || r == r3 ) );
}
}
@@ -142,4 +155,8 @@ void test_interfacecontainer()
}
}
+CPPUNIT_TEST_SUITE_REGISTRATION(TestInterfaceContainer2);
+
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */