Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _UnoControlDateFieldModel.java
blobe0918f9e9461d633d97b35cb46919b7986c1e233
1 /*
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 .
19 package ifc.awt;
21 import lib.MultiPropertyTest;
22 import util.utils;
25 * Testing <code>com.sun.star.awt.UnoControlDateFieldModel</code>
26 * service properties :
27 * <ul>
28 * <li><code> BackgroundColor</code></li>
29 * <li><code> Border</code></li>
30 * <li><code> Date</code></li>
31 * <li><code> DateMax</code></li>
32 * <li><code> DateMin</code></li>
33 * <li><code> DefaultControl</code></li>
34 * <li><code> Enabled</code></li>
35 * <li><code> DateFormat</code></li>
36 * <li><code> FontDescriptor</code></li>
37 * <li><code> Printable</code></li>
38 * <li><code> ReadOnly</code></li>
39 * <li><code> Spin</code></li>
40 * <li><code> StrictFormat</code></li>
41 * <li><code> Tabstop</code></li>
42 * <li><code> TextColor</code></li>
43 * </ul>
44 * Almost all properties testing is automated by
45 * <code>lib.MultiPropertyTest</code>.
46 * @see com.sun.star.awt.UnoControlDateFieldModel
48 public class _UnoControlDateFieldModel extends MultiPropertyTest {
50 /**
51 * This property can be void, so if old value is <code> null </code>
52 * new value must be specified.
54 public void _BackgroundColor() {
55 testProperty("BackgroundColor", new PropertyTester() {
56 @Override
57 protected Object getNewValue(String prop, Object old) {
58 return utils.isVoid(old) ? Integer.valueOf(6543) : null ;
60 }) ;
63 /**
64 * This property can be VOID, and in case if it is so new
65 * value must defined.
67 public void _BorderColor() {
68 testProperty("BorderColor", new PropertyTester() {
69 @Override
70 protected Object getNewValue(String p, Object old) {
71 return utils.isVoid(old) ? Integer.valueOf(1234) : null ;
73 }) ;
77 /**
78 * This property can be void, so if old value is <code> null </code>
79 * new value must be specified.
81 public void _Date() {
82 testProperty("Date", new PropertyTester() {
83 @Override
84 protected Object getNewValue(String prop, Object old) {
85 return utils.isVoid(old) ? Integer.valueOf(6543) :
86 super.getNewValue(prop, old) ;
88 }) ;
91 /**
92 * This property can be void, so if old value is <code> null </code>
93 * new value must be specified.
95 public void _Tabstop() {
96 testProperty("Tabstop", new PropertyTester() {
97 @Override
98 protected Object getNewValue(String prop, Object old) {
99 return utils.isVoid(old) ? Boolean.TRUE : null ;
101 }) ;
105 * This property can be void, so if old value is <code> null </code>
106 * new value must be specified.
108 public void _TextColor() {
109 testProperty("TextColor", new PropertyTester() {
110 @Override
111 protected Object getNewValue(String prop, Object old) {
112 return utils.isVoid(old) ? Integer.valueOf(123) : null ;
114 }) ;
118 * Redefined method returns value, that differs from property value.
120 protected PropertyTester ColorTester = new PropertyTester() {
121 @Override
122 protected Object getNewValue(String propName, Object oldValue) {
123 if (util.ValueComparer.equalValue(oldValue, Integer.valueOf(17)))
124 return Integer.valueOf(25);
125 else
126 return Integer.valueOf(17);
131 * This property can be void, so if old value is <code> null </code>
132 * new value must be specified.
134 public void _TextLineColor() {
135 log.println("Testing with custom Property tester") ;
136 testProperty("TextLineColor", ColorTester) ;
139 public void _DateShowCentury() {
140 boolean res = false;
141 try {
142 util.dbg.printPropertyInfo(oObj,"DateShowCentury",log);
143 Object oDsc = oObj.getPropertyValue("DateShowCentury");
144 Boolean dsc = null;
145 if (util.utils.isVoid(oDsc)) {
146 log.println("Property is void, set it to true");
147 dsc = Boolean.TRUE;
148 } else {
149 dsc = (Boolean) oDsc;
150 dsc = Boolean.valueOf(!dsc.booleanValue());
151 log.println("Setting property to "+dsc);
153 oObj.setPropertyValue("DateShowCentury",dsc);
154 Boolean getdsc = (Boolean) oObj.getPropertyValue("DateShowCentury");
155 log.println("Getting value "+getdsc);
156 res = dsc.equals(getdsc);
157 } catch (com.sun.star.beans.UnknownPropertyException upe) {
158 log.println("Don't know the Property 'DateShowCentury'");
159 } catch (com.sun.star.lang.WrappedTargetException wte) {
160 log.println("WrappedTargetException while getting Property 'DateShowCentury'");
161 } catch (com.sun.star.lang.IllegalArgumentException iae) {
162 log.println("IllegalArgumentException while getting Property 'DateShowCentury'");
163 } catch (com.sun.star.beans.PropertyVetoException pve) {
164 log.println("PropertyVetoException while getting Property 'DateShowCentury'");
166 tRes.tested("DateShowCentury",res);