1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.sheet;
25 
26 import lib.MultiMethodTest;
27 import lib.Status;
28 import lib.StatusException;
29 
30 import com.sun.star.sheet.XDataPilotTable;
31 import com.sun.star.table.CellAddress;
32 import com.sun.star.table.CellRangeAddress;
33 import com.sun.star.table.XCell;
34 
35 /**
36 * Testing <code>com.sun.star.sheet.XDataPilotTable</code>
37 * interface methods :
38 * <ul>
39 *  <li><code> getOutputRange()</code></li>
40 *  <li><code> refresh()</code></li>
41 * </ul> <p>
42 * This test needs the following object relations :
43 * <ul>
44 *  <li> <code>'OUTPUTRANGE'</code> (of type <code>CellAddress</code>):
45 *   to check value returned by method <code>getOutputRange()</code> </li>
46 *  <li> <code>'CELLFORCHANGE'</code> (of type <code>XCell</code>):
47 *   to check the method refresh(value of this cell will be changed)</li>
48 *  <li> <code>'CELLFORCHECK'</code> (of type <code>XCell</code>):
49 * to check the method refresh (value of this cell must be changed after refresh
50 * call) </li><ul> <p>
51 * @see com.sun.star.sheet.XDataPilotTable
52 * @see com.sun.star.table.CellAddress
53 */
54 public class _XDataPilotTable extends MultiMethodTest {
55 
56     public XDataPilotTable oObj = null;
57     XCell xCellForChange = null;
58     XCell xCellForCheck = null;
59     CellAddress OutputRange = null;
60 
before()61     protected void before() {
62         xCellForChange = (XCell)tEnv.getObjRelation("CELLFORCHANGE");
63         xCellForCheck = (XCell)tEnv.getObjRelation("CELLFORCHECK");
64         OutputRange = (CellAddress)tEnv.getObjRelation("OUTPUTRANGE");
65         if (xCellForChange == null || OutputRange == null ||
66                 xCellForCheck == null) {
67             throw new StatusException(Status.failed("Relation not found"));
68         }
69     }
70     /**
71     * Test calls the method and checks returned value using value obtained by
72     * object relation <code>'OUTPUTRANGE'</code>. <p>
73     * Has <b> OK </b> status if values are equal. <p>
74     */
_getOutputRange()75     public void _getOutputRange(){
76         boolean bResult = true;
77         CellRangeAddress objRange = oObj.getOutputRange();
78         bResult &= OutputRange.Sheet == objRange.Sheet;
79         bResult &= OutputRange.Row == objRange.StartRow;
80         bResult &= OutputRange.Column == objRange.StartColumn;
81         tRes.tested("getOutputRange()", bResult);
82     }
83 
84     /**
85     * Test sets new value of the cell obtained by object relation
86     * 'CELLFORCHANGE', and checks value of the cell obtained by object
87     * relation 'CELLFORCHECK'.<p>
88     * Has <b>OK</b> status if value of the cell obtained by object relation
89     * 'CELLFORCHECK' is changed. <p>
90     */
_refresh()91     public void _refresh(){
92         xCellForChange.setValue(5);
93         double oldData = xCellForCheck.getValue();
94         oObj.refresh();
95         double newData = xCellForCheck.getValue();
96         log.println("Old data:" + oldData + "; new data:" + newData);
97 
98         tRes.tested("refresh()", oldData != newData);
99     }
100 }
101 
102