blob: 5883f4d1a69806092ea1c984fa3110c3c5ee9e0c [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="accessibility_XAccessibleSelection" 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
'*************************************************************************
' This Interface/Service test depends on the following GLOBAL variables,
' which must be specified in the object creation:
' Global multiSelection As Boolean
'*************************************************************************
Sub RunTest()
'*************************************************************************
' INTERFACE:
' com.sun.star.accessibility.XAccessibleSelection
'*************************************************************************
On Error Goto ErrHndl
Dim bOK As Boolean, locRes As Boolean
Dim chCount As Long, selCount As Long
Dim i As Long, mCount As Integer
if multiSelection then
Out.Log("Object allows multiple selection!")
else
Out.Log("Object does not allow multiple selection!")
End If
chCount = oObj.getAccessibleChildCount()
selCount = oObj.getSelectedAccessibleChildCount()
Out.Log("Object has "+chCount+" child(ren), "+selCount+" of them selected.")
If (chCount &gt; 50) then
mCount = 50
Out.Log("Object has too many children. Testing only first 50.")
else
mCount = chCount
End If
clearSelection()
Test.StartMethod("selectAccessibleChild()")
bOK = true
if (mCount &gt; 0) then
i = mCount - 1
while (oObj.isAccessibleChildSelected(i) OR itemDisabled(oObj.getAccessibleChild(i))) AND (i &gt; 0)
i = i - 1
wend
if (i &gt;= 0) then
Out.Log("Selecting child #"+i+"...")
oObj.selectAccessibleChild(i)
wait(500)
locRes = oObj.isAccessibleChildSelected(i)
Out.Log("Child #"+i+" selected: "+locRes)
bOK = bOK AND locRes
End If
End If
clearSelection()
Test.MethodTested("selectAccessibleChild()",bOK)
Test.StartMethod("isAccessibleChildSelected()")
bOK = true
if (mCount &gt; 0) then
i = mCount - 1
while (oObj.isAccessibleChildSelected(i) OR itemDisabled(oObj.getAccessibleChild(i))) AND (i &gt; 0)
i = i - 1
wend
if (i &gt;= 0) then
Out.Log("Selecting child #"+i+"...")
oObj.selectAccessibleChild(i)
wait(500)
locRes = oObj.isAccessibleChildSelected(i)
Out.Log("Child #"+i+" selected: "+locRes)
bOK = bOK AND locRes
End If
End If
clearSelection()
Test.MethodTested("isAccessibleChildSelected()",bOK)
Test.StartMethod("clearAccessibleSelection()")
bOK = true
if (mCount &gt; 0) AND (multiSelection) then
oObj.selectAccessibleChild(chCount - 1)
wait(500)
oObj.clearAccessibleSelection()
wait(500)
bOK = bOK AND NOT oObj.isAccessibleChildSelected(mCount - 1)
else
Out.Log("Cannot clear all selection for this object!")
End If
Test.MethodTested("clearAccessibleSelection()",bOK)
' ### The following property was not found in correspond IDL file! ###
Test.StartMethod("selectAllAccessibleChildren()")
bOK = true
i = 0
if ((mCount &gt; 0) AND multiSelection) then
' ### The following property was not found in correspond IDL file! ###
oObj.selectAllAccessibleChildren()
wait(500)
while (i &lt; mCount)
bOK = bOK AND oObj.isAccessibleChildSelected(i)
i = i + 1
wend
else
Out.Log("Cannot select all children for this object!")
End If
clearSelection()
Test.MethodTested("selectAllAccessibleChildren()",bOK)
Test.StartMethod("getSelectedAccessibleChildCount()")
bOK = true
Out.Log("Selecting all...")
oObj.selectAllAccessibleChildren()
wait(500)
selCount = oObj.getSelectedAccessibleChildCount()
Out.Log("Selected "+selCount+" child(ren).")
If (multiSelection) then
bOK = bOK AND (selCount = chCount)
else
bOK = bOK AND (selCount = 1)
End If
clearSelection()
selCount = oObj.getSelectedAccessibleChildCount()
if (multiSelection) then
bOK = bOK AND (selCount = 0)
else
bOK = bOK AND (selCount = 1)
End If
Test.MethodTested("getSelectedAccessibleChildCount()",bOK)
Test.StartMethod("getSelectedAccessibleChild()")
Dim selAccChild As Object, accChild As Object
bOK = true
if (mCount &gt; 0) then
i = mCount - 1
while (oObj.isAccessibleChildSelected(i) OR itemDisabled(oObj.getAccessibleChild(i))) AND (i &gt; 0)
i = i - 1
wend
if (i &gt;= 0) then
Out.Log("Selecting child #"+i+"...")
oObj.selectAccessibleChild(i)
wait(500)
Out.Log("Child #"+i+" selected: "+oObj.isAccessibleChildSelected(i))
Out.Log("Now "+oObj.getSelectedAccessibleChildCount()+" child(ren) selected.")
selCount = oObj.getSelectedAccessibleChildCount()
if (selCount &gt; 0) then
selAccChild = oObj.getSelectedAccessibleChild(selCount-1)
accChild = oObj.getAccessibleChild(i)
bOK = bOK AND utils.at_equals(accChild,selAccChild)
else
Out.Log("There are no selected children. Test fails.")
bOK = false
End If
End If
End If
Test.MethodTested("getSelectedAccessibleChild()",bOK)
Test.StartMethod("deselectAccessibleChild()")
Dim newSelCount As Long
Dim isSelected as Boolean
bOK = true
oObj.selectAllAccessibleChildren()
wait(500)
selCount = oObj.getSelectedAccessibleChildCount()
Out.Log("There was "+selCount+" selected child(ren)")
Out.Log("Deselecting child...")
for i = 0 to mCount - 1
if oObj.isAccessibleChildSelected(i) then
isSelected = true
end if
oObj.deselectAccessibleChild(i)
wait(500)
newSelCount = oObj.getSelectedAccessibleChildCount()
Out.Log("selCount = " + selCount + " newSelCount = " + newSelCount)
if (multiSelection) then
if isSelected then
Out.Log("isSelected")
bOK = bOK AND (selCount - 1 = newSelCount)
else
bOK = bOK AND (selCount = newSelCount)
end if
else
Out.Log("is not multi")
bOK = bOK AND (newSelCount &lt;= 1)
End If
selCount = newSelCount
next
Test.MethodTested("deselectAccessibleChild()",bOK)
Exit Sub
ErrHndl:
Test.Exception()
bOK = false
resume next
End Sub
Sub clearSelection()
if NOT multiSelection then Exit Sub
Dim selCount As Long
selCount = oObj.getSelectedAccessibleChildCount()
if (selCount = 0) then Exit Sub
oObj.clearAccessibleSelection()
wait(500)
selCount = oObj.getSelectedAccessibleChildCount()
if selCount = 0 then
Out.Log("Deselect all: success")
else
Out.Log("Deselect all: error!. "+selCount+" child(ren) remains selected.")
End If
End Sub
Function itemDisabled(oChild As Object) As Boolean
if NOT hasUNOInterfaces(oChild,"com.sun.star.accessibility.XAccessibleContext") then
oChild = oChild.getAccessibleContext()
End If
itemDisabled = NOT oChild.getAccessibleStateSet().contains(21)
End Function
</script:module>