1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XToolkit.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
35 import com
.sun
.star
.awt
.Rectangle
;
36 import com
.sun
.star
.awt
.WindowDescriptor
;
37 import com
.sun
.star
.awt
.XDevice
;
38 import com
.sun
.star
.awt
.XRegion
;
39 import com
.sun
.star
.awt
.XToolkit
;
40 import com
.sun
.star
.awt
.XWindowPeer
;
43 * Testing <code>com.sun.star.awt.XToolkit</code>
46 * <li><code> getDesktopWindow() </code></li>
47 * <li><code> getWorkArea() </code></li>
48 * <li><code> createWindow() </code></li>
49 * <li><code> createWindows() </code></li>
50 * <li><code> createScreenCompatibleDevice() </code></li>
51 * <li><code> createRegion() </code></li>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.awt.XToolkit
56 public class _XToolkit
extends MultiMethodTest
{
57 public XToolkit oObj
= null;
60 * Test calls the method. <p>
61 * Has <b> OK </b> status always, because Desktop component
62 * currently is not supported as visible.
64 public void _getDesktopWindow() {
65 XWindowPeer win
= oObj
.getDesktopWindow();
67 log
.println("getDesktopWindow() returns NULL");
69 tRes
.tested("getDesktopWindow()", true);
73 * Test calls the method. <p>
74 * Has <b> OK </b> status if the method does not return null.
76 public void _getWorkArea() {
77 Rectangle area
= oObj
.getWorkArea();
78 tRes
.tested("getWorkArea()", area
!= null);
82 * Test calls the method. <p>
83 * Has <b> OK </b> status if the method does not return null.
85 public void _createWindow() {
88 XWindowPeer cWin
= oObj
.createWindow(
89 createDesc(new Rectangle(0,0,100,100)));
91 log
.println("createWindow() create a NULL Object");
95 } catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
96 log
.println("Exception occured while checking 'createWindow':");
97 ex
.printStackTrace(log
);
99 tRes
.tested("createWindow()", res
);
103 * After defining of WindowDescriptor array, test calls the method. <p>
104 * Has <b> OK </b> status if all elements of the returned array are
107 public void _createWindows() {
110 WindowDescriptor
[] descs
= new WindowDescriptor
[2];
111 descs
[0] = createDesc(new Rectangle(0,0,100,100));
112 descs
[1] = createDesc(new Rectangle(100,100,200,200));
113 XWindowPeer
[] cWins
= oObj
.createWindows(descs
);
114 if ( (cWins
[0] == null) || (cWins
[1] == null) ) {
115 log
.println("createWindows() creates NULL Windows");
119 } catch (com
.sun
.star
.lang
.IllegalArgumentException ex
) {
120 log
.println("Exception occured while checking 'createWindows':");
121 ex
.printStackTrace(log
);
123 tRes
.tested("createWindows()", res
);
127 * Test calls the method. <p>
128 * Has <b> OK </b> status if the method does not return null.
130 public void _createScreenCompatibleDevice() {
131 XDevice dev
= oObj
.createScreenCompatibleDevice(100, 100);
132 tRes
.tested("createScreenCompatibleDevice()", dev
!= null);
136 * Test calls the method. <p>
137 * Has <b> OK </b> status if the method does not return null.
139 public void _createRegion() {
140 XRegion reg
= oObj
.createRegion();
141 tRes
.tested("createRegion()", reg
!= null);
145 * Just creates the WindowDescriptor as an argument for createWindow().
147 public WindowDescriptor
createDesc(Rectangle rect
) {
148 XWindowPeer win
= (XWindowPeer
) tEnv
.getObjRelation("WINPEER");
149 return new WindowDescriptor(com
.sun
.star
.awt
.WindowClass
.TOP
,
150 "", win
, (short) -1, rect
, com
.sun
.star
.awt
.WindowAttribute
.SHOW
);