Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XComboBox.java
blob094bcf18c52aeb62a1f07ca7a288c87e8f8849ce
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;
22 import lib.Status;
24 import com.sun.star.awt.XComboBox;
26 /**
27 * Testing <code>com.sun.star.awt.XComboBox</code>
28 * interface methods :
29 * <ul>
30 * <li><code> addItemListener()</code></li>
31 * <li><code> removeItemListener()</code></li>
32 * <li><code> addActionListener()</code></li>
33 * <li><code> removeActionListener()</code></li>
34 * <li><code> addItem()</code></li>
35 * <li><code> addItems()</code></li>
36 * <li><code> removeItems()</code></li>
37 * <li><code> getItemCount()</code></li>
38 * <li><code> getItem()</code></li>
39 * <li><code> getItems()</code></li>
40 * <li><code> getDropDownLineCount()</code></li>
41 * <li><code> setDropDownLineCount()</code></li>
42 * </ul> <p>
43 * Test is <b> NOT </b> multithread compliant. <p>
44 * @see com.sun.star.awt.XComboBox
46 public class _XComboBox extends MultiMethodTest {
48 public XComboBox oObj = null;
50 /**
51 * Listener implementation which sets flags on appropriate method calls
53 protected class TestActionListener
54 implements com.sun.star.awt.XActionListener {
55 public boolean disposingCalled = false;
56 public boolean actionPerformedCalled = false;
58 public void disposing(com.sun.star.lang.EventObject e) {
59 disposingCalled = true;
62 public void actionPerformed(com.sun.star.awt.ActionEvent e) {
63 actionPerformedCalled = true;
68 /**
69 * Listener implementation which sets flags on appropriate method calls
71 protected class TestItemListener
72 implements com.sun.star.awt.XItemListener {
73 public boolean disposingCalled = false;
74 public boolean itemStateChangedCalled = false;
76 public void disposing(com.sun.star.lang.EventObject e) {
77 disposingCalled = true;
80 public void itemStateChanged(com.sun.star.awt.ItemEvent e) {
81 itemStateChangedCalled = true;
85 private final TestActionListener actionListener = new TestActionListener();
86 private final TestItemListener itemListener = new TestItemListener();
87 short lineCount = 0;
88 short itemCount = 0;
90 /**
91 * !!! Can be checked only interactively !!!
93 public void _addItemListener() {
95 oObj.addItemListener(itemListener);
97 tRes.tested("addItemListener()", Status.skipped(true));
101 * !!! Can be checked only interactively !!!
103 public void _removeItemListener() {
104 requiredMethod("addItemListener()");
106 oObj.removeItemListener(itemListener);
108 tRes.tested("removeItemListener()", Status.skipped(true));
112 * !!! Can be checked only interactively !!!
114 public void _addActionListener() {
116 oObj.addActionListener(actionListener);
118 tRes.tested("addActionListener()", Status.skipped(true));
122 * !!! Can be checked only interactively !!!
124 public void _removeActionListener() {
125 requiredMethod("addActionListener()");
127 oObj.removeActionListener(actionListener);
129 tRes.tested("removeActionListener()", Status.skipped(true));
133 * Adds one item to the last position and check the number of
134 * items after addition. <p>
135 * Has <b>OK</b> status if the number of items increased by 1.<p>
136 * The following method tests are to be completed successfully before :
137 * <ul>
138 * <li> <code> getItemCount </code> </li>
139 * </ul>
141 public void _addItem() {
142 requiredMethod("getItemCount()");
144 boolean result = true;
145 oObj.addItem("Item1", itemCount);
146 result = oObj.getItemCount() == itemCount + 1;
148 tRes.tested("addItem()", result);
152 * Adds one two items to the last position and check the number of
153 * items after addition. <p>
154 * Has <b>OK</b> status if the number of items increased by 2.<p>
155 * The following method tests are to be executed before :
156 * <ul>
157 * <li> <code> addItem </code> </li>
158 * </ul>
160 public void _addItems() {
161 executeMethod("addItem()");
163 boolean result = true;
164 short oldCnt = oObj.getItemCount();
165 oObj.addItems(new String[] { "Item2", "Item3" }, oldCnt);
166 result = oObj.getItemCount() == oldCnt + 2;
168 tRes.tested("addItems()", result);
172 * Gets the current number of items and tries to remove them all
173 * then checks number of items. <p>
174 * Has <b>OK</b> status if no items remains. <p>
175 * The following method tests are to be executed before :
176 * <ul>
177 * <li> <code> getItems </code> </li>
178 * <li> <code> getItem </code> </li>
179 * </ul>
181 public void _removeItems() {
182 executeMethod("getItems()");
183 executeMethod("getItem()");
185 boolean result = true;
186 short oldCnt = oObj.getItemCount();
187 oObj.removeItems((short) 0, oldCnt);
188 result = oObj.getItemCount() == 0;
190 tRes.tested("removeItems()", result);
194 * Just retrieves current number of items and stores it. <p>
195 * Has <b>OK</b> status if the count is not less than 0.
197 public void _getItemCount() {
199 itemCount = oObj.getItemCount();
201 tRes.tested("getItemCount()", itemCount >= 0);
205 * After <code>addItem</code> and <code>addItems</code> methods
206 * test the following items must exist {..., "Item1", "Item2", "Item3"}
207 * Retrieves the item from the position which was ititially the last.<p>
208 * Has <b>OK</b> status if the "Item1" was retrieved. <p>
209 * The following method tests are to be executed before :
210 * <ul>
211 * <li> <code> addItems </code> </li>
212 * </ul>
214 public void _getItem() {
215 requiredMethod("addItems()");
217 boolean result = true;
218 String item = oObj.getItem(itemCount);
219 result = "Item1".equals(item);
221 tRes.tested("getItem()", result);
225 * After <code>addItem</code> and <code>addItems</code> methods
226 * test the following items must exist {..., "Item1", "Item2", "Item3"}
227 * Retrieves all items. <p>
228 * Has <b>OK</b> status if the last three items retrieved are
229 * "Item1", "Item2" and "Item3". <p>
230 * The following method tests are to be executed before :
231 * <ul>
232 * <li> <code> addItems </code> </li>
233 * </ul>
235 public void _getItems() {
236 requiredMethod("addItems()");
238 boolean result = true;
239 String[] items = oObj.getItems();
240 for (int i = itemCount; i < (itemCount + 3); i++) {
241 result &= ("Item" + (i + 1)).equals(items[i]);
244 tRes.tested("getItems()", result);
248 * Gets line count and stores it. <p>
249 * Has <b>OK</b> status if no runtime exceptions occurred.
251 public void _getDropDownLineCount() {
253 boolean result = true;
254 lineCount = oObj.getDropDownLineCount();
256 tRes.tested("getDropDownLineCount()", result);
260 * Sets a new value and then checks get value. <p>
261 * Has <b>OK</b> status if set and get values are equal. <p>
262 * The following method tests are to be completed successfully before :
263 * <ul>
264 * <li> <code> getDropDownLineCount </code> </li>
265 * </ul>
267 public void _setDropDownLineCount() {
268 requiredMethod("getDropDownLineCount()");
270 boolean result = true;
271 oObj.setDropDownLineCount((short) (lineCount + 1));
272 result = oObj.getDropDownLineCount() == lineCount + 1;
274 tRes.tested("setDropDownLineCount()", result);