Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / text / _XTextTable.java
blob65f1d6f2c8016e51fdc922d1c926894435a4d575
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: _XTextTable.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;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.text.XTextTable;
39 /**
40 * Testing <code>com.sun.star.text.XTextTable</code>
41 * interface methods :
42 * <ul>
43 * <li><code> initialize()</code></li>
44 * <li><code> getRows()</code></li>
45 * <li><code> getColumns()</code></li>
46 * <li><code> getCellByName()</code></li>
47 * <li><code> getCellNames()</code></li>
48 * <li><code> createCursorByCellName()</code></li>
49 * </ul> <p>
50 * This test needs the following object relations :
51 * <ul>
52 * <li> <code>'NROW'</code> : the number of rows in table
53 * </li>
54 * <li> <code>'NCOL'</code> : the number of columns in table
55 * </li>
57 * Test is <b> NOT </b> multithread compilant. <p>
58 * @see com.sun.star.text.XTextTable
60 public class _XTextTable extends MultiMethodTest {
62 public XTextTable oObj = null; // oObj filled by MultiMethodTest
63 int nRow;
64 int nCol;
66 String cellNamesList[] = null ;
68 protected void before() {
69 Integer num_row = (Integer)tEnv.getObjRelation("NROW");
70 if (num_row == null) {
71 throw new StatusException
72 (Status.failed("Couldn't get relation 'NROW'"));
74 Integer num_col = (Integer)tEnv.getObjRelation("NCOL");
75 if (num_col == null) {
76 throw new StatusException
77 (Status.failed("Couldn't get relation 'NCOL'"));
79 nRow = num_row.intValue();
80 nCol = num_col.intValue();
83 /**
84 * The method is not called directly here, because it must
85 * be called before being inserted to the document. <p>
87 * Always has <b> OK </b> status. <p>
89 public void _initialize() {
91 // initialize()
92 log.println( "test for initialize()" );
93 tRes.tested( "initialize()", true);
96 /**
97 * Test calls the method passing as cell name the first
98 * element from names returned by <code>getCellNames</code>
99 * method. <p>
101 * Has <b> OK </b> status if the method returns not
102 * <code>null</code> value.
104 * The following method tests are to be completed successfully before :
105 * <ul>
106 * <li> <code> getCellNames() </code> : its result used by test. </li>
107 * </ul>
109 public void _createCursorByCellName(){
110 requiredMethod("getCellNames()") ;
112 // createCursorByCellName()
113 log.println( "test for createCursorByCellName()" );
114 tRes.tested( "createCursorByCellName()",
115 oObj.createCursorByCellName( cellNamesList[0] ) != null );
119 * Test calls the method passing as cell name the first
120 * element from names returned by <code>getCellNames</code>
121 * method. <p>
123 * Has <b> OK </b> status if the method returns not
124 * <code>null</code> value.
126 * The following method tests are to be completed successfully before :
127 * <ul>
128 * <li> <code> getCellNames() </code> : its result used by test. </li>
129 * </ul>
131 public void _getCellByName(){
132 requiredMethod("getCellNames()") ;
134 // getCellByName()
135 log.println( "test for getCellByName()" );
136 tRes.tested( "getCellByName()",
137 oObj.getCellByName( cellNamesList[0] ) != null );
141 * Obtains cell names of the table. <p>
143 * Has <b>OK</b> status if number of elements in the returned
144 * array is equal to [row number] * [column number]
145 * and if the first name is 'A1'.
147 public void _getCellNames(){
148 // getCellNames()
149 log.println( "test for getCellNames()" );
150 cellNamesList = oObj.getCellNames();
152 boolean result = cellNamesList.length == ( nRow * nCol ) ;
153 result &= cellNamesList[0].equals( "A1" ) ;
155 tRes.tested( "getCellNames()", result ) ;
159 * Obtains columns of the table. <p>
161 * Has <b>OK</b> status if the number of element of returned
162 * collection is equal to real number of columns in the table.
164 public void _getColumns(){
165 // getColumns()
166 log.println( "test for getColumns()" );
167 tRes.tested( "getColumns()", nCol == oObj.getColumns().getCount() );
171 * Obtains rows of the table. <p>
173 * Has <b>OK</b> status if the number of element of returned
174 * collection is equal to real number of rows in the table.
176 public void _getRows(){
177 // getRows()
178 log.println( "test for getRows()" );
179 tRes.tested( "getRows()", nRow == oObj.getRows().getCount() );