Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / ui / dialogs / _XControlInformation.java
blob2bed4ffa121ce03741ddf6ef2720fe07998cbb72
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XControlInformation.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.ui.dialogs;
33 import lib.MultiMethodTest;
35 import com.sun.star.ui.dialogs.XControlInformation;
37 /**
38 * Testing <code>com.sun.star.ui.XControlInformation</code>
39 * interface methods :
40 * <ul>
41 * <li><code> getSupportedControls()</code></li>
42 * <li><code> isControlSupported()</code></li>
43 * <li><code> getSupportedControlProperties()</code></li>
44 * <li><code> isControlPropertySupported()</code></li>
45 * </ul> <p>
47 * @see com.sun.star.ui.XFolderPicker
49 public class _XControlInformation extends MultiMethodTest {
51 public XControlInformation oObj = null;
52 private String[] supControls = null ;
53 private String[][] supProperties = null ;
55 /**
56 * Gets supported controls and stores them. <p>
57 * Has <b>OK</b> status if not <code>null</code> returned.
59 public void _getSupportedControls() {
60 supControls = oObj.getSupportedControls();
62 tRes.tested("getSupportedControls()", supControls != null) ;
65 /**
66 * For every available control check if it is supported.
67 * Also wrong control name (non-existant and empty) are checked.<p>
69 * Has <b>OK</b> status if <code>true</code> returned for valid
70 * control names and <code>false</code> for invalid.<p>
72 * The following method tests are to be completed successfully before :
73 * <ul>
74 * <li> <code> getSupportedControls </code> to have
75 * valid control names</li>
76 * </ul>
78 public void _isControlSupported() {
79 requiredMethod("getSupportedControls()") ;
81 boolean result = true ;
83 log.println("Supported controls :");
84 for (int i = 0; i < supControls.length; i++) {
85 log.println(" " + supControls[i]);
86 result &= oObj.isControlSupported(supControls[i]) ;
89 result &= !oObj.isControlSupported("SuchNameMustNotExist");
90 result &= !oObj.isControlSupported("");
92 tRes.tested("isControlSupported()", result) ;
95 /**
96 * For each control obtains its properties and stores them. Then tries to
97 * obtain properties for control with invalid name. <p>
99 * Has <b>OK</b> status if properties arrays are not null and exception
100 * thrown or null returned for control with invalid name <p>
102 * The following method tests are to be completed successfully before :
103 * <ul>
104 * <li> <code> getSupportedControls </code> to have
105 * valid control names</li>
106 * </ul>
108 public void _getSupportedControlProperties() {
109 requiredMethod("getSupportedControls()") ;
111 boolean result = true;
113 supProperties = new String[supControls.length][];
114 for (int i = 0; i < supControls.length; i++) {
115 log.println("Getting proeprties for control: " + supControls[i]);
116 try {
117 supProperties[i] =
118 oObj.getSupportedControlProperties(supControls[i]);
119 } catch (com.sun.star.lang.IllegalArgumentException e) {
120 log.println("Unexpected exception:" + e);
121 result = false ;
123 result &= supProperties[i] != null;
126 try {
127 Object prop = oObj.getSupportedControlProperties("NoSuchControl") ;
128 result &= prop == null;
129 } catch (com.sun.star.lang.IllegalArgumentException e) {
130 log.println("Expected exception getting properties " +
131 "for wrong control:" + e);
134 tRes.tested("getSupportedControlProperties()", true) ;
138 * <ul>
139 * <li>For each property of each control checks if it is supported.</li>
140 * <li>For each control checks if non-existent property
141 * (with wrong name and with empty name) supported.</li>
142 * <li>Tries to check the property of non-existent control </li>
143 * </ul>
144 * <p>
145 * Has <b>OK</b> status if <code>true</code> returned for the first case,
146 * <code>false</code> for the second, and <code>false</code> or exception
147 * for the third.<p>
149 * The following method tests are to be completed successfully before :
150 * <ul>
151 * <li> <code> getSupportedControlProperties </code> to have a set of
152 * valid properties </li>
153 * </ul>
155 public void _isControlPropertySupported() {
156 requiredMethod("getSupportedControlProperties()") ;
158 boolean result = true;
160 for (int i = 0; i < supControls.length; i++) {
161 log.println("Checking proeprties for control " + supControls[i]);
162 for (int j = 0; j < supProperties[i].length; j++) {
163 log.println(" " + supProperties[i][j]);
164 try {
165 result &= oObj.isControlPropertySupported
166 (supControls[i], supProperties[i][j]) ;
167 } catch (com.sun.star.lang.IllegalArgumentException e) {
168 log.println("Unexpected exception:" + e);
169 result = false ;
173 try {
174 result &= !oObj.isControlPropertySupported
175 (supControls[i], "NoSuchPropertyForThisControl") ;
176 result &= !oObj.isControlPropertySupported
177 (supControls[i], "") ;
178 } catch (com.sun.star.lang.IllegalArgumentException e) {
179 log.println
180 ("Unexpected exception (just false must be returned):" + e);
181 result = false ;
185 try {
186 result &= !oObj.isControlPropertySupported("NoSuchControl", "") ;
187 } catch (com.sun.star.lang.IllegalArgumentException e) {
188 log.println("Expected exception: " + e);
191 tRes.tested("isControlPropertySupported()", result) ;