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