/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace css; using namespace css::uno; namespace { /** * Initial tests for SwXFootnote. */ class SwXFootnote final : public test::BootstrapFixture, public unotest::MacrosTest, public apitest::XComponent, public apitest::XSimpleText, public apitest::XTextRange, public apitest::XTextContent, public apitest::XText, public apitest::XFootnote, public apitest::Footnote { public: virtual void setUp() override; void tearDown() override; Reference init() override; Reference getTextRange() override; Reference getTextContent() override; bool isAttachSupported() override { return true; } Reference getTextDocument() { return mxTextDocument; } void triggerDesktopTerminate() override {} CPPUNIT_TEST_SUITE(SwXFootnote); CPPUNIT_TEST(testDispose); CPPUNIT_TEST(testAddEventListener); CPPUNIT_TEST(testRemoveEventListener); CPPUNIT_TEST(testAttach); CPPUNIT_TEST(testGetAnchor); CPPUNIT_TEST(testCreateTextCursor); CPPUNIT_TEST(testCreateTextCursorByRange); CPPUNIT_TEST(testInsertString); CPPUNIT_TEST(testInsertControlCharacter); CPPUNIT_TEST(testGetEnd); CPPUNIT_TEST(testGetSetString); CPPUNIT_TEST(testGetStart); CPPUNIT_TEST(testGetText); CPPUNIT_TEST(testFootnoteProperties); // CPPUNIT_TEST(testInsertRemoveTextContent); CPPUNIT_TEST(testGetSetLabel); CPPUNIT_TEST_SUITE_END(); private: Reference mxTextDocument; Reference mxTextRange; Reference mxTextContent; }; void SwXFootnote::setUp() { test::BootstrapFixture::setUp(); mxDesktop.set(frame::Desktop::create(mxComponentContext)); mxTextDocument = Reference( loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"), uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(mxTextDocument.is()); } void SwXFootnote::tearDown() { if (mxTextDocument.is()) mxTextDocument->dispose(); test::BootstrapFixture::tearDown(); } Reference SwXFootnote::init() { Reference xMSF(mxTextDocument, UNO_QUERY_THROW); Reference xFootnote(xMSF->createInstance("com.sun.star.text.Footnote"), UNO_QUERY_THROW); Reference xText = getTextDocument()->getText(); Reference xCursor = xText->createTextCursor(); xText->insertTextContent(xCursor, xFootnote, false); mxTextRange = Reference(xCursor, UNO_QUERY_THROW); mxTextContent = Reference( xMSF->createInstance("com.sun.star.text.Footnote"), UNO_QUERY_THROW); return Reference(xFootnote, UNO_QUERY_THROW); } Reference SwXFootnote::getTextRange() { return mxTextRange; } Reference SwXFootnote::getTextContent() { return mxTextContent; } CPPUNIT_TEST_SUITE_REGISTRATION(SwXFootnote); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */