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
.ui
.dialogs
;
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.ui
.dialogs
.XControlInformation
;
26 * Testing <code>com.sun.star.ui.XControlInformation</code>
29 * <li><code> getSupportedControls()</code></li>
30 * <li><code> isControlSupported()</code></li>
31 * <li><code> getSupportedControlProperties()</code></li>
32 * <li><code> isControlPropertySupported()</code></li>
35 * @see com.sun.star.ui.XFolderPicker
37 public class _XControlInformation
extends MultiMethodTest
{
39 public XControlInformation oObj
= null;
40 private String
[] supControls
= null ;
41 private String
[][] supProperties
= null ;
44 * Gets supported controls and stores them. <p>
45 * Has <b>OK</b> status if not <code>null</code> returned.
47 public void _getSupportedControls() {
48 supControls
= oObj
.getSupportedControls();
50 tRes
.tested("getSupportedControls()", supControls
!= null) ;
54 * For every available control check if it is supported.
55 * Also wrong control name (non-existent and empty) are checked.<p>
57 * Has <b>OK</b> status if <code>true</code> returned for valid
58 * control names and <code>false</code> for invalid.<p>
60 * The following method tests are to be completed successfully before :
62 * <li> <code> getSupportedControls </code> to have
63 * valid control names</li>
66 public void _isControlSupported() {
67 requiredMethod("getSupportedControls()") ;
69 boolean result
= true ;
71 log
.println("Supported controls :");
72 for (int i
= 0; i
< supControls
.length
; i
++) {
73 log
.println(" " + supControls
[i
]);
74 result
&= oObj
.isControlSupported(supControls
[i
]) ;
77 result
&= !oObj
.isControlSupported("SuchNameMustNotExist");
78 result
&= !oObj
.isControlSupported("");
80 tRes
.tested("isControlSupported()", result
) ;
84 * For each control obtains its properties and stores them. Then tries to
85 * obtain properties for control with invalid name. <p>
87 * Has <b>OK</b> status if properties arrays are not null and exception
88 * thrown or null returned for control with invalid name <p>
90 * The following method tests are to be completed successfully before :
92 * <li> <code> getSupportedControls </code> to have
93 * valid control names</li>
96 public void _getSupportedControlProperties() {
97 requiredMethod("getSupportedControls()") ;
99 supProperties
= new String
[supControls
.length
][];
100 for (int i
= 0; i
< supControls
.length
; i
++) {
101 log
.println("Getting proeprties for control: " + supControls
[i
]);
104 oObj
.getSupportedControlProperties(supControls
[i
]);
105 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
106 log
.println("Unexpected exception:" + e
);
111 oObj
.getSupportedControlProperties("NoSuchControl");
112 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
113 log
.println("Expected exception getting properties " +
114 "for wrong control:" + e
);
117 tRes
.tested("getSupportedControlProperties()", true) ;
122 * <li>For each property of each control checks if it is supported.</li>
123 * <li>For each control checks if non-existent property
124 * (with wrong name and with empty name) supported.</li>
125 * <li>Tries to check the property of non-existent control </li>
128 * Has <b>OK</b> status if <code>true</code> returned for the first case,
129 * <code>false</code> for the second, and <code>false</code> or exception
132 * The following method tests are to be completed successfully before :
134 * <li> <code> getSupportedControlProperties </code> to have a set of
135 * valid properties </li>
138 public void _isControlPropertySupported() {
139 requiredMethod("getSupportedControlProperties()") ;
141 boolean result
= true;
143 for (int i
= 0; i
< supControls
.length
; i
++) {
144 log
.println("Checking proeprties for control " + supControls
[i
]);
145 for (int j
= 0; j
< supProperties
[i
].length
; j
++) {
146 log
.println(" " + supProperties
[i
][j
]);
148 result
&= oObj
.isControlPropertySupported
149 (supControls
[i
], supProperties
[i
][j
]) ;
150 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
151 log
.println("Unexpected exception:" + e
);
157 result
&= !oObj
.isControlPropertySupported
158 (supControls
[i
], "NoSuchPropertyForThisControl") ;
159 result
&= !oObj
.isControlPropertySupported
160 (supControls
[i
], "") ;
161 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
163 ("Unexpected exception (just false must be returned):" + e
);
169 result
&= !oObj
.isControlPropertySupported("NoSuchControl", "") ;
170 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
171 log
.println("Expected exception: " + e
);
174 tRes
.tested("isControlPropertySupported()", result
) ;