| <?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_XAccessibleTable" 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 |
| |
| |
| |
| |
| Sub RunTest() |
| |
| '************************************************************************* |
| ' INTERFACE: |
| ' com.sun.star.accessibility.XAccessibleTable |
| '************************************************************************* |
| On Error Goto ErrHndl |
| Dim bOK As Boolean |
| Dim implSel As Boolean |
| |
| implSel = hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleSelection") |
| if (NOT implSel) then |
| Out.Log("!!! The component doesn't implement the interface XAccessibleSelection.") |
| Out.Log("!!! This interface is required for more detailed tests.") |
| End If |
| |
| Test.StartMethod("getAccessibleRowCount()") |
| Dim rowCount As Long |
| bOK = true |
| rowCount = oObj.getAccessibleRowCount() |
| Out.Log("Accessible row count: "+rowCount) |
| Test.MethodTested("getAccessibleRowCount()",bOK) |
| |
| Test.StartMethod("getAccessibleColumnCount()") |
| Dim colCount As Long |
| bOK = true |
| colCount = oObj.getAccessibleColumnCount() |
| Out.Log("Accessible column count: "+colCount) |
| Test.MethodTested("getAccessibleColumnCount()",bOK) |
| |
| Test.StartMethod("getAccessibleRowDescription()") |
| Dim rowDescr As String |
| bOK = true |
| if (rowCount > 0) then |
| rowDescr = oObj.getAccessibleRowDescription(rowCount - 1) |
| Out.Log("Row "+(rowCount-1)+" description: "+rowDescr) |
| bOK = bOK AND NOT isNull(rowDescr) |
| else |
| Out.Log("!!! RowCount is 0. Could not test this method.") |
| End If |
| Test.MethodTested("getAccessibleRowDescription()",bOK) |
| |
| Test.StartMethod("getAccessibleColumnDescription()") |
| Dim colDescr As String |
| bOK = true |
| if (colCount > 0) then |
| colDescr = oObj.getAccessibleRowDescription(colCount - 1) |
| Out.Log("Column "+(colCount-1)+" description: "+colDescr) |
| bOK = bOK AND NOT isNull(colDescr) |
| else |
| Out.Log("!!! ColumnCount is 0. Could not test this method.") |
| End If |
| Test.MethodTested("getAccessibleColumnDescription()",bOK) |
| |
| Test.StartMethod("getAccessibleRowExtentAt()") |
| Dim ext As Long |
| bOK = true |
| ext = oObj.getAccessibleRowExtentAt(rowCount - 1, colCount - 1) |
| Out.Log(ext) |
| bOK = bOK AND (ext >= 1) |
| Test.MethodTested("getAccessibleRowExtentAt()",bOK) |
| |
| Test.StartMethod("getAccessibleColumnExtentAt()") |
| bOK = true |
| ext = oObj.getAccessibleColumnExtentAt(rowCount - 1, colCount - 1) |
| Out.Log(ext) |
| bOK = bOK AND (ext >= 1) |
| Test.MethodTested("getAccessibleColumnExtentAt()",bOK) |
| |
| Test.StartMethod("getAccessibleRowHeaders()") |
| Dim rowHeaders As Object |
| bOK = true |
| rowHeaders = oObj.getAccessibleRowHeaders() |
| bOK = bOK AND NOT isNull(rowHeaders) |
| Test.MethodTested("getAccessibleRowHeaders()",bOK) |
| |
| Test.StartMethod("getAccessibleColumnHeaders()") |
| Dim colHeaders As Object |
| bOK = true |
| colHeaders = oObj.getAccessibleColumnHeaders() |
| bOK = bOK AND NOT isNull(colHeaders) |
| Test.MethodTested("getAccessibleColumnHeaders()",bOK) |
| |
| Test.StartMethod("getSelectedAccessibleRows()") |
| Dim selRows As Variant |
| Dim elCount As Long, i As Integer |
| Dim locRes As Boolean |
| bOK = true |
| if implSel then |
| oObj.selectAllAccessible() |
| End If |
| selRows = oObj.getSelectedAccessibleRows() |
| elCount = ubound(selRows) - 1 |
| Out.Log("Returned sequence has "+elCount+" elements") |
| if implSel then |
| bOK = bOK AND (elCount = rowCount) |
| else |
| bOK = bOK AND (elCount = 0) |
| End If |
| if (elCount > 0) then |
| Out.Log("Checking that returned sequence is in ascending order") |
| End If |
| i = 1 |
| while (i < elCount) |
| locRes = (selRows(i) >= selRows(i-1)) |
| bOK = bOK AND locRes |
| if NOT locRes then |
| Out.Log("Element "+i+" : Returned sequence is not in accending order.") |
| break |
| End If |
| wend |
| Test.MethodTested("getSelectedAccessibleRows()",bOK) |
| |
| Test.StartMethod("getSelectedAccessibleColumns()") |
| Dim selCols As Variant |
| bOK = true |
| selCols = oObj.getSelectedAccessibleRows() |
| elCount = ubound(selCols) - 1 |
| Out.Log("Returned sequence has "+elCount+" elements") |
| if implSel then |
| bOK = bOK AND (elCount = colCount) |
| else |
| bOK = bOK AND (elCount = 0) |
| End If |
| if (elCount > 0) then |
| Out.Log("Checking that returned sequence is in ascending order") |
| End If |
| i = 1 |
| while (i < elCount) |
| locRes = (selCols(i) >= selCols(i-1)) |
| bOK = bOK AND locRes |
| if NOT locRes then |
| Out.Log("Element "+i+" : Returned sequence is not in accending order.") |
| break |
| End If |
| wend |
| Test.MethodTested("getSelectedAccessibleColumns()",bOK) |
| |
| Test.StartMethod("isAccessibleRowSelected()") |
| Dim mCount As Integer |
| bOK = true |
| locRes = true |
| if (rowCount > 299) then |
| mCount = 299 |
| else |
| mCount = rowCount - 1 |
| End If |
| for i=0 to mCount |
| locRes = oObj.isAccessibleRowSelected(i) |
| if implSel then |
| bOK = bOK AND locRes |
| else |
| bOK = bOK AND NOT locRes |
| End If |
| next i |
| Out.Log("Checked "+i+" of "+rowCount+" rows.") |
| Test.MethodTested("isAccessibleRowSelected()",bOK) |
| |
| Test.StartMethod("isAccessibleColumnSelected()") |
| bOK = true |
| locRes = true |
| if (colCount > 299) then |
| mCount = 299 |
| else |
| mCount = colCount - 1 |
| End If |
| for i=0 to mCount |
| locRes = oObj.isAccessibleColumnSelected(i) |
| if implSel then |
| bOK = bOK AND locRes |
| else |
| bOK = bOK AND NOT locRes |
| End If |
| next i |
| Out.Log("Checked "+i+" of "+colCount+" columns.") |
| Test.MethodTested("isAccessibleColumnSelected()",bOK) |
| |
| Test.StartMethod("getAccessibleCellAt()") |
| Dim xAccCell As Object |
| bOK = true |
| xAccCell = oObj.getAccessibleCellAt(rowCount - 1, colCount - 1) |
| bOK = bOK AND NOT isNull(xAccCell) |
| Test.MethodTested("getAccessibleCellAt()",bOK) |
| |
| Test.StartMethod("getAccessibleCaption()") |
| Dim caption As Object |
| bOK = true |
| caption = oObj.getAccessibleCaption() |
| Test.MethodTested("getAccessibleCaption()",bOK) |
| |
| Test.StartMethod("getAccessibleSummary()") |
| Dim summary As Object |
| bOK = true |
| summary = oObj.getAccessibleSummary() |
| Test.MethodTested("getAccessibleSummary()",bOK) |
| |
| Test.StartMethod("isAccessibleSelected()") |
| bOK = true |
| locRes = oObj.isAccessibleSelected(rowCount - 1, colCount - 1) |
| if implSel then |
| bOK = bOK AND locRes |
| else |
| bOK = bOK AND NOT locRes |
| End If |
| Test.MethodTested("isAccessibleSelected()",bOK) |
| |
| Test.StartMethod("getAccessibleIndex()") |
| Dim ind As Long, expIndex As Long |
| bOK = true |
| ind = oObj.getAccessibleIndex(rowCount - 1, colCount - 1) |
| Out.Log("AccessibleIndex is: "+ind) |
| if NOT isNull(xAccCell) then |
| expIndex = xAccCell.getAccessibleContext().getAccessibleIndexInParent() |
| Out.Log("Expected index is: "+expIndex) |
| bOK = bOK AND (ind = expIndex) |
| End If |
| Test.MethodTested("getAccessibleIndex()",bOK) |
| |
| Test.StartMethod("getAccessibleRow()") |
| Dim rowIndex As Long |
| Dim chCount As Long |
| bOK = true |
| if hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleContext") then |
| chCount = oObj.getAccessibleChildCount() |
| rowIndex = oObj.getAccessibleRow(chCount - 1) |
| bOK = bOK AND (rowIndex >= 0) AND (rowIndex <= rowCount) |
| End If |
| rowIndex = oObj.getAccessibleRow(0) |
| bOK = bOK AND (rowIndex >= 0) AND (rowIndex <= rowCount) |
| Test.MethodTested("getAccessibleRow()",bOK) |
| |
| Test.StartMethod("getAccessibleColumn()") |
| Dim colIndex As Long |
| bOK = true |
| if hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleContext") then |
| chCount = oObj.getAccessibleChildCount() |
| colIndex = oObj.getAccessibleColumn(chCount - 1) |
| bOK = bOK AND (colIndex >= 0) AND (colIndex <= colCount) |
| End If |
| colIndex = oObj.getAccessibleColumn(0) |
| bOK = bOK AND (colIndex >= 0) AND (colIndex <= colCount) |
| Test.MethodTested("getAccessibleColumn()",bOK) |
| |
| Exit Sub |
| ErrHndl: |
| Test.Exception() |
| bOK = false |
| resume next |
| End Sub |
| </script:module> |