Avoid potential negative array index access to cached text.
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _XParagraphCursor.java
blob1aa58a3008d2f3dcb7453fa865c4b2b723fb50d0
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 com.sun.star.text.XParagraphCursor;
24 /**
25 * Testing <code>com.sun.star.text.XParagraphCursor</code>
26 * interface methods :
27 * <ul>
28 * <li><code> isStartOfParagraph()</code></li>
29 * <li><code> isEndOfParagraph()</code></li>
30 * <li><code> gotoStartOfParagraph()</code></li>
31 * <li><code> gotoEndOfParagraph()</code></li>
32 * <li><code> gotoNextParagraph()</code></li>
33 * <li><code> gotoPreviousParagraph()</code></li>
34 * </ul> <p>
36 * <b>Prerequisites :</b> the text must have at least
37 * two paragraphs. <p>
39 * Test is <b> NOT </b> multithread compliant. <p>
40 * @see com.sun.star.text.XParagraphCursor
42 public class _XParagraphCursor extends MultiMethodTest {
44 public XParagraphCursor oObj = null; // oObj filled by MultiMethodTest
46 /**
47 * Test calls the method. <p>
48 * Has <b> OK </b> status if the method returns
49 * <code>true</code> value.
51 public void _gotoEndOfParagraph(){
52 log.println( "test for gotoEndOfParagraph()" );
53 if (oObj.isEndOfParagraph()) log.println("This is the end of the paragraph");
54 else log.println("This isn't the end of the paragraph");
55 log.println("gotoEndOfParagraph()");
56 boolean result = oObj.gotoEndOfParagraph(false);
57 tRes.tested("gotoEndOfParagraph()", result );
58 if (oObj.isEndOfParagraph()) log.println("This is the end of the paragraph");
59 else log.println("This isn't the end of the paragraph");
60 if (!result) log.println("But 'gotoEndOfParagraph()' returns false");
63 /**
64 * Test calls the method. <p>
65 * Has <b> OK </b> status if the method returns
66 * <code>true</code> value. <p>
68 * The following method tests are to be completed successfully before :
69 * <ul>
70 * <li> <code>gotoPreviousParagraph()</code> : to be sure next paragraph
71 * exists. </li>
72 * </ul>
74 public void _gotoNextParagraph(){
75 requiredMethod( "gotoPreviousParagraph()" );
76 log.println( "test for gotoNextParagraph()" );
77 tRes.tested("gotoNextParagraph()", oObj.gotoNextParagraph(false) );
80 /**
81 * First moves the cursor to the next paragraph to be sure
82 * that previous paragraph exists and then calls the method. <p>
83 * Has <b> OK </b> status if the method returns
84 * <code>true</code> value.
86 public void _gotoPreviousParagraph(){
87 //requiredMethod( "gotoNextParagraph()" );
88 oObj.gotoNextParagraph(false);
89 log.println( "test for gotoPreviousParagraph()" );
90 tRes.tested("gotoPreviousParagraph()", oObj.gotoPreviousParagraph(false) );
93 /**
94 * Test calls the method. <p>
95 * Has <b> OK </b> status if the method returns
96 * <code>true</code> value.
98 public void _gotoStartOfParagraph(){
99 log.println( "test for gotoStartOfParagraph()" );
100 tRes.tested("gotoStartOfParagraph()", oObj.gotoStartOfParagraph(false) );
104 * Moves the cursor to the end of paragraph then check if it is
105 * at the end. <p>
106 * Has <b> OK </b> status if the method returns
107 * <code>true</code> value.
109 public void _isEndOfParagraph(){
110 oObj.gotoEndOfParagraph(false);
111 log.println( "test for isEndOfParagraph()" );
112 tRes.tested("isEndOfParagraph()", oObj.isEndOfParagraph() );
116 * Moves the cursor to the start of paragraph then check if it is
117 * at the start. <p>
118 * Has <b> OK </b> status if the method returns
119 * <code>true</code> value.
121 public void _isStartOfParagraph(){
122 oObj.gotoStartOfParagraph(false);
123 log.println( "test for isStartOfParagraph()" );
124 tRes.tested("isStartOfParagraph()", oObj.isStartOfParagraph() );
127 } // finish class _XParagraphCursor