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.XTimeField; 34 35 /** 36 * Testing <code>com.sun.star.awt.XTimeField</code> 37 * interface methods : 38 * <ul> 39 * <li><code> setTime()</code></li> 40 * <li><code> getTime()</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> setEmpty()</code></li> 50 * <li><code> isEmpty()</code></li> 51 * <li><code> setStrictFormat()</code></li> 52 * <li><code> isStrictFormat()</code></li> 53 * </ul> <p> 54 * Test is <b> NOT </b> multithread compilant. <p> 55 * @see com.sun.star.awt.XTimeField 56 */ 57 public class _XTimeField extends MultiMethodTest { 58 59 public XTimeField oObj = null; 60 private boolean strict = 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 */ 70 public void _setTime() { 71 requiredMethod("getTime()") ; 72 73 boolean result = true ; 74 oObj.setTime(11150000) ; 75 76 result = oObj.getTime() == 11150000 ; 77 78 if (! result ) { 79 System.out.println("Getting "+oObj.getTime()+ " expected 11150000"); 80 } 81 82 tRes.tested("setTime()", result) ; 83 } 84 85 /** 86 * Gets the current value. <p> 87 * Has <b> OK </b> status if no runtime exceptions occured 88 */ 89 public void _getTime() { 90 91 boolean result = true ; 92 oObj.getTime() ; 93 94 tRes.tested("getTime()", 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 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 */ 237 public void _setEmpty() { 238 requiredMethod("setTime()") ; 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 */ 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 set. 266 * The following method tests are to be completed successfully before : 267 * <ul> 268 * <li> <code> isStrictFormat </code> </li> 269 * </ul> 270 */ 271 public void _setStrictFormat() { 272 requiredMethod("isStrictFormat()") ; 273 274 boolean result = true ; 275 oObj.setStrictFormat(!strict) ; 276 277 result = oObj.isStrictFormat() == !strict ; 278 279 tRes.tested("setStrictFormat()", result) ; 280 } 281 282 /** 283 * Gets strict state and stores it. <p> 284 * Has <b> OK </b> status if no runtime exceptions occured. 285 */ 286 public void _isStrictFormat() { 287 288 boolean result = true ; 289 strict = oObj.isStrictFormat() ; 290 291 tRes.tested("isStrictFormat()", result) ; 292 } 293 } 294 295 296