Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XPatternField.java
blob1613be4a0c20e19a7c2570686f9e40f36294df7c
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc.awt;
22 import lib.MultiMethodTest;
24 import com.sun.star.awt.XPatternField;
26 /**
27 * Testing <code>com.sun.star.awt.XPatternField</code>
28 * interface methods :
29 * <ul>
30 * <li><code> setMasks()</code></li>
31 * <li><code> getMasks()</code></li>
32 * <li><code> setString()</code></li>
33 * <li><code> getString()</code></li>
34 * <li><code> setStrictFormat()</code></li>
35 * <li><code> isStrictFormat()</code></li>
36 * </ul> <p>
37 * Test is <b> NOT </b> multithread compliant. <p>
38 * @see com.sun.star.awt.XPatternField
40 public class _XPatternField extends MultiMethodTest {
42 public XPatternField oObj = null ;
43 private String editMask = null ;
44 private String literalMask = null ;
45 private String string = null ;
46 private boolean strict = false ;
48 /**
49 * Sets masks to new values then gets them and compare. <p>
50 * Has <b> OK </b> status if set and get masks are equal. <p>
51 * The following method tests are to be completed successfully before :
52 * <ul>
53 * <li> <code> getMasks </code> </li>
54 * </ul>
56 public void _setMasks() {
57 requiredMethod("getMasks()") ;
59 boolean result = true ;
60 String newEdit = editMask == null ? "ccc" : editMask + "ccc" ;
61 String newLiteral = literalMask == null ? " " : literalMask + " " ;
62 oObj.setMasks(newEdit, newLiteral) ;
64 String[] edit = new String[1] ;
65 String[] literal = new String[1] ;
66 oObj.getMasks(edit, literal) ;
68 result &= newEdit.equals(edit[0]) ;
69 result &= newLiteral.equals(literal[0]) ;
71 tRes.tested("setMasks()", result) ;
74 /**
75 * Gets masks and stores them. <p>
76 * Has <b> OK </b> status if no runtime exceptions occurred.
78 public void _getMasks() {
80 boolean result = true ;
81 String[] edit = new String[1] ;
82 String[] literal = new String[1] ;
83 oObj.getMasks(edit, literal) ;
85 log.println("Edit mask = '" + edit[0] + "', literal = '" +
86 literal[0] + "'") ;
88 editMask = edit[0] ;
89 literalMask = literal[0] ;
91 tRes.tested("getMasks()", result) ;
94 /**
95 * Sets new string and then get it for verification. <p>
96 * Has <b> OK </b> status if get and set strings are equal. <p>
97 * The following method tests are to be completed successfully before :
98 * <ul>
99 * <li> <code> getString </code> </li>
100 * <li> <code> setMasks </code> : mask must be set for new string
101 * would be valid. </li>
102 * </ul>
104 public void _setString() {
105 requiredMethod("setMasks()") ;
106 requiredMethod("getString()") ;
108 boolean result = true ;
109 String newString = string = "abc" ;
110 oObj.setString(newString) ;
111 String getString = oObj.getString() ;
113 result = newString.equals(getString) ;
115 if (!result) {
116 log.println("Was '" + string + "', Set '" + newString
117 + "', Get '" + getString + "'") ;
120 tRes.tested("setString()", result) ;
124 * Gets current string and stores it. <p>
125 * Has <b> OK </b> status if no runtime exceptions occurred
127 public void _getString() {
129 boolean result = true ;
130 string = oObj.getString() ;
132 tRes.tested("getString()", result) ;
136 * Sets new strict state then checks it. <p>
137 * Has <b> OK </b> status if the state was changed.
138 * The following method tests are to be completed successfully before :
139 * <ul>
140 * <li> <code> isStrictFormat </code> </li>
141 * </ul>
143 public void _setStrictFormat() {
144 requiredMethod("isStrictFormat()") ;
146 boolean result = true ;
147 oObj.setStrictFormat(!strict) ;
149 result = oObj.isStrictFormat() == !strict ;
151 tRes.tested("setStrictFormat()", result) ;
155 * Gets the current strict state and stores it. <p>
156 * Has <b> OK </b> status if no runtime exceptions occurred.
158 public void _isStrictFormat() {
160 boolean result = true ;
161 strict = oObj.isStrictFormat() ;
163 tRes.tested("isStrictFormat()", result) ;