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