diff options
Diffstat (limited to 'qadevOOo/tests/basic/ifc/accessibility/XAccessibleSelection/accessibility_XAccessibleSelection.xba')
-rw-r--r-- | qadevOOo/tests/basic/ifc/accessibility/XAccessibleSelection/accessibility_XAccessibleSelection.xba | 291 |
1 files changed, 291 insertions, 0 deletions
diff --git a/qadevOOo/tests/basic/ifc/accessibility/XAccessibleSelection/accessibility_XAccessibleSelection.xba b/qadevOOo/tests/basic/ifc/accessibility/XAccessibleSelection/accessibility_XAccessibleSelection.xba new file mode 100644 index 000000000000..24da0fc989e5 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/accessibility/XAccessibleSelection/accessibility_XAccessibleSelection.xba @@ -0,0 +1,291 @@ +<?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"> + + +'************************************************************************* +'* +'* $RCSfile: accessibility_XAccessibleSelection.xba,v $ +'* +'* $Revision: 1.1 $ +'* +'* last change:$Date: 2003-01-27 17:43:33 $ +'* +'* The Contents of this file are made available subject to the terms of +'* either of the following licenses +'* +'* - GNU Lesser General Public License Version 2.1 +'* - Sun Industry Standards Source License Version 1.1 +'* +'* Sun Microsystems Inc., October, 2000 +'* +'* GNU Lesser General Public License Version 2.1 +'* ============================================= +'* Copyright 2000 by Sun Microsystems, Inc. +'* 901 San Antonio Road, Palo Alto, CA 94303, USA +'* +'* This library is free software; you can redistribute it and/or +'* modify it under the terms of the GNU Lesser General Public +'* License version 2.1, as published by the Free Software Foundation. +'* +'* This library 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 for more details. +'* +'* You should have received a copy of the GNU Lesser General Public +'* License along with this library; if not, write to the Free Software +'* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +'* MA 02111-1307 USA +'* +'* +'* Sun Industry Standards Source License Version 1.1 +'* ================================================= +'* The contents of this file are subject to the Sun Industry Standards +'* Source License Version 1.1 (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.openoffice.org/license.html. +'* +'* Software provided under this License is provided on an "AS IS" basis, +'* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +'* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +'* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +'* See the License for the specific provisions governing your rights and +'* obligations concerning the Software. +'* +'* The Initial Developer of the Original Code is: Sun Microsystems, Inc. +'* +'* Copyright: 2000 by Sun Microsystems, Inc. +'* +'* All Rights Reserved. +'* +'* Contributor(s): _______________________________________ +'* +'* +'************************************************************************* +'************************************************************************* + + + +' 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 > 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 > 0) then + i = mCount - 1 + while (oObj.isAccessibleChildSelected(i) OR itemDisabled(oObj.getAccessibleChild(i))) AND (i > 0) + i = i - 1 + wend + if (i >= 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 > 0) then + i = mCount - 1 + while (oObj.isAccessibleChildSelected(i) OR itemDisabled(oObj.getAccessibleChild(i))) AND (i > 0) + i = i - 1 + wend + if (i >= 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 > 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) + + Test.StartMethod("selectAllAccessible()") + bOK = true + i = 0 + if ((mCount > 0) AND multiSelection) then + oObj.selectAllAccessible() + wait(500) + while (i < 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("selectAllAccessible()",bOK) + + Test.StartMethod("getSelectedAccessibleChildCount()") + bOK = true + Out.Log("Selecting all...") + oObj.selectAllAccessible() + 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 > 0) then + i = mCount - 1 + while (oObj.isAccessibleChildSelected(i) OR itemDisabled(oObj.getAccessibleChild(i))) AND (i > 0) + i = i - 1 + wend + if (i >= 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 > 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("deselectSelectedAccessibleChild()") + Dim newSelCount As Long + Dim isSelected as Boolean + bOK = true + oObj.selectAllAccessible() + 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.deselectSelectedAccessibleChild(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 = 1) + End If + selCount = newSelCount + next + Test.MethodTested("deselectSelectedAccessibleChild()",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,"drafts.com.sun.star.accessibility.XAccessibleContext") then + oChild = oChild.getAccessibleContext() + End If + itemDisabled = NOT oChild.getAccessibleStateSet().contains(21) +End Function + +</script:module> |