1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.awt;
25 
26 
27 import lib.MultiMethodTest;
28 
29 import com.sun.star.awt.XDateField;
30 
31 /**
32 * Testing <code>com.sun.star.awt.XDateField</code>
33 * interface methods :
34 * <ul>
35 *  <li><code> setDate()</code></li>
36 *  <li><code> getDate()</code></li>
37 *  <li><code> setMin()</code></li>
38 *  <li><code> getMin()</code></li>
39 *  <li><code> setMax()</code></li>
40 *  <li><code> getMax()</code></li>
41 *  <li><code> setFirst()</code></li>
42 *  <li><code> getFirst()</code></li>
43 *  <li><code> setLast()</code></li>
44 *  <li><code> getLast()</code></li>
45 *  <li><code> setLongFormat()</code></li>
46 *  <li><code> isLongFormat()</code></li>
47 *  <li><code> setEmpty()</code></li>
48 *  <li><code> isEmpty()</code></li>
49 *  <li><code> setStrictFormat()</code></li>
50 *  <li><code> isStrictFormat()</code></li>
51 * </ul> <p>
52 * Test is <b> NOT </b> multithread compilant. <p>
53 * @see com.sun.star.awt.XDateField
54 */
55 public class _XDateField extends MultiMethodTest {
56 
57     public XDateField oObj = null;
58 
59     private boolean strict = false ;
60     private boolean longFormat = false ;
61 
62     /**
63     * Sets a new value and checks if it was correctly set. <p>
64     * Has <b> OK </b> status if set and get values are equal.
65     * The following method tests are to be completed successfully before :
66     * <ul>
67     *  <li> <code> getTime </code> </li>
68     * </ul>
69     */
_setDate()70     public void _setDate() {
71         requiredMethod("getDate()") ;
72 
73         boolean result = true ;
74         oObj.setDate(19000101) ;
75 
76         result = oObj.getDate() == 19000101 ;
77 
78         if (! result ) {
79             System.out.println("getDate: "+oObj.getDate()+" , expected 19000101");
80         }
81 
82         tRes.tested("setDate()", result) ;
83     }
84 
85     /**
86     * Gets the current value. <p>
87     * Has <b> OK </b> status if no runtime exceptions occured
88     */
_getDate()89     public void _getDate() {
90 
91         boolean result = true ;
92         oObj.getDate() ;
93 
94         tRes.tested("getDate()", result) ;
95     }
96 
97     /**
98     * Sets a new value and checks if it was correctly set. <p>
99     * Has <b> OK </b> status if set and get values are equal.
100     * The following method tests are to be completed successfully before :
101     * <ul>
102     *  <li> <code> getMin </code> </li>
103     * </ul>
104     */
_setMin()105     public void _setMin() {
106 
107         boolean result = true ;
108         oObj.setMin(4978) ;
109 
110         result = oObj.getMin() == 4978 ;
111 
112         tRes.tested("setMin()", result) ;
113     }
114 
115     /**
116     * Gets the current value. <p>
117     * Has <b> OK </b> status if no runtime exceptions occured
118     */
_getMin()119     public void _getMin() {
120 
121         boolean result = true ;
122         oObj.getMin() ;
123 
124         tRes.tested("getMin()", result) ;
125     }
126 
127     /**
128     * Sets a new value and checks if it was correctly set. <p>
129     * Has <b> OK </b> status if set and get values are equal.
130     * The following method tests are to be completed successfully before :
131     * <ul>
132     *  <li> <code> getMax </code> </li>
133     * </ul>
134     */
_setMax()135     public void _setMax() {
136 
137         boolean result = true ;
138         oObj.setMax(27856) ;
139 
140         result = oObj.getMax() == 27856 ;
141 
142         tRes.tested("setMax()", result) ;
143     }
144 
145     /**
146     * Gets the current value. <p>
147     * Has <b> OK </b> status if no runtime exceptions occured
148     */
_getMax()149     public void _getMax() {
150 
151         boolean result = true ;
152         oObj.getMax() ;
153 
154         tRes.tested("getMax()", result) ;
155     }
156 
157     /**
158     * Sets a new value and checks if it was correctly set. <p>
159     * Has <b> OK </b> status if set and get values are equal.
160     * The following method tests are to be completed successfully before :
161     * <ul>
162     *  <li> <code> getFirst </code> </li>
163     * </ul>
164     */
_setFirst()165     public void _setFirst() {
166 
167         boolean result = true ;
168         oObj.setFirst(5118) ;
169 
170         result = oObj.getFirst() == 5118 ;
171 
172         if (!result) {
173             log.println("Set to " + 5118 + " but returned " + oObj.getFirst()) ;
174         }
175 
176         tRes.tested("setFirst()", result) ;
177     }
178 
179     /**
180     * Gets the current value. <p>
181     * Has <b> OK </b> status if no runtime exceptions occured
182     */
_getFirst()183     public void _getFirst() {
184 
185         boolean result = true ;
186         int val = oObj.getFirst() ;
187 
188         log.println("getFirst() = " + val) ;
189 
190         tRes.tested("getFirst()", result) ;
191     }
192 
193     /**
194     * Sets a new value and checks if it was correctly set. <p>
195     * Has <b> OK </b> status if set and get values are equal.
196     * The following method tests are to be completed successfully before :
197     * <ul>
198     *  <li> <code> getLast </code> </li>
199     * </ul>
200     */
_setLast()201     public void _setLast() {
202 
203         boolean result = true ;
204         oObj.setLast(23450) ;
205 
206         result = oObj.getLast() == 23450 ;
207 
208         if (!result) {
209             log.println("Set to " + 23450 + " but returned " + oObj.getLast()) ;
210         }
211 
212         tRes.tested("setLast()", result) ;
213     }
214 
215     /**
216     * Gets the current value. <p>
217     * Has <b> OK </b> status if no runtime exceptions occured
218     */
_getLast()219     public void _getLast() {
220 
221         boolean result = true ;
222         int val = oObj.getLast() ;
223 
224         log.println("getLast() = " + val) ;
225 
226         tRes.tested("getLast()", result) ;
227     }
228 
229     /**
230     * Sets the value to empty. <p>
231     * Has <b> OK </b> status if no runtime exceptions occured
232     * The following method tests are to be completed successfully before :
233     * <ul>
234     *  <li> <code> setTime </code> : value must be not empty </li>
235     * </ul>
236     */
_setEmpty()237     public void _setEmpty() {
238         requiredMethod("setDate()") ;
239 
240         boolean result = true ;
241         oObj.setEmpty() ;
242 
243         tRes.tested("setEmpty()", result) ;
244     }
245 
246     /**
247     * Checks if the field is empty. <p>
248     * Has <b> OK </b> status if the value is empty.<p>
249     * The following method tests are to be completed successfully before :
250     * <ul>
251     *  <li> <code> setEmpty() </code>  </li>
252     * </ul>
253     */
_isEmpty()254     public void _isEmpty() {
255         requiredMethod("setEmpty()") ;
256 
257         boolean result = true ;
258         result = oObj.isEmpty() ;
259 
260         tRes.tested("isEmpty()", result) ;
261     }
262 
263     /**
264     * Checks strict state. <p>
265     * Has <b> OK </b> status if strict format is properly set.
266     * The following method tests are to be completed successfully before :
267     * <ul>
268     *  <li> <code> isStrictFormat </code> </li>
269     * </ul>
270     */
_setStrictFormat()271     public void _setStrictFormat() {
272         requiredMethod("isStrictFormat()") ;
273 
274         boolean result = true ;
275         oObj.setStrictFormat(!strict) ;
276 
277         result = oObj.isStrictFormat() == !strict ;
278 
279         if (!result) {
280             log.println("Was '" + strict + "', set to '" + !strict +
281                 "' but returned '" + oObj.isStrictFormat() + "'") ;
282         }
283 
284         tRes.tested("setStrictFormat()", result) ;
285     }
286 
287     /**
288     * Gets strict state and stores it. <p>
289     * Has <b> OK </b> status if no runtime exceptions occured.
290     */
_isStrictFormat()291     public void _isStrictFormat() {
292 
293         boolean result = true ;
294         strict = oObj.isStrictFormat() ;
295 
296         tRes.tested("isStrictFormat()", result) ;
297     }
298 
299 
300     /**
301     * Checks long format state. <p>
302     * Has <b> OK </b> status if long format is properly set.
303     * The following method tests are to be completed successfully before :
304     * <ul>
305     *  <li> <code> isLongFormat </code> </li>
306     * </ul>
307     */
_setLongFormat()308     public void _setLongFormat() {
309 
310         boolean result = true ;
311         oObj.setLongFormat(!longFormat) ;
312 
313         result = oObj.isLongFormat() == !longFormat ;
314 
315         if (!result) {
316             log.println("Was '" + longFormat + "', set to '" + !longFormat +
317                 "' but returned '" + oObj.isLongFormat() + "'") ;
318         }
319 
320         tRes.tested("setLongFormat()", result) ;
321     }
322 
323     /**
324     * Gets long format state and stores it. <p>
325     * Has <b> OK </b> status if no runtime exceptions occured.
326     */
_isLongFormat()327     public void _isLongFormat() {
328 
329         boolean result = true ;
330         longFormat = oObj.isLongFormat() ;
331 
332         tRes.tested("isLongFormat()", result) ;
333     }
334 }
335 
336 
337