summaryrefslogtreecommitdiffstats
path: root/qadevOOo/tests/basic/ifc/awt/XListBox/awt_XListBox.xba
blob: f7ebe0b1603d90a9b92957548e133d6b748cb188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="awt_XListBox" script:language="StarBasic">


'*************************************************************************
'
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
' 
' Copyright 2000, 2010 Oracle and/or its affiliates.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' 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
' <http://www.openoffice.org/license.html>
' 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 &gt; 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
</script:module>