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: _XControlAccess.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 lib
.StatusException
;
37 import com
.sun
.star
.ui
.dialogs
.XControlAccess
;
38 import com
.sun
.star
.ui
.dialogs
.XControlInformation
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
42 * Testing <code>com.sun.star.ui.XFilePicker</code>
45 * <li><code> setControlProperty()</code></li>
46 * <li><code> getControlProperty()</code></li>
49 * For testing this interface the component must implement
50 * <code>com.sun.star.ui.dialogs.XControlInformation</code>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.ui.XFolderPicker
56 public class _XControlAccess
extends MultiMethodTest
{
58 public XControlAccess oObj
= null;
59 private XControlInformation xCI
= null ;
60 private String
[] supControls
= null ;
61 private String
[][] supProperties
= null ;
64 * Tries to query <code>com.sun.star.ui.dialogs.XControlInformation</code>
65 * interface, and obtain properties' names of each available
68 * @throw StatusException if interface is not supported or
69 * properties couldn't be get.
71 protected void before() {
72 xCI
= (XControlInformation
) UnoRuntime
.queryInterface
73 (XControlInformation
.class, oObj
);
75 if (xCI
== null) throw new StatusException
76 (Status
.failed("XControlInformation not supported")) ;
78 supControls
= xCI
.getSupportedControls();
79 supProperties
= new String
[supControls
.length
][];
80 for (int i
= 0; i
< supControls
.length
; i
++) {
83 xCI
.getSupportedControlProperties(supControls
[i
]);
84 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
85 e
.printStackTrace(log
);
86 throw new StatusException
87 ("Exception while init.", e
) ;
93 * Tries to change each property of each control.
94 * Has <b>OK</b> status if values are properly changed.
96 public void _setControlProperty() {
97 boolean result
= true ;
100 for (int i
= 0; i
< supControls
.length
; i
++) {
101 log
.println("Checking properties for control " + supControls
[i
]);
102 for (int j
= 0; j
< supProperties
[i
].length
; j
++) {
103 log
.println("\t" + supProperties
[i
][j
]);
105 Object oldVal
= oObj
.getControlProperty(supControls
[i
],
106 supProperties
[i
][j
]);
107 Object newVal
= util
.ValueChanger
.changePValue(oldVal
);
108 if (supProperties
[i
][j
].startsWith("Help")) {
111 oObj
.setControlProperty
112 (supControls
[i
], supProperties
[i
][j
], newVal
) ;
113 Object resVal
= oObj
.getControlProperty(supControls
[i
],
114 supProperties
[i
][j
]);
115 log
.println("\t Old:" + oldVal
+ ",New:" + newVal
116 + ",Result:" + resVal
);
117 if (!util
.ValueComparer
.equalValue(newVal
, resVal
)) {
118 error
+= "####Property '"+supProperties
[i
][j
]+
119 " of "+supControls
[i
]+" didn't work\n\r"+
120 "\t Old:" + oldVal
+ ",New:" + newVal
121 + ",Result:" + resVal
+ "\n\r";
123 result
&= util
.ValueComparer
.equalValue(newVal
, resVal
);
124 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
125 log
.println("Unexpected exception:" );
126 e
.printStackTrace(log
);
134 tRes
.tested("setControlProperty()", result
) ;
135 tRes
.tested("getControlProperty()", result
) ;
139 * Does nothing. Testing performed in <code>setControlProperty</code>
142 public void _getControlProperty() {}