1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="awt_XListBox" script:language="StarBasic"> 4 5 6'************************************************************************* 7' 8' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9' 10' Copyright 2000, 2010 Oracle and/or its affiliates. 11' 12' OpenOffice.org - a multi-platform office productivity suite 13' 14' This file is part of OpenOffice.org. 15' 16' OpenOffice.org is free software: you can redistribute it and/or modify 17' it under the terms of the GNU Lesser General Public License version 3 18' only, as published by the Free Software Foundation. 19' 20' OpenOffice.org is distributed in the hope that it will be useful, 21' but WITHOUT ANY WARRANTY; without even the implied warranty of 22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23' GNU Lesser General Public License version 3 for more details 24' (a copy is included in the LICENSE file that accompanied this code). 25' 26' You should have received a copy of the GNU Lesser General Public License 27' version 3 along with OpenOffice.org. If not, see 28' <http://www.openoffice.org/license.html> 29' for a copy of the LGPLv3 License. 30' 31'************************************************************************* 32***** 33'************************************************************************* 34 35 36 37' Be sure that all variables are dimensioned: 38option explicit 39 40 41Dim bIL_itemStateChanged, bAL_actionPerformed As Boolean 42 43 44Sub RunTest() 45 46'************************************************************************* 47' INTERFACE: 48' com.sun.star.awt.XListBox 49'************************************************************************* 50On Error Goto ErrHndl 51 Dim bOK As Boolean 52 53 54 Test.StartMethod("addItemListener()") 55 Dim oIListener As Object 56 oIListener = createUnoListener("IL_", "com.sun.star.awt.XItemListener") 57 bIL_itemStateChanged = False 58 oObj.addItemListener(oIListener) 59 Out.Log("Can be checked only interactively !!!") 60 bOK = True 61 Test.MethodTested("addItemListener()", bOK) 62 63 Test.StartMethod("removeItemListener()") 64 oObj.removeItemListener(oIListener) 65 bOK = True 66 Test.MethodTested("removeItemListener()", bOK) 67 68 Test.StartMethod("addActionListener()") 69 Dim oAListener As Object 70 oAListener = createUnoListener("AL_", "com.sun.star.awt.XActionListener") 71 bAL_actionPerformed = False 72 Out.Log("Can be checked only interactively !!!") 73 oObj.addActionListener(oAListener) 74 bOK = True 75 Test.MethodTested("addActionListener()", bOK) 76 77 Test.StartMethod("removeActionListener()") 78 oObj.removeActionListener(oAListner) 79 bOK = True 80 Test.MethodTested("removeActionListener()", bOK) 81 82 Test.StartMethod("getItemCount()") 83 Dim itemCount As Integer 84 itemCount = oObj.getItemCount() 85 bOK = itemCount > 0 Or itemCount = 0 86 Test.MethodTested("getItemCount()", bOK) 87 88 Test.StartMethod("addItem()") 89 oObj.addItem("Item1", itemCount) 90 bOK = oObj.getItemCount() = (itemCount + 1) 91 Test.MethodTested("addItem()", bOK) 92 93 Test.StartMethod("addItems()") 94 Dim oldCount As Integer 95 oldCount = oObj.getItemCount() 96 Dim items As Variant 97 items = Array("Item2", "Item3") 98 oObj.addItems(items, oldCount) 99 bOK = oObj.getItemCount() = (oldCount + 2) 100 Test.MethodTested("addItems()", bOK) 101 102 Test.StartMethod("getItem()") 103 Dim item As String 104 item = oObj.getItem(itemCount) 105 bOK = (item = "Item1") 106 Test.MethodTested("getItem()", bOK) 107 108 Test.StartMethod("getItems()") 109 Dim itms As Variant 110 itms = oObj.getItems() 111 bOK = True 112 Dim i As Integer 113 Dim iName As String 114 For i = itemCount to itemCount + 2 115 iName = "Item" + (i + 1) 116 bOK = bOK And (iName = itms(i)) 117 Next i 118 Test.MethodTested("getItems()", bOK) 119 120 Test.StartMethod("getSelectedItemPos()") 121 oObj.selectItemPos(1, True) 122 bOK = (oObj.getSelectedItemPos() = 1) 123 Test.MethodTested("getSelectedItemPos()", bOK) 124 125 Test.StartMethod("setMultipleMode()") 126 oObj.setMultipleMode(True) 127 bOK = True 128 Test.MethodTested("setMultipleMode()", bOK) 129 130 Test.StartMethod("selectItemsPos()") 131 Dim selItems As Variant 132 selItems = Array(0, 2) 133 oObj.selectItemsPos(selItems, True) 134 bOK = True 135 Test.MethodTested("selectItemsPos()", bOK) 136 137 Test.StartMethod("getSelectedItemsPos()") 138 Dim cnt As Integer 139 cnt = oObj.getItemCount() 140 For i = 0 to cnt 141 oObj.selectItemPos(i, False) 142 Next i 143 selItems = Array(0, 2) 144 oObj.selectItemsPos(selItems, True) 145 Dim selItemsPos As Variant 146 selItemsPos = oObj.getSelectedItemsPos() 147 Out.Log("Selected items position:") 148 For i = 0 to ubound(selItemsPos) 149 Out.log(selItemsPos(i)) 150 Next i 151 bOK = (ubound(selItemsPos) = 1) And (selItemsPos(0) = "0") And (selItemsPos(1) = "2") 152 Test.MethodTested("getSelectedItemsPos()", bOK) 153 154 Test.StartMethod("selectItem()") 155 bOK = true 156 oObj.selectItem("Item3", True) 157 Test.MethodTested("selectItem()", bOK) 158 159 Test.StartMethod("getSelectedItem()") 160 cnt = oObj.getItemCount() 161 For i = 0 to cnt 162 oObj.selectItemPos(i, False) 163 Next i 164 oObj.selectItem("Item3", True) 165 bOK = (oObj.getSelectedItem() = "Item3") 166 Test.MethodTested("getSelectedItem()", bOK) 167 168 Test.StartMethod("getSelectedItems()") 169 bOK = true 170 cnt = oObj.getItemCount() 171 For i = 0 to cnt 172 oObj.selectItemPos(i, False) 173 Next i 174 oObj.selectItemsPos(selItems, True) 175 items = oObj.getSelectedItems() 176 Out.Log("Selected items:") 177 For i = 0 to ubound(items) 178 Out.log(items(i)) 179 Next i 180 bOK = (ubound(items) = 1) And (oObj.getItem(0) = items(0)) And (oObj.getItem(2) = items(1)) 181 Test.MethodTested("getSelectedItems()", bOK) 182 183 Test.StartMethod("selectItemPos()") 184 cnt = oObj.getItemCount() 185 For i = 0 to cnt 186 oObj.selectItemPos(i, False) 187 Next i 188 oObj.selectItemPos(1, True) 189 bOK = True 190 Test.MethodTested("selectItemPos()", bOK) 191 192 Test.StartMethod("isMutipleMode()") 193 bOK = oObj.isMutipleMode() 194 Test.MethodTested("isMutipleMode()", bOK) 195 196 Test.StartMethod("makeVisible()") 197 bOK = true 198 oObj.makeVisible(2) 199 Test.MethodTested("makeVisible()", bOK) 200 201 Test.StartMethod("getDropDownLineCount()") 202 Dim lineCount As Integer 203 lineCount = oObj.getDropDownLineCount() 204 bOK = True 205 Test.MethodTested("getDropDownLineCount()", bOK) 206 207 Test.StartMethod("setDropDownLineCount()") 208 oObj.setDropDownLineCount(lineCount + 1) 209 bOK = oObj.getDropDownLineCount() = (lineCount + 1) 210 Test.MethodTested("setDropDownLineCount()", bOK) 211 212 Test.StartMethod("removeItems()") 213 cnt = oObj.getItemCount() 214 oObj.removeItems(0, cnt) 215 bOK = oObj.getItemCount() = 0 216 Test.MethodTested("removeItems()", bOK) 217 218Exit Sub 219ErrHndl: 220 Test.Exception() 221 bOK = false 222 resume next 223End Sub 224 225Sub IL_itemStateChanged 226 bIL_itemStateChanged = True 227 Out.Log("CallBack for ItemListener itemStateChanged was called.") 228End Sub 229 230Sub AL_actionPerformed 231 bAL_actionPerformed = True 232 Out.Log("CallBack for ActionListener actionPerformed was called.") 233End Sub 234 235Sub AL_disposing 236End Sub 237 238Sub IL_disposing 239End Sub 240</script:module> 241