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="awt_XTopWindow" 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.awt.XTopWindow
41'*************************************************************************
42On Error Goto ErrHndl
43    Dim bOK As Boolean
44    Dim list1 As Object, list2 As Object
45    Dim aDoc As Object
46
47    list1 = createUnoListener("L1_", "com.sun.star.awt.XTopWindowListener")
48    list2 = createUnoListener("L2_", "com.sun.star.awt.XTopWindowListener")
49
50    l1Called = false
51    l2Called = false
52
53    Test.StartMethod("addTopWindowListener()")
54    bOK = true
55
56    oObj.addTopWindowListener(list1)
57    oObj.addTopWindowListener(list2)
58
59    Test.StartMethod("removeTopWindowListener()")
60    oObj.removeTopWindowListener(list1)
61
62    Out.Log("Creating a doc ...")
63    aDoc = utils.createDocument("swriter", "Window On Top")
64    Out.Log("Doc created.")
65    wait(1000)
66
67    Test.StartMethod("toFront()")
68    bOK = true
69    activated = false
70    deactivated = false
71    oObj.toFront()
72    wait(1000)
73    bOK = bOK AND activated AND NOT deactivated
74    Test.MethodTested("toFront()", bOK)
75
76    Test.StartMethod("toBack()")
77    bOK = true
78    activated = false
79    deactivated = false
80    oObj.toBack()
81    wait(1000)
82    bOK = bOK AND deactivated AND NOT activated
83    Test.MethodTested("toBack()", bOK)
84
85    Out.Log("Disposing a doc ...")
86    aDoc.dispose()
87    Out.Log("Doc disposed.")
88    wait(1000)
89
90    bOK = L2Called
91    Test.MethodTested("addTopWindowListener()", bOK)
92    bOK = bOK AND NOT L1Called
93    Test.MethodTested("removeTopWindowListener()", bOK)
94
95    Test.StartMethod("setMenuBar()")
96    bOK = true
97    Dim menu As Object
98    menu = createUnoService("com.sun.star.awt.MenuBar")
99    menu.insertItem(1, "MenuItem", com.sun.star.awt.MenuItemStyle.CHECKABLE, 1)
100    oObj.setMenuBar(menu)
101    Test.MethodTested("setMenuBar()", bOK)
102
103Exit Sub
104ErrHndl:
105    Test.Exception()
106    bOK = false
107    resume next
108End Sub
109
110Dim L1Called As Boolean
111Dim L2Called As Boolean
112
113Dim activated As Boolean
114Dim deactivated As Boolean
115
116Sub L1_windowActivated()
117    L1Called = true
118End Sub
119Sub L1_windowDeactivated()
120    L1Called = true
121End Sub
122
123Sub L2_windowActivated()
124    L2Called = true
125    activated = true
126    Out.Log("Activated ...")
127End Sub
128Sub L2_windowDeactivated()
129    L2Called = true
130    deactivated = true
131    Out.Log("Deactivated ...")
132End Sub
133</script:module>
134