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: _XTextTable.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 lib
.StatusException
;
37 import com
.sun
.star
.text
.XTextTable
;
40 * Testing <code>com.sun.star.text.XTextTable</code>
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>
50 * This test needs the following object relations :
52 * <li> <code>'NROW'</code> : the number of rows in table
54 * <li> <code>'NCOL'</code> : the number of columns in table
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
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();
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() {
92 log
.println( "test for initialize()" );
93 tRes
.tested( "initialize()", true);
97 * Test calls the method passing as cell name the first
98 * element from names returned by <code>getCellNames</code>
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 :
106 * <li> <code> getCellNames() </code> : its result used by test. </li>
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>
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 :
128 * <li> <code> getCellNames() </code> : its result used by test. </li>
131 public void _getCellByName(){
132 requiredMethod("getCellNames()") ;
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(){
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(){
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(){
178 log
.println( "test for getRows()" );
179 tRes
.tested( "getRows()", nRow
== oObj
.getRows().getCount() );