Revert "tdf#127471 Remove font width scaling hack"
[LibreOffice.git] / test / source / util / xrefreshable.cxx
blobf448d93e50088df95a99df0e25378ff8b2078784
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <test/util/xrefreshable.hxx>
12 #include <com/sun/star/lang/EventObject.hpp>
13 #include <com/sun/star/util/XRefreshListener.hpp>
14 #include <com/sun/star/util/XRefreshable.hpp>
16 #include <com/sun/star/uno/Reference.hxx>
18 #include <cppuhelper/implbase.hxx>
19 #include <rtl/ref.hxx>
21 #include <cppunit/TestAssert.h>
23 using namespace com::sun::star;
24 using namespace com::sun::star::uno;
26 namespace apitest
28 namespace
30 class MockedRefreshListener : public ::cppu::WeakImplHelper<util::XRefreshListener>
32 public:
33 MockedRefreshListener()
34 : m_bListenerCalled(false)
38 bool m_bListenerCalled;
39 virtual void SAL_CALL refreshed(const lang::EventObject& /* xEvent */) override
41 m_bListenerCalled = true;
43 virtual void SAL_CALL disposing(const lang::EventObject& /* xEventObj */) override {}
47 void XRefreshable::testRefreshListener()
49 uno::Reference<util::XRefreshable> xRefreshable(init(), uno::UNO_QUERY_THROW);
51 rtl::Reference<MockedRefreshListener> xListener = new MockedRefreshListener();
52 xRefreshable->addRefreshListener(uno::Reference<util::XRefreshListener>(xListener.get()));
54 xRefreshable->refresh();
55 CPPUNIT_ASSERT(xListener->m_bListenerCalled);
57 xListener->m_bListenerCalled = false;
58 xRefreshable->removeRefreshListener(uno::Reference<util::XRefreshListener>(xListener.get()));
59 xRefreshable->refresh();
60 CPPUNIT_ASSERT(!xListener->m_bListenerCalled);
63 } // namespace apitest
64 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */