Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / awt / _XComboBox.java
blobdf609aade16f86626dcd92a2c2203ccde8df5ea3
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: _XComboBox.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;
34 import lib.Status;
36 import com.sun.star.awt.XComboBox;
38 /**
39 * Testing <code>com.sun.star.awt.XComboBox</code>
40 * interface methods :
41 * <ul>
42 * <li><code> addItemListener()</code></li>
43 * <li><code> removeItemListener()</code></li>
44 * <li><code> addActionListener()</code></li>
45 * <li><code> removeActionListener()</code></li>
46 * <li><code> addItem()</code></li>
47 * <li><code> addItems()</code></li>
48 * <li><code> removeItems()</code></li>
49 * <li><code> getItemCount()</code></li>
50 * <li><code> getItem()</code></li>
51 * <li><code> getItems()</code></li>
52 * <li><code> getDropDownLineCount()</code></li>
53 * <li><code> setDropDownLineCount()</code></li>
54 * </ul> <p>
55 * Test is <b> NOT </b> multithread compilant. <p>
56 * @see com.sun.star.awt.XComboBox
58 public class _XComboBox extends MultiMethodTest {
60 public XComboBox oObj = null;
62 /**
63 * Listener implementation which sets flags on appropriate method calls
65 protected class TestActionListener
66 implements com.sun.star.awt.XActionListener {
67 public boolean disposingCalled = false;
68 public boolean actionPerformedCalled = false;
70 public void disposing(com.sun.star.lang.EventObject e) {
71 disposingCalled = true;
74 public void actionPerformed(com.sun.star.awt.ActionEvent e) {
75 actionPerformedCalled = true;
80 /**
81 * Listener implementation which sets flags on appropriate method calls
83 protected class TestItemListener
84 implements com.sun.star.awt.XItemListener {
85 public boolean disposingCalled = false;
86 public boolean itemStateChangedCalled = false;
88 public void disposing(com.sun.star.lang.EventObject e) {
89 disposingCalled = true;
92 public void itemStateChanged(com.sun.star.awt.ItemEvent e) {
93 itemStateChangedCalled = true;
97 private TestActionListener actionListener = new TestActionListener();
98 private TestItemListener itemListener = new TestItemListener();
99 short lineCount = 0;
100 short itemCount = 0;
103 * !!! Can be checked only interactively !!!
105 public void _addItemListener() {
107 oObj.addItemListener(itemListener);
109 tRes.tested("addItemListener()", Status.skipped(true));
113 * !!! Can be checked only interactively !!!
115 public void _removeItemListener() {
116 requiredMethod("addItemListener()");
118 oObj.removeItemListener(itemListener);
120 tRes.tested("removeItemListener()", Status.skipped(true));
124 * !!! Can be checked only interactively !!!
126 public void _addActionListener() {
128 oObj.addActionListener(actionListener);
130 tRes.tested("addActionListener()", Status.skipped(true));
134 * !!! Can be checked only interactively !!!
136 public void _removeActionListener() {
137 requiredMethod("addActionListener()");
139 oObj.removeActionListener(actionListener);
141 tRes.tested("removeActionListener()", Status.skipped(true));
145 * Adds one item to the last position and check the number of
146 * items after addition. <p>
147 * Has <b>OK</b> status if the number of items increased by 1.<p>
148 * The following method tests are to be completed successfully before :
149 * <ul>
150 * <li> <code> getItemCount </code> </li>
151 * </ul>
153 public void _addItem() {
154 requiredMethod("getItemCount()");
156 boolean result = true;
157 oObj.addItem("Item1", itemCount);
158 result = oObj.getItemCount() == itemCount + 1;
160 tRes.tested("addItem()", result);
164 * Adds one two items to the last position and check the number of
165 * items after addition. <p>
166 * Has <b>OK</b> status if the number of items increased by 2.<p>
167 * The following method tests are to be executed before :
168 * <ul>
169 * <li> <code> addItem </code> </li>
170 * </ul>
172 public void _addItems() {
173 executeMethod("addItem()");
175 boolean result = true;
176 short oldCnt = oObj.getItemCount();
177 oObj.addItems(new String[] { "Item2", "Item3" }, oldCnt);
178 result = oObj.getItemCount() == oldCnt + 2;
180 tRes.tested("addItems()", result);
184 * Gets the current number of items and tries to remove them all
185 * then checks number of items. <p>
186 * Has <b>OK</b> status if no items remains. <p>
187 * The following method tests are to be executed before :
188 * <ul>
189 * <li> <code> getItems </code> </li>
190 * <li> <code> getItem </code> </li>
191 * </ul>
193 public void _removeItems() {
194 executeMethod("getItems()");
195 executeMethod("getItem()");
197 boolean result = true;
198 short oldCnt = oObj.getItemCount();
199 oObj.removeItems((short) 0, oldCnt);
200 result = oObj.getItemCount() == 0;
202 tRes.tested("removeItems()", result);
206 * Just retrieves current number of items and stores it. <p>
207 * Has <b>OK</b> status if the count is not less than 0.
209 public void _getItemCount() {
211 itemCount = oObj.getItemCount();
213 tRes.tested("getItemCount()", itemCount >= 0);
217 * After <code>addItem</code> and <code>addItems</code> methods
218 * test the following items must exist {..., "Item1", "Item2", "Item3"}
219 * Retrieves the item from the position which was ititially the last.<p>
220 * Has <b>OK</b> status if the "Item1" was retrieved. <p>
221 * The following method tests are to be executed before :
222 * <ul>
223 * <li> <code> addItems </code> </li>
224 * </ul>
226 public void _getItem() {
227 requiredMethod("addItems()");
229 boolean result = true;
230 String item = oObj.getItem(itemCount);
231 result = "Item1".equals(item);
233 tRes.tested("getItem()", result);
237 * After <code>addItem</code> and <code>addItems</code> methods
238 * test the following items must exist {..., "Item1", "Item2", "Item3"}
239 * Retrieves all items. <p>
240 * Has <b>OK</b> status if the last three items retrieved are
241 * "Item1", "Item2" and "Item3". <p>
242 * The following method tests are to be executed before :
243 * <ul>
244 * <li> <code> addItems </code> </li>
245 * </ul>
247 public void _getItems() {
248 requiredMethod("addItems()");
250 boolean result = true;
251 String[] items = oObj.getItems();
252 for (int i = itemCount; i < (itemCount + 3); i++) {
253 result &= ("Item" + (i + 1)).equals(items[i]);
256 tRes.tested("getItems()", result);
260 * Gets line count and stores it. <p>
261 * Has <b>OK</b> status if no runtime exceptions occured.
263 public void _getDropDownLineCount() {
265 boolean result = true;
266 lineCount = oObj.getDropDownLineCount();
268 tRes.tested("getDropDownLineCount()", result);
272 * Sets a new value and then checks get value. <p>
273 * Has <b>OK</b> status if set and get values are equal. <p>
274 * The following method tests are to be completed successfully before :
275 * <ul>
276 * <li> <code> getDropDownLineCount </code> </li>
277 * </ul>
279 public void _setDropDownLineCount() {
280 requiredMethod("getDropDownLineCount()");
282 boolean result = true;
283 oObj.setDropDownLineCount((short) (lineCount + 1));
284 result = oObj.getDropDownLineCount() == lineCount + 1;
286 tRes.tested("setDropDownLineCount()", result);