1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 package ifc.awt; 29 30 import lib.MultiPropertyTest; 31 import util.utils; 32 33 /* 34 * Testing <code>com.sun.star.awt.UnoControlDateFieldModel</code> 35 * service properties : 36 * <ul> 37 * <li><code> BackgroundColor</code></li> 38 * <li><code> Border</code></li> 39 * <li><code> Date</code></li> 40 * <li><code> DateMax</code></li> 41 * <li><code> DateMin</code></li> 42 * <li><code> DefaultControl</code></li> 43 * <li><code> Enabled</code></li> 44 * <li><code> DateFormat</code></li> 45 * <li><code> FontDescriptor</code></li> 46 * <li><code> Printable</code></li> 47 * <li><code> ReadOnly</code></li> 48 * <li><code> Spin</code></li> 49 * <li><code> StrictFormat</code></li> 50 * <li><code> Tabstop</code></li> 51 * <li><code> TextColor</code></li> 52 * </ul> 53 * Almost all properties testing is automated by 54 * <code>lib.MultiPropertyTest</code>. 55 * @see com.sun.star.awt.UnoControlDateFieldModel 56 */ 57 public class _UnoControlDateFieldModel extends MultiPropertyTest { 58 59 /** 60 * This property can be void, so if old value is <code> null </code> 61 * new value must be specified. 62 */ 63 public void _BackgroundColor() { 64 testProperty("BackgroundColor", new PropertyTester() { 65 protected Object getNewValue(String prop, Object old) { 66 return utils.isVoid(old) ? new Integer(6543) : null ; 67 } 68 }) ; 69 } 70 71 /** 72 * This property can be VOID, and in case if it is so new 73 * value must defined. 74 */ 75 public void _BorderColor() { 76 testProperty("BorderColor", new PropertyTester() { 77 protected Object getNewValue(String p, Object old) { 78 return utils.isVoid(old) ? new Integer(1234) : null ; 79 } 80 }) ; 81 } 82 83 84 /** 85 * This property can be void, so if old value is <code> null </code> 86 * new value must be specified. 87 */ 88 public void _Date() { 89 testProperty("Date", new PropertyTester() { 90 protected Object getNewValue(String prop, Object old) { 91 return utils.isVoid(old) ? new Integer(6543) : 92 super.getNewValue(prop, old) ; 93 } 94 }) ; 95 } 96 97 /** 98 * This property can be void, so if old value is <code> null </code> 99 * new value must be specified. 100 */ 101 public void _Tabstop() { 102 testProperty("Tabstop", new PropertyTester() { 103 protected Object getNewValue(String prop, Object old) { 104 return utils.isVoid(old) ? new Boolean(true) : null ; 105 } 106 }) ; 107 } 108 109 /** 110 * This property can be void, so if old value is <code> null </code> 111 * new value must be specified. 112 */ 113 public void _TextColor() { 114 testProperty("TextColor", new PropertyTester() { 115 protected Object getNewValue(String prop, Object old) { 116 return utils.isVoid(old) ? new Integer(123) : null ; 117 } 118 }) ; 119 } 120 121 /** 122 * Redefined method returns value, that differs from property value. 123 */ 124 protected PropertyTester ColorTester = new PropertyTester() { 125 protected Object getNewValue(String propName, Object oldValue) { 126 if (util.ValueComparer.equalValue(oldValue, new Integer(17))) 127 return new Integer(25); 128 else 129 return new Integer(17); 130 } 131 }; 132 133 /** 134 * This property can be void, so if old value is <code> null </code> 135 * new value must be specified. 136 */ 137 public void _TextLineColor() { 138 log.println("Testing with custom Property tester") ; 139 testProperty("TextLineColor", ColorTester) ; 140 } 141 142 public void _DateShowCentury() { 143 boolean res = false; 144 try { 145 util.dbg.printPropertyInfo(oObj,"DateShowCentury",log); 146 Object oDsc = oObj.getPropertyValue("DateShowCentury"); 147 Boolean dsc = null; 148 if (util.utils.isVoid(oDsc)) { 149 log.println("Property is void, set it to true"); 150 dsc = new Boolean(true); 151 } else { 152 dsc = (Boolean) oDsc; 153 dsc = new Boolean(!dsc.booleanValue()); 154 log.println("Setting property to "+dsc); 155 } 156 oObj.setPropertyValue("DateShowCentury",dsc); 157 Boolean getdsc = (Boolean) oObj.getPropertyValue("DateShowCentury"); 158 log.println("Getting value "+getdsc); 159 res = dsc.equals(getdsc); 160 } catch (com.sun.star.beans.UnknownPropertyException upe) { 161 log.println("Don't know the Property 'DateShowCentury'"); 162 } catch (com.sun.star.lang.WrappedTargetException wte) { 163 log.println("WrappedTargetException while getting Property 'DateShowCentury'"); 164 } catch (com.sun.star.lang.IllegalArgumentException iae) { 165 log.println("IllegalArgumentException while getting Property 'DateShowCentury'"); 166 } catch (com.sun.star.beans.PropertyVetoException pve) { 167 log.println("PropertyVetoException while getting Property 'DateShowCentury'"); 168 } 169 tRes.tested("DateShowCentury",res); 170 171 } 172 } 173 174