1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <test/unoapi_test.hxx>
11 #include <test/container/xnameaccess.hxx>
12 #include <test/container/xindexaccess.hxx>
13 #include <test/container/xelementaccess.hxx>
15 #include <com/sun/star/frame/Desktop.hpp>
17 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
19 #include <com/sun/star/text/XTextDocument.hpp>
20 #include <com/sun/star/text/XText.hpp>
21 #include <com/sun/star/text/XBookmarksSupplier.hpp>
24 using namespace css::uno
;
29 * Initial tests for SwXBookmarks.
31 class SwXBookmarks final
: public UnoApiTest
,
32 public apitest::XElementAccess
,
33 public apitest::XIndexAccess
,
34 public apitest::XNameAccess
38 : UnoApiTest(u
""_ustr
)
39 , XElementAccess(cppu::UnoType
<text::XTextContent
>::get())
41 , XNameAccess(u
"Bookmark"_ustr
)
45 Reference
<XInterface
> init() override
47 loadFromURL(u
"private:factory/swriter"_ustr
);
48 Reference
<text::XTextDocument
> xTextDocument(mxComponent
, UNO_QUERY_THROW
);
49 Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, UNO_QUERY_THROW
);
51 Reference
<text::XText
> xText
= xTextDocument
->getText();
52 Reference
<text::XTextCursor
> xCursor
= xText
->createTextCursor();
54 Reference
<text::XTextContent
> xBookmark(
55 xMSF
->createInstance(u
"com.sun.star.text.Bookmark"_ustr
), UNO_QUERY_THROW
);
56 xText
->insertTextContent(xCursor
, xBookmark
, false);
58 Reference
<text::XBookmarksSupplier
> xSupplier(xTextDocument
, UNO_QUERY_THROW
);
59 Reference
<container::XNameAccess
> xNameAccess
= xSupplier
->getBookmarks();
61 return Reference
<XInterface
>(xNameAccess
, UNO_QUERY_THROW
);
64 CPPUNIT_TEST_SUITE(SwXBookmarks
);
65 CPPUNIT_TEST(testGetByName
);
66 CPPUNIT_TEST(testGetElementNames
);
67 CPPUNIT_TEST(testHasByName
);
68 CPPUNIT_TEST(testGetCount
);
69 CPPUNIT_TEST(testGetByIndex
);
70 CPPUNIT_TEST(testGetElementType
);
71 CPPUNIT_TEST(testHasElements
);
72 CPPUNIT_TEST_SUITE_END();
75 CPPUNIT_TEST_SUITE_REGISTRATION(SwXBookmarks
);
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */