1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.ui.dialogs; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import lib.MultiMethodTest; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import com.sun.star.ui.dialogs.XControlInformation; 29cdf0e10cSrcweir 30cdf0e10cSrcweir /** 31cdf0e10cSrcweir * Testing <code>com.sun.star.ui.XControlInformation</code> 32cdf0e10cSrcweir * interface methods : 33cdf0e10cSrcweir * <ul> 34cdf0e10cSrcweir * <li><code> getSupportedControls()</code></li> 35cdf0e10cSrcweir * <li><code> isControlSupported()</code></li> 36cdf0e10cSrcweir * <li><code> getSupportedControlProperties()</code></li> 37cdf0e10cSrcweir * <li><code> isControlPropertySupported()</code></li> 38cdf0e10cSrcweir * </ul> <p> 39cdf0e10cSrcweir * 40cdf0e10cSrcweir * @see com.sun.star.ui.XFolderPicker 41cdf0e10cSrcweir */ 42cdf0e10cSrcweir public class _XControlInformation extends MultiMethodTest { 43cdf0e10cSrcweir 44cdf0e10cSrcweir public XControlInformation oObj = null; 45cdf0e10cSrcweir private String[] supControls = null ; 46cdf0e10cSrcweir private String[][] supProperties = null ; 47cdf0e10cSrcweir 48cdf0e10cSrcweir /** 49cdf0e10cSrcweir * Gets supported controls and stores them. <p> 50cdf0e10cSrcweir * Has <b>OK</b> status if not <code>null</code> returned. 51cdf0e10cSrcweir */ _getSupportedControls()52cdf0e10cSrcweir public void _getSupportedControls() { 53cdf0e10cSrcweir supControls = oObj.getSupportedControls(); 54cdf0e10cSrcweir 55cdf0e10cSrcweir tRes.tested("getSupportedControls()", supControls != null) ; 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir /** 59cdf0e10cSrcweir * For every available control check if it is supported. 60cdf0e10cSrcweir * Also wrong control name (non-existant and empty) are checked.<p> 61cdf0e10cSrcweir * 62cdf0e10cSrcweir * Has <b>OK</b> status if <code>true</code> returned for valid 63cdf0e10cSrcweir * control names and <code>false</code> for invalid.<p> 64cdf0e10cSrcweir * 65cdf0e10cSrcweir * The following method tests are to be completed successfully before : 66cdf0e10cSrcweir * <ul> 67cdf0e10cSrcweir * <li> <code> getSupportedControls </code> to have 68cdf0e10cSrcweir * valid control names</li> 69cdf0e10cSrcweir * </ul> 70cdf0e10cSrcweir */ _isControlSupported()71cdf0e10cSrcweir public void _isControlSupported() { 72cdf0e10cSrcweir requiredMethod("getSupportedControls()") ; 73cdf0e10cSrcweir 74cdf0e10cSrcweir boolean result = true ; 75cdf0e10cSrcweir 76cdf0e10cSrcweir log.println("Supported controls :"); 77cdf0e10cSrcweir for (int i = 0; i < supControls.length; i++) { 78cdf0e10cSrcweir log.println(" " + supControls[i]); 79cdf0e10cSrcweir result &= oObj.isControlSupported(supControls[i]) ; 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir result &= !oObj.isControlSupported("SuchNameMustNotExist"); 83cdf0e10cSrcweir result &= !oObj.isControlSupported(""); 84cdf0e10cSrcweir 85cdf0e10cSrcweir tRes.tested("isControlSupported()", result) ; 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** 89cdf0e10cSrcweir * For each control obtains its properties and stores them. Then tries to 90cdf0e10cSrcweir * obtain properties for control with invalid name. <p> 91cdf0e10cSrcweir * 92cdf0e10cSrcweir * Has <b>OK</b> status if properties arrays are not null and exception 93cdf0e10cSrcweir * thrown or null returned for control with invalid name <p> 94cdf0e10cSrcweir * 95cdf0e10cSrcweir * The following method tests are to be completed successfully before : 96cdf0e10cSrcweir * <ul> 97cdf0e10cSrcweir * <li> <code> getSupportedControls </code> to have 98cdf0e10cSrcweir * valid control names</li> 99cdf0e10cSrcweir * </ul> 100cdf0e10cSrcweir */ _getSupportedControlProperties()101cdf0e10cSrcweir public void _getSupportedControlProperties() { 102cdf0e10cSrcweir requiredMethod("getSupportedControls()") ; 103cdf0e10cSrcweir 104cdf0e10cSrcweir boolean result = true; 105cdf0e10cSrcweir 106cdf0e10cSrcweir supProperties = new String[supControls.length][]; 107cdf0e10cSrcweir for (int i = 0; i < supControls.length; i++) { 108cdf0e10cSrcweir log.println("Getting proeprties for control: " + supControls[i]); 109cdf0e10cSrcweir try { 110cdf0e10cSrcweir supProperties[i] = 111cdf0e10cSrcweir oObj.getSupportedControlProperties(supControls[i]); 112cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 113cdf0e10cSrcweir log.println("Unexpected exception:" + e); 114cdf0e10cSrcweir result = false ; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir result &= supProperties[i] != null; 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir try { 120cdf0e10cSrcweir Object prop = oObj.getSupportedControlProperties("NoSuchControl") ; 121cdf0e10cSrcweir result &= prop == null; 122cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 123cdf0e10cSrcweir log.println("Expected exception getting properties " + 124cdf0e10cSrcweir "for wrong control:" + e); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir tRes.tested("getSupportedControlProperties()", true) ; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir 130cdf0e10cSrcweir /** 131cdf0e10cSrcweir * <ul> 132cdf0e10cSrcweir * <li>For each property of each control checks if it is supported.</li> 133cdf0e10cSrcweir * <li>For each control checks if non-existent property 134cdf0e10cSrcweir * (with wrong name and with empty name) supported.</li> 135cdf0e10cSrcweir * <li>Tries to check the property of non-existent control </li> 136cdf0e10cSrcweir * </ul> 137cdf0e10cSrcweir * <p> 138cdf0e10cSrcweir * Has <b>OK</b> status if <code>true</code> returned for the first case, 139cdf0e10cSrcweir * <code>false</code> for the second, and <code>false</code> or exception 140cdf0e10cSrcweir * for the third.<p> 141cdf0e10cSrcweir * 142cdf0e10cSrcweir * The following method tests are to be completed successfully before : 143cdf0e10cSrcweir * <ul> 144cdf0e10cSrcweir * <li> <code> getSupportedControlProperties </code> to have a set of 145cdf0e10cSrcweir * valid properties </li> 146cdf0e10cSrcweir * </ul> 147cdf0e10cSrcweir */ _isControlPropertySupported()148cdf0e10cSrcweir public void _isControlPropertySupported() { 149cdf0e10cSrcweir requiredMethod("getSupportedControlProperties()") ; 150cdf0e10cSrcweir 151cdf0e10cSrcweir boolean result = true; 152cdf0e10cSrcweir 153cdf0e10cSrcweir for (int i = 0; i < supControls.length; i++) { 154cdf0e10cSrcweir log.println("Checking proeprties for control " + supControls[i]); 155cdf0e10cSrcweir for (int j = 0; j < supProperties[i].length; j++) { 156cdf0e10cSrcweir log.println(" " + supProperties[i][j]); 157cdf0e10cSrcweir try { 158cdf0e10cSrcweir result &= oObj.isControlPropertySupported 159cdf0e10cSrcweir (supControls[i], supProperties[i][j]) ; 160cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 161cdf0e10cSrcweir log.println("Unexpected exception:" + e); 162cdf0e10cSrcweir result = false ; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir try { 167cdf0e10cSrcweir result &= !oObj.isControlPropertySupported 168cdf0e10cSrcweir (supControls[i], "NoSuchPropertyForThisControl") ; 169cdf0e10cSrcweir result &= !oObj.isControlPropertySupported 170cdf0e10cSrcweir (supControls[i], "") ; 171cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 172cdf0e10cSrcweir log.println 173cdf0e10cSrcweir ("Unexpected exception (just false must be returned):" + e); 174cdf0e10cSrcweir result = false ; 175cdf0e10cSrcweir } 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir try { 179cdf0e10cSrcweir result &= !oObj.isControlPropertySupported("NoSuchControl", "") ; 180cdf0e10cSrcweir } catch (com.sun.star.lang.IllegalArgumentException e) { 181cdf0e10cSrcweir log.println("Expected exception: " + e); 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir tRes.tested("isControlPropertySupported()", result) ; 185cdf0e10cSrcweir } 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir 189