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: _XPageCursor.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
;
35 import com
.sun
.star
.text
.ControlCharacter
;
36 import com
.sun
.star
.text
.XPageCursor
;
37 import com
.sun
.star
.text
.XText
;
38 import com
.sun
.star
.text
.XTextCursor
;
39 import com
.sun
.star
.text
.XTextDocument
;
43 * Testing <code>com.sun.star.text.XPageCursor</code>
46 * <li><code> jumpToFirstPage()</code></li>
47 * <li><code> jumpToLastPage()</code></li>
48 * <li><code> jumpToPage()</code></li>
49 * <li><code> getPage()</code></li>
50 * <li><code> jumpToNextPage()</code></li>
51 * <li><code> jumpToPreviousPage()</code></li>
52 * <li><code> jumpToEndOfPage()</code></li>
53 * <li><code> jumpToStartOfPage()</code></li>
55 * This test needs the following object relations :
57 * <li> <code>'TEXTDOC'</code> (of type <code>XTextDocument</code>):
58 * is used to insert text to document to fill at least two pages. </li>
60 * Test is <b> NOT </b> multithread compilant. <p>
61 * @see com.sun.star.text.XPageCursor
63 public class _XPageCursor
extends MultiMethodTest
{
65 public XPageCursor oObj
= null; // oObj filled by MultiMethodTest
69 * First adds text to the document using relation to fill at least two
70 * pages. Then obtains the number of current page. <p>
72 * Has <b>OK</b> status if the returned value is positive.
74 public void _getPage(){
75 log
.println( "test for getPage()" );
76 XTextDocument myText
= (XTextDocument
)tEnv
.getObjRelation( "TEXTDOC" );
77 XText aText
= myText
.getText();
78 XTextCursor myCursor
= aText
.createTextCursor();
81 for (int i
= 0; i
< 10; i
++){
82 for (int j
= 0; j
< 20; j
++){
83 aText
.insertString(myCursor
, "The quick brown fox ",false);
84 aText
.insertString(myCursor
, "jumps over the lazy dog ",
87 aText
.insertControlCharacter(myCursor
,
88 ControlCharacter
.PARAGRAPH_BREAK
, false);
90 } catch(com
.sun
.star
.lang
.IllegalArgumentException e
) {
91 log
.println( "Exception :" );
92 e
.printStackTrace(log
);
95 count
= oObj
.getPage();
96 tRes
.tested("getPage()", count
> 0 );
100 * Test calls the method. <p>
101 * Has <b> OK </b> status if the method returns
102 * <code>true</code> value.
104 public void _jumpToEndOfPage(){
105 log
.println( "test for jumpToEndOfPage()" );
106 tRes
.tested("jumpToEndOfPage()", oObj
.jumpToEndOfPage());
110 * Test calls the method. <p>
111 * Has <b> OK </b> status if the method returns
112 * <code>true</code> value.
114 public void _jumpToFirstPage(){
115 log
.println( "test for jumpToFirstPage()" );
116 tRes
.tested("jumpToFirstPage()", oObj
.jumpToFirstPage());
120 * Test calls the method. <p>
121 * Has <b> OK </b> status if the method returns
122 * <code>true</code> value.
124 public void _jumpToLastPage(){
125 log
.println( "test for jumpToLastPage()" );
126 tRes
.tested("jumpToLastPage()", oObj
.jumpToLastPage());
130 * Firts jumps to the first page to have at least one
131 * next page, then call the method. <p>
132 * Has <b> OK </b> status if the method returns
133 * <code>true</code> value.
135 public void _jumpToNextPage(){
136 oObj
.jumpToFirstPage() ;
137 log
.println( "test for jumpToNextPage()" );
138 tRes
.tested("jumpToNextPage()", oObj
.jumpToNextPage());
142 * Tries to jump to the page with number 1. <p>
143 * Has <b> OK </b> status if the method returns
144 * <code>true</code> value.
146 public void _jumpToPage(){
148 log
.println( "test for jumpToPage()" );
149 tRes
.tested("jumpToPage()", oObj
.jumpToPage(n
));
153 * Firts jumps to the last page to have at least one
154 * previous page, then call the method. <p>
155 * Has <b> OK </b> status if the method returns
156 * <code>true</code> value.
158 public void _jumpToPreviousPage(){
159 log
.println( "test for jumpToPreviousPage()" );
160 oObj
.jumpToLastPage();
161 tRes
.tested("jumpToPreviousPage()", oObj
.jumpToPreviousPage());
165 * Test calls the method. <p>
166 * Has <b> OK </b> status if the method returns
167 * <code>true</code> value.
169 public void _jumpToStartOfPage(){
170 log
.println( "test for jumpToStartOfPage()" );
171 tRes
.tested("jumpToStartOfPage()", oObj
.jumpToStartOfPage());
173 } // finish class _XPageCursor