/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
package ifc.sheet;
import lib.MultiMethodTest;
import lib.Status;
import lib.StatusException;
import com.sun.star.sheet.XDataPilotTable;
import com.sun.star.table.CellAddress;
import com.sun.star.table.CellRangeAddress;
import com.sun.star.table.XCell;
/**
* Testing com.sun.star.sheet.XDataPilotTable
* interface methods :
*
getOutputRange()
refresh()
* This test needs the following object relations : *
'OUTPUTRANGE'
(of type CellAddress
):
* to check value returned by method getOutputRange()
'CELLFORCHANGE'
(of type XCell
):
* to check the method refresh(value of this cell will be changed)'CELLFORCHECK'
(of type XCell
):
* to check the method refresh (value of this cell must be changed after refresh
* call)
* @see com.sun.star.sheet.XDataPilotTable
* @see com.sun.star.table.CellAddress
*/
public class _XDataPilotTable extends MultiMethodTest {
public XDataPilotTable oObj = null;
XCell xCellForChange = null;
XCell xCellForCheck = null;
CellAddress OutputRange = null;
protected void before() {
xCellForChange = (XCell)tEnv.getObjRelation("CELLFORCHANGE");
xCellForCheck = (XCell)tEnv.getObjRelation("CELLFORCHECK");
OutputRange = (CellAddress)tEnv.getObjRelation("OUTPUTRANGE");
if (xCellForChange == null || OutputRange == null ||
xCellForCheck == null) {
throw new StatusException(Status.failed("Relation not found"));
}
}
/**
* Test calls the method and checks returned value using value obtained by
* object relation 'OUTPUTRANGE'
.
* Has OK status if values are equal.
*/ public void _getOutputRange(){ boolean bResult = true; CellRangeAddress objRange = oObj.getOutputRange(); bResult &= OutputRange.Sheet == objRange.Sheet; bResult &= OutputRange.Row == objRange.StartRow; bResult &= OutputRange.Column == objRange.StartColumn; tRes.tested("getOutputRange()", bResult); } /** * Test sets new value of the cell obtained by object relation * 'CELLFORCHANGE', and checks value of the cell obtained by object * relation 'CELLFORCHECK'.
* Has OK status if value of the cell obtained by object relation * 'CELLFORCHECK' is changed.
*/ public void _refresh(){ xCellForChange.setValue(5); double oldData = xCellForCheck.getValue(); oObj.refresh(); double newData = xCellForCheck.getValue(); log.println("Old data:" + oldData + "; new data:" + newData); tRes.tested("refresh()", oldData != newData); } }