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 37' Be sure that all variables are dimensioned: 38option explicit 39 40 41 42 43Sub RunTest() 44 45'************************************************************************* 46' INTERFACE: 47' com.sun.star.accessibility.XAccessibleTable 48'************************************************************************* 49On Error Goto ErrHndl 50 Dim bOK As Boolean 51 Dim implSel As Boolean 52 53 implSel = hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleSelection") 54 if (NOT implSel) then 55 Out.Log("!!! The component doesn't implement the interface XAccessibleSelection.") 56 Out.Log("!!! This interface is required for more detailed tests.") 57 End If 58 59 Test.StartMethod("getAccessibleRowCount()") 60 Dim rowCount As Long 61 bOK = true 62 rowCount = oObj.getAccessibleRowCount() 63 Out.Log("Accessible row count: "+rowCount) 64 Test.MethodTested("getAccessibleRowCount()",bOK) 65 66 Test.StartMethod("getAccessibleColumnCount()") 67 Dim colCount As Long 68 bOK = true 69 colCount = oObj.getAccessibleColumnCount() 70 Out.Log("Accessible column count: "+colCount) 71 Test.MethodTested("getAccessibleColumnCount()",bOK) 72 73 Test.StartMethod("getAccessibleRowDescription()") 74 Dim rowDescr As String 75 bOK = true 76 if (rowCount > 0) then 77 rowDescr = oObj.getAccessibleRowDescription(rowCount - 1) 78 Out.Log("Row "+(rowCount-1)+" description: "+rowDescr) 79 bOK = bOK AND NOT isNull(rowDescr) 80 else 81 Out.Log("!!! RowCount is 0. Could not test this method.") 82 End If 83 Test.MethodTested("getAccessibleRowDescription()",bOK) 84 85 Test.StartMethod("getAccessibleColumnDescription()") 86 Dim colDescr As String 87 bOK = true 88 if (colCount > 0) then 89 colDescr = oObj.getAccessibleRowDescription(colCount - 1) 90 Out.Log("Column "+(colCount-1)+" description: "+colDescr) 91 bOK = bOK AND NOT isNull(colDescr) 92 else 93 Out.Log("!!! ColumnCount is 0. Could not test this method.") 94 End If 95 Test.MethodTested("getAccessibleColumnDescription()",bOK) 96 97 Test.StartMethod("getAccessibleRowExtentAt()") 98 Dim ext As Long 99 bOK = true 100 ext = oObj.getAccessibleRowExtentAt(rowCount - 1, colCount - 1) 101 Out.Log(ext) 102 bOK = bOK AND (ext >= 1) 103 Test.MethodTested("getAccessibleRowExtentAt()",bOK) 104 105 Test.StartMethod("getAccessibleColumnExtentAt()") 106 bOK = true 107 ext = oObj.getAccessibleColumnExtentAt(rowCount - 1, colCount - 1) 108 Out.Log(ext) 109 bOK = bOK AND (ext >= 1) 110 Test.MethodTested("getAccessibleColumnExtentAt()",bOK) 111 112 Test.StartMethod("getAccessibleRowHeaders()") 113 Dim rowHeaders As Object 114 bOK = true 115 rowHeaders = oObj.getAccessibleRowHeaders() 116 bOK = bOK AND NOT isNull(rowHeaders) 117 Test.MethodTested("getAccessibleRowHeaders()",bOK) 118 119 Test.StartMethod("getAccessibleColumnHeaders()") 120 Dim colHeaders As Object 121 bOK = true 122 colHeaders = oObj.getAccessibleColumnHeaders() 123 bOK = bOK AND NOT isNull(colHeaders) 124 Test.MethodTested("getAccessibleColumnHeaders()",bOK) 125 126 Test.StartMethod("getSelectedAccessibleRows()") 127 Dim selRows As Variant 128 Dim elCount As Long, i As Integer 129 Dim locRes As Boolean 130 bOK = true 131 if implSel then 132 oObj.selectAllAccessible() 133 End If 134 selRows = oObj.getSelectedAccessibleRows() 135 elCount = ubound(selRows) - 1 136 Out.Log("Returned sequence has "+elCount+" elements") 137 if implSel then 138 bOK = bOK AND (elCount = rowCount) 139 else 140 bOK = bOK AND (elCount = 0) 141 End If 142 if (elCount > 0) then 143 Out.Log("Checking that returned sequence is in ascending order") 144 End If 145 i = 1 146 while (i < elCount) 147 locRes = (selRows(i) >= selRows(i-1)) 148 bOK = bOK AND locRes 149 if NOT locRes then 150 Out.Log("Element "+i+" : Returned sequence is not in accending order.") 151 break 152 End If 153 wend 154 Test.MethodTested("getSelectedAccessibleRows()",bOK) 155 156 Test.StartMethod("getSelectedAccessibleColumns()") 157 Dim selCols As Variant 158 bOK = true 159 selCols = oObj.getSelectedAccessibleRows() 160 elCount = ubound(selCols) - 1 161 Out.Log("Returned sequence has "+elCount+" elements") 162 if implSel then 163 bOK = bOK AND (elCount = colCount) 164 else 165 bOK = bOK AND (elCount = 0) 166 End If 167 if (elCount > 0) then 168 Out.Log("Checking that returned sequence is in ascending order") 169 End If 170 i = 1 171 while (i < elCount) 172 locRes = (selCols(i) >= selCols(i-1)) 173 bOK = bOK AND locRes 174 if NOT locRes then 175 Out.Log("Element "+i+" : Returned sequence is not in accending order.") 176 break 177 End If 178 wend 179 Test.MethodTested("getSelectedAccessibleColumns()",bOK) 180 181 Test.StartMethod("isAccessibleRowSelected()") 182 Dim mCount As Integer 183 bOK = true 184 locRes = true 185 if (rowCount > 299) then 186 mCount = 299 187 else 188 mCount = rowCount - 1 189 End If 190 for i=0 to mCount 191 locRes = oObj.isAccessibleRowSelected(i) 192 if implSel then 193 bOK = bOK AND locRes 194 else 195 bOK = bOK AND NOT locRes 196 End If 197 next i 198 Out.Log("Checked "+i+" of "+rowCount+" rows.") 199 Test.MethodTested("isAccessibleRowSelected()",bOK) 200 201 Test.StartMethod("isAccessibleColumnSelected()") 202 bOK = true 203 locRes = true 204 if (colCount > 299) then 205 mCount = 299 206 else 207 mCount = colCount - 1 208 End If 209 for i=0 to mCount 210 locRes = oObj.isAccessibleColumnSelected(i) 211 if implSel then 212 bOK = bOK AND locRes 213 else 214 bOK = bOK AND NOT locRes 215 End If 216 next i 217 Out.Log("Checked "+i+" of "+colCount+" columns.") 218 Test.MethodTested("isAccessibleColumnSelected()",bOK) 219 220 Test.StartMethod("getAccessibleCellAt()") 221 Dim xAccCell As Object 222 bOK = true 223 xAccCell = oObj.getAccessibleCellAt(rowCount - 1, colCount - 1) 224 bOK = bOK AND NOT isNull(xAccCell) 225 Test.MethodTested("getAccessibleCellAt()",bOK) 226 227 Test.StartMethod("getAccessibleCaption()") 228 Dim caption As Object 229 bOK = true 230 caption = oObj.getAccessibleCaption() 231 Test.MethodTested("getAccessibleCaption()",bOK) 232 233 Test.StartMethod("getAccessibleSummary()") 234 Dim summary As Object 235 bOK = true 236 summary = oObj.getAccessibleSummary() 237 Test.MethodTested("getAccessibleSummary()",bOK) 238 239 Test.StartMethod("isAccessibleSelected()") 240 bOK = true 241 locRes = oObj.isAccessibleSelected(rowCount - 1, colCount - 1) 242 if implSel then 243 bOK = bOK AND locRes 244 else 245 bOK = bOK AND NOT locRes 246 End If 247 Test.MethodTested("isAccessibleSelected()",bOK) 248 249 Test.StartMethod("getAccessibleIndex()") 250 Dim ind As Long, expIndex As Long 251 bOK = true 252 ind = oObj.getAccessibleIndex(rowCount - 1, colCount - 1) 253 Out.Log("AccessibleIndex is: "+ind) 254 if NOT isNull(xAccCell) then 255 expIndex = xAccCell.getAccessibleContext().getAccessibleIndexInParent() 256 Out.Log("Expected index is: "+expIndex) 257 bOK = bOK AND (ind = expIndex) 258 End If 259 Test.MethodTested("getAccessibleIndex()",bOK) 260 261 Test.StartMethod("getAccessibleRow()") 262 Dim rowIndex As Long 263 Dim chCount As Long 264 bOK = true 265 if hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleContext") then 266 chCount = oObj.getAccessibleChildCount() 267 rowIndex = oObj.getAccessibleRow(chCount - 1) 268 bOK = bOK AND (rowIndex >= 0) AND (rowIndex <= rowCount) 269 End If 270 rowIndex = oObj.getAccessibleRow(0) 271 bOK = bOK AND (rowIndex >= 0) AND (rowIndex <= rowCount) 272 Test.MethodTested("getAccessibleRow()",bOK) 273 274 Test.StartMethod("getAccessibleColumn()") 275 Dim colIndex As Long 276 bOK = true 277 if hasUNOInterfaces(oObj,"drafts.com.sun.star.accessibility.XAccessibleContext") then 278 chCount = oObj.getAccessibleChildCount() 279 colIndex = oObj.getAccessibleColumn(chCount - 1) 280 bOK = bOK AND (colIndex >= 0) AND (colIndex <= colCount) 281 End If 282 colIndex = oObj.getAccessibleColumn(0) 283 bOK = bOK AND (colIndex >= 0) AND (colIndex <= colCount) 284 Test.MethodTested("getAccessibleColumn()",bOK) 285 286Exit Sub 287ErrHndl: 288 Test.Exception() 289 bOK = false 290 resume next 291End Sub 292</script:module> 293