bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / text / _XTextTable.java
blob9201720ffb777a675bdd7bfb5f5b867f76e067fa
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;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.text.XTextTable;
27 /**
28 * Testing <code>com.sun.star.text.XTextTable</code>
29 * interface methods :
30 * <ul>
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>
37 * </ul> <p>
38 * This test needs the following object relations :
39 * <ul>
40 * <li> <code>'NROW'</code> : the number of rows in table
41 * </li>
42 * <li> <code>'NCOL'</code> : the number of columns in table
43 * </li>
45 * Test is <b> NOT </b> multithread compilant. <p>
46 * @see com.sun.star.text.XTextTable
48 public class _XTextTable extends MultiMethodTest {
50 public XTextTable oObj = null; // oObj filled by MultiMethodTest
51 int nRow;
52 int nCol;
54 String cellNamesList[] = null ;
56 protected void before() {
57 Integer num_row = (Integer)tEnv.getObjRelation("NROW");
58 if (num_row == null) {
59 throw new StatusException
60 (Status.failed("Couldn't get relation 'NROW'"));
62 Integer num_col = (Integer)tEnv.getObjRelation("NCOL");
63 if (num_col == null) {
64 throw new StatusException
65 (Status.failed("Couldn't get relation 'NCOL'"));
67 nRow = num_row.intValue();
68 nCol = num_col.intValue();
71 /**
72 * The method is not called directly here, because it must
73 * be called before being inserted to the document. <p>
75 * Always has <b> OK </b> status. <p>
77 public void _initialize() {
79 // initialize()
80 log.println( "test for initialize()" );
81 tRes.tested( "initialize()", true);
84 /**
85 * Test calls the method passing as cell name the first
86 * element from names returned by <code>getCellNames</code>
87 * method. <p>
89 * Has <b> OK </b> status if the method returns not
90 * <code>null</code> value.
92 * The following method tests are to be completed successfully before :
93 * <ul>
94 * <li> <code> getCellNames() </code> : its result used by test. </li>
95 * </ul>
97 public void _createCursorByCellName(){
98 requiredMethod("getCellNames()") ;
100 // createCursorByCellName()
101 log.println( "test for createCursorByCellName()" );
102 tRes.tested( "createCursorByCellName()",
103 oObj.createCursorByCellName( cellNamesList[0] ) != null );
107 * Test calls the method passing as cell name the first
108 * element from names returned by <code>getCellNames</code>
109 * method. <p>
111 * Has <b> OK </b> status if the method returns not
112 * <code>null</code> value.
114 * The following method tests are to be completed successfully before :
115 * <ul>
116 * <li> <code> getCellNames() </code> : its result used by test. </li>
117 * </ul>
119 public void _getCellByName(){
120 requiredMethod("getCellNames()") ;
122 // getCellByName()
123 log.println( "test for getCellByName()" );
124 tRes.tested( "getCellByName()",
125 oObj.getCellByName( cellNamesList[0] ) != null );
129 * Obtains cell names of the table. <p>
131 * Has <b>OK</b> status if number of elements in the returned
132 * array is equal to [row number] * [column number]
133 * and if the first name is 'A1'.
135 public void _getCellNames(){
136 // getCellNames()
137 log.println( "test for getCellNames()" );
138 cellNamesList = oObj.getCellNames();
140 boolean result = cellNamesList.length == ( nRow * nCol ) ;
141 result &= cellNamesList[0].equals( "A1" ) ;
143 tRes.tested( "getCellNames()", result ) ;
147 * Obtains columns of the table. <p>
149 * Has <b>OK</b> status if the number of element of returned
150 * collection is equal to real number of columns in the table.
152 public void _getColumns(){
153 // getColumns()
154 log.println( "test for getColumns()" );
155 tRes.tested( "getColumns()", nCol == oObj.getColumns().getCount() );
159 * Obtains rows 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 rows in the table.
164 public void _getRows(){
165 // getRows()
166 log.println( "test for getRows()" );
167 tRes.tested( "getRows()", nRow == oObj.getRows().getCount() );