'************************************************************************* ' ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ' ' Copyright 2008 by Sun Microsystems, Inc. ' ' OpenOffice.org - a multi-platform office productivity suite ' ' $RCSfile: awt_XListBox.xba,v $ ' ' $Revision: 1.3 $ ' ' This file is part of OpenOffice.org. ' ' OpenOffice.org is free software: you can redistribute it and/or modify ' it under the terms of the GNU Lesser General Public License version 3 ' only, as published by the Free Software Foundation. ' ' OpenOffice.org is distributed in the hope that it will be useful, ' but WITHOUT ANY WARRANTY; without even the implied warranty of ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' GNU Lesser General Public License version 3 for more details ' (a copy is included in the LICENSE file that accompanied this code). ' ' You should have received a copy of the GNU Lesser General Public License ' version 3 along with OpenOffice.org. If not, see ' ' for a copy of the LGPLv3 License. ' '************************************************************************* '************************************************************************* ' Be sure that all variables are dimensioned: option explicit Dim bIL_itemStateChanged, bAL_actionPerformed As Boolean Sub RunTest() '************************************************************************* ' INTERFACE: ' com.sun.star.awt.XListBox '************************************************************************* On Error Goto ErrHndl Dim bOK As Boolean Test.StartMethod("addItemListener()") Dim oIListener As Object oIListener = createUnoListener("IL_", "com.sun.star.awt.XItemListener") bIL_itemStateChanged = False oObj.addItemListener(oIListener) Out.Log("Can be checked only interactively !!!") bOK = True Test.MethodTested("addItemListener()", bOK) Test.StartMethod("removeItemListener()") oObj.removeItemListener(oIListener) bOK = True Test.MethodTested("removeItemListener()", bOK) Test.StartMethod("addActionListener()") Dim oAListener As Object oAListener = createUnoListener("AL_", "com.sun.star.awt.XActionListener") bAL_actionPerformed = False Out.Log("Can be checked only interactively !!!") oObj.addActionListener(oAListener) bOK = True Test.MethodTested("addActionListener()", bOK) Test.StartMethod("removeActionListener()") oObj.removeActionListener(oAListner) bOK = True Test.MethodTested("removeActionListener()", bOK) Test.StartMethod("getItemCount()") Dim itemCount As Integer itemCount = oObj.getItemCount() bOK = itemCount > 0 Or itemCount = 0 Test.MethodTested("getItemCount()", bOK) Test.StartMethod("addItem()") oObj.addItem("Item1", itemCount) bOK = oObj.getItemCount() = (itemCount + 1) Test.MethodTested("addItem()", bOK) Test.StartMethod("addItems()") Dim oldCount As Integer oldCount = oObj.getItemCount() Dim items As Variant items = Array("Item2", "Item3") oObj.addItems(items, oldCount) bOK = oObj.getItemCount() = (oldCount + 2) Test.MethodTested("addItems()", bOK) Test.StartMethod("getItem()") Dim item As String item = oObj.getItem(itemCount) bOK = (item = "Item1") Test.MethodTested("getItem()", bOK) Test.StartMethod("getItems()") Dim itms As Variant itms = oObj.getItems() bOK = True Dim i As Integer Dim iName As String For i = itemCount to itemCount + 2 iName = "Item" + (i + 1) bOK = bOK And (iName = itms(i)) Next i Test.MethodTested("getItems()", bOK) Test.StartMethod("getSelectedItemPos()") oObj.selectItemPos(1, True) bOK = (oObj.getSelectedItemPos() = 1) Test.MethodTested("getSelectedItemPos()", bOK) Test.StartMethod("setMultipleMode()") oObj.setMultipleMode(True) bOK = True Test.MethodTested("setMultipleMode()", bOK) Test.StartMethod("selectItemsPos()") Dim selItems As Variant selItems = Array(0, 2) oObj.selectItemsPos(selItems, True) bOK = True Test.MethodTested("selectItemsPos()", bOK) Test.StartMethod("getSelectedItemsPos()") Dim cnt As Integer cnt = oObj.getItemCount() For i = 0 to cnt oObj.selectItemPos(i, False) Next i selItems = Array(0, 2) oObj.selectItemsPos(selItems, True) Dim selItemsPos As Variant selItemsPos = oObj.getSelectedItemsPos() Out.Log("Selected items position:") For i = 0 to ubound(selItemsPos) Out.log(selItemsPos(i)) Next i bOK = (ubound(selItemsPos) = 1) And (selItemsPos(0) = "0") And (selItemsPos(1) = "2") Test.MethodTested("getSelectedItemsPos()", bOK) Test.StartMethod("selectItem()") bOK = true oObj.selectItem("Item3", True) Test.MethodTested("selectItem()", bOK) Test.StartMethod("getSelectedItem()") cnt = oObj.getItemCount() For i = 0 to cnt oObj.selectItemPos(i, False) Next i oObj.selectItem("Item3", True) bOK = (oObj.getSelectedItem() = "Item3") Test.MethodTested("getSelectedItem()", bOK) Test.StartMethod("getSelectedItems()") bOK = true cnt = oObj.getItemCount() For i = 0 to cnt oObj.selectItemPos(i, False) Next i oObj.selectItemsPos(selItems, True) items = oObj.getSelectedItems() Out.Log("Selected items:") For i = 0 to ubound(items) Out.log(items(i)) Next i bOK = (ubound(items) = 1) And (oObj.getItem(0) = items(0)) And (oObj.getItem(2) = items(1)) Test.MethodTested("getSelectedItems()", bOK) Test.StartMethod("selectItemPos()") cnt = oObj.getItemCount() For i = 0 to cnt oObj.selectItemPos(i, False) Next i oObj.selectItemPos(1, True) bOK = True Test.MethodTested("selectItemPos()", bOK) Test.StartMethod("isMutipleMode()") bOK = oObj.isMutipleMode() Test.MethodTested("isMutipleMode()", bOK) Test.StartMethod("makeVisible()") bOK = true oObj.makeVisible(2) Test.MethodTested("makeVisible()", bOK) Test.StartMethod("getDropDownLineCount()") Dim lineCount As Integer lineCount = oObj.getDropDownLineCount() bOK = True Test.MethodTested("getDropDownLineCount()", bOK) Test.StartMethod("setDropDownLineCount()") oObj.setDropDownLineCount(lineCount + 1) bOK = oObj.getDropDownLineCount() = (lineCount + 1) Test.MethodTested("setDropDownLineCount()", bOK) Test.StartMethod("removeItems()") cnt = oObj.getItemCount() oObj.removeItems(0, cnt) bOK = oObj.getItemCount() = 0 Test.MethodTested("removeItems()", bOK) Exit Sub ErrHndl: Test.Exception() bOK = false resume next End Sub Sub IL_itemStateChanged bIL_itemStateChanged = True Out.Log("CallBack for ItemListener itemStateChanged was called.") End Sub Sub AL_actionPerformed bAL_actionPerformed = True Out.Log("CallBack for ActionListener actionPerformed was called.") End Sub Sub AL_disposing End Sub Sub IL_disposing End Sub