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