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_XAccessibleContext" 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.XAccessibleContext
48'*************************************************************************
49On Error Goto ErrHndl
50    Dim bOK As Boolean
51    Dim childCount As Long, i As Integer
52    Dim oParent As Object
53
54    Test.StartMethod("getAccessibleChildCount()")
55    bOK = true
56    childCount = oObj.getAccessibleChildCount()
57    bOK = bOK AND (childCount &gt; -1)
58    Test.MethodTested("getAccessibleChildCount()",bOK)
59
60
61    Test.StartMethod("getAccessibleChild()")
62    Dim childContext As Object
63    Dim mCount As Integer
64    bOK = true
65    i = 0
66    if (childCount &gt; 50) then
67        mCount = 50
68    else
69        mCount = childCount
70    End If
71    while (i &lt; mCount)
72        childContext = oObj.getAccessibleChild(i).getAccessibleContext()
73        Out.Log("  Child " + i + ": " + childContext.getAccessibleDescription())
74        bOK = bOK AND utils.at_equals(childContext.getAccessibleParent(), oObj)
75        i = i + 1
76    wend
77    Test.MethodTested("getAccessibleChild()",bOK)
78
79
80    Test.StartMethod("getAccessibleParent()")
81    bOK = true
82    oParent = oObj.getAccessibleParent()
83    bOK = bOK AND NOT isNull(oParent)
84    Test.MethodTested("getAccessibleParent()",bOK)
85
86
87    Test.StartMethod("getAccessibleIndexInParent()")
88    Dim idx As Integer
89    Dim parentAC As Object
90    bOK = true
91    idx = oObj.getAccessibleIndexInParent()
92    parentAC = oParent.getAccessibleContext()
93    bOK = bOK AND utils.at_equals(parentAC.getAccessibleChild(idx), oObj)
94    Test.MethodTested("getAccessibleIndexInParent()",bOK)
95
96
97    Test.StartMethod("getAccessibleRole()")
98    Dim role As Integer
99    bOK = true
100    role = oObj.getAccessibleRole()
101    Out.Log("The role is " + role)
102    bOK = bOK AND (role &gt; -1)
103    Test.MethodTested("getAccessibleRole()",bOK)
104
105
106    Test.StartMethod("getAccessibleDescription()")
107    Dim descr As String
108    bOK = true
109    descr = oObj.getAccessibleDescription()
110    Out.Log("The description is " + descr)
111    bOK = bOK AND NOT isNull(descr)
112    Test.MethodTested("getAccessibleDescription()",bOK)
113
114
115    Test.StartMethod("getAccessibleName()")
116    Dim oName As String
117    bOK = true
118    oName = oObj.getAccessibleName()
119    Out.Log("The name is " + oName)
120    bOK = bOK AND NOT isNull(oName)
121    Test.MethodTested("getAccessibleName()",bOK)
122
123
124    Test.StartMethod("getAccessibleRelationSet()")
125    Dim oSet As Variant
126    bOK = true
127    oSet = oObj.getAccessibleRelationSet()
128	' Relationset could be null
129	if not isNull(oSet) then
130		oSet.getRelationCount()
131	end if
132    Test.MethodTested("getAccessibleRelationSet()",bOK)
133
134
135    Test.StartMethod("getAccessibleStateSet()")
136    bOK = true
137    oSet = oObj.getAccessibleStateSet()
138    bOK = bOK AND NOT isNull(oSet)
139    if NOT bOK then Out.Log("This object does not support states")
140    Test.MethodTested("getAccessibleStateSet()",bOK)
141
142
143    Test.StartMethod("getLocale()")
144    Dim oLoc As Variant
145    bOK = true
146    oLoc = oObj.getLocale()
147    Out.Log("The locale is "+oLoc.Language+", "+oLoc.Country)
148    bOK = bOK AND NOT isNull(oLoc) AND (len(oLoc.Language) &gt; 0) AND (len(oLoc.Country) &gt; 0)
149    Test.MethodTested("getLocale()",bOK)
150
151Exit Sub
152ErrHndl:
153    Test.Exception()
154    bOK = false
155    resume next
156End Sub
157</script:module>
158