Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / table / _XCellCursor.java
bloba01c4667c5b172db18424ee8660aadcc73faa536
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.table;
21 import lib.MultiMethodTest;
23 import com.sun.star.sheet.XCellRangeAddressable;
24 import com.sun.star.sheet.XSheetCellCursor;
25 import com.sun.star.sheet.XSheetCellRange;
26 import com.sun.star.sheet.XSpreadsheet;
27 import com.sun.star.table.CellRangeAddress;
28 import com.sun.star.table.XCellCursor;
29 import com.sun.star.table.XCellRange;
30 import com.sun.star.uno.UnoRuntime;
32 /**
33 * Testing <code>com.sun.star.table.XCellCursor</code>
34 * interface methods :
35 * <ul>
36 * <li><code> gotoStart()</code></li>
37 * <li><code> gotoEnd()</code></li>
38 * <li><code> gotoNext()</code></li>
39 * <li><code> gotoPrevious()</code></li>
40 * <li><code> gotoOffset()</code></li>
41 * </ul> <p>
42 * This test needs the following object relations :
43 * <ul>
44 * <li> <code>'SHEET'</code> (of type <code>XSpreadsheet</code>):
45 * is used for creating a new cell range.</li>
46 * <ul> <p>
48 * The component tested <b>must implement</b>
49 * <code>XCellRangeAddressable</code> interface. <p>
51 * Test is <b> NOT </b> multithread compliant. <p>
52 * After test completion object environment has to be recreated.
53 * @see com.sun.star.table.XCellCursor
55 public class _XCellCursor extends MultiMethodTest {
57 public XCellCursor oObj = null;
59 /**
60 * <code>XCellRangeAddressable</code> interface is queried
61 * first for getting current position of cursor. The cursor
62 * is moved to next cell. Address of cursor obtained before
63 * and after moving. <p>
64 * Has <b> OK </b> status if cursor column is changed after
65 * movement. <p>
67 public void _gotoNext(){
68 boolean bResult = false;
69 int startCol;
70 int startCol2;
72 XCellRangeAddressable oRange = UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj);
73 CellRangeAddress oAddr = oRange.getRangeAddress();
74 startCol = oAddr.StartColumn;
75 oObj.gotoNext();
77 oAddr = oRange.getRangeAddress();
78 startCol2 = oAddr.StartColumn;
79 if (startCol != startCol2){
80 bResult = true;
82 tRes.tested( "gotoNext()", bResult );
85 /**
86 * <code>XCellRangeAddressable</code> interface is queried
87 * first for getting current position of cursor. The cursor
88 * is moved then. Address of cursor obtained before
89 * and after moving. <p>
90 * Has <b> OK </b> status if starting column and row of
91 * cursor is changed after movement. <p>
93 public void _gotoOffset(){
94 boolean bResult = false;
95 int startCol, startRow;
96 int startCol2, startRow2;
98 XCellRangeAddressable oRange = UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj);
99 CellRangeAddress oAddr = oRange.getRangeAddress();
100 startRow = oAddr.StartRow;
101 startCol = oAddr.StartColumn;
102 oObj.gotoOffset(4,4);
104 oAddr = oRange.getRangeAddress();
105 startRow2 = oAddr.StartRow;
106 startCol2 = oAddr.StartColumn;
107 if ((startCol != startCol2) || (startRow == startRow2)){
108 bResult = true;
110 tRes.tested( "gotoOffset()", bResult );
114 * <code>XCellRangeAddressable</code> interface is queried
115 * first for getting current position of cursor. The cursor
116 * is moved to previous cell. Address of cursor obtained before
117 * and after moving. <p>
118 * Has <b> OK </b> status if cursor column is changed after
119 * movement. <p>
121 public void _gotoPrevious(){
122 boolean bResult = false;
123 int startCol;
124 int startCol2;
126 XCellRangeAddressable oRange = UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj);
127 CellRangeAddress oAddr = oRange.getRangeAddress();
128 startCol = oAddr.StartColumn;
129 oObj.gotoPrevious();
131 oAddr = oRange.getRangeAddress();
132 startCol2 = oAddr.StartColumn;
133 if (startCol != startCol2){
134 bResult = true;
136 tRes.tested( "gotoPrevious()", bResult );
140 * <code>XCellRangeAddressable</code> interface is queried
141 * first for getting current position of cursor. The cursor
142 * is moved to the start of its range .
143 * Address of cursor obtained before and after moving. <p>
144 * Has <b> OK </b> status if cursor was collapsed to a single
145 * cell (i.e. start column is the same as end column) after
146 * movement. <p>
148 public void _gotoStart(){
149 boolean bResult = false;
150 int startCol, endCol, startRow, endRow = 0;
152 XCellRangeAddressable oRange = UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj);
153 oObj.gotoStart();
154 CellRangeAddress oAddr = oRange.getRangeAddress();
155 startRow = oAddr.StartRow;
156 startCol = oAddr.StartColumn;
157 endRow = oAddr.EndRow;
158 endCol = oAddr.EndColumn;
159 if ((startCol == endCol) && (endRow == startRow)){
160 bResult = true;
163 tRes.tested( "gotoStart()", bResult );
167 * A new cell range is created using spreadsheet passed by relation.
168 * The method is tested on that range. <code>gotoEnd</code> is
169 * called and range address is checked.<p>
170 * Has <b> OK </b> status if cursor was collapsed to a single
171 * cell (i.e. start column is the same as end column) after
172 * movement. <p>
174 public void _gotoEnd(){
175 //gotoEnd gets it's own cursor to see a change
176 XSpreadsheet oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET");
177 XCellRange testRange = oSheet.getCellRangeByName("$A$1:$g$7") ;
178 XSheetCellRange testSheetRange = UnoRuntime.queryInterface(XSheetCellRange.class,testRange);
179 XSheetCellCursor oCellCursor = oSheet.createCursorByRange
180 (testSheetRange);
181 XCellCursor oCursor = UnoRuntime.queryInterface(XCellCursor.class,oCellCursor);
183 boolean bResult = false;
184 int startCol, endCol, startRow, endRow = 0;
186 XCellRangeAddressable oRange = UnoRuntime.queryInterface(XCellRangeAddressable.class, oCursor);
187 oCursor.gotoEnd();
188 CellRangeAddress oAddr = oRange.getRangeAddress();
189 startRow = oAddr.StartRow;
190 startCol = oAddr.StartColumn;
191 endRow = oAddr.EndRow;
192 endCol = oAddr.EndColumn;
193 if ((startCol == endCol) && (endRow == startRow)){
194 bResult = true;
197 tRes.tested( "gotoEnd()", bResult );
201 * Forces object environment recreation.
203 @Override
204 protected void after() {
205 disposeEnvironment();
209 } //EOC _XCellCursor