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: _XDesktop.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
.container
.NoSuchElementException
;
36 import com
.sun
.star
.container
.XEnumeration
;
37 import com
.sun
.star
.container
.XEnumerationAccess
;
38 import com
.sun
.star
.frame
.XDesktop
;
39 import com
.sun
.star
.lang
.WrappedTargetException
;
40 import com
.sun
.star
.uno
.AnyConverter
;
41 import com
.sun
.star
.uno
.Type
;
42 import com
.sun
.star
.uno
.XInterface
;
45 * Testing <code>com.sun.star.frame.XDesktop</code>
48 * <li><code> getComponents() </code></li>
49 * <li><code> terminate() </code></li>
50 * <li><code> addTerminateListener() </code></li>
51 * <li><code> removeTerminateListener() </code></li>
52 * <li><code> getCurrentComponent() </code></li>
53 * <li><code> getCurrentFrame() </code></li>
55 * Test is <b> NOT </b> multithread compilant. <p>
56 * @see com.sun.star.frame.XDesktop
58 public class _XDesktop
extends MultiMethodTest
{
59 public XDesktop oObj
= null; // oObj filled by MultiMethodTest
62 * Test calls the method. Then elements enumeration is created and tested.<p>
63 * Has <b> OK </b> status if no exceptions were thrown.
65 public void _getComponents() {
66 XEnumerationAccess xComps
= oObj
.getComponents();
67 XEnumeration xEnum
= xComps
.createEnumeration();
68 boolean result
= false;
71 for (; xEnum
.hasMoreElements();) {
72 XInterface xInt
= null;
74 xInt
= (XInterface
) AnyConverter
.toObject(
75 new Type(XInterface
.class), xEnum
.nextElement());
76 } catch (com
.sun
.star
.lang
.IllegalArgumentException iae
) {
77 log
.println("Can't convert any");
81 } catch (WrappedTargetException e
) {
82 log
.println("Couldn't get a component : " + e
.getMessage());
84 } catch (NoSuchElementException e
) {
85 log
.println("Couldn't get a component : " + e
.getMessage());
88 tRes
.tested("getComponents()", result
);
92 * Cannot test the method because it requires
93 * terminating StarOffice. Will add real test later.
95 public void _terminate() {
96 tRes
.tested("terminate()", true);
100 * Cannot test the method because of terminate().
101 * Will add real test later.
103 public void _addTerminateListener() {
104 tRes
.tested("addTerminateListener()", true);
108 * Cannot test the method because of terminate().
109 * Will add real test later.
111 public void _removeTerminateListener() {
112 tRes
.tested("removeTerminateListener()", true);
116 * Test calls the method. <p>
117 * Has <b> OK </b> status if the method does not return null.
119 public void _getCurrentComponent() {
120 tRes
.tested("getCurrentComponent()",
121 oObj
.getCurrentComponent() != null);
125 * Test calls the method. <p>
126 * Has <b> OK </b> status if the method does not return null.
128 public void _getCurrentFrame() {
129 tRes
.tested("getCurrentFrame()", oObj
.getCurrentFrame() != null);