LibreOffice Module unotest (master) 1
bootstrapfixturebase.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 */
9#ifndef INCLUDED_UNOTEST_BOOTSTRAPFIXTUREBASE_HXX
10#define INCLUDED_UNOTEST_BOOTSTRAPFIXTUREBASE_HXX
11
12#include <sal/config.h>
13
14#include <com/sun/star/uno/XComponentContext.hpp>
15#include <com/sun/star/lang/XMultiServiceFactory.hpp>
16#include <com/sun/star/lang/XMultiComponentFactory.hpp>
17
18#include <cppunit/TestAssert.h>
19#include <cppunit/TestFixture.h>
20#include <cppunit/extensions/HelperMacros.h>
21#include <cppunit/plugin/TestPlugIn.h>
24
25// For cppunit < 1.15.0.
26#ifndef CPPUNIT_TEST_FIXTURE
27#define CPPUNIT_TEST_FIXTURE(TestClass, TestName) \
28 class TestName : public TestClass \
29 { \
30 public: \
31 void TestBody(); \
32 CPPUNIT_TEST_SUITE(TestName); \
33 CPPUNIT_TEST(TestBody); \
34 CPPUNIT_TEST_SUITE_END(); \
35 }; \
36 CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
37 void TestName::TestBody()
38#endif
39
40namespace test {
41
42// Class to do lots of heavy-lifting UNO & environment
43// bootstrapping for unit tests, such that we can use
44// almost an entire LibreOffice during compile - so
45// that we can get pieces of code alone to beat them up.
46
47// NB. this class is instantiated multiple times during a
48// run of unit tests ...
49class OOO_DLLPUBLIC_UNOTEST BootstrapFixtureBase : public CppUnit::TestFixture
50{
51protected:
53 css::uno::Reference<css::uno::XComponentContext> m_xContext;
54 css::uno::Reference<css::lang::XMultiServiceFactory> m_xSFactory;
55 css::uno::Reference<css::lang::XMultiComponentFactory> m_xFactory;
56
57public:
59 virtual ~BootstrapFixtureBase() override;
60
61 const css::uno::Reference<css::uno::XComponentContext>&
62 getComponentContext() const { return m_xContext; }
63 const css::uno::Reference<css::lang::XMultiServiceFactory>&
64 getMultiServiceFactory() const { return m_xSFactory; }
65
66 virtual void setUp() override;
67 virtual void tearDown() override;
68};
69
70}
71
72#endif
73
74/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XComponentContext > m_xContext
const css::uno::Reference< css::lang::XMultiServiceFactory > & getMultiServiceFactory() const
css::uno::Reference< css::lang::XMultiServiceFactory > m_xSFactory
css::uno::Reference< css::lang::XMultiComponentFactory > m_xFactory
const css::uno::Reference< css::uno::XComponentContext > & getComponentContext() const
css::uno::Reference< css::uno::XComponentContext > m_xContext
#define OOO_DLLPUBLIC_UNOTEST