Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / test / source / text / xsimpletext.cxx
blob23ea6c785eebf2b4fb239787938bb00b848332cb
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/text/xsimpletext.hxx>
11 #include <com/sun/star/text/XTextCursor.hpp>
12 #include <com/sun/star/text/ControlCharacter.hpp>
13 #include <com/sun/star/lang/IllegalArgumentException.hpp>
14 #include <cppunit/TestAssert.h>
16 using namespace css;
17 using namespace css::uno;
19 namespace apitest
21 void XSimpleText::testCreateTextCursor()
23 uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
25 CPPUNIT_ASSERT(xSimpleText->createTextCursor());
28 void XSimpleText::testCreateTextCursorByRange()
30 uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
31 uno::Reference<text::XTextCursor> xCursor(xSimpleText->createTextCursor(), UNO_SET_THROW);
33 xCursor->gotoStart(false);
35 CPPUNIT_ASSERT(xSimpleText->createTextCursorByRange(xCursor));
38 void XSimpleText::testInsertString()
40 uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
41 uno::Reference<text::XTextRange> xCursor(xSimpleText->createTextCursor(), UNO_QUERY_THROW);
42 ::rtl::OUString sString = "TestString";
44 xSimpleText->insertString(xCursor, sString, false);
45 ::rtl::OUString gString = xSimpleText->getText()->getString();
47 CPPUNIT_ASSERT(!gString.isEmpty());
48 CPPUNIT_ASSERT(gString.indexOf(sString) >= 0);
51 void XSimpleText::testInsertControlCharacter()
53 bool bOK = true;
55 uno::Reference<text::XSimpleText> xSimpleText(init(), UNO_QUERY_THROW);
56 uno::Reference<text::XTextRange> xCursor(xSimpleText->createTextCursor(), UNO_QUERY_THROW);
58 try
60 xSimpleText->insertControlCharacter(xCursor, text::ControlCharacter::PARAGRAPH_BREAK,
61 false);
62 xSimpleText->insertControlCharacter(xCursor, text::ControlCharacter::LINE_BREAK, false);
63 xSimpleText->insertString(xSimpleText->createTextCursor(), "newLine", false);
65 catch (const lang::IllegalArgumentException&)
67 bOK = false;
70 OUString gString = xSimpleText->getString();
71 CPPUNIT_ASSERT(bOK);
72 CPPUNIT_ASSERT(gString.indexOf("\n") > -1);
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */