tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XListBox.java
blob6c6ddd6b247ed8782f97453bdf47706b2cce80c5
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;
22 import lib.MultiMethodTest;
23 import lib.Status;
25 import com.sun.star.awt.XListBox;
27 /**
28 * Testing <code>com.sun.star.awt.XListBox</code>
29 * interface methods :
30 * <ul>
31 * <li><code> addItemListener()</code></li>
32 * <li><code> removeItemListener()</code></li>
33 * <li><code> addActionListener()</code></li>
34 * <li><code> removeActionListener()</code></li>
35 * <li><code> addItem()</code></li>
36 * <li><code> addItems()</code></li>
37 * <li><code> removeItems()</code></li>
38 * <li><code> getItemCount()</code></li>
39 * <li><code> getItem()</code></li>
40 * <li><code> getItems()</code></li>
41 * <li><code> getSelectedItemPos()</code></li>
42 * <li><code> getSelectedItemsPos()</code></li>
43 * <li><code> getSelectedItem()</code></li>
44 * <li><code> getSelectedItems()</code></li>
45 * <li><code> selectItemPos()</code></li>
46 * <li><code> selectItemsPos()</code></li>
47 * <li><code> selectItem()</code></li>
48 * <li><code> isMutipleMode()</code></li>
49 * <li><code> setMultipleMode()</code></li>
50 * <li><code> getDropDownLineCount()</code></li>
51 * <li><code> setDropDownLineCount()</code></li>
52 * <li><code> makeVisible()</code></li>
53 * </ul> <p>
54 * Test is <b> NOT </b> multithread compliant. <p>
55 * @see com.sun.star.awt.XListBox
57 public class _XListBox extends MultiMethodTest {
59 public XListBox oObj = null;
61 /**
62 * Listener implementation which sets flags on appropriate method calls
64 protected static class TestActionListener implements com.sun.star.awt.XActionListener {
66 public void disposing(com.sun.star.lang.EventObject e) {}
68 public void actionPerformed(com.sun.star.awt.ActionEvent e) {}
72 TestActionListener actionListener = new TestActionListener() ;
74 /**
75 * Listener implementation which sets flags on appropriate method calls
77 protected static class TestItemListener implements com.sun.star.awt.XItemListener {
79 public void disposing(com.sun.star.lang.EventObject e) {}
81 public void itemStateChanged(com.sun.star.awt.ItemEvent e) {}
84 TestItemListener itemListener = new TestItemListener() ;
86 short lineCount = 0 ;
87 short itemCount = 0 ;
89 /**
90 * Retrieves object relations.
92 @Override
93 public void before() {
94 itemCount = oObj.getItemCount();
97 /**
98 * !!! Can be checked only interactively !!!
100 public void _addItemListener() {
102 oObj.addItemListener(itemListener) ;
104 tRes.tested("addItemListener()", Status.skipped(true)) ;
108 * !!! Can be checked only interactively !!!
110 public void _removeItemListener() {
111 requiredMethod("addItemListener()") ;
113 oObj.removeItemListener(itemListener) ;
115 tRes.tested("removeItemListener()", Status.skipped(true)) ;
119 * !!! Can be checked only interactively !!!
121 public void _addActionListener() {
123 oObj.addActionListener(actionListener) ;
125 tRes.tested("addActionListener()", Status.skipped(true)) ;
129 * !!! Can be checked only interactively !!!
131 public void _removeActionListener() {
132 requiredMethod("addActionListener()") ;
134 oObj.removeActionListener(actionListener) ;
136 tRes.tested("removeActionListener()", Status.skipped(true)) ;
140 * Adds one item to the last position and check the number of
141 * items after addition. <p>
142 * Has <b>OK</b> status if the number of items increased by 1.<p>
143 * The following method tests are to be completed successfully before :
144 * <ul>
145 * <li> <code> getItemCount </code> </li>
146 * </ul>
148 public void _addItem() {
149 requiredMethod("getItemCount()") ;
151 boolean result = true ;
152 oObj.addItem("Item1", itemCount) ;
153 result = oObj.getItemCount() == itemCount + 1 ;
155 tRes.tested("addItem()", result) ;
159 * Adds one two items to the last position and check the number of
160 * items after addition. <p>
161 * Has <b>OK</b> status if the number of items increased by 2.<p>
162 * The following method tests are to be executed before :
163 * <ul>
164 * <li> <code> addItem </code> </li>
165 * </ul>
167 public void _addItems() {
168 executeMethod("addItem()") ;
170 boolean result = true ;
171 short oldCnt = oObj.getItemCount() ;
172 oObj.addItems(new String[] {"Item2", "Item3"}, oldCnt) ;
173 result = oObj.getItemCount() == oldCnt + 2 ;
175 tRes.tested("addItems()", result) ;
179 * Gets the current number of items and tries to remove them all
180 * then checks number of items. <p>
181 * Has <b>OK</b> status if no items remains. <p>
182 * The following method tests are to be executed before :
183 * <ul>
184 * <li> <code> getItems </code> </li>
185 * <li> <code> getItem </code> </li>
186 * </ul>
188 public void _removeItems() {
189 executeMethod("getItems()") ;
190 executeMethod("getItem()") ;
191 executeMethod("getSelectedItemPos()") ;
192 executeMethod("getSelectedItemsPos()") ;
193 executeMethod("getSelectedItem()") ;
194 executeMethod("getSelectedItems()") ;
196 boolean result = true ;
197 short oldCnt = oObj.getItemCount() ;
198 oObj.removeItems((short)0, oldCnt) ;
199 result = oObj.getItemCount() == 0 ;
201 tRes.tested("removeItems()", result) ;
205 * Just retrieves current number of items and stores it. <p>
206 * Has <b>OK</b> status if the count is not less than 0.
208 public void _getItemCount() {
210 itemCount = oObj.getItemCount() ;
212 tRes.tested("getItemCount()", itemCount >= 0) ;
216 * After <code>addItem</code> and <code>addItems</code> methods
217 * test the following items must exist {..., "Item1", "Item2", "Item3"}
218 * Retrieves the item from the position which was ititially the last.<p>
219 * Has <b>OK</b> status if the "Item1" was retrieved. <p>
220 * The following method tests are to be executed before :
221 * <ul>
222 * <li> <code> addItems </code> </li>
223 * </ul>
225 public void _getItem() {
226 requiredMethod("addItems()") ;
228 boolean result = true ;
229 String item = oObj.getItem(itemCount) ;
230 result = "Item1".equals(item) ;
232 tRes.tested("getItem()", result) ;
236 * After <code>addItem</code> and <code>addItems</code> methods
237 * test the following items must exist {..., "Item1", "Item2", "Item3"}
238 * Retrieves all items. <p>
239 * Has <b>OK</b> status if the last three items retrieved are
240 * "Item1", "Item2" and "Item3". <p>
241 * The following method tests are to be executed before :
242 * <ul>
243 * <li> <code> addItems </code> </li>
244 * </ul>
246 public void _getItems() {
247 requiredMethod("addItems()") ;
249 boolean result = true ;
250 String[] items = oObj.getItems() ;
251 for (int i = itemCount; i < (itemCount + 3); i++) {
252 result &= ("Item" + (i+1 - itemCount)).equals(items[i]) ;
255 tRes.tested("getItems()", result) ;
259 * Gets line count and stores it. <p>
260 * Has <b>OK</b> status if no runtime exceptions occurred.
262 public void _getDropDownLineCount() {
264 boolean result = true ;
265 lineCount = oObj.getDropDownLineCount() ;
267 tRes.tested("getDropDownLineCount()", result) ;
271 * Sets a new value and then checks get value. <p>
272 * Has <b>OK</b> status if set and get values are equal. <p>
273 * The following method tests are to be completed successfully before :
274 * <ul>
275 * <li> <code> getDropDownLineCount </code> </li>
276 * </ul>
278 public void _setDropDownLineCount() {
279 requiredMethod("getDropDownLineCount()") ;
281 boolean result = true ;
282 oObj.setDropDownLineCount((short)(lineCount + 1)) ;
283 result = oObj.getDropDownLineCount() == lineCount + 1 ;
285 tRes.tested("setDropDownLineCount()", result) ;
289 * Selects some item and gets selected item position. <p>
290 * Has <b> OK </b> status if position is equal to position set. <p>
291 * The following method tests are to be completed successfully before :
292 * <ul>
293 * <li> <code> addItems </code> : to have some items </li>
294 * </ul>
296 public void _getSelectedItemPos() {
297 requiredMethod("addItems()") ;
299 boolean result = true ;
300 oObj.selectItemPos((short)1, true) ;
301 short pos = oObj.getSelectedItemPos() ;
303 result = pos == 1 ;
305 tRes.tested("getSelectedItemPos()", result) ;
309 * Clears all selections, then selects some items and gets selected
310 * item positions. <p>
311 * Has <b> OK </b> status if positions get are the same as were set.<p>
312 * The following method tests are to be completed successfully before :
313 * <ul>
314 * <li> <code> selectItemsPos </code> </li>
315 * </ul>
317 public void _getSelectedItemsPos() {
318 requiredMethod("selectItemsPos()") ;
320 boolean result = true ;
321 short cnt = oObj.getItemCount() ;
322 for (short i = 0; i < cnt; i++) {
323 oObj.selectItemPos(i, false) ;
325 oObj.selectItemsPos(new short[] {0, 2}, true) ;
327 short[] items = oObj.getSelectedItemsPos() ;
329 result = items != null && items.length == 2 &&
330 items[0] == 0 && items[1] == 2 ;
332 tRes.tested("getSelectedItemsPos()", result) ;
336 * Unselects all items, selects some item and then gets selected item. <p>
337 * Has <b> OK </b> status if items selected and get are equal.
338 * The following method tests are to be completed successfully before :
339 * <ul>
340 * <li> <code> addItems </code> : to have some items </li>
341 * </ul>
343 public void _getSelectedItem() {
344 requiredMethod("addItems()") ;
346 boolean result = true ;
347 short cnt = oObj.getItemCount() ;
348 for (short i = 0; i < cnt; i++) {
349 oObj.selectItemPos(i, false) ;
351 oObj.selectItem("Item3", true) ;
352 String item = oObj.getSelectedItem() ;
354 result = "Item3".equals(item) ;
356 tRes.tested("getSelectedItem()", result) ;
360 * Clears all selections, then selects some items positions and gets
361 * selected items. <p>
362 * Has <b> OK </b> status if items get are the same as items on
363 * positions which were set.<p>
364 * The following method tests are to be completed successfully before :
365 * <ul>
366 * <li> <code> selectItemsPos </code> </li>
367 * <li> <code> getItem </code>: this method is used here for checking.
368 * </li>
369 * </ul>
371 public void _getSelectedItems() {
372 requiredMethod("selectItemsPos()") ;
373 requiredMethod("getItem()") ;
375 boolean result = true ;
376 short cnt = oObj.getItemCount() ;
377 for (short i = 0; i < cnt; i++) {
378 oObj.selectItemPos(i, false) ;
380 oObj.selectItemsPos(new short[] {0, 2}, true) ;
382 String[] items = oObj.getSelectedItems() ;
383 result = items != null && items.length == 2 &&
384 oObj.getItem((short)0).equals(items[0]) &&
385 oObj.getItem((short)2).equals(items[1]) ;
387 tRes.tested("getSelectedItems()", result) ;
391 * Unselects all items, then selects a single item. <p>
392 * Has <b> OK </b> status if no runtime exceptions occurred
393 * The following method tests are to be completed successfully before :
394 * <ul>
395 * <li> <code> addItems </code> : to have some items </li>
396 * </ul>
398 public void _selectItemPos() {
399 requiredMethod("addItems()") ;
401 boolean result = true ;
402 short cnt = oObj.getItemCount() ;
403 for (short i = 0; i < cnt; i++) {
404 oObj.selectItemPos(i, false) ;
406 oObj.selectItemPos((short)1, true) ;
408 tRes.tested("selectItemPos()", result) ;
412 * Just selects some items. <p>
413 * Has <b> OK </b> status if no runtime exceptions occurred
414 * The following method tests are to be completed successfully before :
415 * <ul>
416 * <li> <code> addItems </code> : to have some items </li>
417 * </ul>
419 public void _selectItemsPos() {
420 requiredMethod("addItems()") ;
421 requiredMethod("setMultipleMode()") ;
423 boolean result = true ;
424 oObj.selectItemsPos(new short[] {0, 2}, true) ;
426 tRes.tested("selectItemsPos()", result) ;
430 * Just selects an item. <p>
431 * Has <b> OK </b> status if no runtime exceptions occurred
432 * The following method tests are to be completed successfully before :
433 * <ul>
434 * <li> <code> addItems </code> : to have some items </li>
435 * </ul>
437 public void _selectItem() {
438 requiredMethod("addItems()") ;
440 boolean result = true ;
441 oObj.selectItem("Item3", true) ;
443 tRes.tested("selectItem()", result) ;
447 * Checks if multiple mode is set. <p>
448 * Has <b> OK </b> status if multiple mode is set. <p>
449 * The following method tests are to be completed successfully before :
450 * <ul>
451 * <li> <code> setMultipleMode </code> </li>
452 * </ul>
454 public void _isMutipleMode() {
455 requiredMethod("setMultipleMode()") ;
457 boolean result = true ;
458 result = oObj.isMutipleMode() ;
460 tRes.tested("isMutipleMode()", result) ;
464 * Sets multiple mode. <p>
465 * Has <b> OK </b> status if no runtime exceptions occurred
467 public void _setMultipleMode() {
469 boolean result = true ;
470 oObj.setMultipleMode(true) ;
472 tRes.tested("setMultipleMode()", result) ;
476 * Just calls the method to make visible third item. <p>
477 * Has <b> OK </b> status if no runtime exceptions occurred.<p>
478 * The following method tests are to be completed successfully before :
479 * <ul>
480 * <li> <code> addItems </code> </li>
481 * </ul>
483 public void _makeVisible() {
484 requiredMethod("addItems()") ;
486 boolean result = true ;
487 oObj.makeVisible((short)2) ;
489 tRes.tested("makeVisible()", result) ;