Debian Codegraph @

qadevOOo/tests/java/ifc/awt/tree/_XTreeNode.java

raw
1 /*
2 * This file is part of the LibreOffice project.
3 *
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/.
7 *
8 * This file incorporates work covered by the following license notice:
9 *
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 .
17 */
18
19 package ifc.awt.tree;
20
21 import com.sun.star.awt.tree.XTreeNode;
22 import com.sun.star.uno.AnyConverter;
23 import lib.MultiMethodTest;
24 import lib.Status;
25 import lib.StatusException;
26
27 /**
28 * Testing <code>com.sun.star.awt.tree.XTreeDataModel</code>
29 * interface methods :
30 * <ul>
31 * <li><code> getChildAt()</code></li>
32 * <li><code> getChildCount()</code></li>
33 * <li><code> getParent()</code></li>
34 * <li><code> getIndex()</code></li>
35 * <li><code> hasChildrenOnDemand()</code></li>
36 * <li><code> getDisplayValue()</code></li>
37 * <li><code> getNodeGraphicURL()</code></li>
38 * <li><code> getExpandedGraphicURL()</code></li>
39 * <li><code> getCollapsedGraphicURL()</code></li> * </ul> <p>
40 * Test is <b> NOT </b> multithread compliant. <p>
41 *
42 * @see com.sun.star.awt.tree.XTreeDataModel
43 */
44 public class _XTreeNode extends MultiMethodTest {
45
46 public XTreeNode oObj = null;
47
48 private int mCount = 0;
49
50 String msDisplayValue = null;
51 String msExpandedGraphicURL = null;
52 String msCollapsedGraphicURL = null;
53 String msNodeGraphicURL = null;
54
55
56 @Override
57 public void before(){
58 msDisplayValue = (String) tEnv.getObjRelation("XTreeNode_DisplayValue");
59 if (msDisplayValue == null){
60 throw new StatusException(Status.failed(
61 "Couldn't get relation 'XTreeNode_DisplayValue'"));
62 }
63
64 msExpandedGraphicURL = (String) tEnv.getObjRelation("XTreeNode_ExpandedGraphicURL");
65 if (msExpandedGraphicURL == null){
66 throw new StatusException(Status.failed(
67 "Couldn't get relation 'XTreeNode_ExpandedGraphicURL'"));
68 }
69
70 msCollapsedGraphicURL = (String) tEnv.getObjRelation("XTreeNode_CollapsedGraphicURL");
71 if (msCollapsedGraphicURL == null){
72 throw new StatusException(Status.failed(
73 "Couldn't get relation 'XTreeNode_CollapsedGraphicURL'"));
74 }
75
76 msNodeGraphicURL = (String) tEnv.getObjRelation("XTreeNode_NodeGraphicURL");
77 if(msNodeGraphicURL == null){
78 throw new StatusException(Status.failed(
79 "Couldn't get relation 'XTreeNode_NodeGraphicURL'"));
80 }
81
82 }
83
84 /**
85 * Gets the title and compares it to the value set in
86 * <code>setTitle</code> method test. <p>
87 * Has <b>OK</b> status is set/get values are equal.
88 * The following method tests are to be completed successfully before :
89 * <ul>
90 * <li> <code> setTitle </code> </li>
91 * </ul>
92 */
93 public void _getChildAt(){
94 this.requiredMethod("getChildCount()");
95 boolean bOK = true;
96
97 for (int i=0; i < mCount ; i++){
98 XTreeNode xNode = null;
99 try {
100 xNode = oObj.getChildAt(i);
101 } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
102 log.println("ERROR: getChildAt(" + i + "): " + ex.toString());
103 }
104 if (xNode == null){
105 log.println("ERROR: getChildAt(" + i + ") returns null => FAILED");
106 bOK = false;
107 }
108 }
109
110 tRes.tested("getChildAt()", bOK);
111 }
112
113
114 public void _getChildCount(){
115
116 boolean bOK = true;
117 mCount = oObj.getChildCount();
118 log.println("got count '" + mCount + "' of children");
119 if (mCount < 1 ) {
120 log.println("ERROR: got a count < 1. The test object must support more than zero children => FAILED");
121 bOK = false;
122 }
123 tRes.tested("getChildCount()", bOK);
124 }
125
126
127 public void _getParent(){
128 this.requiredMethod("getChildAt()");
129
130 boolean bOK = true;
131 XTreeNode xNode = null;
132 try {
133 log.println("try to getChildAt(0)");
134 xNode = oObj.getChildAt(0);
135 } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
136 log.println("ERROR: getChildAt(0): " + ex.toString());
137 }
138
139 log.println("try to get parent of children");
140 if (xNode == null) {
141 log.println("missing xNode");
142 tRes.tested("getParent()", false);
143 }
144 else {
145 XTreeNode xParrent = xNode.getParent();
146
147
148 bOK = oObj.equals(xParrent);
149 log.println("original object and parent should be the same: " + bOK);
150 tRes.tested("getParent()", bOK);
151 }
152 }
153
154
155 public void _getIndex(){
156 this.requiredMethod("getChildAt()");
157
158 boolean bOK = true;
159 XTreeNode xNode = null;
160 try {
161 log.println("try to getChildAt(0)");
162 xNode = oObj.getChildAt(0);
163 } catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
164 log.println("ERROR: getChildAt(0): " + ex.toString());
165 }
166
167 log.println("try to get index from child...");
168 int index = oObj.getIndex(xNode);
169
170 if (index != 0){
171 log.println("ERROR: getIndex() does not return '0' => FAILED");
172 bOK = false;
173 }
174
175 tRes.tested("getIndex()", bOK);
176 }
177
178
179 public void _hasChildrenOnDemand(){
180
181 boolean bOK = true;
182
183 bOK = oObj.hasChildrenOnDemand();
184 tRes.tested("hasChildrenOnDemand()", bOK);
185 }
186
187
188 public void _getDisplayValue(){
189
190 boolean bOK = true;
191 String DisplayValue = null;
192 Object dispVal = oObj.getDisplayValue();
193
194 try {
195 DisplayValue = AnyConverter.toString(dispVal);
196 } catch (com.sun.star.lang.IllegalArgumentException ex) {
197 log.println("ERROR: could not convert the returned object of 'getDisplayValue()' " +
198 "to String with AnyConverter: " + ex.toString());
199 }
200
201 if ( ! this.msDisplayValue.equals(DisplayValue)){
202 log.println("ERROR: getNodeGraphicURL() does not return expected value:\n" +
203 "\tExpected: " + this.msDisplayValue +"\n" +
204 "\tGot: " + DisplayValue);
205 bOK = false;
206 }
207
208 tRes.tested("getDisplayValue()", bOK);
209 }
210
211
212 public void _getNodeGraphicURL(){
213
214 boolean bOK = true;
215 String graphicURL = oObj.getNodeGraphicURL();
216
217 if ( ! this.msNodeGraphicURL.equals(graphicURL)){
218 log.println("ERROR: getNodeGraphicURL() does not return expected value:\n" +
219 "\tExpected: " + this.msNodeGraphicURL +"\n" +
220 "\tGot: " + graphicURL);
221 bOK = false;
222 }
223 tRes.tested("getNodeGraphicURL()", bOK);
224 }
225
226
227 public void _getExpandedGraphicURL(){
228
229 boolean bOK = true;
230 String ExpandedGraphicURL = oObj.getExpandedGraphicURL();
231
232 if ( ! this.msExpandedGraphicURL.equals(ExpandedGraphicURL)){
233 log.println("ERROR: getExpandedGraphicURL() does not return expected value:\n" +
234 "\tExpected: " + this.msExpandedGraphicURL +"\n" +
235 "\tGot: " + ExpandedGraphicURL);
236 bOK = false;
237 }
238
239 tRes.tested("getExpandedGraphicURL()", bOK);
240 }
241
242
243 public void _getCollapsedGraphicURL(){
244
245 boolean bOK = true;
246
247 String CollapsedGraphicURL = oObj.getCollapsedGraphicURL();
248
249 if ( ! this.msCollapsedGraphicURL.equals(CollapsedGraphicURL)){
250 log.println("ERROR: getExpandedGraphicURL() does not return expected value:\n" +
251 "\tExpected: " + this.msCollapsedGraphicURL +"\n" +
252 "\tGot: " + CollapsedGraphicURL);
253 bOK = false;
254 }
255
256 tRes.tested("getCollapsedGraphicURL()", bOK);
257 }
258
259 }