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 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.awt
.SpinEvent
;
24 import com
.sun
.star
.awt
.XSpinField
;
25 import com
.sun
.star
.awt
.XSpinListener
;
26 import com
.sun
.star
.lang
.EventObject
;
29 * Testing <code>com.sun.star.awt.XSpinField</code>
32 * <li><code> addSpinListener()</code></li>
33 * <li><code> removeSpinListener()</code></li>
34 * <li><code> up()</code></li>
35 * <li><code> down()</code></li>
36 * <li><code> first()</code></li>
37 * <li><code> last()</code></li>
38 * <li><code> enableRepeat()</code></li>
40 * Test is <b> NOT </b> multithread compliant. <p>
41 * @see com.sun.star.awt.XSpinField
43 public class _XSpinField
extends MultiMethodTest
{
45 public XSpinField oObj
= null;
48 * Listener implementation which set flags on appropriate
49 * listener methods calls.
51 protected static class TestListener
implements XSpinListener
{
52 public boolean upFl
= false ;
53 public boolean downFl
= false ;
54 public boolean firstFl
= false ;
55 public boolean lastFl
= false ;
57 public void up(SpinEvent e
) {
60 public void down(SpinEvent e
) {
63 public void first(SpinEvent e
) {
66 public void last(SpinEvent e
) {
69 public void disposing(EventObject e
) {}
72 private final TestListener listener
= new TestListener() ;
75 * Just adds a listener. <p>
76 * Has <b>OK</b> status if no runtime exceptions occurred.
78 public void _addSpinListener() {
79 oObj
.addSpinListener(listener
) ;
81 tRes
.tested("addSpinListener()", true) ;
85 * Calls the method. <p>
86 * Has <b>OK</b> status if the appropriate listener method
88 * The following method tests are to be completed successfully before :
90 * <li> <code> addSpinListener </code> </li>
94 requiredMethod("addSpinListener()") ;
99 tRes
.tested("up()", listener
.upFl
) ;
103 * Calls the method. <p>
104 * Has <b>OK</b> status if the appropriate listener method
106 * The following method tests are to be completed successfully before :
108 * <li> <code> addSpinListener </code> </li>
111 public void _down() throws Exception
{
112 requiredMethod("addSpinListener()") ;
117 tRes
.tested("down()", listener
.downFl
) ;
121 * Calls the method. <p>
122 * Has <b>OK</b> status if the appropriate listener method
124 * The following method tests are to be completed successfully before :
126 * <li> <code> addSpinListener </code> </li>
129 public void _first() throws Exception
{
130 requiredMethod("addSpinListener()") ;
135 tRes
.tested("first()", listener
.firstFl
) ;
139 * Calls the method. <p>
140 * Has <b>OK</b> status if the appropriate listener method
142 * The following method tests are to be completed successfully before :
144 * <li> <code> addSpinListener </code> </li>
147 public void _last() throws Exception
{
148 requiredMethod("addSpinListener()") ;
153 tRes
.tested("last()", listener
.lastFl
) ;
157 * Removes the listener, then calls <code>up</code> method and
158 * checks if the listener wasn't called. <p>
159 * Has <b>OK</b> status if listener wasn't called. <p>
160 * The following method tests are to be completed successfully before :
162 * <li> <code> addSpinListener </code> </li>
163 * <li> <code> up </code> </li>
164 * <li> <code> down </code> </li>
165 * <li> <code> first </code> </li>
166 * <li> <code> last </code> </li>
169 public void _removeSpinListener() {
170 requiredMethod("addSpinListener()") ;
171 executeMethod("up()") ;
172 executeMethod("down()") ;
173 executeMethod("first()") ;
174 executeMethod("last()") ;
176 listener
.upFl
= false ;
178 oObj
.removeSpinListener(listener
) ;
182 tRes
.tested("removeSpinListener()", !listener
.upFl
) ;
186 * Enables then disables repeating. <p>
187 * Has <b>OK</b> status if no runtime exceptions occurred.
189 public void _enableRepeat() {
190 oObj
.enableRepeat(true) ;
191 oObj
.enableRepeat(false) ;
193 tRes
.tested("enableRepeat()", true) ;