merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / awt / _UnoControlFormattedFieldModel.java
blob0fe9df090d65aacb364b970814bb0b3cf24afccc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _UnoControlFormattedFieldModel.java,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.awt;
33 import lib.MultiPropertyTest;
34 import util.utils;
36 import com.sun.star.lang.XMultiServiceFactory;
38 /**
39 * Testing <code>com.sun.star.awt.UnoControlFormattedFieldModel</code>
40 * service properties :
41 * <ul>
42 * <li><code> Align</code></li>
43 * <li><code> BackgroundColor</code></li>
44 * <li><code> Border</code></li>
45 * <li><code> DefaultControl</code></li>
46 * <li><code> EffectiveDefault</code></li>
47 * <li><code> EffectiveMax</code></li>
48 * <li><code> EffectiveMin</code></li>
49 * <li><code> EffectiveValue</code></li>
50 * <li><code> Enabled</code></li>
51 * <li><code> FontDescriptor</code></li>
52 * <li><code> FormatKey</code></li>
53 * <li><code> FormatsSupplier</code></li>
54 * <li><code> MaxTextLen</code></li>
55 * <li><code> Printable</code></li>
56 * <li><code> ReadOnly</code></li>
57 * <li><code> Spin</code></li>
58 * <li><code> StrictFormat</code></li>
59 * <li><code> Tabstop</code></li>
60 * <li><code> Text</code></li>
61 * <li><code> TextColor</code></li>
62 * <li><code> HelpText</code></li>
63 * <li><code> HelpURL</code></li>
64 * </ul> <p>
65 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
66 * @see com.sun.star.awt.UnoControlFormattedFieldModel
68 public class _UnoControlFormattedFieldModel extends MultiPropertyTest {
70 /**
71 * Redefined method must return a valid service name, that differs from
72 * name exists.
75 protected PropertyTester ControlTester = new PropertyTester() {
76 protected Object getNewValue(String propName, Object oldValue) {
77 if (util.ValueComparer.equalValue(oldValue,
78 "com.sun.star.form.control.FormattedField"))
79 return "com.sun.star.awt.UnoControlFormattedField";
80 else
81 return "com.sun.star.form.control.FormattedField";
85 /**
86 * This property must contain a valid service name.
88 public void _DefaultControl() {
89 log.println("Testing with custom Property tester") ;
90 testProperty("DefaultControl", ControlTester) ;
93 /**
94 * This property can be VOID, and in case if it is so new
95 * value must defined.
97 public void _BorderColor() {
98 testProperty("BorderColor", new PropertyTester() {
99 protected Object getNewValue(String p, Object old) {
100 return utils.isVoid(old) ? new Integer(1234) : null ;
102 }) ;
106 * This property can be void, so if old value is <code> null </code>
107 * new value must be specified.
109 public void _TextColor() {
110 testProperty("TextColor", new PropertyTester() {
111 protected Object getNewValue(String p, Object v) {
112 return utils.isVoid(v) ? new Integer(123) :
113 super.getNewValue(p,v) ;
115 }) ;
119 * This property can be void, so if old value is <code> null </code>
120 * new value must be specified.
122 public void _TextLineColor() {
123 testProperty("TextLineColor", new PropertyTester() {
124 protected Object getNewValue(String p, Object v) {
125 return utils.isVoid(v) ? new Integer(123) :
126 super.getNewValue(p,v) ;
128 }) ;
132 * This property can be void, so if old value is <code> null </code>
133 * new value must be specified.
135 public void _BackgroundColor() {
136 testProperty("BackgroundColor", new PropertyTester() {
137 protected Object getNewValue(String p, Object v) {
138 return utils.isVoid(v) ? new Integer(123) :
139 super.getNewValue(p,v) ;
141 }) ;
145 * This property can be void, so if old value is <code> null </code>
146 * new value must be specified.
148 public void _EffectiveDefault() {
149 testProperty("EffectiveDefault", new Double(5.8),new Double(2.3)) ;
153 * This property can be void, so if old value is <code> null </code>
154 * new value must be specified.
156 public void _EffectiveValue() {
157 testProperty("EffectiveValue", new Double(5.8),new Double(2.3)) ;
161 * This property can be void, so if old value is <code> null </code>
162 * new value must be specified.
164 public void _EffectiveMax() {
165 testProperty("EffectiveMax", new PropertyTester() {
166 protected Object getNewValue(String p, Object v) {
167 return utils.isVoid(v) ? new Double(123.8) :
168 super.getNewValue(p,v) ;
170 }) ;
174 * This property can be void, so if old value is <code> null </code>
175 * new value must be specified.
177 public void _FormatsSupplier() {
178 testProperty("FormatsSupplier", new PropertyTester() {
179 protected Object getNewValue(String p, Object v) {
180 Object newValue = null;
181 try {
182 newValue = ((XMultiServiceFactory)tParam.getMSF()).createInstance(
183 "com.sun.star.util.NumberFormatsSupplier");
184 } catch (com.sun.star.uno.Exception e) {}
185 return newValue;
187 }) ;
191 * This property can be void, so if old value is <code> null </code>
192 * new value must be specified.
194 public void _EffectiveMin() {
195 testProperty("EffectiveMin", new PropertyTester() {
196 protected Object getNewValue(String p, Object v) {
197 return utils.isVoid(v) ? new Double(0.1) :
198 super.getNewValue(p,v) ;
200 }) ;
204 * This property can be void, so if old value is <code> null </code>
205 * new value must be specified.
207 public void _FormatKey() {
208 testProperty("FormatKey", new PropertyTester() {
209 protected Object getNewValue(String p, Object v) {
210 return utils.isVoid(v) ? new Integer(0) :
211 super.getNewValue(p,v) ;
213 }) ;
217 * This property can be void, so if old value is <code> null </code>
218 * new value must be specified.
220 public void _StrictFromat() {
221 testProperty("StrictFromat", new PropertyTester() {
222 protected Object getNewValue(String p, Object v) {
223 return utils.isVoid(v) ? new Boolean(true) :
224 super.getNewValue(p,v) ;
226 }) ;
230 * This property can be void, so if old value is <code> null </code>
231 * new value must be specified.
233 public void _Tabstop() {
234 testProperty("Tabstop", new PropertyTester() {
235 protected Object getNewValue(String p, Object v) {
236 return utils.isVoid(v) ? new Boolean(true) :
237 null ;
239 }) ;
243 * This property can be void, so if old value is <code> null </code>
244 * new value must be specified.
246 public void _Text() {
247 testProperty("Text", new PropertyTester() {
248 protected Object getNewValue(String p, Object v) {
249 return utils.isVoid(v) ? "UnoControlFormattedFieldModel" :
250 super.getNewValue(p,v) ;
252 }) ;