blob: 0ba3764349ee847cdeb7d60a2483357d4ce85888 [file] [log] [blame]
<?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">
'*************************************************************************
'
' Licensed to the Apache Software Foundation (ASF) under one
' or more contributor license agreements. See the NOTICE file
' distributed with this work for additional information
' regarding copyright ownership. The ASF licenses this file
' to you under the Apache License, Version 2.0 (the
' "License"); you may not use this file except in compliance
' with the License. You may obtain a copy of the License at
'
' http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing,
' software distributed under the License is distributed on an
' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
' KIND, either express or implied. See the License for the
' specific language governing permissions and limitations
' under the 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>