1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.awt;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir 
27cdf0e10cSrcweir import lib.MultiMethodTest;
28cdf0e10cSrcweir 
29cdf0e10cSrcweir import com.sun.star.awt.XPatternField;
30cdf0e10cSrcweir 
31cdf0e10cSrcweir /**
32cdf0e10cSrcweir * Testing <code>com.sun.star.awt.XPatternField</code>
33cdf0e10cSrcweir * interface methods :
34cdf0e10cSrcweir * <ul>
35cdf0e10cSrcweir *  <li><code> setMasks()</code></li>
36cdf0e10cSrcweir *  <li><code> getMasks()</code></li>
37cdf0e10cSrcweir *  <li><code> setString()</code></li>
38cdf0e10cSrcweir *  <li><code> getString()</code></li>
39cdf0e10cSrcweir *  <li><code> setStrictFormat()</code></li>
40cdf0e10cSrcweir *  <li><code> isStrictFormat()</code></li>
41cdf0e10cSrcweir * </ul> <p>
42cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p>
43cdf0e10cSrcweir * @see com.sun.star.awt.XPatternField
44cdf0e10cSrcweir */
45cdf0e10cSrcweir public class _XPatternField extends MultiMethodTest {
46cdf0e10cSrcweir 
47cdf0e10cSrcweir     public XPatternField oObj = null ;
48cdf0e10cSrcweir     private String editMask = null ;
49cdf0e10cSrcweir     private String literalMask = null ;
50cdf0e10cSrcweir     private String string = null ;
51cdf0e10cSrcweir     private boolean strict = false ;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     /**
54cdf0e10cSrcweir     * Sets masks to new values then gets them and compare. <p>
55cdf0e10cSrcweir     * Has <b> OK </b> status if set and get masks are equal. <p>
56cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
57cdf0e10cSrcweir     * <ul>
58cdf0e10cSrcweir     *  <li> <code> getMasks </code> </li>
59cdf0e10cSrcweir     * </ul>
60cdf0e10cSrcweir     */
_setMasks()61cdf0e10cSrcweir     public void _setMasks() {
62cdf0e10cSrcweir         requiredMethod("getMasks()") ;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir         boolean result = true ;
65cdf0e10cSrcweir         String newEdit = editMask == null ? "ccc" : editMask + "ccc" ;
66cdf0e10cSrcweir         String newLiteral = literalMask == null ? " " : literalMask + " " ;
67cdf0e10cSrcweir         oObj.setMasks(newEdit, newLiteral) ;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir         String[] edit = new String[1] ;
70cdf0e10cSrcweir         String[] literal = new String[1] ;
71cdf0e10cSrcweir         oObj.getMasks(edit, literal) ;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         result &= newEdit.equals(edit[0]) ;
74cdf0e10cSrcweir         result &= newLiteral.equals(literal[0]) ;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir         tRes.tested("setMasks()", result) ;
77cdf0e10cSrcweir     }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     /**
80cdf0e10cSrcweir     * Gets masks and stores them. <p>
81cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured.
82cdf0e10cSrcweir     */
_getMasks()83cdf0e10cSrcweir     public void _getMasks() {
84cdf0e10cSrcweir 
85cdf0e10cSrcweir         boolean result = true ;
86cdf0e10cSrcweir         String[] edit = new String[1] ;
87cdf0e10cSrcweir         String[] literal = new String[1] ;
88cdf0e10cSrcweir         oObj.getMasks(edit, literal) ;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         log.println("Edit mask = '" + edit[0] + "', literal = '" +
91cdf0e10cSrcweir             literal[0] + "'") ;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         editMask = edit[0] ;
94cdf0e10cSrcweir         literalMask = literal[0] ;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir         tRes.tested("getMasks()", result) ;
97cdf0e10cSrcweir     }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     /**
100cdf0e10cSrcweir     * Sets new string and then get it for verification. <p>
101cdf0e10cSrcweir     * Has <b> OK </b> status if get and set strings are equal. <p>
102cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
103cdf0e10cSrcweir     * <ul>
104cdf0e10cSrcweir     *  <li> <code> getString </code> </li>
105cdf0e10cSrcweir     *  <li> <code> setMasks </code> : mask must be set for new string
106cdf0e10cSrcweir     *   would be valid. </li>
107cdf0e10cSrcweir     * </ul>
108cdf0e10cSrcweir     */
_setString()109cdf0e10cSrcweir     public void _setString() {
110cdf0e10cSrcweir         requiredMethod("setMasks()") ;
111cdf0e10cSrcweir         requiredMethod("getString()") ;
112cdf0e10cSrcweir 
113cdf0e10cSrcweir         boolean result = true ;
114cdf0e10cSrcweir         String newString = string = "abc" ;
115cdf0e10cSrcweir         oObj.setString(newString) ;
116cdf0e10cSrcweir         String getString = oObj.getString() ;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         result = newString.equals(getString) ;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir         if (!result) {
121cdf0e10cSrcweir             log.println("Was '" + string + "', Set '" + newString
122cdf0e10cSrcweir                 + "', Get '" + getString + "'") ;
123cdf0e10cSrcweir         }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         tRes.tested("setString()", result) ;
126cdf0e10cSrcweir     }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     /**
129cdf0e10cSrcweir     * Gets current string and stores it. <p>
130cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured
131cdf0e10cSrcweir     */
_getString()132cdf0e10cSrcweir     public void _getString() {
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         boolean result = true ;
135cdf0e10cSrcweir         string = oObj.getString() ;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         tRes.tested("getString()", result) ;
138cdf0e10cSrcweir     }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     /**
141cdf0e10cSrcweir     * Sets new strict state then checks it. <p>
142cdf0e10cSrcweir     * Has <b> OK </b> status if the state was changed.
143cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
144cdf0e10cSrcweir     * <ul>
145cdf0e10cSrcweir     *  <li> <code> isStrictFormat </code> </li>
146cdf0e10cSrcweir     * </ul>
147cdf0e10cSrcweir     */
_setStrictFormat()148cdf0e10cSrcweir     public void _setStrictFormat() {
149cdf0e10cSrcweir         requiredMethod("isStrictFormat()") ;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         boolean result = true ;
152cdf0e10cSrcweir         oObj.setStrictFormat(!strict) ;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         result = oObj.isStrictFormat() == !strict ;
155cdf0e10cSrcweir 
156cdf0e10cSrcweir         tRes.tested("setStrictFormat()", result) ;
157cdf0e10cSrcweir     }
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     /**
160cdf0e10cSrcweir     * Gets the current strict state and stores it. <p>
161cdf0e10cSrcweir     * Has <b> OK </b> status if no runtime exceptions occured.
162cdf0e10cSrcweir     */
_isStrictFormat()163cdf0e10cSrcweir     public void _isStrictFormat() {
164cdf0e10cSrcweir 
165cdf0e10cSrcweir         boolean result = true ;
166cdf0e10cSrcweir         strict = oObj.isStrictFormat() ;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         tRes.tested("isStrictFormat()", result) ;
169cdf0e10cSrcweir     }
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 
173