use insert function instead of for loop
[LibreOffice.git] / sw / qa / api / SwXBodyText.cxx
blob3d727d9910ade5f03b4c9d6de8f15a54beb27757
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <test/unoapi_test.hxx>
11 #include <test/text/xsimpletext.hxx>
12 #include <test/container/xelementaccess.hxx>
13 #include <test/text/xtextrange.hxx>
14 #include <test/container/xenumerationaccess.hxx>
15 #include <test/text/xtextrangecompare.hxx>
17 #include <com/sun/star/frame/Desktop.hpp>
19 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
21 #include <com/sun/star/text/XTextDocument.hpp>
22 #include <com/sun/star/text/XText.hpp>
24 #include <comphelper/processfactory.hxx>
26 using namespace css;
27 using namespace css::uno;
29 namespace
31 /**
32 * Initial tests for SwXBodyText.
34 class SwXBodyText final : public UnoApiTest,
35 public apitest::XElementAccess,
36 public apitest::XTextRange,
37 public apitest::XSimpleText,
38 public apitest::XEnumerationAccess,
39 public apitest::XTextRangeCompare
41 public:
42 SwXBodyText();
44 Reference<XInterface> init() override;
46 CPPUNIT_TEST_SUITE(SwXBodyText);
47 CPPUNIT_TEST(testCreateTextCursor);
48 CPPUNIT_TEST(testCreateTextCursorByRange);
49 CPPUNIT_TEST(testInsertString);
50 CPPUNIT_TEST(testInsertControlCharacter);
51 CPPUNIT_TEST(testGetElementType);
52 CPPUNIT_TEST(testHasElements);
53 CPPUNIT_TEST(testGetText);
54 CPPUNIT_TEST(testGetStart);
55 CPPUNIT_TEST(testGetEnd);
56 CPPUNIT_TEST(testGetSetString);
57 CPPUNIT_TEST(testCreateEnumeration);
58 CPPUNIT_TEST(testCompareRegionStarts);
59 CPPUNIT_TEST(testCompareRegionEnds);
60 CPPUNIT_TEST_SUITE_END();
63 SwXBodyText::SwXBodyText()
64 : UnoApiTest(u""_ustr)
65 , XElementAccess(cppu::UnoType<text::XTextRange>::get())
69 Reference<XInterface> SwXBodyText::init()
71 loadFromURL(u"private:factory/swriter"_ustr);
72 Reference<text::XTextDocument> xTextDocument(mxComponent, UNO_QUERY_THROW);
73 Reference<lang::XMultiServiceFactory> xMSF(mxComponent, UNO_QUERY_THROW);
75 Reference<text::XText> xText = xTextDocument->getText();
77 return Reference<XInterface>(xText, UNO_QUERY_THROW);
80 CPPUNIT_TEST_SUITE_REGISTRATION(SwXBodyText);
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */