Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _XSimpleText.java
blob8f1c32d40911267da46815369571ccffa4dfc298
1 /*
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 .
19 package ifc.text;
21 import lib.MultiMethodTest;
22 import lib.Status;
24 import com.sun.star.text.ControlCharacter;
25 import com.sun.star.text.XSimpleText;
26 import com.sun.star.text.XTextCursor;
28 /**
29 * Testing <code>com.sun.star.text.XSimpleText</code>
30 * interface methods :
31 * <ul>
32 * <li><code> createTextCursor()</code></li>
33 * <li><code> createTextCursorByRange()</code></li>
34 * <li><code> insertString()</code></li>
35 * <li><code> insertControlCharacter()</code></li>
36 * </ul> <p>
37 * Test is <b> NOT </b> multithread compliant. <p>
38 * @see com.sun.star.text.XSimpleText
40 public class _XSimpleText extends MultiMethodTest {
42 XTextCursor oCursor = null;
43 public XSimpleText oObj = null;
45 /**
46 * Creates text cursor. <p>
47 * Has <b> OK </b> status if not null value returned. <p>
49 public void _createTextCursor() {
51 log.println( "Testing createTextCursor()" );
52 oCursor = oObj.createTextCursor();
53 tRes.tested( "createTextCursor()", oCursor != null );
56 /**
57 * Inserts a string at the cursor position.<p>
58 * Has <b> OK </b> status if the whole result string has a string
59 * inserted as its substring. <p>
60 * The following method tests are to be completed successfully before :
61 * <ul>
62 * <li> <code> createTextCursor() </code> : to have a cursor
63 * where text should be inserted. </li>
64 * </ul>
66 public void _insertString() {
67 requiredMethod("createTextCursor()");
68 log.println( "Testing insertString" );
69 String sStr = getInterfaceName() ;
70 oObj.insertString( oCursor, sStr, false );
71 String gStr = oObj.getText().getString() ;
73 tRes.tested( "insertString()", gStr != null &&
74 gStr.indexOf(sStr) >= 0) ;
77 /**
78 * Inserts paragraph break character into text and then checks
79 * if this character is present in the result string. <p>
80 * Has <b> OK </b> status if the result string has
81 * paragraph break character. <p>
82 * The following method tests are to be completed successfully before :
83 * <ul>
84 * <li> <code> createTextCursor </code> : to have a cursor object. </li>
85 * </ul>
87 public void _insertControlCharacter() {
88 boolean bOK = true;
90 requiredMethod("createTextCursor()");
91 log.println( "Testing insertControlCharacter()" );
92 try {
93 oObj.insertControlCharacter( oCursor,
94 ControlCharacter.PARAGRAPH_BREAK, false);
95 oObj.insertControlCharacter( oCursor,
96 ControlCharacter.LINE_BREAK, false);
97 oObj.insertString(oObj.createTextCursor(),"newLine",false);
99 catch(com.sun.star.lang.IllegalArgumentException e ) {
100 // Some exception.FAILED
101 Status.failed( e.toString() );
102 bOK = false;
104 String gStr = oObj.getString() ;
106 tRes.tested( "insertControlCharacter()", bOK && gStr != null &&
107 gStr.indexOf("\n") > -1);
111 * Creates another text cursor using existing cursor's range. <p>
112 * Has <b> OK </b> status if not null value returned. <p>
113 * The following method tests are to be completed successfully before :
114 * <ul>
115 * <li> <code> createTextCursor </code> : to have a cursor object. </li>
116 * </ul>
118 public void _createTextCursorByRange() {
120 requiredMethod("createTextCursor()");
121 oCursor.gotoStart(false);
122 log.println( "Testing createTextCursorByRange()" );
123 XTextCursor oTCursor = oObj.createTextCursorByRange(oCursor);
124 tRes.tested("createTextCursorByRange()", oTCursor != null) ;
126 } // finish class _XSimpleText