1<?xml version="1.0" encoding="UTF-8"?>
2<script:module xmlns:script="http://openoffice.org/2000/script" script:name="container_XHierarchicalName" script:language="StarBasic">
3
4'*************************************************************************
5'
6'  Licensed to the Apache Software Foundation (ASF) under one
7'  or more contributor license agreements.  See the NOTICE file
8'  distributed with this work for additional information
9'  regarding copyright ownership.  The ASF licenses this file
10'  to you under the Apache License, Version 2.0 (the
11'  "License"); you may not use this file except in compliance
12'  with the License.  You may obtain a copy of the License at
13'
14'    http://www.apache.org/licenses/LICENSE-2.0
15'
16'  Unless required by applicable law or agreed to in writing,
17'  software distributed under the License is distributed on an
18'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19'  KIND, either express or implied.  See the License for the
20'  specific language governing permissions and limitations
21'  under the License.
22'
23'*************************************************************************
24
25
26
27' This Interface/Service test depends on the followingobject relations
28' variables, which must be specified in the object creation:
29
30'      ObjectRelation: oObjRelation(0).Name = "ElementName"
31'      ObjectRelation: oObjRelation(0).Value = "MyAccessibleElementName"
32'      ObjectRelation: oObjRelation(1).Name = "HierarchicalName"
33'      ObjectRelation: oObjRelation(1).Value = "MyHierachicalName"
34
35'*************************************************************************
36
37' Be sure that all variables are dimensioned:
38option explicit
39
40Sub RunTest()
41
42'*************************************************************************
43' INTERFACE:
44' com.sun.star.container.XHierarchicalName
45'*************************************************************************
46On Error Goto ErrHndl
47    Dim bOK As Boolean
48
49    Dim cElemName as Variant
50    cElemName = utils.getObjectRelation("ElementName")
51    if isNull(cElemName) then
52        out.log("Could not get relation 'ElenemtName' -> FALSE")
53    end if
54
55    Dim cExpName as Variant
56    cExpName = utils.getObjectRelation("HierarchicalName")
57    if isNull(cExpName) then
58        out.log("Could not get relation 'HierarchicalName' -> FALSE")
59    end if
60
61    Test.StartMethod("getHierarchicalName()")
62    bOK = TRUE
63    Dim cHName as String
64    cHName = oObj.getHierarchicalName()
65    Dim result as String
66    result = instr(cHName, cExpName)
67    if len(result) = 0 then
68        olt.log("Getting: " + cHName + " but expected it to start with " + _
69                cExpName)
70        bOK = FALSE
71    end if
72    Test.MethodTested("getHierarchicalName()", bOK)
73
74    Test.StartMethod("composeHierarchicalName()")
75    bOK = TRUE
76    Dim  gettedName as String
77    gettedName = oObj.composeHierarchicalName(cElemName)
78    result = instr(gettedName, cElemName)
79    if len(result) = 0 then
80        olt.log("Getting: " + gettedName + " but expected it to start with " + _
81                cElemetName)
82        bOK = FALSE
83    end if
84    Test.MethodTested("composeHierarchicalName()", bOK)
85
86Exit Sub
87ErrHndl:
88    Test.Exception()
89    bOK = false
90    resume next
91End Sub
92</script:module>
93