1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
33 import com
.sun
.star
.text
.ControlCharacter
;
34 import com
.sun
.star
.text
.XSimpleText
;
35 import com
.sun
.star
.text
.XTextCursor
;
38 * Testing <code>com.sun.star.text.XSimpleText</code>
41 * <li><code> createTextCursor()</code></li>
42 * <li><code> createTextCursorByRange()</code></li>
43 * <li><code> insertString()</code></li>
44 * <li><code> insertControlCharacter()</code></li>
46 * Test is <b> NOT </b> multithread compilant. <p>
47 * @see com.sun.star.text.XSimpleText
49 public class _XSimpleText
extends MultiMethodTest
{
51 XTextCursor oCursor
= null;
52 public XSimpleText oObj
= null;
55 * Creates text cursor. <p>
56 * Has <b> OK </b> status if not null value returned. <p>
58 public void _createTextCursor() {
60 log
.println( "Testing createTextCursor()" );
61 oCursor
= oObj
.createTextCursor();
62 tRes
.tested( "createTextCursor()", oCursor
!= null );
66 * Inserts a string at the cursor position.<p>
67 * Has <b> OK </b> status if the whole result string has a string
68 * inserted as its substring. <p>
69 * The following method tests are to be completed successfully before :
71 * <li> <code> createTextCursor() </code> : to have a cursor
72 * where text should be inserted. </li>
75 public void _insertString() {
76 requiredMethod("createTextCursor()");
77 log
.println( "Testing insertString" );
78 String sStr
= getInterfaceName() ;
79 oObj
.insertString( oCursor
, sStr
, false );
80 String gStr
= oObj
.getText().getString() ;
82 tRes
.tested( "insertString()", gStr
!= null &&
83 gStr
.indexOf(sStr
) >= 0) ;
87 * Inserts paragraph break character into text and then checks
88 * if this character is present in the result string. <p>
89 * Has <b> OK </b> status if the result string has
90 * paragraph break character. <p>
91 * The following method tests are to be completed successfully before :
93 * <li> <code> createTextCursor </code> : to have a cursor object. </li>
96 public void _insertControlCharacter() {
99 requiredMethod("createTextCursor()");
100 log
.println( "Testing insertControlCharacter()" );
102 oObj
.insertControlCharacter( oCursor
,
103 ControlCharacter
.PARAGRAPH_BREAK
, false);
104 oObj
.insertControlCharacter( oCursor
,
105 ControlCharacter
.LINE_BREAK
, false);
106 oObj
.insertString(oObj
.createTextCursor(),"newLine",false);
108 catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
109 // Some exception.FAILED
110 Status
.failed( e
.toString() );
113 String gStr
= oObj
.getString() ;
115 tRes
.tested( "insertControlCharacter()", bOK
&& gStr
!= null &&
116 gStr
.indexOf("\n") > -1);
120 * Creates another text cursor using existing cursor's range. <p>
121 * Has <b> OK </b> status if not null value returned. <p>
122 * The following method tests are to be completed successfully before :
124 * <li> <code> createTextCursor </code> : to have a cursor object. </li>
127 public void _createTextCursorByRange() {
129 requiredMethod("createTextCursor()");
130 oCursor
.gotoStart(false);
131 log
.println( "Testing createTextCursorByRange()" );
132 XTextCursor oTCursor
= oObj
.createTextCursorByRange(oCursor
);
133 tRes
.tested("createTextCursorByRange()", oTCursor
!= null) ;
135 } // finish class _XSimpleText