1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="accessibility_XAccessibleTable" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31' Be sure that all variables are dimensioned:
32option explicit
33
34
35
36
37Sub RunTest()
38
39'*************************************************************************
40' INTERFACE:
41' com.sun.star.accessibility.XAccessibleTable
42'*************************************************************************
43On Error Goto ErrHndl
44    Dim bOK As Boolean
45    Dim implSel As Boolean
46
47    implSel = hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleSelection")
48    if (NOT implSel) then
49        Out.Log("!!! The component doesn't implement the interface XAccessibleSelection.")
50        Out.Log("!!! This interface is required for more detailed tests.")
51    End If
52
53    Test.StartMethod("getAccessibleRowCount()")
54    Dim rowCount As Long
55    bOK = true
56    rowCount = oObj.getAccessibleRowCount()
57    Out.Log("Accessible row count: "+rowCount)
58    Test.MethodTested("getAccessibleRowCount()",bOK)
59
60    Test.StartMethod("getAccessibleColumnCount()")
61    Dim colCount As Long
62    bOK = true
63    colCount = oObj.getAccessibleColumnCount()
64    Out.Log("Accessible column count: "+colCount)
65    Test.MethodTested("getAccessibleColumnCount()",bOK)
66
67    Test.StartMethod("getAccessibleRowDescription()")
68    Dim rowDescr As String
69    bOK = true
70    if (rowCount &gt; 0) then
71        rowDescr = oObj.getAccessibleRowDescription(rowCount - 1)
72        Out.Log("Row "+(rowCount-1)+" description: "+rowDescr)
73        bOK = bOK AND NOT isNull(rowDescr)
74    else
75        Out.Log("!!! RowCount is 0. Could not test this method.")
76    End If
77    Test.MethodTested("getAccessibleRowDescription()",bOK)
78
79    Test.StartMethod("getAccessibleColumnDescription()")
80    Dim colDescr As String
81    bOK = true
82    if (colCount &gt; 0) then
83        colDescr = oObj.getAccessibleRowDescription(colCount - 1)
84        Out.Log("Column "+(colCount-1)+" description: "+colDescr)
85        bOK = bOK AND NOT isNull(colDescr)
86    else
87        Out.Log("!!! ColumnCount is 0. Could not test this method.")
88    End If
89    Test.MethodTested("getAccessibleColumnDescription()",bOK)
90
91    Test.StartMethod("getAccessibleRowExtentAt()")
92    Dim ext As Long
93    bOK = true
94    ext = oObj.getAccessibleRowExtentAt(rowCount - 1, colCount - 1)
95    Out.Log(ext)
96    bOK = bOK AND (ext &gt;= 1)
97    Test.MethodTested("getAccessibleRowExtentAt()",bOK)
98
99    Test.StartMethod("getAccessibleColumnExtentAt()")
100    bOK = true
101    ext = oObj.getAccessibleColumnExtentAt(rowCount - 1, colCount - 1)
102    Out.Log(ext)
103    bOK = bOK AND (ext &gt;= 1)
104    Test.MethodTested("getAccessibleColumnExtentAt()",bOK)
105
106    Test.StartMethod("getAccessibleRowHeaders()")
107    Dim rowHeaders As Object
108    bOK = true
109    rowHeaders = oObj.getAccessibleRowHeaders()
110    bOK = bOK AND NOT isNull(rowHeaders)
111    Test.MethodTested("getAccessibleRowHeaders()",bOK)
112
113    Test.StartMethod("getAccessibleColumnHeaders()")
114    Dim colHeaders As Object
115    bOK = true
116    colHeaders = oObj.getAccessibleColumnHeaders()
117    bOK = bOK AND NOT isNull(colHeaders)
118    Test.MethodTested("getAccessibleColumnHeaders()",bOK)
119
120    Test.StartMethod("getSelectedAccessibleRows()")
121    Dim selRows As Variant
122    Dim elCount As Long, i As Integer
123    Dim locRes As Boolean
124    bOK = true
125    if implSel then
126        oObj.selectAllAccessible()
127    End If
128    selRows = oObj.getSelectedAccessibleRows()
129    elCount = ubound(selRows) - 1
130    Out.Log("Returned sequence has "+elCount+" elements")
131    if implSel then
132        bOK = bOK AND (elCount = rowCount)
133    else
134        bOK = bOK AND (elCount = 0)
135    End If
136    if (elCount &gt; 0) then
137        Out.Log("Checking that returned sequence is in ascending order")
138    End If
139    i = 1
140    while (i &lt; elCount)
141        locRes = (selRows(i) &gt;= selRows(i-1))
142        bOK = bOK AND locRes
143        if NOT locRes then
144            Out.Log("Element "+i+" : Returned sequence is not in accending order.")
145            break
146        End If
147    wend
148    Test.MethodTested("getSelectedAccessibleRows()",bOK)
149
150    Test.StartMethod("getSelectedAccessibleColumns()")
151    Dim selCols As Variant
152    bOK = true
153    selCols = oObj.getSelectedAccessibleRows()
154    elCount = ubound(selCols) - 1
155    Out.Log("Returned sequence has "+elCount+" elements")
156    if implSel then
157        bOK = bOK AND (elCount = colCount)
158    else
159        bOK = bOK AND (elCount = 0)
160    End If
161    if (elCount &gt; 0) then
162        Out.Log("Checking that returned sequence is in ascending order")
163    End If
164    i = 1
165    while (i &lt; elCount)
166        locRes = (selCols(i) &gt;= selCols(i-1))
167        bOK = bOK AND locRes
168        if NOT locRes then
169            Out.Log("Element "+i+" : Returned sequence is not in accending order.")
170            break
171        End If
172    wend
173    Test.MethodTested("getSelectedAccessibleColumns()",bOK)
174
175    Test.StartMethod("isAccessibleRowSelected()")
176    Dim mCount As Integer
177    bOK = true
178    locRes = true
179    if (rowCount &gt; 299) then
180        mCount = 299
181    else
182        mCount = rowCount - 1
183    End If
184    for i=0 to mCount
185        locRes = oObj.isAccessibleRowSelected(i)
186        if implSel then
187            bOK = bOK AND locRes
188        else
189            bOK = bOK AND NOT locRes
190        End If
191    next i
192    Out.Log("Checked "+i+" of "+rowCount+" rows.")
193    Test.MethodTested("isAccessibleRowSelected()",bOK)
194
195    Test.StartMethod("isAccessibleColumnSelected()")
196    bOK = true
197    locRes = true
198    if (colCount &gt; 299) then
199        mCount = 299
200    else
201        mCount = colCount - 1
202    End If
203    for i=0 to mCount
204        locRes = oObj.isAccessibleColumnSelected(i)
205        if implSel then
206            bOK = bOK AND locRes
207        else
208            bOK = bOK AND NOT locRes
209        End If
210    next i
211    Out.Log("Checked "+i+" of "+colCount+" columns.")
212    Test.MethodTested("isAccessibleColumnSelected()",bOK)
213
214    Test.StartMethod("getAccessibleCellAt()")
215    Dim xAccCell As Object
216    bOK = true
217    xAccCell = oObj.getAccessibleCellAt(rowCount - 1, colCount - 1)
218    bOK = bOK AND NOT isNull(xAccCell)
219    Test.MethodTested("getAccessibleCellAt()",bOK)
220
221    Test.StartMethod("getAccessibleCaption()")
222    Dim caption As Object
223    bOK = true
224    caption = oObj.getAccessibleCaption()
225    Test.MethodTested("getAccessibleCaption()",bOK)
226
227    Test.StartMethod("getAccessibleSummary()")
228    Dim summary As Object
229    bOK = true
230    summary = oObj.getAccessibleSummary()
231    Test.MethodTested("getAccessibleSummary()",bOK)
232
233    Test.StartMethod("isAccessibleSelected()")
234    bOK = true
235    locRes = oObj.isAccessibleSelected(rowCount - 1, colCount - 1)
236    if implSel then
237        bOK = bOK AND locRes
238    else
239        bOK = bOK AND NOT locRes
240    End If
241    Test.MethodTested("isAccessibleSelected()",bOK)
242
243    Test.StartMethod("getAccessibleIndex()")
244    Dim ind As Long, expIndex As Long
245    bOK = true
246    ind = oObj.getAccessibleIndex(rowCount - 1, colCount - 1)
247    Out.Log("AccessibleIndex is: "+ind)
248    if NOT isNull(xAccCell) then
249        expIndex = xAccCell.getAccessibleContext().getAccessibleIndexInParent()
250        Out.Log("Expected index is: "+expIndex)
251        bOK = bOK AND (ind = expIndex)
252    End If
253    Test.MethodTested("getAccessibleIndex()",bOK)
254
255    Test.StartMethod("getAccessibleRow()")
256    Dim rowIndex As Long
257    Dim chCount As Long
258    bOK = true
259    if hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleContext") then
260        chCount = oObj.getAccessibleChildCount()
261        rowIndex = oObj.getAccessibleRow(chCount - 1)
262        bOK = bOK AND (rowIndex &gt;= 0) AND (rowIndex &lt;= rowCount)
263    End If
264    rowIndex = oObj.getAccessibleRow(0)
265    bOK = bOK AND (rowIndex &gt;= 0) AND (rowIndex &lt;= rowCount)
266    Test.MethodTested("getAccessibleRow()",bOK)
267
268    Test.StartMethod("getAccessibleColumn()")
269    Dim colIndex As Long
270    bOK = true
271    if hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleContext") then
272        chCount = oObj.getAccessibleChildCount()
273        colIndex = oObj.getAccessibleColumn(chCount - 1)
274        bOK = bOK AND (colIndex &gt;= 0) AND (colIndex &lt;= colCount)
275    End If
276    colIndex = oObj.getAccessibleColumn(0)
277    bOK = bOK AND (colIndex &gt;= 0) AND (colIndex &lt;= colCount)
278    Test.MethodTested("getAccessibleColumn()",bOK)
279
280Exit Sub
281ErrHndl:
282    Test.Exception()
283    bOK = false
284    resume next
285End Sub
286</script:module>
287