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="form_XLoadable" 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' Be sure that all variables are dimensioned:
32option explicit
33
34
35
36Sub RunTest()
37
38'*************************************************************************
39' INTERFACE:
40' com.sun.star.form.XLoadable
41'*************************************************************************
42On Error Goto ErrHndl
43    Dim bOK As Boolean
44    Dim bLoaded As Boolean
45    Dim list As Object
46
47    list = createUnoListener("L_", "com.sun.star.form.XLoadListener")
48    initListener()
49
50    Test.StartMethod("isLoaded()")
51    bOK = true
52    bLoaded = oObj.isLoaded()
53    if bLoaded then  oObj.unload()
54    bLoaded = oObj.isLoaded()
55    bOK = bOK AND NOT bLoaded
56    Test.MethodTested("isLoaded()", bOK)
57
58    Test.StartMethod("addLoadListener()")
59    oObj.addLoadListener(list)
60
61    Test.StartMethod("load()")
62    bOK = true
63    oObj.load()
64    bOK = bOK AND oObj.isLoaded()
65    bOK = bOK AND loaded
66    Test.MethodTested("load()", bOK)
67
68    Test.StartMethod("reload()")
69    bOK = true
70    oObj.reload()
71    bOK = bOK AND oObj.isLoaded()
72    bOK = bOK AND reloaded
73    Test.MethodTested("reload()", bOK)
74
75    Test.StartMethod("unload()")
76    bOK = true
77    oObj.unload()
78    bOK = bOK AND NOT oObj.isLoaded()
79    bOK = bOK AND unloaded
80    Test.MethodTested("unload()", bOK)
81
82    bOK = loaded AND reloaded AND reloading AND unloaded AND unloading
83    Test.MethodTested("addLoadListener()", bOK)
84
85    Test.StartMethod("removeLoadListener()")
86    bOK = true
87    oObj.removeLoadListener(list)
88    initListener()
89    oObj.load()
90    bOK = bOK AND NOT loaded
91    Test.MethodTested("removeLoadListener()", bOK)
92
93Exit Sub
94ErrHndl:
95    Test.Exception()
96    bOK = false
97    resume next
98End Sub
99
100Sub initListener()
101    loaded = false
102    reloaded = false
103    reloading = false
104    unloaded = false
105    unloading = false
106End Sub
107
108Dim loaded As Boolean
109Dim reloaded As Boolean
110Dim reloading As Boolean
111Dim unloaded As Boolean
112Dim unloading As Boolean
113
114Sub L_loaded()
115   Out.Log("Listener: loaded")
116   loaded = true
117End Sub
118Sub L_reloaded()
119   Out.Log("Listener: reloaded")
120   reloaded = true
121End Sub
122Sub L_reloading()
123   Out.Log("Listener: reloading")
124   reloading = true
125End Sub
126Sub L_unloaded()
127   Out.Log("Listener: unloaded")
128   unloaded = true
129End Sub
130Sub L_unloading()
131   Out.Log("Listener: unloading")
132   unloading = true
133End Sub
134</script:module>
135