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