[Libreoffice-commits] core.git: test/source
Noel (via logerrit)
logerrit at kemper.freedesktop.org
Sat Feb 20 06:34:53 UTC 2021
test/source/lang/xcomponent.cxx | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
New commits:
commit 6aecd49aa6de7c7f65c3c240ee3b7db36497df4d
Author: Noel <noel.grandin at collabora.co.uk>
AuthorDate: Fri Feb 19 14:32:47 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Feb 20 07:34:06 2021 +0100
loplugin:refcounting in test
Change-Id: I1e741283bffae6c3e40f4e61aaed5c085997c74f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111214
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/test/source/lang/xcomponent.cxx b/test/source/lang/xcomponent.cxx
index abe5111e4f2a..286f66c5c77a 100644
--- a/test/source/lang/xcomponent.cxx
+++ b/test/source/lang/xcomponent.cxx
@@ -9,6 +9,7 @@
#include <cppuhelper/implbase.hxx>
#include <test/lang/xcomponent.hxx>
+#include <rtl/ref.hxx>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
@@ -38,9 +39,8 @@ namespace apitest
void XComponent::testAddEventListener()
{
Reference<lang::XComponent> xComponent(init(), uno::UNO_QUERY_THROW);
- auto pListenerAdded(new TestEventListener());
- Reference<lang::XEventListener> xListenerAdded(pListenerAdded);
- xComponent->addEventListener(xListenerAdded);
+ rtl::Reference<TestEventListener> pListenerAdded(new TestEventListener());
+ xComponent->addEventListener(pListenerAdded);
xComponent->dispose();
CPPUNIT_ASSERT_EQUAL(true, pListenerAdded->m_hasDisposingCalled);
}
@@ -48,10 +48,9 @@ void XComponent::testAddEventListener()
void XComponent::testRemoveEventListener()
{
Reference<lang::XComponent> xComponent(init(), uno::UNO_QUERY_THROW);
- auto pListenerAddedAndRemoved(new TestEventListener());
- Reference<lang::XEventListener> xListenerAddedAndRemoved(pListenerAddedAndRemoved);
- xComponent->addEventListener(xListenerAddedAndRemoved);
- xComponent->removeEventListener(xListenerAddedAndRemoved);
+ rtl::Reference<TestEventListener> pListenerAddedAndRemoved(new TestEventListener());
+ xComponent->addEventListener(pListenerAddedAndRemoved);
+ xComponent->removeEventListener(pListenerAddedAndRemoved);
xComponent->dispose();
CPPUNIT_ASSERT_EQUAL(false, pListenerAddedAndRemoved->m_hasDisposingCalled);
}
@@ -59,9 +58,8 @@ void XComponent::testRemoveEventListener()
void XComponent::testDispose()
{
Reference<lang::XComponent> xComponent(init(), uno::UNO_QUERY_THROW);
- auto pListenerAdded(new TestEventListener());
- Reference<lang::XEventListener> xListenerAdded(pListenerAdded);
- xComponent->addEventListener(xListenerAdded);
+ rtl::Reference<TestEventListener> pListenerAdded(new TestEventListener());
+ xComponent->addEventListener(pListenerAdded);
xComponent->dispose();
CPPUNIT_ASSERT_EQUAL(true, pListenerAdded->m_hasDisposingCalled);
}
@@ -69,9 +67,8 @@ void XComponent::testDispose()
void XComponent::testDisposedByDesktopTerminate()
{
Reference<lang::XComponent> xComponent(init(), uno::UNO_QUERY_THROW);
- auto pListenerAdded(new TestEventListener());
- Reference<lang::XEventListener> xListenerAdded(pListenerAdded);
- xComponent->addEventListener(xListenerAdded);
+ rtl::Reference<TestEventListener> pListenerAdded(new TestEventListener());
+ xComponent->addEventListener(pListenerAdded);
triggerDesktopTerminate();
CPPUNIT_ASSERT_EQUAL(true, pListenerAdded->m_hasDisposingCalled);
}
More information about the Libreoffice-commits
mailing list