Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _XAreaLink.java
blobc5026eb692f05182a3408b221793ae8ca75c7a01
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.XAreaLink;
24 import com.sun.star.table.CellRangeAddress;
26 /**
27 * Testing <code>com.sun.star.sheet.XAreaLink</code>
28 * interface methods :
29 * <ul>
30 * <li><code> getSourceArea()</code></li>
31 * <li><code> setSourceArea()</code></li>
32 * <li><code> getDestArea()</code></li>
33 * <li><code> setDestArea()</code></li>
34 * </ul> <p>
35 * Test is <b> NOT </b> multithread compliant. <p>
36 * @see com.sun.star.sheet.XAreaLink
38 public class _XAreaLink extends MultiMethodTest {
40 public XAreaLink oObj = null;
41 CellRangeAddress oORAdd, oNRAdd, oCRAdd = null;
43 /**
44 * Just calls the method and checks the value returned.
45 * (More complicated testing done in <code>setDestArea</code>)<p>
46 * Has <b>OK</b> status if not null value returned.
48 public void _getDestArea(){
49 log.println("testing getDestArea()");
50 boolean bResult = false;
51 oORAdd = oObj.getDestArea();
52 if (oORAdd != null){ bResult = true; }
53 tRes.tested("getDestArea()", bResult) ;
56 /**
57 * Just calls the method and checks the value returned.
58 * (More complicated testing done in <code>setSourceArea</code>)<p>
59 * Has <b>OK</b> status if not null value returned.
61 public void _getSourceArea(){
62 log.println("testing getSourceArea()");
63 boolean bResult = false;
64 String src = null;
65 src = oObj.getSourceArea() ;
66 if (src != null){ bResult = true; }
67 tRes.tested("getSourceArea()", bResult) ;
70 /**
71 * Creates a new desination CellRange address and sets it for
72 * the link object. <p>
73 * After setting the DestArea, the link is refreshed and the area is
74 * adjusted to the size of the source data.
75 * Therefore EndCol and EndRow will change after setting. <p>
76 * Has <b>OK</b> status if Sheet, Starting Column and Row
77 * of the destination range is changed correctly.
79 public void _setDestArea(){
80 log.println("testing setDestArea()");
81 boolean bResult = false;
82 int newStartCol = 3, newStartRow = 4, newEndCol = 5, newEndRow = 8 ;
83 oORAdd = oObj.getDestArea();
84 log.print("Getting: ");
85 log.println(getCRA(oORAdd));
86 oNRAdd = new CellRangeAddress ((short) 2, newStartCol, newStartRow,
87 newEndCol, newEndRow) ;
88 oObj.setDestArea(oNRAdd) ;
89 log.print("Setting: ");
90 log.println(getCRA(oNRAdd));
91 oCRAdd = oObj.getDestArea();
92 log.print("Getting: ");
93 log.println(getCRA(oCRAdd));
94 // After setting the DestArea, the link is refreshed and the area is
95 // adjusted to the size of the source data.
96 // Therefore EndCol and EndRow will change after setting.
97 log.println("After setting the DestArea, the link is refreshed "+
98 "and the area is");
99 log.println("adjusted to the size of the source data.");
100 log.println("Therefore only 'Sheet', 'StartCol' and 'StartRow' "+
101 "are compared.");
102 if ((oCRAdd.StartColumn == oNRAdd.StartColumn) &&
103 (oCRAdd.Sheet == oNRAdd.Sheet) &&
104 (oCRAdd.StartRow == oNRAdd.StartRow)){
105 bResult = true;
106 oObj.setDestArea(oORAdd);
108 tRes.tested("setDestArea()", bResult) ;
112 * Sets a new source area for the link and then check
113 * it using <code>getSourceArea</code> method. <p>
114 * Has <b>OK</b> status if areas set and get are equal.
116 public void _setSourceArea(){
117 log.println("testing setSourceArea()");
118 boolean bResult = false;
119 String oSrc = oObj.getSourceArea() ;
120 String nSrc = "a1:b2";
121 oObj.setSourceArea(nSrc);
122 String cSrc = oObj.getSourceArea();
123 if( nSrc.equals(cSrc)){
124 bResult = true;
125 oObj.setSourceArea(oSrc);
127 tRes.tested("setSourceArea()", bResult) ;
131 * Prints cell range structure to LOG
133 public String getCRA ( CellRangeAddress oCRA ) {
134 String res = "( Sheet: ";
135 res += oCRA.Sheet;
136 res += ";StartColumn: ";
137 res += oCRA.StartColumn;
138 res += ";StartRow: ";
139 res += oCRA.StartRow;
140 res += ";EndColumn: ";
141 res += oCRA.EndColumn;
142 res += ";EndRow: ";
143 res += oCRA.EndRow;
144 res += " )";
145 return res;
148 } // EOC _XAreaLink