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