blob: fa4520a7df2ccc8696e1ee444a2085f94039e88f [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="lang_XSingleServiceFactory" script:language="StarBasic">
'*************************************************************************
'
' 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 aArguments As Variant [optional]
' Array of arguments for createInstanceWithArguments()
' Global aMustSupportInterface As Variant [optional]
' Array of Strings with names of interfaces which must be supported by created instance.
'*************************************************************************
Sub RunTest()
'*************************************************************************
' INTERFACE:
' com.sun.star.lang.XSingleServiceFactory
'*************************************************************************
On Error Goto ErrHndl
Dim bOK As Boolean
Dim aArgs()
Dim inst As Object
Dim i As Integer
Test.StartMethod("createInstance()")
bOK = true
if (cObjectName = "inv.Invocation") then
Out.Log("createInstance() not available in " + cObjectName + " - SKIPPED")
else
bOK = bOK AND isObject(oObj.createInstance())
end if
Test.MethodTested("createInstance()", bOK)
Test.StartMethod("createInstanceWithArguments()")
bOK = true
if isArray(aArguments) then
inst = oObj.createInstanceWithArguments(aArguments())
else
inst = oObj.createInstanceWithArguments(aArgs())
end if
if NOT isObject(inst) then
bOK = false
Out.Log("The returned instance is not object : FAILED.")
end if
if isArray(aMustSupportInterface) AND bOK then
Out.Log("Checking supported interfaces ...")
for i = 0 to ubound(aMustSupportInterface())
if NOT hasUnoInterfaces(inst, aMustSupportInterface(i)) then
Out.Log("The created instance doesn't support '" + aMustSupportInterface(i) + "'")
bOK = false
end if
next i
end if
Test.MethodTested("createInstanceWithArguments()", bOK)
Exit Sub
ErrHndl:
Test.Exception()
bOK = false
resume next
End Sub
</script:module>