Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / qadevOOo / tests / java / ifc / ui / dialogs / _XControlAccess.java
bloba1a9197cd4a67821babb0a9b785c3c5f7dcf0b18
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;
31 import lib.Status;
32 import lib.StatusException;
34 import com.sun.star.ui.dialogs.XControlAccess;
35 import com.sun.star.ui.dialogs.XControlInformation;
36 import com.sun.star.uno.UnoRuntime;
38 /**
39 * Testing <code>com.sun.star.ui.XFilePicker</code>
40 * interface methods :
41 * <ul>
42 * <li><code> setControlProperty()</code></li>
43 * <li><code> getControlProperty()</code></li>
44 * </ul> <p>
46 * For testing this interface the component must implement
47 * <code>com.sun.star.ui.dialogs.XControlInformation</code>
48 * interface. <p>
50 * Test is <b> NOT </b> multithread compilant. <p>
51 * @see com.sun.star.ui.XFolderPicker
53 public class _XControlAccess extends MultiMethodTest {
55 public XControlAccess oObj = null;
56 private XControlInformation xCI = null ;
57 private String[] supControls = null ;
58 private String[][] supProperties = null ;
60 /**
61 * Tries to query <code>com.sun.star.ui.dialogs.XControlInformation</code>
62 * interface, and obtain properties' names of each available
63 * control. <p>
65 * @throw StatusException if interface is not supported or
66 * properties couldn't be get.
68 protected void before() {
69 xCI = (XControlInformation) UnoRuntime.queryInterface
70 (XControlInformation.class, oObj);
72 if (xCI == null) throw new StatusException
73 (Status.failed("XControlInformation not supported")) ;
75 supControls = xCI.getSupportedControls();
76 supProperties = new String[supControls.length][];
77 for (int i = 0; i < supControls.length; i++) {
78 try {
79 supProperties[i] =
80 xCI.getSupportedControlProperties(supControls[i]);
81 } catch (com.sun.star.lang.IllegalArgumentException e) {
82 e.printStackTrace(log);
83 throw new StatusException
84 ("Exception while init.", e) ;
89 /**
90 * Tries to change each property of each control.
91 * Has <b>OK</b> status if values are properly changed.
93 public void _setControlProperty() {
94 boolean result = true ;
95 String error = "";
97 for (int i = 0; i < supControls.length; i++) {
98 log.println("Checking properties for control " + supControls[i]);
99 for (int j = 0; j < supProperties[i].length; j++) {
100 log.println("\t" + supProperties[i][j]);
101 try {
102 Object oldVal = oObj.getControlProperty(supControls[i],
103 supProperties[i][j]);
104 Object newVal = util.ValueChanger.changePValue(oldVal);
105 if (supProperties[i][j].startsWith("Help")) {
106 newVal = "HID:133";
108 oObj.setControlProperty
109 (supControls[i], supProperties[i][j], newVal) ;
110 Object resVal = oObj.getControlProperty(supControls[i],
111 supProperties[i][j]);
112 log.println("\t Old:" + oldVal + ",New:" + newVal
113 + ",Result:" + resVal);
114 if (!util.ValueComparer.equalValue(newVal, resVal)) {
115 error += "####Property '"+supProperties[i][j]+
116 " of "+supControls[i]+" didn't work\n\r"+
117 "\t Old:" + oldVal + ",New:" + newVal
118 + ",Result:" + resVal+ "\n\r";
120 result &= util.ValueComparer.equalValue(newVal, resVal);
121 } catch (com.sun.star.lang.IllegalArgumentException e) {
122 log.println("Unexpected exception:" );
123 e.printStackTrace(log);
124 result = false ;
129 log.println(error);
131 tRes.tested("setControlProperty()", result) ;
132 tRes.tested("getControlProperty()", result) ;
136 * Does nothing. Testing performed in <code>setControlProperty</code>
137 * method test.
139 public void _getControlProperty() {}