'************************************************************************* ' ' Licensed to the Apache Software Foundation (ASF) under one ' or more contributor license agreements. See the NOTICE file ' distributed with this work for additional information ' regarding copyright ownership. The ASF licenses this file ' to you under the Apache License, Version 2.0 (the ' "License"); you may not use this file except in compliance ' with the License. You may obtain a copy of the License at ' ' http://www.apache.org/licenses/LICENSE-2.0 ' ' Unless required by applicable law or agreed to in writing, ' software distributed under the License is distributed on an ' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ' KIND, either express or implied. See the License for the ' specific language governing permissions and limitations ' under the License. ' '************************************************************************* ' Be sure that all variables are dimensioned: option explicit '************************************************************************* ' This Interface/Service test depends on the following GLOBAL variables, ' which must be specified in the object creation: ' Global cNameToSet As String "fixed" if name is fixed '************************************************************************* Sub RunTest() '************************************************************************* ' INTERFACE: ' com.sun.star.container.XNamed '************************************************************************* On Error Goto ErrHndl Dim bOK As Boolean Dim cName As String, cNewName As String if VarType(cNameToSet) = 8 then if cNameToSet = "" then cNewName = cIfcShortName else cNewName = cNameToSet endif else cNewName = cIfcShortName endif Test.StartMethod("getName()") bOK = true cName = oObj.getName() Out.Log("Name is '" + cName + "'") bOK = bOK AND NOT isNULL(cName) bOK = bOK AND (VarType(oObj.Name) = 8 ) Test.MethodTested("getName()", bOK) Test.StartMethod("setName()") bOK = true Out.Log("nameToSet is '" + cNewName + "'") if (cNewName = "fixed") then Out.Log("Object " + cObjectName + " has fixed name.") on error goto ex1: Out.Log("Trying to change fixed name") oObj.setName(cNewName) Out.Log("After setting name, oObj.Name is '" + oObj.Name + "'") bOK = bOK AND oObj.Name <> cNameToSet if (NOT bOK) then Out.Log("Fixed name was changed! - FAILED") goto cont1: ex1: Out.Log("Expected exception - OK") resume next cont1: else oObj.setName(cNewName) Out.Log("After setting name, oObj.Name is '" + oObj.Name + "'") bOK = bOK AND (cName <> oObj.Name) oObj.Name = cName bOK = bOK AND (cName = oObj.Name) end if Test.MethodTested("setName()", bOK) Exit Sub ErrHndl: Test.Exception() bOK = false resume next End Sub