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'  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.XListBox
43'*************************************************************************
44On Error Goto ErrHndl
45    Dim bOK As Boolean
46
47
48    Test.StartMethod("addItemListener()")
49    Dim oIListener As Object
50    oIListener = createUnoListener("IL_", "com.sun.star.awt.XItemListener")
51    bIL_itemStateChanged = False
52    oObj.addItemListener(oIListener)
53    Out.Log("Can be checked only interactively !!!")
54    bOK = True
55    Test.MethodTested("addItemListener()", bOK)
56
57    Test.StartMethod("removeItemListener()")
58    oObj.removeItemListener(oIListener)
59    bOK = True
60    Test.MethodTested("removeItemListener()", bOK)
61
62    Test.StartMethod("addActionListener()")
63    Dim oAListener As Object
64    oAListener = createUnoListener("AL_", "com.sun.star.awt.XActionListener")
65    bAL_actionPerformed = False
66    Out.Log("Can be checked only interactively !!!")
67    oObj.addActionListener(oAListener)
68    bOK = True
69    Test.MethodTested("addActionListener()", bOK)
70
71    Test.StartMethod("removeActionListener()")
72    oObj.removeActionListener(oAListener)
73    bOK = True
74    Test.MethodTested("removeActionListener()", bOK)
75
76    Test.StartMethod("getItemCount()")
77    Dim itemCount As Integer
78    itemCount = oObj.getItemCount()
79    bOK = itemCount &gt; 0 Or itemCount = 0
80    Test.MethodTested("getItemCount()", bOK)
81
82    Test.StartMethod("addItem()")
83    oObj.addItem("Item1", itemCount)
84    bOK = oObj.getItemCount() = (itemCount + 1)
85    Test.MethodTested("addItem()", bOK)
86
87    Test.StartMethod("addItems()")
88    Dim oldCount As Integer
89    oldCount = oObj.getItemCount()
90    Dim items As Variant
91    items = Array("Item2", "Item3")
92    oObj.addItems(items, oldCount)
93    bOK = oObj.getItemCount() = (oldCount + 2)
94    Test.MethodTested("addItems()", bOK)
95
96    Test.StartMethod("getItem()")
97    Dim item As String
98    item = oObj.getItem(itemCount)
99    bOK = (item = "Item1")
100    Test.MethodTested("getItem()", bOK)
101
102    Test.StartMethod("getItems()")
103    Dim itms As Variant
104    itms = oObj.getItems()
105    bOK = True
106    Dim i As Integer
107    Dim iName As String
108    For i = itemCount to itemCount + 2
109        iName = "Item" + (i + 1)
110        bOK = bOK And (iName = itms(i))
111    Next i
112    Test.MethodTested("getItems()", bOK)
113
114    Test.StartMethod("getSelectedItemPos()")
115    oObj.selectItemPos(1, True)
116    bOK = (oObj.getSelectedItemPos() = 1)
117    Test.MethodTested("getSelectedItemPos()", bOK)
118
119    Test.StartMethod("setMultipleMode()")
120    oObj.setMultipleMode(True)
121    bOK = True
122    Test.MethodTested("setMultipleMode()", bOK)
123
124    Test.StartMethod("selectItemsPos()")
125    Dim selItems As Variant
126    selItems = Array(0, 2)
127    oObj.selectItemsPos(selItems, True)
128    bOK = True
129    Test.MethodTested("selectItemsPos()", bOK)
130
131    Test.StartMethod("getSelectedItemsPos()")
132    Dim cnt As Integer
133    cnt = oObj.getItemCount()
134    For i = 0 to cnt
135        oObj.selectItemPos(i, False)
136    Next i
137    selItems = Array(0, 2)
138    oObj.selectItemsPos(selItems, True)
139    Dim selItemsPos As Variant
140    selItemsPos = oObj.getSelectedItemsPos()
141    Out.Log("Selected items position:")
142    For i = 0 to ubound(selItemsPos)
143        Out.log(selItemsPos(i))
144    Next i
145    bOK = (ubound(selItemsPos) = 1) And (selItemsPos(0) = "0") And (selItemsPos(1) = "2")
146    Test.MethodTested("getSelectedItemsPos()", bOK)
147
148    Test.StartMethod("selectItem()")
149    bOK = true
150    oObj.selectItem("Item3", True)
151    Test.MethodTested("selectItem()", bOK)
152
153    Test.StartMethod("getSelectedItem()")
154    cnt = oObj.getItemCount()
155    For i = 0 to cnt
156        oObj.selectItemPos(i, False)
157    Next i
158    oObj.selectItem("Item3", True)
159    bOK = (oObj.getSelectedItem() = "Item3")
160    Test.MethodTested("getSelectedItem()", bOK)
161
162    Test.StartMethod("getSelectedItems()")
163    bOK = true
164    cnt = oObj.getItemCount()
165    For i = 0 to cnt
166        oObj.selectItemPos(i, False)
167    Next i
168    oObj.selectItemsPos(selItems, True)
169    items = oObj.getSelectedItems()
170    Out.Log("Selected items:")
171    For i = 0 to ubound(items)
172        Out.log(items(i))
173    Next i
174    bOK = (ubound(items) = 1) And (oObj.getItem(0) = items(0)) And (oObj.getItem(2) = items(1))
175    Test.MethodTested("getSelectedItems()", bOK)
176
177    Test.StartMethod("selectItemPos()")
178    cnt = oObj.getItemCount()
179    For i = 0 to cnt
180        oObj.selectItemPos(i, False)
181    Next i
182    oObj.selectItemPos(1, True)
183    bOK = True
184    Test.MethodTested("selectItemPos()", bOK)
185
186    Test.StartMethod("isMutipleMode()")
187    bOK = oObj.isMutipleMode()
188    Test.MethodTested("isMutipleMode()", bOK)
189
190    Test.StartMethod("makeVisible()")
191    bOK = true
192    oObj.makeVisible(2)
193    Test.MethodTested("makeVisible()", bOK)
194
195    Test.StartMethod("getDropDownLineCount()")
196    Dim lineCount As Integer
197    lineCount = oObj.getDropDownLineCount()
198    bOK = True
199    Test.MethodTested("getDropDownLineCount()", bOK)
200
201    Test.StartMethod("setDropDownLineCount()")
202    oObj.setDropDownLineCount(lineCount + 1)
203    bOK = oObj.getDropDownLineCount() = (lineCount + 1)
204    Test.MethodTested("setDropDownLineCount()", bOK)
205
206    Test.StartMethod("removeItems()")
207    cnt = oObj.getItemCount()
208    oObj.removeItems(0, cnt)
209    bOK = oObj.getItemCount() = 0
210    Test.MethodTested("removeItems()", bOK)
211
212Exit Sub
213ErrHndl:
214    Test.Exception()
215    bOK = false
216    resume next
217End Sub
218
219Sub IL_itemStateChanged
220    bIL_itemStateChanged = True
221    Out.Log("CallBack for ItemListener itemStateChanged was called.")
222End Sub
223
224Sub AL_actionPerformed
225    bAL_actionPerformed = True
226    Out.Log("CallBack for ActionListener actionPerformed was called.")
227End Sub
228
229Sub AL_disposing
230End Sub
231
232Sub IL_disposing
233End Sub
234</script:module>
235