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/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>
17 using namespace css::uno
;
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()
55 uno::Reference
<text::XSimpleText
> xSimpleText(init(), UNO_QUERY_THROW
);
56 uno::Reference
<text::XTextRange
> xCursor(xSimpleText
->createTextCursor(), UNO_QUERY_THROW
);
60 xSimpleText
->insertControlCharacter(xCursor
, text::ControlCharacter::PARAGRAPH_BREAK
,
62 xSimpleText
->insertControlCharacter(xCursor
, text::ControlCharacter::LINE_BREAK
, false);
63 xSimpleText
->insertString(xSimpleText
->createTextCursor(), "newLine", false);
65 catch (const lang::IllegalArgumentException
&)
70 OUString gString
= xSimpleText
->getString();
72 CPPUNIT_ASSERT(gString
.indexOf("\n") > -1);
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */