merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / awt / _UnoControlDateFieldModel.java
blob6d3b8a1502b4148a3f506419e70ba88a4afc6e02
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: _UnoControlDateFieldModel.java,v $
10 * $Revision: 1.5 $
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;
37 * Testing <code>com.sun.star.awt.UnoControlDateFieldModel</code>
38 * service properties :
39 * <ul>
40 * <li><code> BackgroundColor</code></li>
41 * <li><code> Border</code></li>
42 * <li><code> Date</code></li>
43 * <li><code> DateMax</code></li>
44 * <li><code> DateMin</code></li>
45 * <li><code> DefaultControl</code></li>
46 * <li><code> Enabled</code></li>
47 * <li><code> DateFormat</code></li>
48 * <li><code> FontDescriptor</code></li>
49 * <li><code> Printable</code></li>
50 * <li><code> ReadOnly</code></li>
51 * <li><code> Spin</code></li>
52 * <li><code> StrictFormat</code></li>
53 * <li><code> Tabstop</code></li>
54 * <li><code> TextColor</code></li>
55 * </ul>
56 * Almost all properties testing is automated by
57 * <code>lib.MultiPropertyTest</code>.
58 * @see com.sun.star.awt.UnoControlDateFieldModel
60 public class _UnoControlDateFieldModel extends MultiPropertyTest {
62 /**
63 * This property can be void, so if old value is <code> null </code>
64 * new value must be specified.
66 public void _BackgroundColor() {
67 testProperty("BackgroundColor", new PropertyTester() {
68 protected Object getNewValue(String prop, Object old) {
69 return utils.isVoid(old) ? new Integer(6543) : null ;
71 }) ;
74 /**
75 * This property can be VOID, and in case if it is so new
76 * value must defined.
78 public void _BorderColor() {
79 testProperty("BorderColor", new PropertyTester() {
80 protected Object getNewValue(String p, Object old) {
81 return utils.isVoid(old) ? new Integer(1234) : null ;
83 }) ;
87 /**
88 * This property can be void, so if old value is <code> null </code>
89 * new value must be specified.
91 public void _Date() {
92 testProperty("Date", new PropertyTester() {
93 protected Object getNewValue(String prop, Object old) {
94 return utils.isVoid(old) ? new Integer(6543) :
95 super.getNewValue(prop, old) ;
97 }) ;
101 * This property can be void, so if old value is <code> null </code>
102 * new value must be specified.
104 public void _Tabstop() {
105 testProperty("Tabstop", new PropertyTester() {
106 protected Object getNewValue(String prop, Object old) {
107 return utils.isVoid(old) ? new Boolean(true) : null ;
109 }) ;
113 * This property can be void, so if old value is <code> null </code>
114 * new value must be specified.
116 public void _TextColor() {
117 testProperty("TextColor", new PropertyTester() {
118 protected Object getNewValue(String prop, Object old) {
119 return utils.isVoid(old) ? new Integer(123) : null ;
121 }) ;
125 * Redefined method returns value, that differs from property value.
127 protected PropertyTester ColorTester = new PropertyTester() {
128 protected Object getNewValue(String propName, Object oldValue) {
129 if (util.ValueComparer.equalValue(oldValue, new Integer(17)))
130 return new Integer(25);
131 else
132 return new Integer(17);
137 * This property can be void, so if old value is <code> null </code>
138 * new value must be specified.
140 public void _TextLineColor() {
141 log.println("Testing with custom Property tester") ;
142 testProperty("TextLineColor", ColorTester) ;
145 public void _DateShowCentury() {
146 boolean res = false;
147 try {
148 util.dbg.printPropertyInfo(oObj,"DateShowCentury",log);
149 Object oDsc = oObj.getPropertyValue("DateShowCentury");
150 Boolean dsc = null;
151 if (util.utils.isVoid(oDsc)) {
152 log.println("Property is void, set it to true");
153 dsc = new Boolean(true);
154 } else {
155 dsc = (Boolean) oDsc;
156 dsc = new Boolean(!dsc.booleanValue());
157 log.println("Setting property to "+dsc);
159 oObj.setPropertyValue("DateShowCentury",dsc);
160 Boolean getdsc = (Boolean) oObj.getPropertyValue("DateShowCentury");
161 log.println("Getting value "+getdsc);
162 res = dsc.equals(getdsc);
163 } catch (com.sun.star.beans.UnknownPropertyException upe) {
164 log.println("Don't know the Property 'DateShowCentury'");
165 } catch (com.sun.star.lang.WrappedTargetException wte) {
166 log.println("WrappedTargetException while getting Property 'DateShowCentury'");
167 } catch (com.sun.star.lang.IllegalArgumentException iae) {
168 log.println("IllegalArgumentException while getting Property 'DateShowCentury'");
169 } catch (com.sun.star.beans.PropertyVetoException pve) {
170 log.println("PropertyVetoException while getting Property 'DateShowCentury'");
172 tRes.tested("DateShowCentury",res);