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="frame_XFrameLoader" 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' This Interface/Service test depends on the following GLOBAL variables,
36' which must be specified in the object creation:
37
38' Global FrameLoaderURL As String
39'Global FrameLoaderFrame As Object ' optional
40'Global FrameLoaderArgs As Variant ' optional
41
42'*************************************************************************
43
44
45
46
47
48Sub RunTest()
49
50'*************************************************************************
51' INTERFACE:
52' com.sun.star.form.XFrameLoader
53'*************************************************************************
54On Error Goto ErrHndl
55    Dim bOK As Boolean
56    Dim frame As Object
57    Dim args As Variant
58    Dim listener As Object
59
60    if IsNULL(FrameLoaderFrame) then
61        Out.log("Frame is NULL")
62        Dim oDsk As Object
63        oDsk = createUnoService("com.sun.star.frame.Desktop")
64        frame = oDsk.getCurrentFrame()
65    else
66        frame = FrameLoaderFrame
67    endif
68
69    if IsArray(FrameLoaderArgs) then
70        Out.log("Args isn't array")
71        Dim emptyAr As Variant
72        args = emptyAr
73    else
74        args = FrameLoaderArgs
75    endif
76
77    listener = createUnoListener("L_", "com.sun.star.frame.XLoadEventListener")
78    initListener()
79
80    Test.StartMethod("cancel()")
81
82    oObj.load(frame, FrameLoaderURL, args, listener)
83    oObj.cancel()
84    wait(200)
85
86    bOK = loadCancelled OR loadFinished
87
88    Test.MethodTested("cancel()", bOK)
89
90    Test.StartMethod("load()")
91
92    initListener()
93    oObj.load(frame, FrameLoaderURL, args, listener)
94    wait(200)
95    bOK = loadFinished AND Not loadCancelled
96
97    Test.MethodTested("load()", bOK)
98Exit Sub
99ErrHndl:
100    Test.Exception()
101    bOK = false
102    resume next
103End Sub
104
105Sub initListener()
106    loadFinished = false
107    loadCancelled = false
108End Sub
109
110Dim loadFinished As Boolean
111Dim loadCancelled As Boolean
112
113Sub L_loadFinished()
114   Out.Log("Listener: loadFinished")
115   loadFinished = true
116End Sub
117
118Sub L_loadCancelled()
119   Out.Log("Listener: loadCancelled")
120   loadCancelled = true
121End Sub
122</script:module>
123