1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XSpinField.java,v $
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 ************************************************************************/
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
;
41 * Testing <code>com.sun.star.awt.XSpinField</code>
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>
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;
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
) {
72 public void down(SpinEvent e
) {
75 public void first(SpinEvent e
) {
78 public void last(SpinEvent e
) {
81 public void disposing(EventObject e
) {}
84 private TestListener listener
= new TestListener() ;
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) ;
97 * Calls the method. <p>
98 * Has <b>OK</b> status if the appropriate listener method
100 * The following method tests are to be completed successfully before :
102 * <li> <code> addSpinListener </code> </li>
106 requiredMethod("addSpinListener()") ;
111 tRes
.tested("up()", listener
.upFl
) ;
115 * Calls the method. <p>
116 * Has <b>OK</b> status if the appropriate listener method
118 * The following method tests are to be completed successfully before :
120 * <li> <code> addSpinListener </code> </li>
123 public void _down() {
124 requiredMethod("addSpinListener()") ;
129 tRes
.tested("down()", listener
.downFl
) ;
133 * Calls the method. <p>
134 * Has <b>OK</b> status if the appropriate listener method
136 * The following method tests are to be completed successfully before :
138 * <li> <code> addSpinListener </code> </li>
141 public void _first() {
142 requiredMethod("addSpinListener()") ;
147 tRes
.tested("first()", listener
.firstFl
) ;
151 * Calls the method. <p>
152 * Has <b>OK</b> status if the appropriate listener method
154 * The following method tests are to be completed successfully before :
156 * <li> <code> addSpinListener </code> </li>
159 public void _last() {
160 requiredMethod("addSpinListener()") ;
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 :
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>
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
) ;
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() {
215 catch (InterruptedException ex
) {