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' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32'*************************************************************************
33
34
35
36' Be sure that all variables are dimensioned:
37option explicit
38
39
40
41
42Sub RunTest()
43
44'*************************************************************************
45' INTERFACE:
46' com.sun.star.accessibility.XAccessibleTable
47'*************************************************************************
48On Error Goto ErrHndl
49    Dim bOK As Boolean
50    Dim implSel As Boolean
51
52    implSel = hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleSelection")
53    if (NOT implSel) then
54        Out.Log("!!! The component doesn't implement the interface XAccessibleSelection.")
55        Out.Log("!!! This interface is required for more detailed tests.")
56    End If
57
58    Test.StartMethod("getAccessibleRowCount()")
59    Dim rowCount As Long
60    bOK = true
61    rowCount = oObj.getAccessibleRowCount()
62    Out.Log("Accessible row count: "+rowCount)
63    Test.MethodTested("getAccessibleRowCount()",bOK)
64
65    Test.StartMethod("getAccessibleColumnCount()")
66    Dim colCount As Long
67    bOK = true
68    colCount = oObj.getAccessibleColumnCount()
69    Out.Log("Accessible column count: "+colCount)
70    Test.MethodTested("getAccessibleColumnCount()",bOK)
71
72    Test.StartMethod("getAccessibleRowDescription()")
73    Dim rowDescr As String
74    bOK = true
75    if (rowCount &gt; 0) then
76        rowDescr = oObj.getAccessibleRowDescription(rowCount - 1)
77        Out.Log("Row "+(rowCount-1)+" description: "+rowDescr)
78        bOK = bOK AND NOT isNull(rowDescr)
79    else
80        Out.Log("!!! RowCount is 0. Could not test this method.")
81    End If
82    Test.MethodTested("getAccessibleRowDescription()",bOK)
83
84    Test.StartMethod("getAccessibleColumnDescription()")
85    Dim colDescr As String
86    bOK = true
87    if (colCount &gt; 0) then
88        colDescr = oObj.getAccessibleRowDescription(colCount - 1)
89        Out.Log("Column "+(colCount-1)+" description: "+colDescr)
90        bOK = bOK AND NOT isNull(colDescr)
91    else
92        Out.Log("!!! ColumnCount is 0. Could not test this method.")
93    End If
94    Test.MethodTested("getAccessibleColumnDescription()",bOK)
95
96    Test.StartMethod("getAccessibleRowExtentAt()")
97    Dim ext As Long
98    bOK = true
99    ext = oObj.getAccessibleRowExtentAt(rowCount - 1, colCount - 1)
100    Out.Log(ext)
101    bOK = bOK AND (ext &gt;= 1)
102    Test.MethodTested("getAccessibleRowExtentAt()",bOK)
103
104    Test.StartMethod("getAccessibleColumnExtentAt()")
105    bOK = true
106    ext = oObj.getAccessibleColumnExtentAt(rowCount - 1, colCount - 1)
107    Out.Log(ext)
108    bOK = bOK AND (ext &gt;= 1)
109    Test.MethodTested("getAccessibleColumnExtentAt()",bOK)
110
111    Test.StartMethod("getAccessibleRowHeaders()")
112    Dim rowHeaders As Object
113    bOK = true
114    rowHeaders = oObj.getAccessibleRowHeaders()
115    bOK = bOK AND NOT isNull(rowHeaders)
116    Test.MethodTested("getAccessibleRowHeaders()",bOK)
117
118    Test.StartMethod("getAccessibleColumnHeaders()")
119    Dim colHeaders As Object
120    bOK = true
121    colHeaders = oObj.getAccessibleColumnHeaders()
122    bOK = bOK AND NOT isNull(colHeaders)
123    Test.MethodTested("getAccessibleColumnHeaders()",bOK)
124
125    Test.StartMethod("getSelectedAccessibleRows()")
126    Dim selRows As Variant
127    Dim elCount As Long, i As Integer
128    Dim locRes As Boolean
129    bOK = true
130    if implSel then
131        oObj.selectAllAccessible()
132    End If
133    selRows = oObj.getSelectedAccessibleRows()
134    elCount = ubound(selRows) - 1
135    Out.Log("Returned sequence has "+elCount+" elements")
136    if implSel then
137        bOK = bOK AND (elCount = rowCount)
138    else
139        bOK = bOK AND (elCount = 0)
140    End If
141    if (elCount &gt; 0) then
142        Out.Log("Checking that returned sequence is in ascending order")
143    End If
144    i = 1
145    while (i &lt; elCount)
146        locRes = (selRows(i) &gt;= selRows(i-1))
147        bOK = bOK AND locRes
148        if NOT locRes then
149            Out.Log("Element "+i+" : Returned sequence is not in accending order.")
150            break
151        End If
152    wend
153    Test.MethodTested("getSelectedAccessibleRows()",bOK)
154
155    Test.StartMethod("getSelectedAccessibleColumns()")
156    Dim selCols As Variant
157    bOK = true
158    selCols = oObj.getSelectedAccessibleRows()
159    elCount = ubound(selCols) - 1
160    Out.Log("Returned sequence has "+elCount+" elements")
161    if implSel then
162        bOK = bOK AND (elCount = colCount)
163    else
164        bOK = bOK AND (elCount = 0)
165    End If
166    if (elCount &gt; 0) then
167        Out.Log("Checking that returned sequence is in ascending order")
168    End If
169    i = 1
170    while (i &lt; elCount)
171        locRes = (selCols(i) &gt;= selCols(i-1))
172        bOK = bOK AND locRes
173        if NOT locRes then
174            Out.Log("Element "+i+" : Returned sequence is not in accending order.")
175            break
176        End If
177    wend
178    Test.MethodTested("getSelectedAccessibleColumns()",bOK)
179
180    Test.StartMethod("isAccessibleRowSelected()")
181    Dim mCount As Integer
182    bOK = true
183    locRes = true
184    if (rowCount &gt; 299) then
185        mCount = 299
186    else
187        mCount = rowCount - 1
188    End If
189    for i=0 to mCount
190        locRes = oObj.isAccessibleRowSelected(i)
191        if implSel then
192            bOK = bOK AND locRes
193        else
194            bOK = bOK AND NOT locRes
195        End If
196    next i
197    Out.Log("Checked "+i+" of "+rowCount+" rows.")
198    Test.MethodTested("isAccessibleRowSelected()",bOK)
199
200    Test.StartMethod("isAccessibleColumnSelected()")
201    bOK = true
202    locRes = true
203    if (colCount &gt; 299) then
204        mCount = 299
205    else
206        mCount = colCount - 1
207    End If
208    for i=0 to mCount
209        locRes = oObj.isAccessibleColumnSelected(i)
210        if implSel then
211            bOK = bOK AND locRes
212        else
213            bOK = bOK AND NOT locRes
214        End If
215    next i
216    Out.Log("Checked "+i+" of "+colCount+" columns.")
217    Test.MethodTested("isAccessibleColumnSelected()",bOK)
218
219    Test.StartMethod("getAccessibleCellAt()")
220    Dim xAccCell As Object
221    bOK = true
222    xAccCell = oObj.getAccessibleCellAt(rowCount - 1, colCount - 1)
223    bOK = bOK AND NOT isNull(xAccCell)
224    Test.MethodTested("getAccessibleCellAt()",bOK)
225
226    Test.StartMethod("getAccessibleCaption()")
227    Dim caption As Object
228    bOK = true
229    caption = oObj.getAccessibleCaption()
230    Test.MethodTested("getAccessibleCaption()",bOK)
231
232    Test.StartMethod("getAccessibleSummary()")
233    Dim summary As Object
234    bOK = true
235    summary = oObj.getAccessibleSummary()
236    Test.MethodTested("getAccessibleSummary()",bOK)
237
238    Test.StartMethod("isAccessibleSelected()")
239    bOK = true
240    locRes = oObj.isAccessibleSelected(rowCount - 1, colCount - 1)
241    if implSel then
242        bOK = bOK AND locRes
243    else
244        bOK = bOK AND NOT locRes
245    End If
246    Test.MethodTested("isAccessibleSelected()",bOK)
247
248    Test.StartMethod("getAccessibleIndex()")
249    Dim ind As Long, expIndex As Long
250    bOK = true
251    ind = oObj.getAccessibleIndex(rowCount - 1, colCount - 1)
252    Out.Log("AccessibleIndex is: "+ind)
253    if NOT isNull(xAccCell) then
254        expIndex = xAccCell.getAccessibleContext().getAccessibleIndexInParent()
255        Out.Log("Expected index is: "+expIndex)
256        bOK = bOK AND (ind = expIndex)
257    End If
258    Test.MethodTested("getAccessibleIndex()",bOK)
259
260    Test.StartMethod("getAccessibleRow()")
261    Dim rowIndex As Long
262    Dim chCount As Long
263    bOK = true
264    if hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleContext") then
265        chCount = oObj.getAccessibleChildCount()
266        rowIndex = oObj.getAccessibleRow(chCount - 1)
267        bOK = bOK AND (rowIndex &gt;= 0) AND (rowIndex &lt;= rowCount)
268    End If
269    rowIndex = oObj.getAccessibleRow(0)
270    bOK = bOK AND (rowIndex &gt;= 0) AND (rowIndex &lt;= rowCount)
271    Test.MethodTested("getAccessibleRow()",bOK)
272
273    Test.StartMethod("getAccessibleColumn()")
274    Dim colIndex As Long
275    bOK = true
276    if hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleContext") then
277        chCount = oObj.getAccessibleChildCount()
278        colIndex = oObj.getAccessibleColumn(chCount - 1)
279        bOK = bOK AND (colIndex &gt;= 0) AND (colIndex &lt;= colCount)
280    End If
281    colIndex = oObj.getAccessibleColumn(0)
282    bOK = bOK AND (colIndex &gt;= 0) AND (colIndex &lt;= colCount)
283    Test.MethodTested("getAccessibleColumn()",bOK)
284
285Exit Sub
286ErrHndl:
287    Test.Exception()
288    bOK = false
289    resume next
290End Sub
291</script:module>
292