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 .
21 import lib
.MultiMethodTest
;
23 import lib
.StatusException
;
25 import com
.sun
.star
.sheet
.XDataPilotTable
;
26 import com
.sun
.star
.table
.CellAddress
;
27 import com
.sun
.star
.table
.CellRangeAddress
;
28 import com
.sun
.star
.table
.XCell
;
31 * Testing <code>com.sun.star.sheet.XDataPilotTable</code>
34 * <li><code> getOutputRange()</code></li>
35 * <li><code> refresh()</code></li>
37 * This test needs the following object relations :
39 * <li> <code>'OUTPUTRANGE'</code> (of type <code>CellAddress</code>):
40 * to check value returned by method <code>getOutputRange()</code> </li>
41 * <li> <code>'CELLFORCHANGE'</code> (of type <code>XCell</code>):
42 * to check the method refresh(value of this cell will be changed)</li>
43 * <li> <code>'CELLFORCHECK'</code> (of type <code>XCell</code>):
44 * to check the method refresh (value of this cell must be changed after refresh
46 * @see com.sun.star.sheet.XDataPilotTable
47 * @see com.sun.star.table.CellAddress
49 public class _XDataPilotTable
extends MultiMethodTest
{
51 public XDataPilotTable oObj
= null;
52 XCell xCellForChange
= null;
53 XCell xCellForCheck
= null;
54 CellAddress OutputRange
= null;
57 protected void before() {
58 xCellForChange
= (XCell
)tEnv
.getObjRelation("CELLFORCHANGE");
59 xCellForCheck
= (XCell
)tEnv
.getObjRelation("CELLFORCHECK");
60 OutputRange
= (CellAddress
)tEnv
.getObjRelation("OUTPUTRANGE");
61 if (xCellForChange
== null || OutputRange
== null ||
62 xCellForCheck
== null) {
63 throw new StatusException(Status
.failed("Relation not found"));
67 * Test calls the method and checks returned value using value obtained by
68 * object relation <code>'OUTPUTRANGE'</code>. <p>
69 * Has <b> OK </b> status if values are equal. <p>
71 public void _getOutputRange(){
72 boolean bResult
= true;
73 CellRangeAddress objRange
= oObj
.getOutputRange();
74 bResult
&= OutputRange
.Sheet
== objRange
.Sheet
;
75 bResult
&= OutputRange
.Row
== objRange
.StartRow
;
76 bResult
&= OutputRange
.Column
== objRange
.StartColumn
;
77 tRes
.tested("getOutputRange()", bResult
);
81 * Test sets new value of the cell obtained by object relation
82 * 'CELLFORCHANGE', and checks value of the cell obtained by object
83 * relation 'CELLFORCHECK'.<p>
84 * Has <b>OK</b> status if value of the cell obtained by object relation
85 * 'CELLFORCHECK' is changed. <p>
87 public void _refresh(){
88 xCellForChange
.setValue(5);
89 double oldData
= xCellForCheck
.getValue();
91 double newData
= xCellForCheck
.getValue();
92 log
.println("Old data:" + oldData
+ "; new data:" + newData
);
94 tRes
.tested("refresh()", oldData
!= newData
);