1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 package ifc.sheet;
29 
30 import lib.MultiMethodTest;
31 import lib.Status;
32 import lib.StatusException;
33 
34 import com.sun.star.sheet.XDataPilotTable;
35 import com.sun.star.table.CellAddress;
36 import com.sun.star.table.CellRangeAddress;
37 import com.sun.star.table.XCell;
38 
39 /**
40 * Testing <code>com.sun.star.sheet.XDataPilotTable</code>
41 * interface methods :
42 * <ul>
43 *  <li><code> getOutputRange()</code></li>
44 *  <li><code> refresh()</code></li>
45 * </ul> <p>
46 * This test needs the following object relations :
47 * <ul>
48 *  <li> <code>'OUTPUTRANGE'</code> (of type <code>CellAddress</code>):
49 *   to check value returned by method <code>getOutputRange()</code> </li>
50 *  <li> <code>'CELLFORCHANGE'</code> (of type <code>XCell</code>):
51 *   to check the method refresh(value of this cell will be changed)</li>
52 *  <li> <code>'CELLFORCHECK'</code> (of type <code>XCell</code>):
53 * to check the method refresh (value of this cell must be changed after refresh
54 * call) </li><ul> <p>
55 * @see com.sun.star.sheet.XDataPilotTable
56 * @see com.sun.star.table.CellAddress
57 */
58 public class _XDataPilotTable extends MultiMethodTest {
59 
60     public XDataPilotTable oObj = null;
61     XCell xCellForChange = null;
62     XCell xCellForCheck = null;
63     CellAddress OutputRange = null;
64 
65     protected void before() {
66         xCellForChange = (XCell)tEnv.getObjRelation("CELLFORCHANGE");
67         xCellForCheck = (XCell)tEnv.getObjRelation("CELLFORCHECK");
68         OutputRange = (CellAddress)tEnv.getObjRelation("OUTPUTRANGE");
69         if (xCellForChange == null || OutputRange == null ||
70                 xCellForCheck == null) {
71             throw new StatusException(Status.failed("Relation not found"));
72         }
73     }
74     /**
75     * Test calls the method and checks returned value using value obtained by
76     * object relation <code>'OUTPUTRANGE'</code>. <p>
77     * Has <b> OK </b> status if values are equal. <p>
78     */
79     public void _getOutputRange(){
80         boolean bResult = true;
81         CellRangeAddress objRange = oObj.getOutputRange();
82         bResult &= OutputRange.Sheet == objRange.Sheet;
83         bResult &= OutputRange.Row == objRange.StartRow;
84         bResult &= OutputRange.Column == objRange.StartColumn;
85         tRes.tested("getOutputRange()", bResult);
86     }
87 
88     /**
89     * Test sets new value of the cell obtained by object relation
90     * 'CELLFORCHANGE', and checks value of the cell obtained by object
91     * relation 'CELLFORCHECK'.<p>
92     * Has <b>OK</b> status if value of the cell obtained by object relation
93     * 'CELLFORCHECK' is changed. <p>
94     */
95     public void _refresh(){
96         xCellForChange.setValue(5);
97         double oldData = xCellForCheck.getValue();
98         oObj.refresh();
99         double newData = xCellForCheck.getValue();
100         log.println("Old data:" + oldData + "; new data:" + newData);
101 
102         tRes.tested("refresh()", oldData != newData);
103     }
104 }
105 
106