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