1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XSimpleText.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
36 import com
.sun
.star
.text
.ControlCharacter
;
37 import com
.sun
.star
.text
.XSimpleText
;
38 import com
.sun
.star
.text
.XTextCursor
;
41 * Testing <code>com.sun.star.text.XSimpleText</code>
44 * <li><code> createTextCursor()</code></li>
45 * <li><code> createTextCursorByRange()</code></li>
46 * <li><code> insertString()</code></li>
47 * <li><code> insertControlCharacter()</code></li>
49 * Test is <b> NOT </b> multithread compilant. <p>
50 * @see com.sun.star.text.XSimpleText
52 public class _XSimpleText
extends MultiMethodTest
{
54 XTextCursor oCursor
= null;
55 public XSimpleText oObj
= null;
58 * Creates text cursor. <p>
59 * Has <b> OK </b> status if not null value returned. <p>
61 public void _createTextCursor() {
63 log
.println( "Testing createTextCursor()" );
64 oCursor
= oObj
.createTextCursor();
65 tRes
.tested( "createTextCursor()", oCursor
!= null );
69 * Inserts a string at the cursor position.<p>
70 * Has <b> OK </b> status if the whole result string has a string
71 * inserted as its substring. <p>
72 * The following method tests are to be completed successfully before :
74 * <li> <code> createTextCursor() </code> : to have a cursor
75 * where text should be inserted. </li>
78 public void _insertString() {
79 requiredMethod("createTextCursor()");
80 log
.println( "Testing insertString" );
81 String sStr
= getInterfaceName() ;
82 oObj
.insertString( oCursor
, sStr
, false );
83 String gStr
= oObj
.getText().getString() ;
85 tRes
.tested( "insertString()", gStr
!= null &&
86 gStr
.indexOf(sStr
) >= 0) ;
90 * Inserts paragraph break character into text and then checks
91 * if this character is present in the result string. <p>
92 * Has <b> OK </b> status if the result string has
93 * paragraph break character. <p>
94 * The following method tests are to be completed successfully before :
96 * <li> <code> createTextCursor </code> : to have a cursor object. </li>
99 public void _insertControlCharacter() {
102 requiredMethod("createTextCursor()");
103 log
.println( "Testing insertControlCharacter()" );
105 oObj
.insertControlCharacter( oCursor
,
106 ControlCharacter
.PARAGRAPH_BREAK
, false);
107 oObj
.insertControlCharacter( oCursor
,
108 ControlCharacter
.LINE_BREAK
, false);
109 oObj
.insertString(oObj
.createTextCursor(),"newLine",false);
111 catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
112 // Some exception.FAILED
113 Status
.failed( e
.toString() );
116 String gStr
= oObj
.getString() ;
118 tRes
.tested( "insertControlCharacter()", bOK
&& gStr
!= null &&
119 gStr
.indexOf("\n") > -1);
123 * Creates another text cursor using existing cursor's range. <p>
124 * Has <b> OK </b> status if not null value returned. <p>
125 * The following method tests are to be completed successfully before :
127 * <li> <code> createTextCursor </code> : to have a cursor object. </li>
130 public void _createTextCursorByRange() {
132 requiredMethod("createTextCursor()");
133 oCursor
.gotoStart(false);
134 log
.println( "Testing createTextCursorByRange()" );
135 XTextCursor oTCursor
= oObj
.createTextCursorByRange(oCursor
);
136 tRes
.tested("createTextCursorByRange()", oTCursor
!= null) ;
138 } // finish class _XSimpleText