1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="script_XEventAttacherManager" script:language="StarBasic">
4
5
6'*************************************************************************
7'
8'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31
32
33Sub RunTest()
34
35'*************************************************************************
36' INTERFACE:
37' com.sun.star.script.XEventAttacherManager
38'*************************************************************************
39On Error Goto ErrHndl
40    Dim bOK As Boolean
41
42	oObj.insertEntry(0)
43
44    Test.StartMethod("addScriptListener()")
45    bOK = true
46    Dim oListener1 As Object
47    Dim oListener2 As Object
48
49	oListener = createUnoListener("CB1_", "com.sun.star.script.XScriptListener")
50
51    oObj.addScriptListener(oListener)
52
53    Test.MethodTested("addScriptListener()", bOK)
54
55
56    Test.StartMethod("registerScriptEvent()")
57    bOK = true
58
59	Dim aScriptEvent1 As New com.sun.star.script.ScriptEventDescriptor
60	aScriptEvent1.ListenerType = "ScriptListener"
61	aScriptEvent1.EventMethod = "Test"
62	aScriptEvent1.AddListenerParam = ""
63	aScriptEvent1.ScriptType = "Basic"
64	aScriptEvent1.ScriptCode = "MsgBox ""Script1"""
65	oObj.registerScriptEvent(0, aScriptEvent1)
66
67    Test.MethodTested("registerScriptEvent()", bOK)
68
69    Test.StartMethod("registerScriptEvents()")
70    bOK = true
71	Dim aScriptEvent2 As New com.sun.star.script.ScriptEventDescriptor
72	aScriptEvent2.ListenerType = "ScriptListener"
73	aScriptEvent2.EventMethod = "Test"
74	aScriptEvent2.AddListenerParam = ""
75	aScriptEvent2.ScriptType = "Basic"
76	aScriptEvent2.ScriptCode = "MsgBox ""Script2"""
77	Dim aScriptEvent3 As New com.sun.star.script.ScriptEventDescriptor
78	aScriptEvent3.ListenerType = "ScriptListener"
79	aScriptEvent3.EventMethod = "Test"
80	aScriptEvent3.AddListenerParam = ""
81	aScriptEvent3.ScriptType = "Basic"
82	aScriptEvent3.ScriptCode = "MsgBox ""Script3"""
83
84	Dim aScripts(1)
85	aScripts(0) = aScriptEvent2
86	aScripts(1) = aScriptEvent3
87
88	oObj.registerScriptEvents(0, aScripts())
89
90    Test.MethodTested("registerScriptEvents()", bOK)
91
92    Test.StartMethod("getScriptEvents()")
93    bOK = true
94    allScripts = oObj.getScriptEvents(0)
95    bOK = bOK AND ubound(allScripts) = 2
96    bOK = bOK AND allScripts(0).ScriptCode = "MsgBox ""Script1"""
97    bOK = bOK AND allScripts(1).ScriptCode = "MsgBox ""Script2"""
98    bOK = bOK AND allScripts(2).ScriptCode = "MsgBox ""Script3"""
99    Test.MethodTested("getScriptEvents()", bOK)
100
101    Test.StartMethod("insertEntry()")
102    bOK = true
103    oObj.insertEntry(0)
104    allScripts = oObj.getScriptEvents(0)
105    bOK = bOK AND ubound(allScripts) = -1
106    allScripts = oObj.getScriptEvents(1)
107    bOK = bOK AND ubound(allScripts) = 2
108    Test.MethodTested("insertEntry()", bOK)
109
110    Test.StartMethod("removeEntry()")
111    bOK = true
112    oObj.removeEntry(0)
113    allScripts = oObj.getScriptEvents(1)
114    bOK = bOK AND ubound(allScripts) = -1
115    allScripts = oObj.getScriptEvents(0)
116    bOK = bOK AND ubound(allScripts) = 2
117    Test.MethodTested("removeEntry()", bOK)
118
119    Test.StartMethod("attach()")
120    bOK = true
121    oObj.attach(0, oObj, "")
122    Test.MethodTested("attach()", bOK)
123
124    Test.StartMethod("detach()")
125    bOK = true
126    oObj.detach(0, oObj)
127    Test.MethodTested("detach()", bOK)
128
129
130    Test.StartMethod("revokeScriptEvent()")
131    bOK = true
132    oObj.revokeScriptEvent(0, "ScriptListener", "Test", "")
133    allScripts = oObj.getScriptEvents(0)
134    bOK = bOK AND ubound(allScripts) = 1
135    Test.MethodTested("revokeScriptEvent()", bOK)
136
137    Test.StartMethod("revokeScriptEvents()")
138    bOK = true
139    oObj.revokeScriptEvents(0)
140    allScripts = oObj.getScriptEvents(0)
141    bOK = bOK AND ubound(allScripts) = -1
142    Test.MethodTested("revokeScriptEvents()", bOK)
143
144    Test.StartMethod("removeScriptListener()")
145    bOK = true
146    oObj.removeScriptListener(oListener)
147    Test.MethodTested("removeScriptListener()", bOK)
148
149Exit Sub
150ErrHndl:
151    Test.Exception()
152    bOK = false
153    resume next
154End Sub
155</script:module>
156