1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XControlInformation.java,v $
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
;
38 * Testing <code>com.sun.star.ui.XControlInformation</code>
41 * <li><code> getSupportedControls()</code></li>
42 * <li><code> isControlSupported()</code></li>
43 * <li><code> getSupportedControlProperties()</code></li>
44 * <li><code> isControlPropertySupported()</code></li>
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 ;
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) ;
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 :
74 * <li> <code> getSupportedControls </code> to have
75 * valid control names</li>
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
) ;
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 :
104 * <li> <code> getSupportedControls </code> to have
105 * valid control names</li>
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
]);
118 oObj
.getSupportedControlProperties(supControls
[i
]);
119 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
120 log
.println("Unexpected exception:" + e
);
123 result
&= supProperties
[i
] != null;
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) ;
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>
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
149 * The following method tests are to be completed successfully before :
151 * <li> <code> getSupportedControlProperties </code> to have a set of
152 * valid properties </li>
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
]);
165 result
&= oObj
.isControlPropertySupported
166 (supControls
[i
], supProperties
[i
][j
]) ;
167 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
168 log
.println("Unexpected exception:" + e
);
174 result
&= !oObj
.isControlPropertySupported
175 (supControls
[i
], "NoSuchPropertyForThisControl") ;
176 result
&= !oObj
.isControlPropertySupported
177 (supControls
[i
], "") ;
178 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
180 ("Unexpected exception (just false must be returned):" + e
);
186 result
&= !oObj
.isControlPropertySupported("NoSuchControl", "") ;
187 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
188 log
.println("Expected exception: " + e
);
191 tRes
.tested("isControlPropertySupported()", result
) ;