2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.text
.ControlCharacter
;
24 import com
.sun
.star
.text
.XSimpleText
;
25 import com
.sun
.star
.text
.XTextCursor
;
28 * Testing <code>com.sun.star.text.XSimpleText</code>
31 * <li><code> createTextCursor()</code></li>
32 * <li><code> createTextCursorByRange()</code></li>
33 * <li><code> insertString()</code></li>
34 * <li><code> insertControlCharacter()</code></li>
36 * Test is <b> NOT </b> multithread compliant. <p>
37 * @see com.sun.star.text.XSimpleText
39 public class _XSimpleText
extends MultiMethodTest
{
41 XTextCursor oCursor
= null;
42 public XSimpleText oObj
= null;
45 * Creates text cursor. <p>
46 * Has <b> OK </b> status if not null value returned. <p>
48 public void _createTextCursor() {
50 log
.println( "Testing createTextCursor()" );
51 oCursor
= oObj
.createTextCursor();
52 tRes
.tested( "createTextCursor()", oCursor
!= null );
56 * Inserts a string at the cursor position.<p>
57 * Has <b> OK </b> status if the whole result string has a string
58 * inserted as its substring. <p>
59 * The following method tests are to be completed successfully before :
61 * <li> <code> createTextCursor() </code> : to have a cursor
62 * where text should be inserted. </li>
65 public void _insertString() {
66 requiredMethod("createTextCursor()");
67 log
.println( "Testing insertString" );
68 String sStr
= getInterfaceName() ;
69 oObj
.insertString( oCursor
, sStr
, false );
70 String gStr
= oObj
.getText().getString() ;
72 tRes
.tested( "insertString()", gStr
!= null &&
73 gStr
.indexOf(sStr
) >= 0) ;
77 * Inserts paragraph break character into text and then checks
78 * if this character is present in the result string. <p>
79 * Has <b> OK </b> status if the result string has
80 * paragraph break character. <p>
81 * The following method tests are to be completed successfully before :
83 * <li> <code> createTextCursor </code> : to have a cursor object. </li>
86 public void _insertControlCharacter() {
89 requiredMethod("createTextCursor()");
90 log
.println( "Testing insertControlCharacter()" );
92 oObj
.insertControlCharacter( oCursor
,
93 ControlCharacter
.PARAGRAPH_BREAK
, false);
94 oObj
.insertControlCharacter( oCursor
,
95 ControlCharacter
.LINE_BREAK
, false);
96 oObj
.insertString(oObj
.createTextCursor(),"newLine",false);
98 catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
99 // Some exception.FAILED
100 log
.println(e
.toString());
103 String gStr
= oObj
.getString() ;
105 tRes
.tested( "insertControlCharacter()", bOK
&& gStr
!= null &&
106 gStr
.indexOf("\n") > -1);
110 * Creates another text cursor using existing cursor's range. <p>
111 * Has <b> OK </b> status if not null value returned. <p>
112 * The following method tests are to be completed successfully before :
114 * <li> <code> createTextCursor </code> : to have a cursor object. </li>
117 public void _createTextCursorByRange() {
119 requiredMethod("createTextCursor()");
120 oCursor
.gotoStart(false);
121 log
.println( "Testing createTextCursorByRange()" );
122 XTextCursor oTCursor
= oObj
.createTextCursorByRange(oCursor
);
123 tRes
.tested("createTextCursorByRange()", oTCursor
!= null) ;
125 } // finish class _XSimpleText