merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / ifc / awt / _XPatternField.java
blob8c24a224c6e4a5956608e0e6d2738cc3a805f1d4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XPatternField.java,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package ifc.awt;
34 import lib.MultiMethodTest;
36 import com.sun.star.awt.XPatternField;
38 /**
39 * Testing <code>com.sun.star.awt.XPatternField</code>
40 * interface methods :
41 * <ul>
42 * <li><code> setMasks()</code></li>
43 * <li><code> getMasks()</code></li>
44 * <li><code> setString()</code></li>
45 * <li><code> getString()</code></li>
46 * <li><code> setStrictFormat()</code></li>
47 * <li><code> isStrictFormat()</code></li>
48 * </ul> <p>
49 * Test is <b> NOT </b> multithread compilant. <p>
50 * @see com.sun.star.awt.XPatternField
52 public class _XPatternField extends MultiMethodTest {
54 public XPatternField oObj = null ;
55 private String editMask = null ;
56 private String literalMask = null ;
57 private String string = null ;
58 private boolean strict = false ;
60 /**
61 * Sets masks to new values then gets them and compare. <p>
62 * Has <b> OK </b> status if set and get masks are equal. <p>
63 * The following method tests are to be completed successfully before :
64 * <ul>
65 * <li> <code> getMasks </code> </li>
66 * </ul>
68 public void _setMasks() {
69 requiredMethod("getMasks()") ;
71 boolean result = true ;
72 String newEdit = editMask == null ? "ccc" : editMask + "ccc" ;
73 String newLiteral = literalMask == null ? " " : literalMask + " " ;
74 oObj.setMasks(newEdit, newLiteral) ;
76 String[] edit = new String[1] ;
77 String[] literal = new String[1] ;
78 oObj.getMasks(edit, literal) ;
80 result &= newEdit.equals(edit[0]) ;
81 result &= newLiteral.equals(literal[0]) ;
83 tRes.tested("setMasks()", result) ;
86 /**
87 * Gets masks and stores them. <p>
88 * Has <b> OK </b> status if no runtime exceptions occured.
90 public void _getMasks() {
92 boolean result = true ;
93 String[] edit = new String[1] ;
94 String[] literal = new String[1] ;
95 oObj.getMasks(edit, literal) ;
97 log.println("Edit mask = '" + edit[0] + "', literal = '" +
98 literal[0] + "'") ;
100 editMask = edit[0] ;
101 literalMask = literal[0] ;
103 tRes.tested("getMasks()", result) ;
107 * Sets new string and then get it for verification. <p>
108 * Has <b> OK </b> status if get and set strings are equal. <p>
109 * The following method tests are to be completed successfully before :
110 * <ul>
111 * <li> <code> getString </code> </li>
112 * <li> <code> setMasks </code> : mask must be set for new string
113 * would be valid. </li>
114 * </ul>
116 public void _setString() {
117 requiredMethod("setMasks()") ;
118 requiredMethod("getString()") ;
120 boolean result = true ;
121 String newString = string = "abc" ;
122 oObj.setString(newString) ;
123 String getString = oObj.getString() ;
125 result = newString.equals(getString) ;
127 if (!result) {
128 log.println("Was '" + string + "', Set '" + newString
129 + "', Get '" + getString + "'") ;
132 tRes.tested("setString()", result) ;
136 * Gets current string and stores it. <p>
137 * Has <b> OK </b> status if no runtime exceptions occured
139 public void _getString() {
141 boolean result = true ;
142 string = oObj.getString() ;
144 tRes.tested("getString()", result) ;
148 * Sets new strict state then checks it. <p>
149 * Has <b> OK </b> status if the state was changed.
150 * The following method tests are to be completed successfully before :
151 * <ul>
152 * <li> <code> isStrictFormat </code> </li>
153 * </ul>
155 public void _setStrictFormat() {
156 requiredMethod("isStrictFormat()") ;
158 boolean result = true ;
159 oObj.setStrictFormat(!strict) ;
161 result = oObj.isStrictFormat() == !strict ;
163 tRes.tested("setStrictFormat()", result) ;
167 * Gets the current strict state and stores it. <p>
168 * Has <b> OK </b> status if no runtime exceptions occured.
170 public void _isStrictFormat() {
172 boolean result = true ;
173 strict = oObj.isStrictFormat() ;
175 tRes.tested("isStrictFormat()", result) ;