Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / ui / dialogs / _XControlInformation.java
blobad7c8d782d7d0f48f379fb7e2cf63a5e72bbe875
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc.ui.dialogs;
30 import lib.MultiMethodTest;
32 import com.sun.star.ui.dialogs.XControlInformation;
34 /**
35 * Testing <code>com.sun.star.ui.XControlInformation</code>
36 * interface methods :
37 * <ul>
38 * <li><code> getSupportedControls()</code></li>
39 * <li><code> isControlSupported()</code></li>
40 * <li><code> getSupportedControlProperties()</code></li>
41 * <li><code> isControlPropertySupported()</code></li>
42 * </ul> <p>
44 * @see com.sun.star.ui.XFolderPicker
46 public class _XControlInformation extends MultiMethodTest {
48 public XControlInformation oObj = null;
49 private String[] supControls = null ;
50 private String[][] supProperties = null ;
52 /**
53 * Gets supported controls and stores them. <p>
54 * Has <b>OK</b> status if not <code>null</code> returned.
56 public void _getSupportedControls() {
57 supControls = oObj.getSupportedControls();
59 tRes.tested("getSupportedControls()", supControls != null) ;
62 /**
63 * For every available control check if it is supported.
64 * Also wrong control name (non-existant and empty) are checked.<p>
66 * Has <b>OK</b> status if <code>true</code> returned for valid
67 * control names and <code>false</code> for invalid.<p>
69 * The following method tests are to be completed successfully before :
70 * <ul>
71 * <li> <code> getSupportedControls </code> to have
72 * valid control names</li>
73 * </ul>
75 public void _isControlSupported() {
76 requiredMethod("getSupportedControls()") ;
78 boolean result = true ;
80 log.println("Supported controls :");
81 for (int i = 0; i < supControls.length; i++) {
82 log.println(" " + supControls[i]);
83 result &= oObj.isControlSupported(supControls[i]) ;
86 result &= !oObj.isControlSupported("SuchNameMustNotExist");
87 result &= !oObj.isControlSupported("");
89 tRes.tested("isControlSupported()", result) ;
92 /**
93 * For each control obtains its properties and stores them. Then tries to
94 * obtain properties for control with invalid name. <p>
96 * Has <b>OK</b> status if properties arrays are not null and exception
97 * thrown or null returned for control with invalid name <p>
99 * The following method tests are to be completed successfully before :
100 * <ul>
101 * <li> <code> getSupportedControls </code> to have
102 * valid control names</li>
103 * </ul>
105 public void _getSupportedControlProperties() {
106 requiredMethod("getSupportedControls()") ;
108 boolean result = true;
110 supProperties = new String[supControls.length][];
111 for (int i = 0; i < supControls.length; i++) {
112 log.println("Getting proeprties for control: " + supControls[i]);
113 try {
114 supProperties[i] =
115 oObj.getSupportedControlProperties(supControls[i]);
116 } catch (com.sun.star.lang.IllegalArgumentException e) {
117 log.println("Unexpected exception:" + e);
118 result = false ;
120 result &= supProperties[i] != null;
123 try {
124 Object prop = oObj.getSupportedControlProperties("NoSuchControl") ;
125 result &= prop == null;
126 } catch (com.sun.star.lang.IllegalArgumentException e) {
127 log.println("Expected exception getting properties " +
128 "for wrong control:" + e);
131 tRes.tested("getSupportedControlProperties()", true) ;
135 * <ul>
136 * <li>For each property of each control checks if it is supported.</li>
137 * <li>For each control checks if non-existent property
138 * (with wrong name and with empty name) supported.</li>
139 * <li>Tries to check the property of non-existent control </li>
140 * </ul>
141 * <p>
142 * Has <b>OK</b> status if <code>true</code> returned for the first case,
143 * <code>false</code> for the second, and <code>false</code> or exception
144 * for the third.<p>
146 * The following method tests are to be completed successfully before :
147 * <ul>
148 * <li> <code> getSupportedControlProperties </code> to have a set of
149 * valid properties </li>
150 * </ul>
152 public void _isControlPropertySupported() {
153 requiredMethod("getSupportedControlProperties()") ;
155 boolean result = true;
157 for (int i = 0; i < supControls.length; i++) {
158 log.println("Checking proeprties for control " + supControls[i]);
159 for (int j = 0; j < supProperties[i].length; j++) {
160 log.println(" " + supProperties[i][j]);
161 try {
162 result &= oObj.isControlPropertySupported
163 (supControls[i], supProperties[i][j]) ;
164 } catch (com.sun.star.lang.IllegalArgumentException e) {
165 log.println("Unexpected exception:" + e);
166 result = false ;
170 try {
171 result &= !oObj.isControlPropertySupported
172 (supControls[i], "NoSuchPropertyForThisControl") ;
173 result &= !oObj.isControlPropertySupported
174 (supControls[i], "") ;
175 } catch (com.sun.star.lang.IllegalArgumentException e) {
176 log.println
177 ("Unexpected exception (just false must be returned):" + e);
178 result = false ;
182 try {
183 result &= !oObj.isControlPropertySupported("NoSuchControl", "") ;
184 } catch (com.sun.star.lang.IllegalArgumentException e) {
185 log.println("Expected exception: " + e);
188 tRes.tested("isControlPropertySupported()", result) ;