Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _XSimpleText.java
blob553aa7bbff966ead83ef27dfb6c33011698d6cd6
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 ************************************************************************/
28 package ifc.text;
30 import lib.MultiMethodTest;
31 import lib.Status;
33 import com.sun.star.text.ControlCharacter;
34 import com.sun.star.text.XSimpleText;
35 import com.sun.star.text.XTextCursor;
37 /**
38 * Testing <code>com.sun.star.text.XSimpleText</code>
39 * interface methods :
40 * <ul>
41 * <li><code> createTextCursor()</code></li>
42 * <li><code> createTextCursorByRange()</code></li>
43 * <li><code> insertString()</code></li>
44 * <li><code> insertControlCharacter()</code></li>
45 * </ul> <p>
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;
54 /**
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 );
65 /**
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 :
70 * <ul>
71 * <li> <code> createTextCursor() </code> : to have a cursor
72 * where text should be inserted. </li>
73 * </ul>
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) ;
86 /**
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 :
92 * <ul>
93 * <li> <code> createTextCursor </code> : to have a cursor object. </li>
94 * </ul>
96 public void _insertControlCharacter() {
97 boolean bOK = true;
99 requiredMethod("createTextCursor()");
100 log.println( "Testing insertControlCharacter()" );
101 try {
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() );
111 bOK = false;
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 :
123 * <ul>
124 * <li> <code> createTextCursor </code> : to have a cursor object. </li>
125 * </ul>
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