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.XPatternField; 34 35 /** 36 * Testing <code>com.sun.star.awt.XPatternField</code> 37 * interface methods : 38 * <ul> 39 * <li><code> setMasks()</code></li> 40 * <li><code> getMasks()</code></li> 41 * <li><code> setString()</code></li> 42 * <li><code> getString()</code></li> 43 * <li><code> setStrictFormat()</code></li> 44 * <li><code> isStrictFormat()</code></li> 45 * </ul> <p> 46 * Test is <b> NOT </b> multithread compilant. <p> 47 * @see com.sun.star.awt.XPatternField 48 */ 49 public class _XPatternField extends MultiMethodTest { 50 51 public XPatternField oObj = null ; 52 private String editMask = null ; 53 private String literalMask = null ; 54 private String string = null ; 55 private boolean strict = false ; 56 57 /** 58 * Sets masks to new values then gets them and compare. <p> 59 * Has <b> OK </b> status if set and get masks are equal. <p> 60 * The following method tests are to be completed successfully before : 61 * <ul> 62 * <li> <code> getMasks </code> </li> 63 * </ul> 64 */ 65 public void _setMasks() { 66 requiredMethod("getMasks()") ; 67 68 boolean result = true ; 69 String newEdit = editMask == null ? "ccc" : editMask + "ccc" ; 70 String newLiteral = literalMask == null ? " " : literalMask + " " ; 71 oObj.setMasks(newEdit, newLiteral) ; 72 73 String[] edit = new String[1] ; 74 String[] literal = new String[1] ; 75 oObj.getMasks(edit, literal) ; 76 77 result &= newEdit.equals(edit[0]) ; 78 result &= newLiteral.equals(literal[0]) ; 79 80 tRes.tested("setMasks()", result) ; 81 } 82 83 /** 84 * Gets masks and stores them. <p> 85 * Has <b> OK </b> status if no runtime exceptions occured. 86 */ 87 public void _getMasks() { 88 89 boolean result = true ; 90 String[] edit = new String[1] ; 91 String[] literal = new String[1] ; 92 oObj.getMasks(edit, literal) ; 93 94 log.println("Edit mask = '" + edit[0] + "', literal = '" + 95 literal[0] + "'") ; 96 97 editMask = edit[0] ; 98 literalMask = literal[0] ; 99 100 tRes.tested("getMasks()", result) ; 101 } 102 103 /** 104 * Sets new string and then get it for verification. <p> 105 * Has <b> OK </b> status if get and set strings are equal. <p> 106 * The following method tests are to be completed successfully before : 107 * <ul> 108 * <li> <code> getString </code> </li> 109 * <li> <code> setMasks </code> : mask must be set for new string 110 * would be valid. </li> 111 * </ul> 112 */ 113 public void _setString() { 114 requiredMethod("setMasks()") ; 115 requiredMethod("getString()") ; 116 117 boolean result = true ; 118 String newString = string = "abc" ; 119 oObj.setString(newString) ; 120 String getString = oObj.getString() ; 121 122 result = newString.equals(getString) ; 123 124 if (!result) { 125 log.println("Was '" + string + "', Set '" + newString 126 + "', Get '" + getString + "'") ; 127 } 128 129 tRes.tested("setString()", result) ; 130 } 131 132 /** 133 * Gets current string and stores it. <p> 134 * Has <b> OK </b> status if no runtime exceptions occured 135 */ 136 public void _getString() { 137 138 boolean result = true ; 139 string = oObj.getString() ; 140 141 tRes.tested("getString()", result) ; 142 } 143 144 /** 145 * Sets new strict state then checks it. <p> 146 * Has <b> OK </b> status if the state was changed. 147 * The following method tests are to be completed successfully before : 148 * <ul> 149 * <li> <code> isStrictFormat </code> </li> 150 * </ul> 151 */ 152 public void _setStrictFormat() { 153 requiredMethod("isStrictFormat()") ; 154 155 boolean result = true ; 156 oObj.setStrictFormat(!strict) ; 157 158 result = oObj.isStrictFormat() == !strict ; 159 160 tRes.tested("setStrictFormat()", result) ; 161 } 162 163 /** 164 * Gets the current strict state and stores it. <p> 165 * Has <b> OK </b> status if no runtime exceptions occured. 166 */ 167 public void _isStrictFormat() { 168 169 boolean result = true ; 170 strict = oObj.isStrictFormat() ; 171 172 tRes.tested("isStrictFormat()", result) ; 173 } 174 } 175 176 177