1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package ifc.awt; 25 26 import lib.MultiPropertyTest; 27 import util.utils; 28 29 import com.sun.star.lang.XMultiServiceFactory; 30 31 /** 32 * Testing <code>com.sun.star.awt.UnoControlFormattedFieldModel</code> 33 * service properties : 34 * <ul> 35 * <li><code> Align</code></li> 36 * <li><code> BackgroundColor</code></li> 37 * <li><code> Border</code></li> 38 * <li><code> DefaultControl</code></li> 39 * <li><code> EffectiveDefault</code></li> 40 * <li><code> EffectiveMax</code></li> 41 * <li><code> EffectiveMin</code></li> 42 * <li><code> EffectiveValue</code></li> 43 * <li><code> Enabled</code></li> 44 * <li><code> FontDescriptor</code></li> 45 * <li><code> FormatKey</code></li> 46 * <li><code> FormatsSupplier</code></li> 47 * <li><code> MaxTextLen</code></li> 48 * <li><code> Printable</code></li> 49 * <li><code> ReadOnly</code></li> 50 * <li><code> Spin</code></li> 51 * <li><code> StrictFormat</code></li> 52 * <li><code> Tabstop</code></li> 53 * <li><code> Text</code></li> 54 * <li><code> TextColor</code></li> 55 * <li><code> HelpText</code></li> 56 * <li><code> HelpURL</code></li> 57 * </ul> <p> 58 * Properties testing is automated by <code>lib.MultiPropertyTest</code>. 59 * @see com.sun.star.awt.UnoControlFormattedFieldModel 60 */ 61 public class _UnoControlFormattedFieldModel extends MultiPropertyTest { 62 63 /** 64 * Redefined method must return a valid service name, that differs from 65 * name exists. 66 * 67 */ 68 protected PropertyTester ControlTester = new PropertyTester() { 69 protected Object getNewValue(String propName, Object oldValue) { 70 if (util.ValueComparer.equalValue(oldValue, 71 "com.sun.star.form.control.FormattedField")) 72 return "com.sun.star.awt.UnoControlFormattedField"; 73 else 74 return "com.sun.star.form.control.FormattedField"; 75 } 76 }; 77 78 /** 79 * This property must contain a valid service name. 80 */ _DefaultControl()81 public void _DefaultControl() { 82 log.println("Testing with custom Property tester") ; 83 testProperty("DefaultControl", ControlTester) ; 84 } 85 86 /** 87 * This property can be VOID, and in case if it is so new 88 * value must defined. 89 */ _BorderColor()90 public void _BorderColor() { 91 testProperty("BorderColor", new PropertyTester() { 92 protected Object getNewValue(String p, Object old) { 93 return utils.isVoid(old) ? new Integer(1234) : null ; 94 } 95 }) ; 96 } 97 98 /** 99 * This property can be void, so if old value is <code> null </code> 100 * new value must be specified. 101 */ _TextColor()102 public void _TextColor() { 103 testProperty("TextColor", new PropertyTester() { 104 protected Object getNewValue(String p, Object v) { 105 return utils.isVoid(v) ? new Integer(123) : 106 super.getNewValue(p,v) ; 107 } 108 }) ; 109 } 110 111 /** 112 * This property can be void, so if old value is <code> null </code> 113 * new value must be specified. 114 */ _TextLineColor()115 public void _TextLineColor() { 116 testProperty("TextLineColor", new PropertyTester() { 117 protected Object getNewValue(String p, Object v) { 118 return utils.isVoid(v) ? new Integer(123) : 119 super.getNewValue(p,v) ; 120 } 121 }) ; 122 } 123 124 /** 125 * This property can be void, so if old value is <code> null </code> 126 * new value must be specified. 127 */ _BackgroundColor()128 public void _BackgroundColor() { 129 testProperty("BackgroundColor", new PropertyTester() { 130 protected Object getNewValue(String p, Object v) { 131 return utils.isVoid(v) ? new Integer(123) : 132 super.getNewValue(p,v) ; 133 } 134 }) ; 135 } 136 137 /** 138 * This property can be void, so if old value is <code> null </code> 139 * new value must be specified. 140 */ _EffectiveDefault()141 public void _EffectiveDefault() { 142 testProperty("EffectiveDefault", new Double(5.8),new Double(2.3)) ; 143 } 144 145 /** 146 * This property can be void, so if old value is <code> null </code> 147 * new value must be specified. 148 */ _EffectiveValue()149 public void _EffectiveValue() { 150 testProperty("EffectiveValue", new Double(5.8),new Double(2.3)) ; 151 } 152 153 /** 154 * This property can be void, so if old value is <code> null </code> 155 * new value must be specified. 156 */ _EffectiveMax()157 public void _EffectiveMax() { 158 testProperty("EffectiveMax", new PropertyTester() { 159 protected Object getNewValue(String p, Object v) { 160 return utils.isVoid(v) ? new Double(123.8) : 161 super.getNewValue(p,v) ; 162 } 163 }) ; 164 } 165 166 /** 167 * This property can be void, so if old value is <code> null </code> 168 * new value must be specified. 169 */ _FormatsSupplier()170 public void _FormatsSupplier() { 171 testProperty("FormatsSupplier", new PropertyTester() { 172 protected Object getNewValue(String p, Object v) { 173 Object newValue = null; 174 try { 175 newValue = ((XMultiServiceFactory)tParam.getMSF()).createInstance( 176 "com.sun.star.util.NumberFormatsSupplier"); 177 } catch (com.sun.star.uno.Exception e) {} 178 return newValue; 179 } 180 }) ; 181 } 182 183 /** 184 * This property can be void, so if old value is <code> null </code> 185 * new value must be specified. 186 */ _EffectiveMin()187 public void _EffectiveMin() { 188 testProperty("EffectiveMin", new PropertyTester() { 189 protected Object getNewValue(String p, Object v) { 190 return utils.isVoid(v) ? new Double(0.1) : 191 super.getNewValue(p,v) ; 192 } 193 }) ; 194 } 195 196 /** 197 * This property can be void, so if old value is <code> null </code> 198 * new value must be specified. 199 */ _FormatKey()200 public void _FormatKey() { 201 testProperty("FormatKey", new PropertyTester() { 202 protected Object getNewValue(String p, Object v) { 203 return utils.isVoid(v) ? new Integer(0) : 204 super.getNewValue(p,v) ; 205 } 206 }) ; 207 } 208 209 /** 210 * This property can be void, so if old value is <code> null </code> 211 * new value must be specified. 212 */ _StrictFromat()213 public void _StrictFromat() { 214 testProperty("StrictFromat", new PropertyTester() { 215 protected Object getNewValue(String p, Object v) { 216 return utils.isVoid(v) ? new Boolean(true) : 217 super.getNewValue(p,v) ; 218 } 219 }) ; 220 } 221 222 /** 223 * This property can be void, so if old value is <code> null </code> 224 * new value must be specified. 225 */ _Tabstop()226 public void _Tabstop() { 227 testProperty("Tabstop", new PropertyTester() { 228 protected Object getNewValue(String p, Object v) { 229 return utils.isVoid(v) ? new Boolean(true) : 230 null ; 231 } 232 }) ; 233 } 234 235 /** 236 * This property can be void, so if old value is <code> null </code> 237 * new value must be specified. 238 */ _Text()239 public void _Text() { 240 testProperty("Text", new PropertyTester() { 241 protected Object getNewValue(String p, Object v) { 242 return utils.isVoid(v) ? "UnoControlFormattedFieldModel" : 243 super.getNewValue(p,v) ; 244 } 245 }) ; 246 } 247 } 248