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", Double
.valueOf(5.8),Double
.valueOf(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", Double
.valueOf(5.8),Double
.valueOf(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
) ? Double
.valueOf(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
) {
178 System
.out
.println("caught exception: " + e
);
186 * This property can be void, so if old value is <code> null </code>
187 * new value must be specified.
189 public void _EffectiveMin() {
190 testProperty("EffectiveMin", new PropertyTester() {
192 protected Object
getNewValue(String p
, Object v
) {
193 return utils
.isVoid(v
) ? Double
.valueOf(0.1) :
194 super.getNewValue(p
,v
) ;
200 * This property can be void, so if old value is <code> null </code>
201 * new value must be specified.
203 public void _FormatKey() {
204 testProperty("FormatKey", new PropertyTester() {
206 protected Object
getNewValue(String p
, Object v
) {
207 return utils
.isVoid(v
) ? Integer
.valueOf(0) :
208 super.getNewValue(p
,v
) ;
214 * This property can be void, so if old value is <code> null </code>
215 * new value must be specified.
217 public void _StrictFromat() {
218 testProperty("StrictFromat", new PropertyTester() {
220 protected Object
getNewValue(String p
, Object v
) {
221 return utils
.isVoid(v
) ? Boolean
.TRUE
:
222 super.getNewValue(p
,v
) ;
228 * This property can be void, so if old value is <code> null </code>
229 * new value must be specified.
231 public void _Tabstop() {
232 testProperty("Tabstop", new PropertyTester() {
234 protected Object
getNewValue(String p
, Object v
) {
235 return utils
.isVoid(v
) ? Boolean
.TRUE
:
242 * This property can be void, so if old value is <code> null </code>
243 * new value must be specified.
245 public void _Text() {
246 testProperty("Text", new PropertyTester() {
248 protected Object
getNewValue(String p
, Object v
) {
249 return utils
.isVoid(v
) ?
"UnoControlFormattedFieldModel" :
250 super.getNewValue(p
,v
) ;