Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / awt / _XSpinField.java
blob35ca805009f70d094146b67045b2d5007141975a
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: _XSpinField.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;
33 import lib.MultiMethodTest;
35 import com.sun.star.awt.SpinEvent;
36 import com.sun.star.awt.XSpinField;
37 import com.sun.star.awt.XSpinListener;
38 import com.sun.star.lang.EventObject;
40 /**
41 * Testing <code>com.sun.star.awt.XSpinField</code>
42 * interface methods :
43 * <ul>
44 * <li><code> addSpinListener()</code></li>
45 * <li><code> removeSpinListener()</code></li>
46 * <li><code> up()</code></li>
47 * <li><code> down()</code></li>
48 * <li><code> first()</code></li>
49 * <li><code> last()</code></li>
50 * <li><code> enableRepeat()</code></li>
51 * </ul> <p>
52 * Test is <b> NOT </b> multithread compilant. <p>
53 * @see com.sun.star.awt.XSpinField
55 public class _XSpinField extends MultiMethodTest {
57 public XSpinField oObj = null;
59 /**
60 * Listener implementation which set flags on appropriate
61 * listener methods calls.
63 protected class TestListener implements XSpinListener {
64 public boolean upFl = false ;
65 public boolean downFl = false ;
66 public boolean firstFl = false ;
67 public boolean lastFl = false ;
69 public void up(SpinEvent e) {
70 upFl = true ;
72 public void down(SpinEvent e) {
73 downFl = true ;
75 public void first(SpinEvent e) {
76 firstFl = true ;
78 public void last(SpinEvent e) {
79 lastFl = true ;
81 public void disposing(EventObject e) {}
84 private TestListener listener = new TestListener() ;
86 /**
87 * Just adds a listener. <p>
88 * Has <b>OK</b> status if no runtime exceptions occured.
90 public void _addSpinListener() {
91 oObj.addSpinListener(listener) ;
93 tRes.tested("addSpinListener()", true) ;
96 /**
97 * Calls the method. <p>
98 * Has <b>OK</b> status if the appropriate listener method
99 * was called. <p>
100 * The following method tests are to be completed successfully before :
101 * <ul>
102 * <li> <code> addSpinListener </code> </li>
103 * </ul>
105 public void _up() {
106 requiredMethod("addSpinListener()") ;
108 oObj.up() ;
109 shortWait();
111 tRes.tested("up()", listener.upFl) ;
115 * Calls the method. <p>
116 * Has <b>OK</b> status if the appropriate listener method
117 * was called. <p>
118 * The following method tests are to be completed successfully before :
119 * <ul>
120 * <li> <code> addSpinListener </code> </li>
121 * </ul>
123 public void _down() {
124 requiredMethod("addSpinListener()") ;
126 oObj.down() ;
127 shortWait();
129 tRes.tested("down()", listener.downFl) ;
133 * Calls the method. <p>
134 * Has <b>OK</b> status if the appropriate listener method
135 * was called.<p>
136 * The following method tests are to be completed successfully before :
137 * <ul>
138 * <li> <code> addSpinListener </code> </li>
139 * </ul>
141 public void _first() {
142 requiredMethod("addSpinListener()") ;
144 oObj.first() ;
145 shortWait();
147 tRes.tested("first()", listener.firstFl) ;
151 * Calls the method. <p>
152 * Has <b>OK</b> status if the appropriate listener method
153 * was called.<p>
154 * The following method tests are to be completed successfully before :
155 * <ul>
156 * <li> <code> addSpinListener </code> </li>
157 * </ul>
159 public void _last() {
160 requiredMethod("addSpinListener()") ;
162 oObj.last() ;
163 shortWait();
165 tRes.tested("last()", listener.lastFl) ;
169 * Removes the listener, then calls <code>up</code> method and
170 * checks if te listener wasn't called. <p>
171 * Has <b>OK</b> status if listener wasn't called. <p>
172 * The following method tests are to be completed successfully before :
173 * <ul>
174 * <li> <code> addSpinListener </code> </li>
175 * <li> <code> up </code> </li>
176 * <li> <code> down </code> </li>
177 * <li> <code> first </code> </li>
178 * <li> <code> last </code> </li>
179 * </ul>
181 public void _removeSpinListener() {
182 requiredMethod("addSpinListener()") ;
183 executeMethod("up()") ;
184 executeMethod("down()") ;
185 executeMethod("first()") ;
186 executeMethod("last()") ;
188 listener.upFl = false ;
190 oObj.removeSpinListener(listener) ;
192 oObj.up() ;
194 tRes.tested("removeSpinListener()", !listener.upFl) ;
198 * Enables then disables repeating. <p>
199 * Has <b>OK</b> status if no runtime exceptions occured.
201 public void _enableRepeat() {
202 oObj.enableRepeat(true) ;
203 oObj.enableRepeat(false) ;
205 tRes.tested("enableRepeat()", true) ;
209 * Waits for 0.5 sec to allow listener to be called.
211 private void shortWait() {
212 try {
213 Thread.sleep(500);
215 catch (InterruptedException ex) {