Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / text / _XTextTableCursor.java
blob547676f1586c095371c90a366680181df6a92488
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XTextTableCursor.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.text;
33 import lib.MultiMethodTest;
35 import com.sun.star.table.XCell;
36 import com.sun.star.text.XTextTableCursor;
39 /**
40 * Testing <code>com.sun.star.text.XTextTableCursor</code>
41 * interface methods :
42 * <ul>
43 * <li><code> getRangeName()</code></li>
44 * <li><code> gotoCellByName()</code></li>
45 * <li><code> goLeft()</code></li>
46 * <li><code> goRight()</code></li>
47 * <li><code> goUp()</code></li>
48 * <li><code> goDown()</code></li>
49 * <li><code> gotoStart()</code></li>
50 * <li><code> gotoEnd()</code></li>
51 * <li><code> mergeRange()</code></li>
52 * <li><code> splitRange()</code></li>
53 * </ul> <p>
55 * <b>Prerequisites : </b> the table must have a size
56 * 2x2 and current cursor position must be in the upper
57 * left cell. <p>
59 * Test is <b> NOT </b> multithread compilant. <p>
61 * After test completion object environment has to be recreated
62 * because after merging and splitting cells their names
63 * differ from initial.
65 * @see com.sun.star.text.XTextTableCursor
67 public class _XTextTableCursor extends MultiMethodTest {
69 public XTextTableCursor oObj = null; // oObj filled by MultiMethodTest
71 XCell oCell = null;
73 /**
74 * Moves the cursor to upper-left cell and checks
75 * its range name. <p>
77 * Has <b>OK</b> status if the name returned is 'A1'.
79 public void _getRangeName(){
80 log.println( "test for getRangeName()" );
81 oObj.gotoStart(false);
82 String oCellName = oObj.getRangeName();
83 log.println( "CellName = " + oCellName );
85 tRes.tested("getRangeName()", oCellName.equals("A1") );
88 /**
89 * Calls the method which moves the cursor down by 1 cell,
90 * after that returns cursor to the old position. <p>
92 * Has <b>OK</b> status if the method returns
93 * <code>true</code>.
95 public void _goDown(){
96 boolean bDown = false;
97 log.println( "test for goDown()" );
98 short i = 1;
100 bDown = oObj.goDown(i,false);
102 tRes.tested("goDown()", bDown );
103 oObj.goUp(i,false);
107 * Calls the method which moves the cursor to the right by 1 cell,
108 * after that returns cursor to the old position. <p>
110 * Has <b>OK</b> status if the method returns
111 * <code>true</code>.
113 public void _goRight(){
114 boolean bRight = false;
115 log.println( "test for goRight()" );
116 short i = 1;
118 bRight = oObj.goRight(i,false);
120 tRes.tested("goRight()", bRight );
121 oObj.goLeft(i,false);
125 * Calls the method which moves the cursor to the left by 1 cell,
126 * after that returns cursor to the old position. <p>
128 * Has <b>OK</b> status if the method returns
129 * <code>true</code>.
131 public void _goLeft(){
132 boolean bLeft = false;
133 log.println( "test for goLeft()" );
134 short i = 1;
136 oObj.goRight(i,false);
137 bLeft = oObj.goLeft(i,false);
139 tRes.tested("goLeft()", bLeft );
143 * Calls the method which moves the cursor up by 1 cell,
144 * after that returns cursor to the old position. <p>
146 * Has <b>OK</b> status if the method returns
147 * <code>true</code>.
149 public void _goUp(){
150 boolean bUp = false;
151 log.println( "test for goUp()" );
152 short i = 1;
154 oObj.gotoEnd(true);
156 bUp = oObj.goUp(i,false);
157 tRes.tested("goUp()", bUp );
161 * Moves the cursor to the cell with name 'B1', then
162 * checks the current range name. <p>
163 * Has <b>OK</b> status if the returned range name is
164 * 'B1'.
166 public void _gotoCellByName(){
167 log.println( "test for gotoCellByName()" );
169 oObj.gotoCellByName("B1",false);
170 String oCellName = oObj.getRangeName();
172 tRes.tested("gotoCellByName()", oCellName.equals("B1") );
176 * Moves cursor to the start (upper-left cell). Then
177 * checks the current range name. <p>
179 * Has <b>OK</b> status if current range name is 'A1'.
181 public void _gotoStart(){
182 log.println( "test for gotoStart()" );
184 oObj.gotoStart(false);
185 String oCellName = oObj.getRangeName();
187 tRes.tested("gotoStart()", oCellName.equals("A1") );
191 * Moves cursor to the end (lower-right cell). Then
192 * checks the current range name. <p>
194 * Has <b>OK</b> status if current range name is 'B2'
195 * (the table is assumed to be of size 2x2).
197 public void _gotoEnd(){
198 log.println( "test for gotoEnd()" );
200 oObj.gotoEnd(false);
201 String oCellName = oObj.getRangeName();
203 tRes.tested("gotoEnd()", oCellName.equals("B2") );
207 * Selects all cells in the table and merges them.
208 * Finally move the cursor to the end and checks
209 * current range name.<p>
211 * Has <b>OK</b> status if the end cell has a name
212 * 'A1'.
214 * The following method tests are to be executed before :
215 * <ul>
216 * <li> <code> getRangeName(), gotoStart(), gotoEnd()
217 * goLeft(), goRight(), goUp(), goDown(), gotoCellByName()</code>
218 * : these methods must be completed before all cells of the
219 * table are merged into one cell </li>
220 * </ul>
222 public void _mergeRange(){
223 executeMethod("getRangeName()") ;
224 executeMethod("gotoStart()") ;
225 executeMethod("gotoEnd()") ;
226 executeMethod("goLeft()") ;
227 executeMethod("goRight()") ;
228 executeMethod("goUp()") ;
229 executeMethod("goDown()") ;
230 executeMethod("gotoCellByName()") ;
232 boolean bMerge = false;
233 log.println( "test for mergeRange()" );
235 oObj.gotoStart(false);
236 oObj.gotoEnd(true);
237 bMerge = oObj.mergeRange();
239 oObj.gotoEnd(false);
241 String curName = oObj.getRangeName() ;
242 bMerge &= "A1".equals(curName) ;
244 tRes.tested("mergeRange()", bMerge );
248 * First splits the cell horyzontally. Then the end cell
249 * name is checked. Second split all cells vertically and
250 * again the end cell name is checked<p>
252 * Has <b> OK </b> status if in the first case the end cell name
253 * is not 'A1', and in the second case the end cell name is not
254 * equal to the name gotten in the first case. <p>
256 * The following method tests are to be completed successfully before :
257 * <ul>
258 * <li> <code> mergeRange() </code> : to have one cell in a table
259 * which this test splits. </li>
260 * </ul>
262 public void _splitRange(){
263 requiredMethod("mergeRange()") ;
265 boolean bSplit = true ;
266 log.println( "test for splitRange" ) ;
267 short i = 1 ;
269 bSplit &= oObj.splitRange(i, true) ;
271 oObj.gotoEnd(false);
272 String horName = oObj.getRangeName() ;
273 log.println("The end cell after horiz. split : " + horName) ;
274 bSplit &= !"A1".equals(horName) ;
276 oObj.gotoStart(false);
277 oObj.gotoEnd(true);
278 bSplit &= oObj.splitRange(i, false) ;
280 oObj.gotoEnd(false);
281 String vertName = oObj.getRangeName() ;
282 log.println("The end cell after vert. split : " + vertName) ;
283 bSplit &= !horName.equals(vertName) ;
285 tRes.tested("splitRange()", bSplit ) ;
289 * Forces object environment recreation.
291 public void after() {
292 disposeEnvironment() ;
295 } // finish class _XTextTableCursor