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' Licensed to the Apache Software Foundation (ASF) under one 9' or more contributor license agreements. See the NOTICE file 10' distributed with this work for additional information 11' regarding copyright ownership. The ASF licenses this file 12' to you under the Apache License, Version 2.0 (the 13' "License"); you may not use this file except in compliance 14' with the License. You may obtain a copy of the License at 15' 16' http://www.apache.org/licenses/LICENSE-2.0 17' 18' Unless required by applicable law or agreed to in writing, 19' software distributed under the License is distributed on an 20' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21' KIND, either express or implied. See the License for the 22' specific language governing permissions and limitations 23' under the License. 24' 25'************************************************************************* 26 27 28 29 30 31' Be sure that all variables are dimensioned: 32option explicit 33 34 35Dim bIL_itemStateChanged, bAL_actionPerformed As Boolean 36 37 38Sub RunTest() 39 40'************************************************************************* 41' INTERFACE: 42' com.sun.star.awt.XComboBox 43'************************************************************************* 44On Error Goto ErrHndl 45 Dim bOK As Boolean 46 Dim oIListener, oAListener As Object 47 48 bIL_itemStateChanged = False 49 oIListener = createUnoListener("IL_", "com.sun.star.awt.XItemListener") 50 51 Test.StartMethod("addItemListener()") 52 oObj.addItemListener(oIListener) 53 bOK = True 54 Test.MethodTested("addItemListener()", bOK) 55 56 Test.StartMethod("removeItemListener()") 57 oObj.removeItemListener(oIListener) 58 bOK = True 59 Test.MethodTested("removeItemListener()", bOK) 60 61 bAL_actionPerformed = False 62 oAListener = createUnoListener("AL_", "com.sun.star.awt.XActionListener") 63 Test.StartMethod("addActionListener()") 64 oObj.addActionListener(oAListener) 65 bOK = True 66 Test.MethodTested("addActionListener()", bOK) 67 68 Test.StartMethod("removeActionListener()") 69 oObj.removeActionListener(oAListener) 70 bOK = True 71 Test.MethodTested("removeActionListener()", bOK) 72 73 Dim itemCount As Integer 74 Test.StartMethod("getItemCount()") 75 itemCount = oObj.getItemCount() 76 bOK = itemCount > 0 or itemCount = 0 77 Test.MethodTested("getItemCount()", bOK) 78 79 Test.StartMethod("addItem()") 80 oObj.addItem("Item1", itemCount) 81 bOK = oObj.getItemCount() = (itemCount + 1) 82 Test.MethodTested("addItem()", bOK) 83 84 Dim itemNames As Variant 85 itemNames = Array("Item2", "Item3") 86 Dim oldCount As Integer 87 oldCount = oObj.getItemCount() 88 Test.StartMethod("addItems()") 89 oObj.addItems(itemNames(), oldCount) 90 bOK = (oldCount + 2) = oObj.getItemCount() 91 Test.MethodTested("addItems()", bOK) 92 93 Test.StartMethod("getItem()") 94 bOK = (oObj.getItem(itemCount) = "Item1") 95 Test.MethodTested("getItem()", bOK) 96 97 Test.StartMethod("getItems()") 98 itemNames = oObj.getItems() 99 Dim i As Integer 100 bOK = True 101 Dim iname As String 102 For i = itemCount to itemCount + 2 103 iname = "Item" + (i + 1) 104 bOK = bOK and itemNames(i) = iname 105 out.log(iname + " " + itemNames(i)) 106 Next i 107 Test.MethodTested("getItems()", bOK) 108 109 Test.StartMethod("removeItems()") 110 oObj.removeItems(0, oObj.getItemCount()) 111 bOK = oObj.getItemCount = 0 112 Test.MethodTested("removeItems()", bOK) 113 114 Dim lineCount As Integer 115 Test.StartMethod("getDropDownLineCount()") 116 lineCount = oObj.getDropDownLineCount() 117 bOK = True 118 Test.MethodTested("getDropDownLineCount()", bOK) 119 120 Test.StartMethod("setDropDownLineCount()") 121 oObj.setDropDownLineCount(lineCount + 1) 122 bOK = oObj.getDropDownLineCount() = lineCount + 1 123 Test.MethodTested("setDropDownLineCount()", bOK) 124 125Exit Sub 126ErrHndl: 127 Test.Exception() 128 bOK = false 129 resume next 130End Sub 131 132Sub IL_itemStateChanged 133 Out.Log("CallBack for ItemListener itemStateChanged was called.") 134 bIL_itemStateChanged = true 135End Sub 136 137Sub AL_actionPerformed 138 Out.Log("CallBack for ActionListener actionPerformed was called.") 139 bAL_actionPerformed = true 140End Sub 141</script:module> 142