1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.text; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import lib.MultiMethodTest; 27cdf0e10cSrcweir import lib.Status; 28cdf0e10cSrcweir import lib.StatusException; 29cdf0e10cSrcweir 30cdf0e10cSrcweir import com.sun.star.text.XTextTable; 31cdf0e10cSrcweir 32cdf0e10cSrcweir /** 33cdf0e10cSrcweir * Testing <code>com.sun.star.text.XTextTable</code> 34cdf0e10cSrcweir * interface methods : 35cdf0e10cSrcweir * <ul> 36cdf0e10cSrcweir * <li><code> initialize()</code></li> 37cdf0e10cSrcweir * <li><code> getRows()</code></li> 38cdf0e10cSrcweir * <li><code> getColumns()</code></li> 39cdf0e10cSrcweir * <li><code> getCellByName()</code></li> 40cdf0e10cSrcweir * <li><code> getCellNames()</code></li> 41cdf0e10cSrcweir * <li><code> createCursorByCellName()</code></li> 42cdf0e10cSrcweir * </ul> <p> 43cdf0e10cSrcweir * This test needs the following object relations : 44cdf0e10cSrcweir * <ul> 45cdf0e10cSrcweir * <li> <code>'NROW'</code> : the number of rows in table 46cdf0e10cSrcweir * </li> 47cdf0e10cSrcweir * <li> <code>'NCOL'</code> : the number of columns in table 48cdf0e10cSrcweir * </li> 49cdf0e10cSrcweir * 50cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p> 51cdf0e10cSrcweir * @see com.sun.star.text.XTextTable 52cdf0e10cSrcweir */ 53cdf0e10cSrcweir public class _XTextTable extends MultiMethodTest { 54cdf0e10cSrcweir 55cdf0e10cSrcweir public XTextTable oObj = null; // oObj filled by MultiMethodTest 56cdf0e10cSrcweir int nRow; 57cdf0e10cSrcweir int nCol; 58cdf0e10cSrcweir 59cdf0e10cSrcweir String cellNamesList[] = null ; 60cdf0e10cSrcweir before()61cdf0e10cSrcweir protected void before() { 62cdf0e10cSrcweir Integer num_row = (Integer)tEnv.getObjRelation("NROW"); 63cdf0e10cSrcweir if (num_row == null) { 64cdf0e10cSrcweir throw new StatusException 65cdf0e10cSrcweir (Status.failed("Couldn't get relation 'NROW'")); 66cdf0e10cSrcweir } 67cdf0e10cSrcweir Integer num_col = (Integer)tEnv.getObjRelation("NCOL"); 68cdf0e10cSrcweir if (num_col == null) { 69cdf0e10cSrcweir throw new StatusException 70cdf0e10cSrcweir (Status.failed("Couldn't get relation 'NCOL'")); 71cdf0e10cSrcweir } 72cdf0e10cSrcweir nRow = num_row.intValue(); 73cdf0e10cSrcweir nCol = num_col.intValue(); 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76cdf0e10cSrcweir /** 77cdf0e10cSrcweir * The method is not called directly here, because it must 78cdf0e10cSrcweir * be called before being inserted to the document. <p> 79cdf0e10cSrcweir * 80cdf0e10cSrcweir * Always has <b> OK </b> status. <p> 81cdf0e10cSrcweir */ _initialize()82cdf0e10cSrcweir public void _initialize() { 83cdf0e10cSrcweir 84cdf0e10cSrcweir // initialize() 85cdf0e10cSrcweir log.println( "test for initialize()" ); 86cdf0e10cSrcweir tRes.tested( "initialize()", true); 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir /** 90cdf0e10cSrcweir * Test calls the method passing as cell name the first 91cdf0e10cSrcweir * element from names returned by <code>getCellNames</code> 92cdf0e10cSrcweir * method. <p> 93cdf0e10cSrcweir * 94cdf0e10cSrcweir * Has <b> OK </b> status if the method returns not 95cdf0e10cSrcweir * <code>null</code> value. 96cdf0e10cSrcweir * 97cdf0e10cSrcweir * The following method tests are to be completed successfully before : 98cdf0e10cSrcweir * <ul> 99cdf0e10cSrcweir * <li> <code> getCellNames() </code> : its result used by test. </li> 100cdf0e10cSrcweir * </ul> 101cdf0e10cSrcweir */ _createCursorByCellName()102cdf0e10cSrcweir public void _createCursorByCellName(){ 103cdf0e10cSrcweir requiredMethod("getCellNames()") ; 104cdf0e10cSrcweir 105cdf0e10cSrcweir // createCursorByCellName() 106cdf0e10cSrcweir log.println( "test for createCursorByCellName()" ); 107cdf0e10cSrcweir tRes.tested( "createCursorByCellName()", 108cdf0e10cSrcweir oObj.createCursorByCellName( cellNamesList[0] ) != null ); 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir /** 112cdf0e10cSrcweir * Test calls the method passing as cell name the first 113cdf0e10cSrcweir * element from names returned by <code>getCellNames</code> 114cdf0e10cSrcweir * method. <p> 115cdf0e10cSrcweir * 116cdf0e10cSrcweir * Has <b> OK </b> status if the method returns not 117cdf0e10cSrcweir * <code>null</code> value. 118cdf0e10cSrcweir * 119cdf0e10cSrcweir * The following method tests are to be completed successfully before : 120cdf0e10cSrcweir * <ul> 121cdf0e10cSrcweir * <li> <code> getCellNames() </code> : its result used by test. </li> 122cdf0e10cSrcweir * </ul> 123cdf0e10cSrcweir */ _getCellByName()124cdf0e10cSrcweir public void _getCellByName(){ 125cdf0e10cSrcweir requiredMethod("getCellNames()") ; 126cdf0e10cSrcweir 127cdf0e10cSrcweir // getCellByName() 128cdf0e10cSrcweir log.println( "test for getCellByName()" ); 129cdf0e10cSrcweir tRes.tested( "getCellByName()", 130cdf0e10cSrcweir oObj.getCellByName( cellNamesList[0] ) != null ); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir /** 134cdf0e10cSrcweir * Obtains cell names of the table. <p> 135cdf0e10cSrcweir * 136cdf0e10cSrcweir * Has <b>OK</b> status if number of elements in the returned 137cdf0e10cSrcweir * array is equal to [row number] * [column number] 138cdf0e10cSrcweir * and if the first name is 'A1'. 139cdf0e10cSrcweir */ _getCellNames()140cdf0e10cSrcweir public void _getCellNames(){ 141cdf0e10cSrcweir // getCellNames() 142cdf0e10cSrcweir log.println( "test for getCellNames()" ); 143cdf0e10cSrcweir cellNamesList = oObj.getCellNames(); 144cdf0e10cSrcweir 145cdf0e10cSrcweir boolean result = cellNamesList.length == ( nRow * nCol ) ; 146cdf0e10cSrcweir result &= cellNamesList[0].equals( "A1" ) ; 147cdf0e10cSrcweir 148cdf0e10cSrcweir tRes.tested( "getCellNames()", result ) ; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir /** 152cdf0e10cSrcweir * Obtains columns of the table. <p> 153cdf0e10cSrcweir * 154cdf0e10cSrcweir * Has <b>OK</b> status if the number of element of returned 155cdf0e10cSrcweir * collection is equal to real number of columns in the table. 156cdf0e10cSrcweir */ _getColumns()157cdf0e10cSrcweir public void _getColumns(){ 158cdf0e10cSrcweir // getColumns() 159cdf0e10cSrcweir log.println( "test for getColumns()" ); 160cdf0e10cSrcweir tRes.tested( "getColumns()", nCol == oObj.getColumns().getCount() ); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir /** 164cdf0e10cSrcweir * Obtains rows of the table. <p> 165cdf0e10cSrcweir * 166cdf0e10cSrcweir * Has <b>OK</b> status if the number of element of returned 167cdf0e10cSrcweir * collection is equal to real number of rows in the table. 168cdf0e10cSrcweir */ _getRows()169cdf0e10cSrcweir public void _getRows(){ 170cdf0e10cSrcweir // getRows() 171cdf0e10cSrcweir log.println( "test for getRows()" ); 172cdf0e10cSrcweir tRes.tested( "getRows()", nRow == oObj.getRows().getCount() ); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir 178