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.XTimeField;
30  
31  /**
32  * Testing <code>com.sun.star.awt.XTimeField</code>
33  * interface methods :
34  * <ul>
35  *  <li><code> setTime()</code></li>
36  *  <li><code> getTime()</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> setEmpty()</code></li>
46  *  <li><code> isEmpty()</code></li>
47  *  <li><code> setStrictFormat()</code></li>
48  *  <li><code> isStrictFormat()</code></li>
49  * </ul> <p>
50  * Test is <b> NOT </b> multithread compilant. <p>
51  * @see com.sun.star.awt.XTimeField
52  */
53  public class _XTimeField extends MultiMethodTest {
54  
55      public XTimeField oObj = null;
56      private boolean strict = false ;
57  
58      /**
59      * Sets a new value and checks if it was correctly set. <p>
60      * Has <b> OK </b> status if set and get values are equal.
61      * The following method tests are to be completed successfully before :
62      * <ul>
63      *  <li> <code> getTime </code> </li>
64      * </ul>
65      */
_setTime()66      public void _setTime() {
67          requiredMethod("getTime()") ;
68  
69          boolean result = true ;
70          oObj.setTime(11150000) ;
71  
72          result = oObj.getTime() == 11150000 ;
73  
74          if (! result ) {
75              System.out.println("Getting "+oObj.getTime()+ " expected 11150000");
76          }
77  
78          tRes.tested("setTime()", result) ;
79      }
80  
81      /**
82      * Gets the current value. <p>
83      * Has <b> OK </b> status if no runtime exceptions occured
84      */
_getTime()85      public void _getTime() {
86  
87          boolean result = true ;
88          oObj.getTime() ;
89  
90          tRes.tested("getTime()", result) ;
91      }
92  
93      /**
94      * Sets a new value and checks if it was correctly set. <p>
95      * Has <b> OK </b> status if set and get values are equal.
96      * The following method tests are to be completed successfully before :
97      * <ul>
98      *  <li> <code> getMin </code> </li>
99      * </ul>
100      */
_setMin()101      public void _setMin() {
102  
103          boolean result = true ;
104          oObj.setMin(4978) ;
105  
106          result = oObj.getMin() == 4978 ;
107  
108          tRes.tested("setMin()", result) ;
109      }
110  
111      /**
112      * Gets the current value. <p>
113      * Has <b> OK </b> status if no runtime exceptions occured
114      */
_getMin()115      public void _getMin() {
116  
117          boolean result = true ;
118          oObj.getMin() ;
119  
120          tRes.tested("getMin()", result) ;
121      }
122  
123      /**
124      * Sets a new value and checks if it was correctly set. <p>
125      * Has <b> OK </b> status if set and get values are equal.
126      * The following method tests are to be completed successfully before :
127      * <ul>
128      *  <li> <code> getMax </code> </li>
129      * </ul>
130      */
_setMax()131      public void _setMax() {
132  
133          boolean result = true ;
134          oObj.setMax(27856) ;
135  
136          result = oObj.getMax() == 27856 ;
137  
138          tRes.tested("setMax()", result) ;
139      }
140  
141      /**
142      * Gets the current value. <p>
143      * Has <b> OK </b> status if no runtime exceptions occured
144      */
_getMax()145      public void _getMax() {
146  
147          boolean result = true ;
148          oObj.getMax() ;
149  
150          tRes.tested("getMax()", result) ;
151      }
152  
153      /**
154      * Sets a new value and checks if it was correctly set. <p>
155      * Has <b> OK </b> status if set and get values are equal.
156      * The following method tests are to be completed successfully before :
157      * <ul>
158      *  <li> <code> getFirst </code> </li>
159      * </ul>
160      */
_setFirst()161      public void _setFirst() {
162  
163          boolean result = true ;
164          oObj.setFirst(5118) ;
165  
166          result = oObj.getFirst() == 5118 ;
167  
168          if (!result) {
169              log.println("Set to " + 5118 + " but returned " + oObj.getFirst()) ;
170          }
171  
172          tRes.tested("setFirst()", result) ;
173      }
174  
175      /**
176      * Gets the current value. <p>
177      * Has <b> OK </b> status if no runtime exceptions occured
178      */
_getFirst()179      public void _getFirst() {
180  
181          boolean result = true ;
182          int val = oObj.getFirst() ;
183  
184          log.println("getFirst() = " + val) ;
185  
186          tRes.tested("getFirst()", result) ;
187      }
188  
189      /**
190      * Sets a new value and checks if it was correctly set. <p>
191      * Has <b> OK </b> status if set and get values are equal.
192      * The following method tests are to be completed successfully before :
193      * <ul>
194      *  <li> <code> getLast </code> </li>
195      * </ul>
196      */
_setLast()197      public void _setLast() {
198  
199          boolean result = true ;
200          oObj.setLast(23450) ;
201  
202          result = oObj.getLast() == 23450 ;
203  
204          if (!result) {
205              log.println("Set to " + 23450 + " but returned " + oObj.getLast()) ;
206          }
207  
208          tRes.tested("setLast()", result) ;
209      }
210  
211      /**
212      * Gets the current value. <p>
213      * Has <b> OK </b> status if no runtime exceptions occured
214      */
_getLast()215      public void _getLast() {
216  
217          boolean result = true ;
218          int val = oObj.getLast() ;
219  
220          log.println("getLast() = " + val) ;
221  
222          tRes.tested("getLast()", result) ;
223      }
224  
225      /**
226      * Sets the value to empty. <p>
227      * Has <b> OK </b> status if no runtime exceptions occured
228      * The following method tests are to be completed successfully before :
229      * <ul>
230      *  <li> <code> setTime </code> : value must be not empty </li>
231      * </ul>
232      */
_setEmpty()233      public void _setEmpty() {
234          requiredMethod("setTime()") ;
235  
236          boolean result = true ;
237          oObj.setEmpty() ;
238  
239          tRes.tested("setEmpty()", result) ;
240      }
241  
242      /**
243      * Checks if the field is empty. <p>
244      * Has <b> OK </b> status if the value is empty.<p>
245      * The following method tests are to be completed successfully before :
246      * <ul>
247      *  <li> <code> setEmpty() </code>  </li>
248      * </ul>
249      */
_isEmpty()250      public void _isEmpty() {
251          requiredMethod("setEmpty()") ;
252  
253          boolean result = true ;
254          result = oObj.isEmpty() ;
255  
256          tRes.tested("isEmpty()", result) ;
257      }
258  
259      /**
260      * Checks strict state. <p>
261      * Has <b> OK </b> status if strict format is set.
262      * The following method tests are to be completed successfully before :
263      * <ul>
264      *  <li> <code> isStrictFormat </code> </li>
265      * </ul>
266      */
_setStrictFormat()267      public void _setStrictFormat() {
268          requiredMethod("isStrictFormat()") ;
269  
270          boolean result = true ;
271          oObj.setStrictFormat(!strict) ;
272  
273          result = oObj.isStrictFormat() == !strict ;
274  
275          tRes.tested("setStrictFormat()", result) ;
276      }
277  
278      /**
279      * Gets strict state and stores it. <p>
280      * Has <b> OK </b> status if no runtime exceptions occured.
281      */
_isStrictFormat()282      public void _isStrictFormat() {
283  
284          boolean result = true ;
285          strict = oObj.isStrictFormat() ;
286  
287          tRes.tested("isStrictFormat()", result) ;
288      }
289  }
290  
291  
292