Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XSpinField.java
blobd6a9b3a9b59f75712ac0bb3476a57a382648ac78
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;
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;
28 /**
29 * Testing <code>com.sun.star.awt.XSpinField</code>
30 * interface methods :
31 * <ul>
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>
39 * </ul> <p>
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;
47 /**
48 * Listener implementation which set flags on appropriate
49 * listener methods calls.
51 protected 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) {
58 upFl = true ;
60 public void down(SpinEvent e) {
61 downFl = true ;
63 public void first(SpinEvent e) {
64 firstFl = true ;
66 public void last(SpinEvent e) {
67 lastFl = true ;
69 public void disposing(EventObject e) {}
72 private final TestListener listener = new TestListener() ;
74 /**
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) ;
84 /**
85 * Calls the method. <p>
86 * Has <b>OK</b> status if the appropriate listener method
87 * was called. <p>
88 * The following method tests are to be completed successfully before :
89 * <ul>
90 * <li> <code> addSpinListener </code> </li>
91 * </ul>
93 public void _up() {
94 requiredMethod("addSpinListener()") ;
96 oObj.up() ;
97 util.utils.shortWait();
99 tRes.tested("up()", listener.upFl) ;
103 * Calls the method. <p>
104 * Has <b>OK</b> status if the appropriate listener method
105 * was called. <p>
106 * The following method tests are to be completed successfully before :
107 * <ul>
108 * <li> <code> addSpinListener </code> </li>
109 * </ul>
111 public void _down() {
112 requiredMethod("addSpinListener()") ;
114 oObj.down() ;
115 util.utils.shortWait();
117 tRes.tested("down()", listener.downFl) ;
121 * Calls the method. <p>
122 * Has <b>OK</b> status if the appropriate listener method
123 * was called.<p>
124 * The following method tests are to be completed successfully before :
125 * <ul>
126 * <li> <code> addSpinListener </code> </li>
127 * </ul>
129 public void _first() {
130 requiredMethod("addSpinListener()") ;
132 oObj.first() ;
133 util.utils.shortWait();
135 tRes.tested("first()", listener.firstFl) ;
139 * Calls the method. <p>
140 * Has <b>OK</b> status if the appropriate listener method
141 * was called.<p>
142 * The following method tests are to be completed successfully before :
143 * <ul>
144 * <li> <code> addSpinListener </code> </li>
145 * </ul>
147 public void _last() {
148 requiredMethod("addSpinListener()") ;
150 oObj.last() ;
151 util.utils.shortWait();
153 tRes.tested("last()", listener.lastFl) ;
157 * Removes the listener, then calls <code>up</code> method and
158 * checks if te 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 :
161 * <ul>
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>
167 * </ul>
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) ;
180 oObj.up() ;
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) ;