1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="awt_XToolkit" script:language="StarBasic">
4cdf0e10cSrcweir
5cdf0e10cSrcweir
6cdf0e10cSrcweir'*************************************************************************
7cdf0e10cSrcweir'
8*3709053cSAndrew Rist'  Licensed to the Apache Software Foundation (ASF) under one
9*3709053cSAndrew Rist'  or more contributor license agreements.  See the NOTICE file
10*3709053cSAndrew Rist'  distributed with this work for additional information
11*3709053cSAndrew Rist'  regarding copyright ownership.  The ASF licenses this file
12*3709053cSAndrew Rist'  to you under the Apache License, Version 2.0 (the
13*3709053cSAndrew Rist'  "License"); you may not use this file except in compliance
14*3709053cSAndrew Rist'  with the License.  You may obtain a copy of the License at
15*3709053cSAndrew Rist'
16*3709053cSAndrew Rist'    http://www.apache.org/licenses/LICENSE-2.0
17*3709053cSAndrew Rist'
18*3709053cSAndrew Rist'  Unless required by applicable law or agreed to in writing,
19*3709053cSAndrew Rist'  software distributed under the License is distributed on an
20*3709053cSAndrew Rist'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21*3709053cSAndrew Rist'  KIND, either express or implied.  See the License for the
22*3709053cSAndrew Rist'  specific language governing permissions and limitations
23*3709053cSAndrew Rist'  under the License.
24cdf0e10cSrcweir'
25cdf0e10cSrcweir'*************************************************************************
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29*3709053cSAndrew Rist
30*3709053cSAndrew Rist
31cdf0e10cSrcweir' Be sure that all variables are dimensioned:
32cdf0e10cSrcweiroption explicit
33cdf0e10cSrcweir
34cdf0e10cSrcweir
35cdf0e10cSrcweir
36cdf0e10cSrcweirSub RunTest()
37cdf0e10cSrcweir
38cdf0e10cSrcweir'*************************************************************************
39cdf0e10cSrcweir' INTERFACE:
40cdf0e10cSrcweir' com.sun.star.awt.XToolkit
41cdf0e10cSrcweir'*************************************************************************
42cdf0e10cSrcweirOn Error Goto ErrHndl
43cdf0e10cSrcweir    Dim bOK As Boolean
44cdf0e10cSrcweir
45cdf0e10cSrcweir    Test.StartMethod("getDesktopWindow()")
46cdf0e10cSrcweir    bOK = true
47cdf0e10cSrcweir    Dim oWindow As Object
48cdf0e10cSrcweir    oWindow = oObj.getDesktopWindow()
49cdf0e10cSrcweir    Out.Log("Desktop window is NULL : " &amp; isNULL(oWindow))
50cdf0e10cSrcweir    ' Has "OK" status always, because Desktop component
51cdf0e10cSrcweir    ' currently is not supported as visible.
52cdf0e10cSrcweir    Test.MethodTested("getDesktopWindow()", bOK)
53cdf0e10cSrcweir
54cdf0e10cSrcweir    Test.StartMethod("getWorkArea()")
55cdf0e10cSrcweir    bOK = true
56cdf0e10cSrcweir    Dim oRect As Object
57cdf0e10cSrcweir    oRect = oObj.getWorkArea()
58cdf0e10cSrcweir    Out.Log("WorkArea is NULL : " &amp; isNULL(oRect))
59cdf0e10cSrcweir    if (NOT isNULL(oRect)) then
60cdf0e10cSrcweir        Out.Log("Returned rectangle is: (" &amp; oRect.X &amp; ", " &amp; oRect.Y &amp; ", " &amp; oRect.Width &amp; ", " &amp; oRect.Height &amp; ")")
61cdf0e10cSrcweir    end if
62cdf0e10cSrcweir    Test.MethodTested("getWorkArea()", bOK)
63cdf0e10cSrcweir
64cdf0e10cSrcweir    Test.StartMethod("createWindow()")
65cdf0e10cSrcweir    bOK = true
66cdf0e10cSrcweir    Dim oWndDescr As new com.sun.star.awt.WindowDescriptor
67cdf0e10cSrcweir    Dim oBounds As new com.sun.star.awt.Rectangle
68cdf0e10cSrcweir    oWndDescr.Type = com.sun.star.awt.WindowClass.TOP
69cdf0e10cSrcweir    oWndDescr.WindowServiceName = ""
70cdf0e10cSrcweir    oWndDescr.ParentIndex = -1
71cdf0e10cSrcweir    oBounds.X = 10 : oBounds.Y = 20
72cdf0e10cSrcweir    oBounds.Width = 110 : oBounds.Height = 120
73cdf0e10cSrcweir    oWndDescr.Bounds = oBounds
74cdf0e10cSrcweir    with com.sun.star.awt.WindowAttribute
75cdf0e10cSrcweir        oWndDescr.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
76cdf0e10cSrcweir    end with
77cdf0e10cSrcweir
78cdf0e10cSrcweir    Dim oWnd As Object
79cdf0e10cSrcweir    oWnd = oObj.createWindow(oWndDescr)
80cdf0e10cSrcweir    Out.Log("Window is NULL : " &amp; isNULL(oWnd))
81cdf0e10cSrcweir    bOK = bOK AND NOT isNULL(oWnd)
82cdf0e10cSrcweir    if (bOK) then
83cdf0e10cSrcweir        bOK = bOK AND hasUnoInterfaces(oWnd, "com.sun.star.awt.XWindowPeer")
84cdf0e10cSrcweir        if (NOT bOK) then Out.Log("Returned object doesn't support XWindowPeer interface.")
85cdf0e10cSrcweir    end if
86cdf0e10cSrcweir    Test.MethodTested("createWindow()", bOK)
87cdf0e10cSrcweir
88cdf0e10cSrcweir    Test.StartMethod("createWindows()")
89cdf0e10cSrcweir    bOK = true
90cdf0e10cSrcweir    Dim oWndDescrs(1) As Object
91cdf0e10cSrcweir    Dim oWndDescr1 As new com.sun.star.awt.WindowDescriptor
92cdf0e10cSrcweir    Dim oBounds1 As new com.sun.star.awt.Rectangle
93cdf0e10cSrcweir    oWndDescr1.Type = com.sun.star.awt.WindowClass.TOP
94cdf0e10cSrcweir    oWndDescr1.WindowServiceName = ""
95cdf0e10cSrcweir    'oWndDescr1.Parent = 0
96cdf0e10cSrcweir    oWndDescr1.ParentIndex = -1
97cdf0e10cSrcweir    oBounds1.X = 10 : oBounds1.Y = 20
98cdf0e10cSrcweir    oBounds1.Width = 110 : oBounds1.Height = 120
99cdf0e10cSrcweir    oWndDescr1.Bounds = oBounds1
100cdf0e10cSrcweir    with com.sun.star.awt.WindowAttribute
101cdf0e10cSrcweir        oWndDescr1.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
102cdf0e10cSrcweir    end with
103cdf0e10cSrcweir    Dim oWndDescr2 As new com.sun.star.awt.WindowDescriptor
104cdf0e10cSrcweir    Dim oBounds2 As new com.sun.star.awt.Rectangle
105cdf0e10cSrcweir    oWndDescr2.Type = com.sun.star.awt.WindowClass.TOP
106cdf0e10cSrcweir    oWndDescr2.WindowServiceName = ""
107cdf0e10cSrcweir    'oWndDescr2.Parent = 0
108cdf0e10cSrcweir    oWndDescr2.ParentIndex = -1
109cdf0e10cSrcweir    oBounds2.X = 10 : oBounds2.Y = 20
110cdf0e10cSrcweir    oBounds2.Width = 110 : oBounds2.Height = 120
111cdf0e10cSrcweir    oWndDescr2.Bounds = oBounds2
112cdf0e10cSrcweir    with com.sun.star.awt.WindowAttribute
113cdf0e10cSrcweir        oWndDescr2.WindowAttributes = .CLOSEABLE AND .MOVEABLE AND .SIZEABLE AND .BORDER AND .SHOW
114cdf0e10cSrcweir    end with
115cdf0e10cSrcweir
116cdf0e10cSrcweir    oWndDescrs(0) = oWndDescr1
117cdf0e10cSrcweir    oWndDescrs(1) = oWndDescr2
118cdf0e10cSrcweir
119cdf0e10cSrcweir    Dim oWindows As Object
120cdf0e10cSrcweir
121cdf0e10cSrcweir    oWindows = oObj.createWindows(oWndDescrs())
122cdf0e10cSrcweir    bOK = bOK AND ubound(oWindows) = 1
123cdf0e10cSrcweir    bOK = bOK AND hasUnoInterfaces(oWindows(0), "com.sun.star.awt.XWindowPeer")
124cdf0e10cSrcweir    bOK = bOK AND hasUnoInterfaces(oWindows(1), "com.sun.star.awt.XWindowPeer")
125cdf0e10cSrcweir
126cdf0e10cSrcweir    Test.MethodTested("createWindows()", bOK)
127cdf0e10cSrcweir
128cdf0e10cSrcweir    Test.StartMethod("createScreenCompatibleDevice()")
129cdf0e10cSrcweir    bOK = true
130cdf0e10cSrcweir    Dim oDevice As Object
131cdf0e10cSrcweir    oDevice = oObj.createScreenCompatibleDevice(123, 456)
132cdf0e10cSrcweir    Out.Log("Device is NULL : " &amp; isNULL(oDevice))
133cdf0e10cSrcweir    bOK = bOK AND NOT isNULL(oDevice)
134cdf0e10cSrcweir    if (bOK) then
135cdf0e10cSrcweir        bOK = bOK AND hasUnoInterfaces(oDevice, "com.sun.star.awt.XDevice")
136cdf0e10cSrcweir        if (NOT bOK) then Out.Log("Returned object doesn't support XDevice interface.")
137cdf0e10cSrcweir    end if
138cdf0e10cSrcweir    Test.MethodTested("createScreenCompatibleDevice()", bOK)
139cdf0e10cSrcweir
140cdf0e10cSrcweir    Test.StartMethod("createRegion()")
141cdf0e10cSrcweir    bOK = true
142cdf0e10cSrcweir    Dim oRegion As Object
143cdf0e10cSrcweir    oRegion = oObj.createRegion()
144cdf0e10cSrcweir    Out.Log("Region is NULL : " &amp; isNULL(oRegion))
145cdf0e10cSrcweir    bOK = bOK AND NOT isNULL(oRegion)
146cdf0e10cSrcweir    if (bOK) then
147cdf0e10cSrcweir        bOK = bOK AND hasUnoInterfaces(oRegion, "com.sun.star.awt.XRegion")
148cdf0e10cSrcweir        if (NOT bOK) then Out.Log("Returned object doesn't support XRegion interface.")
149cdf0e10cSrcweir        if (bOK) then
150cdf0e10cSrcweir            oRect = oRegion.getBounds
151cdf0e10cSrcweir            Out.Log("Returned region's bounds are: (" &amp; oRect.X &amp; ", " &amp; oRect.Y &amp; ", " &amp; oRect.Width &amp; ", " &amp; oRect.Height &amp; ")")
152cdf0e10cSrcweir        end if
153cdf0e10cSrcweir    end if
154cdf0e10cSrcweir
155cdf0e10cSrcweir    Test.MethodTested("createRegion()", bOK)
156cdf0e10cSrcweir
157cdf0e10cSrcweirExit Sub
158cdf0e10cSrcweirErrHndl:
159cdf0e10cSrcweir    Test.Exception()
160cdf0e10cSrcweir    bOK = false
161cdf0e10cSrcweir    resume next
162cdf0e10cSrcweirEnd Sub
163cdf0e10cSrcweir</script:module>
164