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 .
21 import lib
.MultiMethodTest
;
23 import lib
.StatusException
;
25 import com
.sun
.star
.text
.XTextTable
;
28 * Testing <code>com.sun.star.text.XTextTable</code>
31 * <li><code> initialize()</code></li>
32 * <li><code> getRows()</code></li>
33 * <li><code> getColumns()</code></li>
34 * <li><code> getCellByName()</code></li>
35 * <li><code> getCellNames()</code></li>
36 * <li><code> createCursorByCellName()</code></li>
38 * This test needs the following object relations :
40 * <li> <code>'NROW'</code> : the number of rows in table
42 * <li> <code>'NCOL'</code> : the number of columns in table
45 * Test is <b> NOT </b> multithread compliant. <p>
46 * @see com.sun.star.text.XTextTable
48 public class _XTextTable
extends MultiMethodTest
{
50 public XTextTable oObj
= null; // oObj filled by MultiMethodTest
54 String cellNamesList
[] = null ;
57 protected void before() {
58 Integer num_row
= (Integer
)tEnv
.getObjRelation("NROW");
59 if (num_row
== null) {
60 throw new StatusException
61 (Status
.failed("Couldn't get relation 'NROW'"));
63 Integer num_col
= (Integer
)tEnv
.getObjRelation("NCOL");
64 if (num_col
== null) {
65 throw new StatusException
66 (Status
.failed("Couldn't get relation 'NCOL'"));
68 nRow
= num_row
.intValue();
69 nCol
= num_col
.intValue();
73 * The method is not called directly here, because it must
74 * be called before being inserted to the document. <p>
76 * Always has <b> OK </b> status. <p>
78 public void _initialize() {
81 log
.println( "test for initialize()" );
82 tRes
.tested( "initialize()", true);
86 * Test calls the method passing as cell name the first
87 * element from names returned by <code>getCellNames</code>
90 * Has <b> OK </b> status if the method returns not
91 * <code>null</code> value.
93 * The following method tests are to be completed successfully before :
95 * <li> <code> getCellNames() </code> : its result used by test. </li>
98 public void _createCursorByCellName(){
99 requiredMethod("getCellNames()") ;
101 // createCursorByCellName()
102 log
.println( "test for createCursorByCellName()" );
103 tRes
.tested( "createCursorByCellName()",
104 oObj
.createCursorByCellName( cellNamesList
[0] ) != null );
108 * Test calls the method passing as cell name the first
109 * element from names returned by <code>getCellNames</code>
112 * Has <b> OK </b> status if the method returns not
113 * <code>null</code> value.
115 * The following method tests are to be completed successfully before :
117 * <li> <code> getCellNames() </code> : its result used by test. </li>
120 public void _getCellByName(){
121 requiredMethod("getCellNames()") ;
124 log
.println( "test for getCellByName()" );
125 tRes
.tested( "getCellByName()",
126 oObj
.getCellByName( cellNamesList
[0] ) != null );
130 * Obtains cell names of the table. <p>
132 * Has <b>OK</b> status if number of elements in the returned
133 * array is equal to [row number] * [column number]
134 * and if the first name is 'A1'.
136 public void _getCellNames(){
138 log
.println( "test for getCellNames()" );
139 cellNamesList
= oObj
.getCellNames();
141 boolean result
= cellNamesList
.length
== ( nRow
* nCol
) ;
142 result
&= cellNamesList
[0].equals( "A1" ) ;
144 tRes
.tested( "getCellNames()", result
) ;
148 * Obtains columns of the table. <p>
150 * Has <b>OK</b> status if the number of element of returned
151 * collection is equal to real number of columns in the table.
153 public void _getColumns(){
155 log
.println( "test for getColumns()" );
156 tRes
.tested( "getColumns()", nCol
== oObj
.getColumns().getCount() );
160 * Obtains rows of the table. <p>
162 * Has <b>OK</b> status if the number of element of returned
163 * collection is equal to real number of rows in the table.
165 public void _getRows(){
167 log
.println( "test for getRows()" );
168 tRes
.tested( "getRows()", nRow
== oObj
.getRows().getCount() );