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_XComboBox" 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' Be sure that all variables are dimensioned: 37option explicit 38 39 40Dim bIL_itemStateChanged, bAL_actionPerformed As Boolean 41 42 43Sub RunTest() 44 45'************************************************************************* 46' INTERFACE: 47' com.sun.star.awt.XComboBox 48'************************************************************************* 49On Error Goto ErrHndl 50 Dim bOK As Boolean 51 Dim oIListener, oAListener As Object 52 53 bIL_itemStateChanged = False 54 oIListener = createUnoListener("IL_", "com.sun.star.awt.XItemListener") 55 56 Test.StartMethod("addItemListener()") 57 oObj.addItemListener(oIListener) 58 bOK = True 59 Test.MethodTested("addItemListener()", bOK) 60 61 Test.StartMethod("removeItemListener()") 62 oObj.removeItemListener(oIListener) 63 bOK = True 64 Test.MethodTested("removeItemListener()", bOK) 65 66 bAL_actionPerformed = False 67 oAListener = createUnoListener("AL_", "com.sun.star.awt.XActionListener") 68 Test.StartMethod("addActionListener()") 69 oObj.addActionListener(oAListener) 70 bOK = True 71 Test.MethodTested("addActionListener()", bOK) 72 73 Test.StartMethod("removeActionListener()") 74 oObj.removeActionListener(oAListener) 75 bOK = True 76 Test.MethodTested("removeActionListener()", bOK) 77 78 Dim itemCount As Integer 79 Test.StartMethod("getItemCount()") 80 itemCount = oObj.getItemCount() 81 bOK = itemCount > 0 or itemCount = 0 82 Test.MethodTested("getItemCount()", bOK) 83 84 Test.StartMethod("addItem()") 85 oObj.addItem("Item1", itemCount) 86 bOK = oObj.getItemCount() = (itemCount + 1) 87 Test.MethodTested("addItem()", bOK) 88 89 Dim itemNames As Variant 90 itemNames = Array("Item2", "Item3") 91 Dim oldCount As Integer 92 oldCount = oObj.getItemCount() 93 Test.StartMethod("addItems()") 94 oObj.addItems(itemNames(), oldCount) 95 bOK = (oldCount + 2) = oObj.getItemCount() 96 Test.MethodTested("addItems()", bOK) 97 98 Test.StartMethod("getItem()") 99 bOK = (oObj.getItem(itemCount) = "Item1") 100 Test.MethodTested("getItem()", bOK) 101 102 Test.StartMethod("getItems()") 103 itemNames = oObj.getItems() 104 Dim i As Integer 105 bOK = True 106 Dim iname As String 107 For i = itemCount to itemCount + 2 108 iname = "Item" + (i + 1) 109 bOK = bOK and itemNames(i) = iname 110 out.log(iname + " " + itemNames(i)) 111 Next i 112 Test.MethodTested("getItems()", bOK) 113 114 Test.StartMethod("removeItems()") 115 oObj.removeItems(0, oObj.getItemCount()) 116 bOK = oObj.getItemCount = 0 117 Test.MethodTested("removeItems()", bOK) 118 119 Dim lineCount As Integer 120 Test.StartMethod("getDropDownLineCount()") 121 lineCount = oObj.getDropDownLineCount() 122 bOK = True 123 Test.MethodTested("getDropDownLineCount()", bOK) 124 125 Test.StartMethod("setDropDownLineCount()") 126 oObj.setDropDownLineCount(lineCount + 1) 127 bOK = oObj.getDropDownLineCount() = lineCount + 1 128 Test.MethodTested("setDropDownLineCount()", bOK) 129 130Exit Sub 131ErrHndl: 132 Test.Exception() 133 bOK = false 134 resume next 135End Sub 136 137Sub IL_itemStateChanged 138 Out.Log("CallBack for ItemListener itemStateChanged was called.") 139 bIL_itemStateChanged = true 140End Sub 141 142Sub AL_actionPerformed 143 Out.Log("CallBack for ActionListener actionPerformed was called.") 144 bAL_actionPerformed = true 145End Sub 146</script:module> 147