diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-02-19 14:32:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-20 07:34:06 +0100 |
commit | 6aecd49aa6de7c7f65c3c240ee3b7db36497df4d (patch) | |
tree | e32f5eacfcc3a28119593915db4158a3782a62fe /test | |
parent | 197bcde5c4d771ace11962213c11c9763be11039 (diff) |
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@collabora.co.uk>
Diffstat (limited to 'test')
-rw-r--r-- | test/source/lang/xcomponent.cxx | 23 |
1 files changed, 10 insertions, 13 deletions
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); } |