1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10*ef39d40dSAndrew Rist * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package ifc.awt; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import lib.MultiMethodTest; 27cdf0e10cSrcweir import lib.Status; 28cdf0e10cSrcweir 29cdf0e10cSrcweir import com.sun.star.awt.XComboBox; 30cdf0e10cSrcweir 31cdf0e10cSrcweir /** 32cdf0e10cSrcweir * Testing <code>com.sun.star.awt.XComboBox</code> 33cdf0e10cSrcweir * interface methods : 34cdf0e10cSrcweir * <ul> 35cdf0e10cSrcweir * <li><code> addItemListener()</code></li> 36cdf0e10cSrcweir * <li><code> removeItemListener()</code></li> 37cdf0e10cSrcweir * <li><code> addActionListener()</code></li> 38cdf0e10cSrcweir * <li><code> removeActionListener()</code></li> 39cdf0e10cSrcweir * <li><code> addItem()</code></li> 40cdf0e10cSrcweir * <li><code> addItems()</code></li> 41cdf0e10cSrcweir * <li><code> removeItems()</code></li> 42cdf0e10cSrcweir * <li><code> getItemCount()</code></li> 43cdf0e10cSrcweir * <li><code> getItem()</code></li> 44cdf0e10cSrcweir * <li><code> getItems()</code></li> 45cdf0e10cSrcweir * <li><code> getDropDownLineCount()</code></li> 46cdf0e10cSrcweir * <li><code> setDropDownLineCount()</code></li> 47cdf0e10cSrcweir * </ul> <p> 48cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p> 49cdf0e10cSrcweir * @see com.sun.star.awt.XComboBox 50cdf0e10cSrcweir */ 51cdf0e10cSrcweir public class _XComboBox extends MultiMethodTest { 52cdf0e10cSrcweir 53cdf0e10cSrcweir public XComboBox oObj = null; 54cdf0e10cSrcweir 55cdf0e10cSrcweir /** 56cdf0e10cSrcweir * Listener implementation which sets flags on appropriate method calls 57cdf0e10cSrcweir */ 58cdf0e10cSrcweir protected class TestActionListener 59cdf0e10cSrcweir implements com.sun.star.awt.XActionListener { 60cdf0e10cSrcweir public boolean disposingCalled = false; 61cdf0e10cSrcweir public boolean actionPerformedCalled = false; 62cdf0e10cSrcweir disposing(com.sun.star.lang.EventObject e)63cdf0e10cSrcweir public void disposing(com.sun.star.lang.EventObject e) { 64cdf0e10cSrcweir disposingCalled = true; 65cdf0e10cSrcweir } 66cdf0e10cSrcweir actionPerformed(com.sun.star.awt.ActionEvent e)67cdf0e10cSrcweir public void actionPerformed(com.sun.star.awt.ActionEvent e) { 68cdf0e10cSrcweir actionPerformedCalled = true; 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir /** 74cdf0e10cSrcweir * Listener implementation which sets flags on appropriate method calls 75cdf0e10cSrcweir */ 76cdf0e10cSrcweir protected class TestItemListener 77cdf0e10cSrcweir implements com.sun.star.awt.XItemListener { 78cdf0e10cSrcweir public boolean disposingCalled = false; 79cdf0e10cSrcweir public boolean itemStateChangedCalled = false; 80cdf0e10cSrcweir disposing(com.sun.star.lang.EventObject e)81cdf0e10cSrcweir public void disposing(com.sun.star.lang.EventObject e) { 82cdf0e10cSrcweir disposingCalled = true; 83cdf0e10cSrcweir } 84cdf0e10cSrcweir itemStateChanged(com.sun.star.awt.ItemEvent e)85cdf0e10cSrcweir public void itemStateChanged(com.sun.star.awt.ItemEvent e) { 86cdf0e10cSrcweir itemStateChangedCalled = true; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir } 90cdf0e10cSrcweir private TestActionListener actionListener = new TestActionListener(); 91cdf0e10cSrcweir private TestItemListener itemListener = new TestItemListener(); 92cdf0e10cSrcweir short lineCount = 0; 93cdf0e10cSrcweir short itemCount = 0; 94cdf0e10cSrcweir 95cdf0e10cSrcweir /** 96cdf0e10cSrcweir * !!! Can be checked only interactively !!! 97cdf0e10cSrcweir */ _addItemListener()98cdf0e10cSrcweir public void _addItemListener() { 99cdf0e10cSrcweir 100cdf0e10cSrcweir oObj.addItemListener(itemListener); 101cdf0e10cSrcweir 102cdf0e10cSrcweir tRes.tested("addItemListener()", Status.skipped(true)); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir /** 106cdf0e10cSrcweir * !!! Can be checked only interactively !!! 107cdf0e10cSrcweir */ _removeItemListener()108cdf0e10cSrcweir public void _removeItemListener() { 109cdf0e10cSrcweir requiredMethod("addItemListener()"); 110cdf0e10cSrcweir 111cdf0e10cSrcweir oObj.removeItemListener(itemListener); 112cdf0e10cSrcweir 113cdf0e10cSrcweir tRes.tested("removeItemListener()", Status.skipped(true)); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir /** 117cdf0e10cSrcweir * !!! Can be checked only interactively !!! 118cdf0e10cSrcweir */ _addActionListener()119cdf0e10cSrcweir public void _addActionListener() { 120cdf0e10cSrcweir 121cdf0e10cSrcweir oObj.addActionListener(actionListener); 122cdf0e10cSrcweir 123cdf0e10cSrcweir tRes.tested("addActionListener()", Status.skipped(true)); 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir /** 127cdf0e10cSrcweir * !!! Can be checked only interactively !!! 128cdf0e10cSrcweir */ _removeActionListener()129cdf0e10cSrcweir public void _removeActionListener() { 130cdf0e10cSrcweir requiredMethod("addActionListener()"); 131cdf0e10cSrcweir 132cdf0e10cSrcweir oObj.removeActionListener(actionListener); 133cdf0e10cSrcweir 134cdf0e10cSrcweir tRes.tested("removeActionListener()", Status.skipped(true)); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir /** 138cdf0e10cSrcweir * Adds one item to the last position and check the number of 139cdf0e10cSrcweir * items after addition. <p> 140cdf0e10cSrcweir * Has <b>OK</b> status if the number of items increased by 1.<p> 141cdf0e10cSrcweir * The following method tests are to be completed successfully before : 142cdf0e10cSrcweir * <ul> 143cdf0e10cSrcweir * <li> <code> getItemCount </code> </li> 144cdf0e10cSrcweir * </ul> 145cdf0e10cSrcweir */ _addItem()146cdf0e10cSrcweir public void _addItem() { 147cdf0e10cSrcweir requiredMethod("getItemCount()"); 148cdf0e10cSrcweir 149cdf0e10cSrcweir boolean result = true; 150cdf0e10cSrcweir oObj.addItem("Item1", itemCount); 151cdf0e10cSrcweir result = oObj.getItemCount() == itemCount + 1; 152cdf0e10cSrcweir 153cdf0e10cSrcweir tRes.tested("addItem()", result); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir /** 157cdf0e10cSrcweir * Adds one two items to the last position and check the number of 158cdf0e10cSrcweir * items after addition. <p> 159cdf0e10cSrcweir * Has <b>OK</b> status if the number of items increased by 2.<p> 160cdf0e10cSrcweir * The following method tests are to be executed before : 161cdf0e10cSrcweir * <ul> 162cdf0e10cSrcweir * <li> <code> addItem </code> </li> 163cdf0e10cSrcweir * </ul> 164cdf0e10cSrcweir */ _addItems()165cdf0e10cSrcweir public void _addItems() { 166cdf0e10cSrcweir executeMethod("addItem()"); 167cdf0e10cSrcweir 168cdf0e10cSrcweir boolean result = true; 169cdf0e10cSrcweir short oldCnt = oObj.getItemCount(); 170cdf0e10cSrcweir oObj.addItems(new String[] { "Item2", "Item3" }, oldCnt); 171cdf0e10cSrcweir result = oObj.getItemCount() == oldCnt + 2; 172cdf0e10cSrcweir 173cdf0e10cSrcweir tRes.tested("addItems()", result); 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir /** 177cdf0e10cSrcweir * Gets the current number of items and tries to remove them all 178cdf0e10cSrcweir * then checks number of items. <p> 179cdf0e10cSrcweir * Has <b>OK</b> status if no items remains. <p> 180cdf0e10cSrcweir * The following method tests are to be executed before : 181cdf0e10cSrcweir * <ul> 182cdf0e10cSrcweir * <li> <code> getItems </code> </li> 183cdf0e10cSrcweir * <li> <code> getItem </code> </li> 184cdf0e10cSrcweir * </ul> 185cdf0e10cSrcweir */ _removeItems()186cdf0e10cSrcweir public void _removeItems() { 187cdf0e10cSrcweir executeMethod("getItems()"); 188cdf0e10cSrcweir executeMethod("getItem()"); 189cdf0e10cSrcweir 190cdf0e10cSrcweir boolean result = true; 191cdf0e10cSrcweir short oldCnt = oObj.getItemCount(); 192cdf0e10cSrcweir oObj.removeItems((short) 0, oldCnt); 193cdf0e10cSrcweir result = oObj.getItemCount() == 0; 194cdf0e10cSrcweir 195cdf0e10cSrcweir tRes.tested("removeItems()", result); 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir /** 199cdf0e10cSrcweir * Just retrieves current number of items and stores it. <p> 200cdf0e10cSrcweir * Has <b>OK</b> status if the count is not less than 0. 201cdf0e10cSrcweir */ _getItemCount()202cdf0e10cSrcweir public void _getItemCount() { 203cdf0e10cSrcweir 204cdf0e10cSrcweir itemCount = oObj.getItemCount(); 205cdf0e10cSrcweir 206cdf0e10cSrcweir tRes.tested("getItemCount()", itemCount >= 0); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir /** 210cdf0e10cSrcweir * After <code>addItem</code> and <code>addItems</code> methods 211cdf0e10cSrcweir * test the following items must exist {..., "Item1", "Item2", "Item3"} 212cdf0e10cSrcweir * Retrieves the item from the position which was ititially the last.<p> 213cdf0e10cSrcweir * Has <b>OK</b> status if the "Item1" was retrieved. <p> 214cdf0e10cSrcweir * The following method tests are to be executed before : 215cdf0e10cSrcweir * <ul> 216cdf0e10cSrcweir * <li> <code> addItems </code> </li> 217cdf0e10cSrcweir * </ul> 218cdf0e10cSrcweir */ _getItem()219cdf0e10cSrcweir public void _getItem() { 220cdf0e10cSrcweir requiredMethod("addItems()"); 221cdf0e10cSrcweir 222cdf0e10cSrcweir boolean result = true; 223cdf0e10cSrcweir String item = oObj.getItem(itemCount); 224cdf0e10cSrcweir result = "Item1".equals(item); 225cdf0e10cSrcweir 226cdf0e10cSrcweir tRes.tested("getItem()", result); 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir /** 230cdf0e10cSrcweir * After <code>addItem</code> and <code>addItems</code> methods 231cdf0e10cSrcweir * test the following items must exist {..., "Item1", "Item2", "Item3"} 232cdf0e10cSrcweir * Retrieves all items. <p> 233cdf0e10cSrcweir * Has <b>OK</b> status if the last three items retrieved are 234cdf0e10cSrcweir * "Item1", "Item2" and "Item3". <p> 235cdf0e10cSrcweir * The following method tests are to be executed before : 236cdf0e10cSrcweir * <ul> 237cdf0e10cSrcweir * <li> <code> addItems </code> </li> 238cdf0e10cSrcweir * </ul> 239cdf0e10cSrcweir */ _getItems()240cdf0e10cSrcweir public void _getItems() { 241cdf0e10cSrcweir requiredMethod("addItems()"); 242cdf0e10cSrcweir 243cdf0e10cSrcweir boolean result = true; 244cdf0e10cSrcweir String[] items = oObj.getItems(); 245cdf0e10cSrcweir for (int i = itemCount; i < (itemCount + 3); i++) { 246cdf0e10cSrcweir result &= ("Item" + (i + 1)).equals(items[i]); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 249cdf0e10cSrcweir tRes.tested("getItems()", result); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir /** 253cdf0e10cSrcweir * Gets line count and stores it. <p> 254cdf0e10cSrcweir * Has <b>OK</b> status if no runtime exceptions occured. 255cdf0e10cSrcweir */ _getDropDownLineCount()256cdf0e10cSrcweir public void _getDropDownLineCount() { 257cdf0e10cSrcweir 258cdf0e10cSrcweir boolean result = true; 259cdf0e10cSrcweir lineCount = oObj.getDropDownLineCount(); 260cdf0e10cSrcweir 261cdf0e10cSrcweir tRes.tested("getDropDownLineCount()", result); 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir /** 265cdf0e10cSrcweir * Sets a new value and then checks get value. <p> 266cdf0e10cSrcweir * Has <b>OK</b> status if set and get values are equal. <p> 267cdf0e10cSrcweir * The following method tests are to be completed successfully before : 268cdf0e10cSrcweir * <ul> 269cdf0e10cSrcweir * <li> <code> getDropDownLineCount </code> </li> 270cdf0e10cSrcweir * </ul> 271cdf0e10cSrcweir */ _setDropDownLineCount()272cdf0e10cSrcweir public void _setDropDownLineCount() { 273cdf0e10cSrcweir requiredMethod("getDropDownLineCount()"); 274cdf0e10cSrcweir 275cdf0e10cSrcweir boolean result = true; 276cdf0e10cSrcweir oObj.setDropDownLineCount((short) (lineCount + 1)); 277cdf0e10cSrcweir result = oObj.getDropDownLineCount() == lineCount + 1; 278cdf0e10cSrcweir 279cdf0e10cSrcweir tRes.tested("setDropDownLineCount()", result); 280cdf0e10cSrcweir } 281cdf0e10cSrcweir }