2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.container
.NoSuchElementException
;
24 import com
.sun
.star
.container
.XEnumeration
;
25 import com
.sun
.star
.container
.XEnumerationAccess
;
26 import com
.sun
.star
.frame
.XDesktop
;
27 import com
.sun
.star
.lang
.WrappedTargetException
;
28 import com
.sun
.star
.uno
.AnyConverter
;
29 import com
.sun
.star
.uno
.Type
;
30 import com
.sun
.star
.uno
.XInterface
;
33 * Testing <code>com.sun.star.frame.XDesktop</code>
36 * <li><code> getComponents() </code></li>
37 * <li><code> terminate() </code></li>
38 * <li><code> addTerminateListener() </code></li>
39 * <li><code> removeTerminateListener() </code></li>
40 * <li><code> getCurrentComponent() </code></li>
41 * <li><code> getCurrentFrame() </code></li>
43 * Test is <b> NOT </b> multithread compliant. <p>
44 * @see com.sun.star.frame.XDesktop
46 public class _XDesktop
extends MultiMethodTest
{
47 public XDesktop oObj
= null; // oObj filled by MultiMethodTest
50 * Test calls the method. Then elements enumeration is created and tested.<p>
51 * Has <b> OK </b> status if no exceptions were thrown.
53 public void _getComponents() {
54 XEnumerationAccess xComps
= oObj
.getComponents();
55 XEnumeration xEnum
= xComps
.createEnumeration();
56 boolean result
= false;
59 while (xEnum
.hasMoreElements()) {
61 AnyConverter
.toObject(
62 new Type(XInterface
.class), xEnum
.nextElement());
63 } catch (com
.sun
.star
.lang
.IllegalArgumentException iae
) {
64 log
.println("Can't convert any");
68 } catch (WrappedTargetException e
) {
69 log
.println("Couldn't get a component : " + e
.getMessage());
71 } catch (NoSuchElementException e
) {
72 log
.println("Couldn't get a component : " + e
.getMessage());
75 tRes
.tested("getComponents()", result
);
79 * Cannot test the method because it requires
80 * terminating StarOffice. Will add real test later.
82 public void _terminate() {
83 tRes
.tested("terminate()", true);
87 * Cannot test the method because of terminate().
88 * Will add real test later.
90 public void _addTerminateListener() {
91 tRes
.tested("addTerminateListener()", true);
95 * Cannot test the method because of terminate().
96 * Will add real test later.
98 public void _removeTerminateListener() {
99 tRes
.tested("removeTerminateListener()", true);
103 * Test calls the method. <p>
104 * Has <b> OK </b> status if the method does not return null.
106 public void _getCurrentComponent() {
107 tRes
.tested("getCurrentComponent()",
108 oObj
.getCurrentComponent() != null);
112 * Test calls the method. <p>
113 * Has <b> OK </b> status if the method does not return null.
115 public void _getCurrentFrame() {
116 tRes
.tested("getCurrentFrame()", oObj
.getCurrentFrame() != null);