Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XUsedAreaCursor.java
blob3ff16306a7a2910d4380a74a8563a72a7f2503e5
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.sheet;
21 import lib.MultiMethodTest;
23 import com.sun.star.sheet.XCellRangeAddressable;
24 import com.sun.star.sheet.XSheetCellCursor;
25 import com.sun.star.sheet.XUsedAreaCursor;
26 import com.sun.star.table.CellRangeAddress;
27 import com.sun.star.uno.UnoRuntime;
29 /**
30 * Testing <code>com.sun.star.sheet.XUsedAreaCursor</code>
31 * interface methods :
32 * <ul>
33 * <li><code> gotoStartOfUsedArea()</code></li>
34 * <li><code> gotoEndOfUsedArea()</code></li>
35 * </ul> <p>
36 * Component must also implement the following interfaces :
37 * <ul>
38 * <li> <code> com.sun.star.XCellRangeAddressable </code> : to check the current
39 * position of the cursor </li>
40 * <ul> <p>
41 * @see com.sun.star.sheet.XUsedAreaCursor
43 public class _XUsedAreaCursor extends MultiMethodTest {
45 public XUsedAreaCursor oObj = null;
46 public XSheetCellCursor oC = null;
47 CellRangeAddress sAddr = null;
49 /**
50 * Test points the cursor to the start of used area, expands cursor to the
51 * end of the used area, gets and checks current range address, then
52 * points the cursor to the end of the used area, gets and checks current
53 * range address again. <p>
54 * Has <b> OK </b> status if the range address expands at all used area
55 * in first case and if the range address just points to the cell at the end
56 * of the used area in second case. <p>
58 public void _gotoEndOfUsedArea() {
59 boolean result = true ;
61 XCellRangeAddressable oAddr = UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ;
63 // first with true argument
64 oObj.gotoStartOfUsedArea(false);
65 oObj.gotoEndOfUsedArea(true);
66 sAddr = oAddr.getRangeAddress();
68 result &= (sAddr.StartColumn == 1);
69 result &= (sAddr.StartRow == 1);
70 result &= (sAddr.EndColumn == 4);
71 result &= (sAddr.EndRow == 5);
73 oObj.gotoEndOfUsedArea(false);
74 sAddr = oAddr.getRangeAddress();
76 result &= (sAddr.StartColumn == 4);
77 result &= (sAddr.StartRow == 5);
78 result &= (sAddr.EndColumn == 4);
79 result &= (sAddr.EndRow == 5);
81 tRes.tested("gotoEndOfUsedArea()", result) ;
84 /**
85 * Test points the cursor to the end of used area, expands cursor to the
86 * start of the used area, gets and checks current range address, then
87 * points the cursor to the start of the used area, gets and checks current
88 * range address again. <p>
89 * Has <b> OK </b> status if the range address expands at all used area
90 * in first case and if the range address just points to the cell at the
91 * start of the used area in second case. <p>
93 public void _gotoStartOfUsedArea() {
94 XCellRangeAddressable oAddr = UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ;
96 boolean result = true ;
98 // with true parameter first
99 oObj.gotoEndOfUsedArea(false);
100 oObj.gotoStartOfUsedArea(true);
101 sAddr = oAddr.getRangeAddress();
103 result &= (sAddr.StartColumn == 1);
104 result &= (sAddr.StartRow == 1);
105 result &= (sAddr.EndColumn == 4);
106 result &= (sAddr.EndRow == 5);
108 // now testing with false parameter
109 oObj.gotoStartOfUsedArea(false);
110 sAddr = oAddr.getRangeAddress();
112 result &= (sAddr.StartColumn == 1);
113 result &= (sAddr.StartRow == 1);
114 result &= (sAddr.EndColumn == 1);
115 result &= (sAddr.EndRow == 1);
117 tRes.tested("gotoStartOfUsedArea()", result) ;
118 } // finished gotoStartOfUsedArea
121 * Forces object environment recreation.
123 @Override
124 protected void after() {
125 this.disposeEnvironment();
127 } // finished class _XUsedAreaCursor