bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XDataPilotTables.java
blobfa0ea9ad65848d7a099bce078ce125163e29aef9
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.sheet;
21 import lib.MultiMethodTest;
22 import lib.Status;
23 import lib.StatusException;
25 import com.sun.star.sheet.XDataPilotDescriptor;
26 import com.sun.star.sheet.XDataPilotTables;
27 import com.sun.star.sheet.XSpreadsheet;
28 import com.sun.star.table.CellAddress;
30 /**
31 * Testing <code>com.sun.star.sheet.XDataPilotTables</code>
32 * interface methods :
33 * <ul>
34 * <li><code> createDataPilotDescriptor()</code></li>
35 * <li><code> insertNewByName()</code></li>
36 * <li><code> removeByName()</code></li>
37 * </ul> <p>
38 * This test needs the following object relations :
39 * <ul>
40 * <li> <code>'SHEET'</code> (of type <code>XSpreadsheet</code>):
41 * to have a spreadsheet document for document content checking</li>
42 * <ul> <p>
43 * @see com.sun.star.sheet.XDataPilotTables
45 public class _XDataPilotTables extends MultiMethodTest {
47 public XDataPilotTables oObj = null;
48 XDataPilotDescriptor DPDscr = null;
49 String name = "XDataPilotTables";
50 CellAddress CA = new CellAddress((short)0, 9, 8);
51 XSpreadsheet oSheet = null;
53 /**
54 * Retrieves object relations.
55 * @throws StatusException If one of relations not found.
57 protected void before() {
58 oSheet = (XSpreadsheet)tEnv.getObjRelation("SHEET");
59 if (oSheet == null) throw new StatusException(Status.failed
60 ("Relation 'SHEET' not found"));
63 /**
64 * Test calls the method, stores returned value and checks returned value.
65 * <p>Has <b> OK </b> status if returned value isn't null. <p>
67 public void _createDataPilotDescriptor(){
68 DPDscr = oObj.createDataPilotDescriptor();
69 tRes.tested("createDataPilotDescriptor()", DPDscr != null);
72 /**
73 * Test calls the method inserting new table with new name and then calls
74 * the method inserting table with existent name. <p>
75 * Has <b> OK </b> status if the cell content where table was inserted is
76 * equal to 'Filter' after first call and exception was thrown during
77 * second call. <p>
78 * The following method tests are to be completed successfully before :
79 * <ul>
80 * <li> <code> createDataPilotDescriptor() </code> : to have
81 * <code>XDataPilotDescriptor</code> created by this method</li>
82 * </ul>
84 public void _insertNewByName(){
85 requiredMethod("createDataPilotDescriptor()");
86 boolean bResult = true;
87 log.println("Inserting new Table \"" + name + "\"");
88 try {
89 oObj.insertNewByName(name, CA, DPDscr);
90 bResult &= oSheet.getCellByPosition
91 (CA.Column, CA.Row).getFormula().equals("Filter");
92 } catch (com.sun.star.uno.Exception e) {
93 log.println("Exception occurred! " + e);
94 bResult = false;
97 log.println(bResult ? "OK" : "FAILED");
98 log.println("Trying to insert element with existent name");
100 try {
101 oObj.insertNewByName(name,new CellAddress((short)0, 7, 7), DPDscr);
102 log.println("No exception! - FAILED");
103 bResult = false;
104 } catch (com.sun.star.uno.RuntimeException e) {
105 log.println("Expected exception - OK " + e);
108 log.println("Inserting new table " + (bResult ? "OK" : "FAILED"));
109 tRes.tested("insertNewByName()", bResult);
113 * Test calls the method for existent table and for unexistent table. <p>
114 * Has <b> OK </b> status if the cell where table was removed from is empty
115 * after first call and exception was thrown during second call. <p>
116 * The following method tests are to be completed successfully before :
117 * <ul>
118 * <li> <code>insertNewByName()</code>: to have name of existent table</li>
119 * </ul>
121 public void _removeByName(){
122 requiredMethod("insertNewByName()");
123 boolean bResult = true;
124 log.println("Remove table with name " + name);
125 try {
126 oObj.removeByName(name);
127 bResult &= oSheet.getCellByPosition
128 (CA.Column, CA.Row).getFormula().equals("");
129 } catch (com.sun.star.uno.Exception e) {
130 log.println("Exception occurred ! " + e);
131 bResult = false;
133 log.println(bResult ? "OK" : "FAILED");
134 log.println("Removing unexistent element");
135 try {
136 oObj.removeByName(name);
137 log.println("No exception! - FAILED");
138 bResult = false;
139 } catch (com.sun.star.uno.RuntimeException e) {
140 log.println("Expected exception - OK " + e);
143 log.println("Removing a table " + (bResult ? "OK" : "FAILED"));
144 tRes.tested("removeByName()", bResult);