bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _XTextTableCursor.java
blob4bbea70463db00954c1147861ed43a0b48723b6f
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;
23 import com.sun.star.table.XCell;
24 import com.sun.star.text.XTextTableCursor;
27 /**
28 * Testing <code>com.sun.star.text.XTextTableCursor</code>
29 * interface methods :
30 * <ul>
31 * <li><code> getRangeName()</code></li>
32 * <li><code> gotoCellByName()</code></li>
33 * <li><code> goLeft()</code></li>
34 * <li><code> goRight()</code></li>
35 * <li><code> goUp()</code></li>
36 * <li><code> goDown()</code></li>
37 * <li><code> gotoStart()</code></li>
38 * <li><code> gotoEnd()</code></li>
39 * <li><code> mergeRange()</code></li>
40 * <li><code> splitRange()</code></li>
41 * </ul> <p>
43 * <b>Prerequisites : </b> the table must have a size
44 * 2x2 and current cursor position must be in the upper
45 * left cell. <p>
47 * Test is <b> NOT </b> multithread compliant. <p>
49 * After test completion object environment has to be recreated
50 * because after merging and splitting cells their names
51 * differ from initial.
53 * @see com.sun.star.text.XTextTableCursor
55 public class _XTextTableCursor extends MultiMethodTest {
57 public XTextTableCursor oObj = null; // oObj filled by MultiMethodTest
59 XCell oCell = null;
61 /**
62 * Moves the cursor to upper-left cell and checks
63 * its range name. <p>
65 * Has <b>OK</b> status if the name returned is 'A1'.
67 public void _getRangeName(){
68 log.println( "test for getRangeName()" );
69 oObj.gotoStart(false);
70 String oCellName = oObj.getRangeName();
71 log.println( "CellName = " + oCellName );
73 tRes.tested("getRangeName()", oCellName.equals("A1") );
76 /**
77 * Calls the method which moves the cursor down by 1 cell,
78 * after that returns cursor to the old position. <p>
80 * Has <b>OK</b> status if the method returns
81 * <code>true</code>.
83 public void _goDown(){
84 boolean bDown = false;
85 log.println( "test for goDown()" );
86 short i = 1;
88 bDown = oObj.goDown(i,false);
90 tRes.tested("goDown()", bDown );
91 oObj.goUp(i,false);
94 /**
95 * Calls the method which moves the cursor to the right by 1 cell,
96 * after that returns cursor to the old position. <p>
98 * Has <b>OK</b> status if the method returns
99 * <code>true</code>.
101 public void _goRight(){
102 boolean bRight = false;
103 log.println( "test for goRight()" );
104 short i = 1;
106 bRight = oObj.goRight(i,false);
108 tRes.tested("goRight()", bRight );
109 oObj.goLeft(i,false);
113 * Calls the method which moves the cursor to the left by 1 cell,
114 * after that returns cursor to the old position. <p>
116 * Has <b>OK</b> status if the method returns
117 * <code>true</code>.
119 public void _goLeft(){
120 boolean bLeft = false;
121 log.println( "test for goLeft()" );
122 short i = 1;
124 oObj.goRight(i,false);
125 bLeft = oObj.goLeft(i,false);
127 tRes.tested("goLeft()", bLeft );
131 * Calls the method which moves the cursor up by 1 cell,
132 * after that returns cursor to the old position. <p>
134 * Has <b>OK</b> status if the method returns
135 * <code>true</code>.
137 public void _goUp(){
138 boolean bUp = false;
139 log.println( "test for goUp()" );
140 short i = 1;
142 oObj.gotoEnd(true);
144 bUp = oObj.goUp(i,false);
145 tRes.tested("goUp()", bUp );
149 * Moves the cursor to the cell with name 'B1', then
150 * checks the current range name. <p>
151 * Has <b>OK</b> status if the returned range name is
152 * 'B1'.
154 public void _gotoCellByName(){
155 log.println( "test for gotoCellByName()" );
157 oObj.gotoCellByName("B1",false);
158 String oCellName = oObj.getRangeName();
160 tRes.tested("gotoCellByName()", oCellName.equals("B1") );
164 * Moves cursor to the start (upper-left cell). Then
165 * checks the current range name. <p>
167 * Has <b>OK</b> status if current range name is 'A1'.
169 public void _gotoStart(){
170 log.println( "test for gotoStart()" );
172 oObj.gotoStart(false);
173 String oCellName = oObj.getRangeName();
175 tRes.tested("gotoStart()", oCellName.equals("A1") );
179 * Moves cursor to the end (lower-right cell). Then
180 * checks the current range name. <p>
182 * Has <b>OK</b> status if current range name is 'B2'
183 * (the table is assumed to be of size 2x2).
185 public void _gotoEnd(){
186 log.println( "test for gotoEnd()" );
188 oObj.gotoEnd(false);
189 String oCellName = oObj.getRangeName();
191 tRes.tested("gotoEnd()", oCellName.equals("B2") );
195 * Selects all cells in the table and merges them.
196 * Finally move the cursor to the end and checks
197 * current range name.<p>
199 * Has <b>OK</b> status if the end cell has a name
200 * 'A1'.
202 * The following method tests are to be executed before :
203 * <ul>
204 * <li> <code> getRangeName(), gotoStart(), gotoEnd()
205 * goLeft(), goRight(), goUp(), goDown(), gotoCellByName()</code>
206 * : these methods must be completed before all cells of the
207 * table are merged into one cell </li>
208 * </ul>
210 public void _mergeRange(){
211 executeMethod("getRangeName()") ;
212 executeMethod("gotoStart()") ;
213 executeMethod("gotoEnd()") ;
214 executeMethod("goLeft()") ;
215 executeMethod("goRight()") ;
216 executeMethod("goUp()") ;
217 executeMethod("goDown()") ;
218 executeMethod("gotoCellByName()") ;
220 boolean bMerge = false;
221 log.println( "test for mergeRange()" );
223 oObj.gotoStart(false);
224 oObj.gotoEnd(true);
225 bMerge = oObj.mergeRange();
227 oObj.gotoEnd(false);
229 String curName = oObj.getRangeName() ;
230 bMerge &= "A1".equals(curName) ;
232 tRes.tested("mergeRange()", bMerge );
236 * First splits the cell horyzontally. Then the end cell
237 * name is checked. Second split all cells vertically and
238 * again the end cell name is checked<p>
240 * Has <b> OK </b> status if in the first case the end cell name
241 * is not 'A1', and in the second case the end cell name is not
242 * equal to the name gotten in the first case. <p>
244 * The following method tests are to be completed successfully before :
245 * <ul>
246 * <li> <code> mergeRange() </code> : to have one cell in a table
247 * which this test splits. </li>
248 * </ul>
250 public void _splitRange(){
251 requiredMethod("mergeRange()") ;
253 boolean bSplit = true ;
254 log.println( "test for splitRange" ) ;
255 short i = 1 ;
257 bSplit &= oObj.splitRange(i, true) ;
259 oObj.gotoEnd(false);
260 String horName = oObj.getRangeName() ;
261 log.println("The end cell after horiz. split : " + horName) ;
262 bSplit &= !"A1".equals(horName) ;
264 oObj.gotoStart(false);
265 oObj.gotoEnd(true);
266 bSplit &= oObj.splitRange(i, false) ;
268 oObj.gotoEnd(false);
269 String vertName = oObj.getRangeName() ;
270 log.println("The end cell after vert. split : " + vertName) ;
271 bSplit &= !horName.equals(vertName) ;
273 tRes.tested("splitRange()", bSplit ) ;
277 * Forces object environment recreation.
279 @Override
280 public void after() {
281 disposeEnvironment() ;
284 } // finish class _XTextTableCursor