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 lib
.StatusException
;
25 import com
.sun
.star
.ui
.dialogs
.XControlAccess
;
26 import com
.sun
.star
.ui
.dialogs
.XControlInformation
;
27 import com
.sun
.star
.uno
.UnoRuntime
;
30 * Testing <code>com.sun.star.ui.XFilePicker</code>
33 * <li><code> setControlProperty()</code></li>
34 * <li><code> getControlProperty()</code></li>
37 * For testing this interface the component must implement
38 * <code>com.sun.star.ui.dialogs.XControlInformation</code>
41 * Test is <b> NOT </b> multithread compliant. <p>
42 * @see com.sun.star.ui.XFolderPicker
44 public class _XControlAccess
extends MultiMethodTest
{
46 public XControlAccess oObj
= null;
47 private String
[] supControls
= null ;
48 private String
[][] supProperties
= null ;
51 * Tries to query <code>com.sun.star.ui.dialogs.XControlInformation</code>
52 * interface, and obtain properties' names of each available
55 * @throw StatusException if interface is not supported or
56 * properties couldn't be get.
59 protected void before() {
60 XControlInformation xCI
= UnoRuntime
.queryInterface
61 (XControlInformation
.class, oObj
);
63 if (xCI
== null) throw new StatusException
64 (Status
.failed("XControlInformation not supported")) ;
66 supControls
= xCI
.getSupportedControls();
67 supProperties
= new String
[supControls
.length
][];
68 for (int i
= 0; i
< supControls
.length
; i
++) {
71 xCI
.getSupportedControlProperties(supControls
[i
]);
72 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
73 e
.printStackTrace(log
);
74 throw new StatusException
75 ("Exception while init.", e
) ;
81 * Tries to change each property of each control.
82 * Has <b>OK</b> status if values are properly changed.
84 public void _setControlProperty() {
85 boolean result
= true ;
88 for (int i
= 0; i
< supControls
.length
; i
++) {
89 log
.println("Checking properties for control " + supControls
[i
]);
90 for (int j
= 0; j
< supProperties
[i
].length
; j
++) {
91 log
.println("\t" + supProperties
[i
][j
]);
93 Object oldVal
= oObj
.getControlProperty(supControls
[i
],
95 Object newVal
= util
.ValueChanger
.changePValue(oldVal
);
96 if (supProperties
[i
][j
].startsWith("Help")) {
99 oObj
.setControlProperty
100 (supControls
[i
], supProperties
[i
][j
], newVal
) ;
101 Object resVal
= oObj
.getControlProperty(supControls
[i
],
102 supProperties
[i
][j
]);
103 log
.println("\t Old:" + oldVal
+ ",New:" + newVal
104 + ",Result:" + resVal
);
105 if (!util
.ValueComparer
.equalValue(newVal
, resVal
)) {
106 error
+= "####Property '"+supProperties
[i
][j
]+
107 " of "+supControls
[i
]+" didn't work\n\r"+
108 "\t Old:" + oldVal
+ ",New:" + newVal
109 + ",Result:" + resVal
+ "\n\r";
111 result
&= util
.ValueComparer
.equalValue(newVal
, resVal
);
112 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
113 log
.println("Unexpected exception:" );
114 e
.printStackTrace(log
);
122 tRes
.tested("setControlProperty()", result
) ;
123 tRes
.tested("getControlProperty()", result
) ;
127 * Does nothing. Testing performed in <code>setControlProperty</code>
130 public void _getControlProperty() {}