Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / sheet / _XDataPilotTables.java
blob92daf98127d7b959cbd5983a0943816ec2a5800b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XDataPilotTables.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.sheet;
33 import lib.MultiMethodTest;
34 import lib.Status;
35 import lib.StatusException;
37 import com.sun.star.sheet.XDataPilotDescriptor;
38 import com.sun.star.sheet.XDataPilotTables;
39 import com.sun.star.sheet.XSpreadsheet;
40 import com.sun.star.table.CellAddress;
42 /**
43 * Testing <code>com.sun.star.sheet.XDataPilotTables</code>
44 * interface methods :
45 * <ul>
46 * <li><code> createDataPilotDescriptor()</code></li>
47 * <li><code> insertNewByName()</code></li>
48 * <li><code> removeByName()</code></li>
49 * </ul> <p>
50 * This test needs the following object relations :
51 * <ul>
52 * <li> <code>'SHEET'</code> (of type <code>XSpreadsheet</code>):
53 * to have a spreadsheet document for document content checking</li>
54 * <ul> <p>
55 * @see com.sun.star.sheet.XDataPilotTables
57 public class _XDataPilotTables extends MultiMethodTest {
59 public XDataPilotTables oObj = null;
60 XDataPilotDescriptor DPDscr = null;
61 String name = "XDataPilotTables";
62 CellAddress CA = new CellAddress((short)0, 9, 8);
63 XSpreadsheet oSheet = null;
65 /**
66 * Retrieves object relations.
67 * @throws StatusException If one of relations not found.
69 protected void before() {
70 oSheet = (XSpreadsheet)tEnv.getObjRelation("SHEET");
71 if (oSheet == null) throw new StatusException(Status.failed
72 ("Relation 'SHEET' not found"));
75 /**
76 * Test calls the method, stores returned value and checks returned value.
77 * <p>Has <b> OK </b> status if returned value isn't null. <p>
79 public void _createDataPilotDescriptor(){
80 DPDscr = oObj.createDataPilotDescriptor();
81 tRes.tested("createDataPilotDescriptor()", DPDscr != null);
84 /**
85 * Test calls the method inserting new table with new name and then calls
86 * the method inserting table with existent name. <p>
87 * Has <b> OK </b> status if the cell content where table was inserted is
88 * equal to 'Filter' after first call and exception was thrown during
89 * second call. <p>
90 * The following method tests are to be completed successfully before :
91 * <ul>
92 * <li> <code> createDataPilotDescriptor() </code> : to have
93 * <code>XDataPilotDescriptor</code> created by this method</li>
94 * </ul>
96 public void _insertNewByName(){
97 requiredMethod("createDataPilotDescriptor()");
98 boolean bResult = true;
99 log.println("Inserting new Table \"" + name + "\"");
100 try {
101 oObj.insertNewByName(name, CA, DPDscr);
102 bResult &= oSheet.getCellByPosition
103 (CA.Column, CA.Row).getFormula().equals("Filter");
104 } catch (com.sun.star.uno.Exception e) {
105 log.println("Exception occured! " + e);
106 bResult = false;
109 log.println(bResult ? "OK" : "FAILED");
110 log.println("Trying to insert element with existent name");
112 try {
113 oObj.insertNewByName(name,new CellAddress((short)0, 7, 7), DPDscr);
114 log.println("No exception! - FAILED");
115 bResult = false;
116 } catch (com.sun.star.uno.RuntimeException e) {
117 log.println("Expected exception - OK " + e);
120 log.println("Inserting new table " + (bResult ? "OK" : "FAILED"));
121 tRes.tested("insertNewByName()", bResult);
125 * Test calls the method for existent table and for unexistent table. <p>
126 * Has <b> OK </b> status if the cell where table was removed from is empty
127 * after first call and exception was thrown during second call. <p>
128 * The following method tests are to be completed successfully before :
129 * <ul>
130 * <li> <code>insertNewByName()</code>: to have name of existent table</li>
131 * </ul>
133 public void _removeByName(){
134 requiredMethod("insertNewByName()");
135 boolean bResult = true;
136 log.println("Remove table with name " + name);
137 try {
138 oObj.removeByName(name);
139 bResult &= oSheet.getCellByPosition
140 (CA.Column, CA.Row).getFormula().equals("");
141 } catch (com.sun.star.uno.Exception e) {
142 log.println("Exception occured ! " + e);
143 bResult = false;
145 log.println(bResult ? "OK" : "FAILED");
146 log.println("Removing unexistent element");
147 try {
148 oObj.removeByName(name);
149 log.println("No exception! - FAILED");
150 bResult = false;
151 } catch (com.sun.star.uno.RuntimeException e) {
152 log.println("Expected exception - OK " + e);
155 log.println("Removing a table " + (bResult ? "OK" : "FAILED"));
156 tRes.tested("removeByName()", bResult);