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