Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / awt / _XListBox.java
blobf85cced4f374a5c495752f517f72cd548cbaf7cd
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: _XListBox.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;
34 import lib.MultiMethodTest;
35 import lib.Status;
37 import com.sun.star.awt.XListBox;
39 /**
40 * Testing <code>com.sun.star.awt.XListBox</code>
41 * interface methods :
42 * <ul>
43 * <li><code> addItemListener()</code></li>
44 * <li><code> removeItemListener()</code></li>
45 * <li><code> addActionListener()</code></li>
46 * <li><code> removeActionListener()</code></li>
47 * <li><code> addItem()</code></li>
48 * <li><code> addItems()</code></li>
49 * <li><code> removeItems()</code></li>
50 * <li><code> getItemCount()</code></li>
51 * <li><code> getItem()</code></li>
52 * <li><code> getItems()</code></li>
53 * <li><code> getSelectedItemPos()</code></li>
54 * <li><code> getSelectedItemsPos()</code></li>
55 * <li><code> getSelectedItem()</code></li>
56 * <li><code> getSelectedItems()</code></li>
57 * <li><code> selectItemPos()</code></li>
58 * <li><code> selectItemsPos()</code></li>
59 * <li><code> selectItem()</code></li>
60 * <li><code> isMutipleMode()</code></li>
61 * <li><code> setMultipleMode()</code></li>
62 * <li><code> getDropDownLineCount()</code></li>
63 * <li><code> setDropDownLineCount()</code></li>
64 * <li><code> makeVisible()</code></li>
65 * </ul> <p>
66 * Test is <b> NOT </b> multithread compilant. <p>
67 * @see com.sun.star.awt.XListBox
69 public class _XListBox extends MultiMethodTest {
71 public XListBox oObj = null;
73 /**
74 * Listener implementation which sets flags on appropriate method calls
76 protected class TestActionListener implements com.sun.star.awt.XActionListener {
77 public boolean disposingCalled = false ;
78 public boolean actionPerformedCalled = false ;
80 public void disposing(com.sun.star.lang.EventObject e) {
81 disposingCalled = true ;
84 public void actionPerformed(com.sun.star.awt.ActionEvent e) {
85 actionPerformedCalled = true ;
90 TestActionListener actionListener = new TestActionListener() ;
92 /**
93 * Listener implementation which sets flags on appropriate method calls
95 protected class TestItemListener implements com.sun.star.awt.XItemListener {
96 public boolean disposingCalled = false ;
97 public boolean itemStateChangedCalled = false ;
99 public void disposing(com.sun.star.lang.EventObject e) {
100 disposingCalled = true ;
103 public void itemStateChanged(com.sun.star.awt.ItemEvent e) {
104 itemStateChangedCalled = true ;
109 TestItemListener itemListener = new TestItemListener() ;
111 short lineCount = 0 ;
112 short itemCount = 0 ;
115 * Retrieves object relations.
116 * @throws StatusException If one of relations not found.
118 public void before() {
119 itemCount = oObj.getItemCount();
123 * !!! Can be checked only interactively !!!
125 public void _addItemListener() {
127 oObj.addItemListener(itemListener) ;
129 tRes.tested("addItemListener()", Status.skipped(true)) ;
133 * !!! Can be checked only interactively !!!
135 public void _removeItemListener() {
136 requiredMethod("addItemListener()") ;
138 oObj.removeItemListener(itemListener) ;
140 tRes.tested("removeItemListener()", Status.skipped(true)) ;
144 * !!! Can be checked only interactively !!!
146 public void _addActionListener() {
148 oObj.addActionListener(actionListener) ;
150 tRes.tested("addActionListener()", Status.skipped(true)) ;
154 * !!! Can be checked only interactively !!!
156 public void _removeActionListener() {
157 requiredMethod("addActionListener()") ;
159 oObj.removeActionListener(actionListener) ;
161 tRes.tested("removeActionListener()", Status.skipped(true)) ;
165 * Adds one item to the last position and check the number of
166 * items after addition. <p>
167 * Has <b>OK</b> status if the number of items increased by 1.<p>
168 * The following method tests are to be completed successfully before :
169 * <ul>
170 * <li> <code> getItemCount </code> </li>
171 * </ul>
173 public void _addItem() {
174 requiredMethod("getItemCount()") ;
176 boolean result = true ;
177 oObj.addItem("Item1", itemCount) ;
178 result = oObj.getItemCount() == itemCount + 1 ;
180 tRes.tested("addItem()", result) ;
184 * Adds one two items to the last position and check the number of
185 * items after addition. <p>
186 * Has <b>OK</b> status if the number of items increased by 2.<p>
187 * The following method tests are to be executed before :
188 * <ul>
189 * <li> <code> addItem </code> </li>
190 * </ul>
192 public void _addItems() {
193 executeMethod("addItem()") ;
195 boolean result = true ;
196 short oldCnt = oObj.getItemCount() ;
197 oObj.addItems(new String[] {"Item2", "Item3"}, oldCnt) ;
198 result = oObj.getItemCount() == oldCnt + 2 ;
200 tRes.tested("addItems()", result) ;
204 * Gets the current number of items and tries to remove them all
205 * then checks number of items. <p>
206 * Has <b>OK</b> status if no items remains. <p>
207 * The following method tests are to be executed before :
208 * <ul>
209 * <li> <code> getItems </code> </li>
210 * <li> <code> getItem </code> </li>
211 * </ul>
213 public void _removeItems() {
214 executeMethod("getItems()") ;
215 executeMethod("getItem()") ;
216 executeMethod("getSelectedItemPos()") ;
217 executeMethod("getSelectedItemsPos()") ;
218 executeMethod("getSelectedItem()") ;
219 executeMethod("getSelectedItems()") ;
221 boolean result = true ;
222 short oldCnt = oObj.getItemCount() ;
223 oObj.removeItems((short)0, oldCnt) ;
224 result = oObj.getItemCount() == 0 ;
226 tRes.tested("removeItems()", result) ;
230 * Just retrieves current number of items and stores it. <p>
231 * Has <b>OK</b> status if the count is not less than 0.
233 public void _getItemCount() {
235 itemCount = oObj.getItemCount() ;
237 tRes.tested("getItemCount()", itemCount >= 0) ;
241 * After <code>addItem</code> and <code>addItems</code> methods
242 * test the following items must exist {..., "Item1", "Item2", "Item3"}
243 * Retrieves the item from the position which was ititially the last.<p>
244 * Has <b>OK</b> status if the "Item1" was retrieved. <p>
245 * The following method tests are to be executed before :
246 * <ul>
247 * <li> <code> addItems </code> </li>
248 * </ul>
250 public void _getItem() {
251 requiredMethod("addItems()") ;
253 boolean result = true ;
254 String item = oObj.getItem(itemCount) ;
255 result = "Item1".equals(item) ;
257 tRes.tested("getItem()", result) ;
261 * After <code>addItem</code> and <code>addItems</code> methods
262 * test the following items must exist {..., "Item1", "Item2", "Item3"}
263 * Retrieves all items. <p>
264 * Has <b>OK</b> status if the last three items retrieved are
265 * "Item1", "Item2" and "Item3". <p>
266 * The following method tests are to be executed before :
267 * <ul>
268 * <li> <code> addItems </code> </li>
269 * </ul>
271 public void _getItems() {
272 requiredMethod("addItems()") ;
274 boolean result = true ;
275 String[] items = oObj.getItems() ;
276 for (int i = itemCount; i < (itemCount + 3); i++) {
277 result &= ("Item" + (i+1 - itemCount)).equals(items[i]) ;
280 tRes.tested("getItems()", result) ;
284 * Gets line count and stores it. <p>
285 * Has <b>OK</b> status if no runtime exceptions occured.
287 public void _getDropDownLineCount() {
289 boolean result = true ;
290 lineCount = oObj.getDropDownLineCount() ;
292 tRes.tested("getDropDownLineCount()", result) ;
296 * Sets a new value and then checks get value. <p>
297 * Has <b>OK</b> status if set and get values are equal. <p>
298 * The following method tests are to be completed successfully before :
299 * <ul>
300 * <li> <code> getDropDownLineCount </code> </li>
301 * </ul>
303 public void _setDropDownLineCount() {
304 requiredMethod("getDropDownLineCount()") ;
306 boolean result = true ;
307 oObj.setDropDownLineCount((short)(lineCount + 1)) ;
308 result = oObj.getDropDownLineCount() == lineCount + 1 ;
310 tRes.tested("setDropDownLineCount()", result) ;
314 * Selects some item and gets selected item position. <p>
315 * Has <b> OK </b> status if position is equal to position set. <p>
316 * The following method tests are to be completed successfully before :
317 * <ul>
318 * <li> <code> addItems </code> : to have some items </li>
319 * </ul>
321 public void _getSelectedItemPos() {
322 requiredMethod("addItems()") ;
324 boolean result = true ;
325 oObj.selectItemPos((short)1, true) ;
326 short pos = oObj.getSelectedItemPos() ;
328 result = pos == 1 ;
330 tRes.tested("getSelectedItemPos()", result) ;
334 * Clears all selections, then selects some items and gets selected
335 * item positions. <p>
336 * Has <b> OK </b> status if positions get are the same as were set.<p>
337 * The following method tests are to be completed successfully before :
338 * <ul>
339 * <li> <code> selectItemsPos </code> </li>
340 * </ul>
342 public void _getSelectedItemsPos() {
343 requiredMethod("selectItemsPos()") ;
345 boolean result = true ;
346 short cnt = oObj.getItemCount() ;
347 for (short i = 0; i < cnt; i++) {
348 oObj.selectItemPos(i, false) ;
350 oObj.selectItemsPos(new short[] {0, 2}, true) ;
352 short[] items = oObj.getSelectedItemsPos() ;
354 result = items != null && items.length == 2 &&
355 items[0] == 0 && items[1] == 2 ;
357 tRes.tested("getSelectedItemsPos()", result) ;
361 * Unselects all items, selects some item and then gets selected item. <p>
362 * Has <b> OK </b> status if items selected and get are equal.
363 * The following method tests are to be completed successfully before :
364 * <ul>
365 * <li> <code> addItems </code> : to have some items </li>
366 * </ul>
368 public void _getSelectedItem() {
369 requiredMethod("addItems()") ;
371 boolean result = true ;
372 short cnt = oObj.getItemCount() ;
373 for (short i = 0; i < cnt; i++) {
374 oObj.selectItemPos(i, false) ;
376 oObj.selectItem("Item3", true) ;
377 String item = oObj.getSelectedItem() ;
379 result = "Item3".equals(item) ;
381 tRes.tested("getSelectedItem()", result) ;
385 * Clears all selections, then selects some items positions and gets
386 * selected items. <p>
387 * Has <b> OK </b> status if items get are the same as items on
388 * positions which were set.<p>
389 * The following method tests are to be completed successfully before :
390 * <ul>
391 * <li> <code> selectItemsPos </code> </li>
392 * <li> <code> getItem </code>: this method is used here for checking.
393 * </li>
394 * </ul>
396 public void _getSelectedItems() {
397 requiredMethod("selectItemsPos()") ;
398 requiredMethod("getItem()") ;
400 boolean result = true ;
401 short cnt = oObj.getItemCount() ;
402 for (short i = 0; i < cnt; i++) {
403 oObj.selectItemPos(i, false) ;
405 oObj.selectItemsPos(new short[] {0, 2}, true) ;
407 String[] items = oObj.getSelectedItems() ;
408 result = items != null && items.length == 2 &&
409 oObj.getItem((short)0).equals(items[0]) &&
410 oObj.getItem((short)2).equals(items[1]) ;
412 tRes.tested("getSelectedItems()", result) ;
416 * Unselects all items, then selects a single item. <p>
417 * Has <b> OK </b> status if no runtime exceptions occured
418 * The following method tests are to be completed successfully before :
419 * <ul>
420 * <li> <code> addItems </code> : to have some items </li>
421 * </ul>
423 public void _selectItemPos() {
424 requiredMethod("addItems()") ;
426 boolean result = true ;
427 short cnt = oObj.getItemCount() ;
428 for (short i = 0; i < cnt; i++) {
429 oObj.selectItemPos(i, false) ;
431 oObj.selectItemPos((short)1, true) ;
433 tRes.tested("selectItemPos()", result) ;
437 * Just selects some items. <p>
438 * Has <b> OK </b> status if no runtime exceptions occured
439 * The following method tests are to be completed successfully before :
440 * <ul>
441 * <li> <code> addItems </code> : to have some items </li>
442 * </ul>
444 public void _selectItemsPos() {
445 requiredMethod("addItems()") ;
446 requiredMethod("setMultipleMode()") ;
448 boolean result = true ;
449 oObj.selectItemsPos(new short[] {0, 2}, true) ;
451 tRes.tested("selectItemsPos()", result) ;
455 * Just selects an item. <p>
456 * Has <b> OK </b> status if no runtime exceptions occured
457 * The following method tests are to be completed successfully before :
458 * <ul>
459 * <li> <code> addItems </code> : to have some items </li>
460 * </ul>
462 public void _selectItem() {
463 requiredMethod("addItems()") ;
465 boolean result = true ;
466 oObj.selectItem("Item3", true) ;
468 tRes.tested("selectItem()", result) ;
472 * Checks if multiple mode is set. <p>
473 * Has <b> OK </b> status if multiple mode is set. <p>
474 * The following method tests are to be completed successfully before :
475 * <ul>
476 * <li> <code> setMultipleMode </code> </li>
477 * </ul>
479 public void _isMutipleMode() {
480 requiredMethod("setMultipleMode()") ;
482 boolean result = true ;
483 result = oObj.isMutipleMode() ;
485 tRes.tested("isMutipleMode()", result) ;
489 * Sets multiple mode. <p>
490 * Has <b> OK </b> status if no runtime exceptions occured
492 public void _setMultipleMode() {
494 boolean result = true ;
495 oObj.setMultipleMode(true) ;
497 tRes.tested("setMultipleMode()", result) ;
501 * Just calls the method to make visible third item. <p>
502 * Has <b> OK </b> status if no runtime exceptions occured.<p>
503 * The following method tests are to be completed successfully before :
504 * <ul>
505 * <li> <code> addItems </code> </li>
506 * </ul>
508 public void _makeVisible() {
509 requiredMethod("addItems()") ;
511 boolean result = true ;
512 oObj.makeVisible((short)2) ;
514 tRes.tested("makeVisible()", result) ;