2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiPropertyTest
;
25 * Testing <code>com.sun.star.awt.UnoControlFormattedFieldModel</code>
26 * service properties :
28 * <li><code> Align</code></li>
29 * <li><code> BackgroundColor</code></li>
30 * <li><code> Border</code></li>
31 * <li><code> DefaultControl</code></li>
32 * <li><code> EffectiveDefault</code></li>
33 * <li><code> EffectiveMax</code></li>
34 * <li><code> EffectiveMin</code></li>
35 * <li><code> EffectiveValue</code></li>
36 * <li><code> Enabled</code></li>
37 * <li><code> FontDescriptor</code></li>
38 * <li><code> FormatKey</code></li>
39 * <li><code> FormatsSupplier</code></li>
40 * <li><code> MaxTextLen</code></li>
41 * <li><code> Printable</code></li>
42 * <li><code> ReadOnly</code></li>
43 * <li><code> Spin</code></li>
44 * <li><code> StrictFormat</code></li>
45 * <li><code> Tabstop</code></li>
46 * <li><code> Text</code></li>
47 * <li><code> TextColor</code></li>
48 * <li><code> HelpText</code></li>
49 * <li><code> HelpURL</code></li>
51 * Properties testing is automated by <code>lib.MultiPropertyTest</code>.
52 * @see com.sun.star.awt.UnoControlFormattedFieldModel
54 public class _UnoControlFormattedFieldModel
extends MultiPropertyTest
{
57 * Redefined method must return a valid service name, that differs from
61 protected PropertyTester ControlTester
= new PropertyTester() {
63 protected Object
getNewValue(String propName
, Object oldValue
) {
64 if (util
.ValueComparer
.equalValue(oldValue
,
65 "com.sun.star.form.control.FormattedField"))
66 return "com.sun.star.awt.UnoControlFormattedField";
68 return "com.sun.star.form.control.FormattedField";
73 * This property must contain a valid service name.
75 public void _DefaultControl() {
76 log
.println("Testing with custom Property tester") ;
77 testProperty("DefaultControl", ControlTester
) ;
81 * This property can be VOID, and in case if it is so new
84 public void _BorderColor() {
85 testProperty("BorderColor", new PropertyTester() {
87 protected Object
getNewValue(String p
, Object old
) {
88 return utils
.isVoid(old
) ? Integer
.valueOf(1234) : null ;
94 * This property can be void, so if old value is <code> null </code>
95 * new value must be specified.
97 public void _TextColor() {
98 testProperty("TextColor", new PropertyTester() {
100 protected Object
getNewValue(String p
, Object v
) {
101 return utils
.isVoid(v
) ? Integer
.valueOf(123) :
102 super.getNewValue(p
,v
) ;
108 * This property can be void, so if old value is <code> null </code>
109 * new value must be specified.
111 public void _TextLineColor() {
112 testProperty("TextLineColor", new PropertyTester() {
114 protected Object
getNewValue(String p
, Object v
) {
115 return utils
.isVoid(v
) ? Integer
.valueOf(123) :
116 super.getNewValue(p
,v
) ;
122 * This property can be void, so if old value is <code> null </code>
123 * new value must be specified.
125 public void _BackgroundColor() {
126 testProperty("BackgroundColor", new PropertyTester() {
128 protected Object
getNewValue(String p
, Object v
) {
129 return utils
.isVoid(v
) ? Integer
.valueOf(123) :
130 super.getNewValue(p
,v
) ;
136 * This property can be void, so if old value is <code> null </code>
137 * new value must be specified.
139 public void _EffectiveDefault() {
140 testProperty("EffectiveDefault", new Double(5.8),new Double(2.3)) ;
144 * This property can be void, so if old value is <code> null </code>
145 * new value must be specified.
147 public void _EffectiveValue() {
148 testProperty("EffectiveValue", new Double(5.8),new Double(2.3)) ;
152 * This property can be void, so if old value is <code> null </code>
153 * new value must be specified.
155 public void _EffectiveMax() {
156 testProperty("EffectiveMax", new PropertyTester() {
158 protected Object
getNewValue(String p
, Object v
) {
159 return utils
.isVoid(v
) ?
new Double(123.8) :
160 super.getNewValue(p
,v
) ;
166 * This property can be void, so if old value is <code> null </code>
167 * new value must be specified.
169 public void _FormatsSupplier() {
170 testProperty("FormatsSupplier", new PropertyTester() {
172 protected Object
getNewValue(String p
, Object v
) {
173 Object newValue
= null;
175 newValue
= tParam
.getMSF().createInstance(
176 "com.sun.star.util.NumberFormatsSupplier");
177 } catch (com
.sun
.star
.uno
.Exception e
) {}
184 * This property can be void, so if old value is <code> null </code>
185 * new value must be specified.
187 public void _EffectiveMin() {
188 testProperty("EffectiveMin", new PropertyTester() {
190 protected Object
getNewValue(String p
, Object v
) {
191 return utils
.isVoid(v
) ?
new Double(0.1) :
192 super.getNewValue(p
,v
) ;
198 * This property can be void, so if old value is <code> null </code>
199 * new value must be specified.
201 public void _FormatKey() {
202 testProperty("FormatKey", new PropertyTester() {
204 protected Object
getNewValue(String p
, Object v
) {
205 return utils
.isVoid(v
) ? Integer
.valueOf(0) :
206 super.getNewValue(p
,v
) ;
212 * This property can be void, so if old value is <code> null </code>
213 * new value must be specified.
215 public void _StrictFromat() {
216 testProperty("StrictFromat", new PropertyTester() {
218 protected Object
getNewValue(String p
, Object v
) {
219 return utils
.isVoid(v
) ? Boolean
.TRUE
:
220 super.getNewValue(p
,v
) ;
226 * This property can be void, so if old value is <code> null </code>
227 * new value must be specified.
229 public void _Tabstop() {
230 testProperty("Tabstop", new PropertyTester() {
232 protected Object
getNewValue(String p
, Object v
) {
233 return utils
.isVoid(v
) ? Boolean
.TRUE
:
240 * This property can be void, so if old value is <code> null </code>
241 * new value must be specified.
243 public void _Text() {
244 testProperty("Text", new PropertyTester() {
246 protected Object
getNewValue(String p
, Object v
) {
247 return utils
.isVoid(v
) ?
"UnoControlFormattedFieldModel" :
248 super.getNewValue(p
,v
) ;