blob: b223eb8ca20dfc054234be03641001502a22fccc [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_XComponent" 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.
'
'*************************************************************************
'*************************************************************************
' This Interface/Service test depends on the following GLOBAL variables,
' which must be specified in the object creation:
' Global oComponentInstance As Object it will be disposed
'*************************************************************************
Dim bCB1 As Boolean, bCB2 As Boolean
' Be sure that all variables are dimensioned:
option explicit
Sub RunTest()
'*************************************************************************
' INTERFACE:
' com.sun.star.lang.XEventListener
On Error Goto ErrHndl
Dim bOK As Boolean
Dim oListener1 as Object, oListener2 As Object
If isNull(oComponentInstance) Then Out.Log("oComponentInstance is not initialized")
bCB1 = false
bCB2 = false
Out.Log("create two listeners")
oListener1 = createUNOListener("CB1_", "com.sun.star.lang.XEventListener")
oListener2 = createUNOListener("CB2_", "com.sun.star.lang.XEventListener")
' add listeners to object if initialized
if NOT(isNull(oListener2)) then
oComponentInstance.addEventListener(oListener2)
end if
if NOT(isNull(oListener1)) then
oComponentInstance.addEventListener(oListener1)
end if
Out.Log("remove Listener2")
oComponentInstance.removeEventListener(oListener2)
' dispose object and check the count
Test.StartMethod("dispose()")
bOK = true
oComponentInstance.dispose()
bOK = bCB1 AND NOT bCB2
Test.MethodTested("dispose()", bOK)
' check if only one eventlistener-callback was executed
Test.StartMethod("addEventListener()")
bOK = bCB1 AND NOT bCB2
Test.MethodTested("addEventListener()", bOK)
' check if there was only one of the listener callbacks executed
Test.StartMethod("removeEventListener()")
bOK = bCB1 AND NOT bCB2
Test.MethodTested("removeEventListener()", bOK)
Exit Sub
ErrHndl:
Test.Exception()
bOK = false
resume next
End Sub
Sub CB1_disposing
Out.Log("CallBack for Listener1 disposing was called.")
bCB1 = true
End Sub
Sub CB2_disposing
Out.Log("CallBack for Listener2 disposing was called.")
bCB2 = true
End Sub
</script:module>