1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <sal/config.h>
12 #include <cppunit/TestAssert.h>
13 #include <cppunit/extensions/HelperMacros.h>
14 #include <cppunit/plugin/TestPlugIn.h>
16 #include <com/sun/star/frame/Desktop.hpp>
17 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
18 #include <com/sun/star/text/XText.hpp>
19 #include <com/sun/star/text/XTextCursor.hpp>
20 #include <com/sun/star/text/XTextDocument.hpp>
21 #include <com/sun/star/text/XTextTable.hpp>
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <com/sun/star/uno/XInterface.hpp>
24 #include <comphelper/processfactory.hxx>
25 #include <test/bootstrapfixture.hxx>
26 #include <test/lang/xcomponent.hxx>
27 #include <unotest/macros_test.hxx>
29 class TerminateTest final
: public test::BootstrapFixture
,
30 public unotest::MacrosTest
,
31 public apitest::XComponent
34 void setUp() override
;
36 css::uno::Reference
<css::uno::XInterface
> init() override
;
38 void triggerDesktopTerminate() override
;
40 CPPUNIT_TEST_SUITE(TerminateTest
);
41 CPPUNIT_TEST(testDisposedByDesktopTerminate
);
42 CPPUNIT_TEST_SUITE_END();
45 void TerminateTest::setUp()
47 test::BootstrapFixture::setUp();
49 css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
52 css::uno::Reference
<css::uno::XInterface
> TerminateTest::init()
55 = loadFromDesktop(u
"private:factory/swriter"_ustr
, u
"com.sun.star.text.TextDocument"_ustr
);
56 css::uno::Reference
<css::text::XTextDocument
> xTextDocument(component
,
57 css::uno::UNO_QUERY_THROW
);
58 css::uno::Reference
<css::lang::XMultiServiceFactory
> xMSF(component
, css::uno::UNO_QUERY_THROW
);
59 css::uno::Reference
<css::text::XText
> xText
= xTextDocument
->getText();
60 css::uno::Reference
<css::text::XTextCursor
> xCursor
= xText
->createTextCursor();
61 css::uno::Reference
<css::text::XTextTable
> xTable(
62 xMSF
->createInstance(u
"com.sun.star.text.TextTable"_ustr
), css::uno::UNO_QUERY_THROW
);
63 xTable
->initialize(4, 3);
64 xText
->insertTextContent(xCursor
, xTable
, false);
65 CPPUNIT_ASSERT(xCursor
.is());
66 return css::uno::Reference
<css::uno::XInterface
>(xTable
, css::uno::UNO_QUERY_THROW
);
69 void TerminateTest::triggerDesktopTerminate() { mxDesktop
->terminate(); }
71 CPPUNIT_TEST_SUITE_REGISTRATION(TerminateTest
);
73 CPPUNIT_PLUGIN_IMPLEMENT();
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */