Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / table / _XTableRows.java
blob71cd35ab5de98e593235575fd71b0fcb58e55d2a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc.table;
30 import com.sun.star.table.XCellRange;
31 import lib.MultiMethodTest;
33 import com.sun.star.table.XTableRows;
34 import lib.Status;
35 import lib.StatusException;
37 /**
38 * Testing <code>com.sun.star.table.XTableRows</code>
39 * interface methods :
40 * <ul>
41 * <li><code> insertByIndex()</code></li>
42 * <li><code> removeByIndex()</code></li>
43 * </ul>
45 public class _XTableRows extends MultiMethodTest {
47 public XTableRows oObj = null;
48 public XCellRange range = null;
50 public void before() {
51 range = (XCellRange) tEnv.getObjRelation("XTableRows.XCellRange");
52 if (range==null) {
53 throw new StatusException(Status.failed("ObjectRelation missing"));
55 try {
56 range.getCellByPosition(0,0).setValue(17);
57 range.getCellByPosition(0,1).setValue(15);
58 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
59 log.println("Couldn't set value for Cell A1");
63 /**
64 * First a row inserted to valid position, then to invalid. <p>
65 * Has <b> OK </b> status if in the first case number of rows increases
66 * by 1, and in the second an exception is thrown. <p>
68 public void _insertByIndex() {
70 boolean result = true;
72 requiredMethod("removeByIndex()");
74 int origCnt = oObj.getCount();
75 log.println("Inserting row before first row");
76 oObj.insertByIndex(0,1);
77 result &= checkCell(1,15);
78 if (checkCell(1,15)) log.println("... successful");
80 try {
81 oObj.insertByIndex(-1,1);
82 log.println("No Exception occurred while inserting row at -1");
83 result &= false;
84 } catch (Exception e) {
85 log.println("Inserting row at Index -1 ... OK");
86 result &= true;
89 tRes.tested( "insertByIndex()", result );
91 } // end insertByIndex()
93 /**
94 * First a row removed from valid position, then from invalid. <p>
96 * Has <b> OK </b> status if in the first case number of columns decreases
97 * by 1, and in the second an exception is thrown. <p>
99 public void _removeByIndex() {
101 boolean result = true;
103 oObj.removeByIndex(0,1);
104 log.println("Removing first row");
105 result &= checkCell(0,15);
106 if (checkCell(0,15)) log.println("... successful");
108 try {
109 oObj.removeByIndex(-1,1);
110 log.println("No Exception occurred while Removing row at -1");
111 result &= false;
112 } catch (Exception e) {
113 log.println("Removing row at Index -1 ... OK");
114 result &= true;
117 tRes.tested( "removeByIndex()", result );
118 } // end removeByIndex()
120 public boolean checkCell(int row,double expected) {
121 double getting=0;
122 try {
123 getting = range.getCellByPosition(0,row).getValue();
124 } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
125 log.println("Couldn't set value for Cell A1");
128 boolean res = (getting==expected);
129 if (!res) {
130 log.println("Expected for row "+row+" was "+expected);
131 log.println("Getting for row "+row+" - "+getting);
132 log.println("=> FAILED");
134 return res;
137 } //finish class _XTableRows