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/XDocumentIndex.hpp>
22 #include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
25 using namespace css::uno
;
30 * Initial tests for SwXDocumentIndexes.
32 class SwXDocumentIndexes final
: public UnoApiTest
,
33 public apitest::XElementAccess
,
34 public apitest::XIndexAccess
,
35 public apitest::XNameAccess
39 : UnoApiTest(u
""_ustr
)
40 , XElementAccess(cppu::UnoType
<text::XDocumentIndex
>::get())
42 , XNameAccess(u
"Table of Contents1"_ustr
)
46 Reference
<XInterface
> init() override
48 loadFromURL(u
"private:factory/swriter"_ustr
);
49 Reference
<text::XTextDocument
> xTextDocument(mxComponent
, UNO_QUERY_THROW
);
50 Reference
<lang::XMultiServiceFactory
> xMSF(mxComponent
, UNO_QUERY_THROW
);
52 Reference
<text::XText
> xText
= xTextDocument
->getText();
53 Reference
<text::XTextCursor
> xCursor
= xText
->createTextCursor();
54 Reference
<text::XTextContent
> xTextContent(
55 xMSF
->createInstance(u
"com.sun.star.text.ContentIndex"_ustr
), UNO_QUERY_THROW
);
57 xText
->insertTextContent(xCursor
, xTextContent
, false);
58 Reference
<text::XDocumentIndexesSupplier
> xDocIndSupp(xTextDocument
, UNO_QUERY_THROW
);
60 return Reference
<XInterface
>(xDocIndSupp
->getDocumentIndexes(), UNO_QUERY_THROW
);
63 CPPUNIT_TEST_SUITE(SwXDocumentIndexes
);
64 CPPUNIT_TEST(testGetByName
);
65 CPPUNIT_TEST(testGetElementNames
);
66 CPPUNIT_TEST(testHasByName
);
67 CPPUNIT_TEST(testGetCount
);
68 CPPUNIT_TEST(testGetByIndex
);
69 CPPUNIT_TEST(testGetElementType
);
70 CPPUNIT_TEST(testHasElements
);
71 CPPUNIT_TEST_SUITE_END();
74 CPPUNIT_TEST_SUITE_REGISTRATION(SwXDocumentIndexes
);
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */