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' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9'
10' Copyright 2000, 2010 Oracle and/or its affiliates.
11'
12' OpenOffice.org - a multi-platform office productivity suite
13'
14' This file is part of OpenOffice.org.
15'
16' OpenOffice.org is free software: you can redistribute it and/or modify
17' it under the terms of the GNU Lesser General Public License version 3
18' only, as published by the Free Software Foundation.
19'
20' OpenOffice.org is distributed in the hope that it will be useful,
21' but WITHOUT ANY WARRANTY; without even the implied warranty of
22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23' GNU Lesser General Public License version 3 for more details
24' (a copy is included in the LICENSE file that accompanied this code).
25'
26' You should have received a copy of the GNU Lesser General Public License
27' version 3 along with OpenOffice.org.  If not, see
28' <http://www.openoffice.org/license.html>
29' for a copy of the LGPLv3 License.
30'
31'*************************************************************************
32'*************************************************************************
33
34
35
36
37
38Sub RunTest()
39
40'*************************************************************************
41' INTERFACE:
42' com.sun.star.script.XEventAttacherManager
43'*************************************************************************
44On Error Goto ErrHndl
45    Dim bOK As Boolean
46
47	oObj.insertEntry(0)
48
49    Test.StartMethod("addScriptListener()")
50    bOK = true
51    Dim oListener1 As Object
52    Dim oListener2 As Object
53
54	oListener = createUnoListener("CB1_", "com.sun.star.script.XScriptListener")
55
56    oObj.addScriptListener(oListener)
57
58    Test.MethodTested("addScriptListener()", bOK)
59
60
61    Test.StartMethod("registerScriptEvent()")
62    bOK = true
63
64	Dim aScriptEvent1 As New com.sun.star.script.ScriptEventDescriptor
65	aScriptEvent1.ListenerType = "ScriptListener"
66	aScriptEvent1.EventMethod = "Test"
67	aScriptEvent1.AddListenerParam = ""
68	aScriptEvent1.ScriptType = "Basic"
69	aScriptEvent1.ScriptCode = "MsgBox ""Script1"""
70	oObj.registerScriptEvent(0, aScriptEvent1)
71
72    Test.MethodTested("registerScriptEvent()", bOK)
73
74    Test.StartMethod("registerScriptEvents()")
75    bOK = true
76	Dim aScriptEvent2 As New com.sun.star.script.ScriptEventDescriptor
77	aScriptEvent2.ListenerType = "ScriptListener"
78	aScriptEvent2.EventMethod = "Test"
79	aScriptEvent2.AddListenerParam = ""
80	aScriptEvent2.ScriptType = "Basic"
81	aScriptEvent2.ScriptCode = "MsgBox ""Script2"""
82	Dim aScriptEvent3 As New com.sun.star.script.ScriptEventDescriptor
83	aScriptEvent3.ListenerType = "ScriptListener"
84	aScriptEvent3.EventMethod = "Test"
85	aScriptEvent3.AddListenerParam = ""
86	aScriptEvent3.ScriptType = "Basic"
87	aScriptEvent3.ScriptCode = "MsgBox ""Script3"""
88
89	Dim aScripts(1)
90	aScripts(0) = aScriptEvent2
91	aScripts(1) = aScriptEvent3
92
93	oObj.registerScriptEvents(0, aScripts())
94
95    Test.MethodTested("registerScriptEvents()", bOK)
96
97    Test.StartMethod("getScriptEvents()")
98    bOK = true
99    allScripts = oObj.getScriptEvents(0)
100    bOK = bOK AND ubound(allScripts) = 2
101    bOK = bOK AND allScripts(0).ScriptCode = "MsgBox ""Script1"""
102    bOK = bOK AND allScripts(1).ScriptCode = "MsgBox ""Script2"""
103    bOK = bOK AND allScripts(2).ScriptCode = "MsgBox ""Script3"""
104    Test.MethodTested("getScriptEvents()", bOK)
105
106    Test.StartMethod("insertEntry()")
107    bOK = true
108    oObj.insertEntry(0)
109    allScripts = oObj.getScriptEvents(0)
110    bOK = bOK AND ubound(allScripts) = -1
111    allScripts = oObj.getScriptEvents(1)
112    bOK = bOK AND ubound(allScripts) = 2
113    Test.MethodTested("insertEntry()", bOK)
114
115    Test.StartMethod("removeEntry()")
116    bOK = true
117    oObj.removeEntry(0)
118    allScripts = oObj.getScriptEvents(1)
119    bOK = bOK AND ubound(allScripts) = -1
120    allScripts = oObj.getScriptEvents(0)
121    bOK = bOK AND ubound(allScripts) = 2
122    Test.MethodTested("removeEntry()", bOK)
123
124    Test.StartMethod("attach()")
125    bOK = true
126    oObj.attach(0, oObj, "")
127    Test.MethodTested("attach()", bOK)
128
129    Test.StartMethod("detach()")
130    bOK = true
131    oObj.detach(0, oObj)
132    Test.MethodTested("detach()", bOK)
133
134
135    Test.StartMethod("revokeScriptEvent()")
136    bOK = true
137    oObj.revokeScriptEvent(0, "ScriptListener", "Test", "")
138    allScripts = oObj.getScriptEvents(0)
139    bOK = bOK AND ubound(allScripts) = 1
140    Test.MethodTested("revokeScriptEvent()", bOK)
141
142    Test.StartMethod("revokeScriptEvents()")
143    bOK = true
144    oObj.revokeScriptEvents(0)
145    allScripts = oObj.getScriptEvents(0)
146    bOK = bOK AND ubound(allScripts) = -1
147    Test.MethodTested("revokeScriptEvents()", bOK)
148
149    Test.StartMethod("removeScriptListener()")
150    bOK = true
151    oObj.removeScriptListener(oListener)
152    Test.MethodTested("removeScriptListener()", bOK)
153
154Exit Sub
155ErrHndl:
156    Test.Exception()
157    bOK = false
158    resume next
159End Sub
160</script:module>
161