1 /* 2 * This file is part of the LibreOffice project. 3 * 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/. 7 * 8 * This file incorporates work covered by the following license notice: 9 * 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 . 17 */ 18 19 package ifc.awt; 20 21 22 import lib.MultiMethodTest; 23 24 import com.sun.star.awt.XPatternField; 25 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 39 */ 40 public class _XPatternField extends MultiMethodTest { 41 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 ; 47 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> 55 */ _setMasks()56 public void _setMasks() { 57 requiredMethod("getMasks()") ; 58 59 boolean result = true ; 60 String newEdit = editMask == null ? "ccc" : editMask + "ccc" ; 61 String newLiteral = literalMask == null ? " " : literalMask + " " ; 62 oObj.setMasks(newEdit, newLiteral) ; 63 64 String[] edit = new String[1] ; 65 String[] literal = new String[1] ; 66 oObj.getMasks(edit, literal) ; 67 68 result &= newEdit.equals(edit[0]) ; 69 result &= newLiteral.equals(literal[0]) ; 70 71 tRes.tested("setMasks()", result) ; 72 } 73 74 /** 75 * Gets masks and stores them. <p> 76 * Has <b> OK </b> status if no runtime exceptions occurred. 77 */ _getMasks()78 public void _getMasks() { 79 80 boolean result = true ; 81 String[] edit = new String[1] ; 82 String[] literal = new String[1] ; 83 oObj.getMasks(edit, literal) ; 84 85 log.println("Edit mask = '" + edit[0] + "', literal = '" + 86 literal[0] + "'") ; 87 88 editMask = edit[0] ; 89 literalMask = literal[0] ; 90 91 tRes.tested("getMasks()", result) ; 92 } 93 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> 103 */ _setString()104 public void _setString() { 105 requiredMethod("setMasks()") ; 106 requiredMethod("getString()") ; 107 108 boolean result = true ; 109 String newString = string = "abc" ; 110 oObj.setString(newString) ; 111 String getString = oObj.getString() ; 112 113 result = newString.equals(getString) ; 114 115 if (!result) { 116 log.println("Was '" + string + "', Set '" + newString 117 + "', Get '" + getString + "'") ; 118 } 119 120 tRes.tested("setString()", result) ; 121 } 122 123 /** 124 * Gets current string and stores it. <p> 125 * Has <b> OK </b> status if no runtime exceptions occurred 126 */ _getString()127 public void _getString() { 128 129 boolean result = true ; 130 string = oObj.getString() ; 131 132 tRes.tested("getString()", result) ; 133 } 134 135 /** 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> 142 */ _setStrictFormat()143 public void _setStrictFormat() { 144 requiredMethod("isStrictFormat()") ; 145 146 boolean result = true ; 147 oObj.setStrictFormat(!strict) ; 148 149 result = oObj.isStrictFormat() == !strict ; 150 151 tRes.tested("setStrictFormat()", result) ; 152 } 153 154 /** 155 * Gets the current strict state and stores it. <p> 156 * Has <b> OK </b> status if no runtime exceptions occurred. 157 */ _isStrictFormat()158 public void _isStrictFormat() { 159 160 boolean result = true ; 161 strict = oObj.isStrictFormat() ; 162 163 tRes.tested("isStrictFormat()", result) ; 164 } 165 } 166 167 168