1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc
.container
;
30 import lib
.MultiMethodTest
;
33 import com
.sun
.star
.container
.XChild
;
34 import com
.sun
.star
.container
.XNamed
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
38 * Testing <code>com.sun.star.container.XChild</code>
41 * <li><code> getParent()</code></li>
42 * <li><code> setParent()</code></li>
44 * @see com.sun.star.container.XChild
46 public class _XChild
extends MultiMethodTest
{
48 public XChild oObj
= null;
49 public Object gotten
= null;
53 * Test calls the method and checks return value and that
54 * no exceptions were thrown. Parent returned is stored.<p>
55 * Has <b> OK </b> status if the method returns not null value
56 * and no exceptions were thrown. <p>
58 public void _getParent() {
59 gotten
= oObj
.getParent();
60 XNamed the_name
= (XNamed
) UnoRuntime
.queryInterface(XNamed
.class,gotten
);
62 log
.println("Parent:"+the_name
.getName());
63 tRes
.tested("getParent()",gotten
!= null);
67 * Sets existing parent and checks that
68 * no exceptions were thrown. <p>
69 * Has <b> OK </b> status if no exceptions were thrown. <p>
70 * The following method tests are to be completed successfully before :
72 * <li> <code> getParent() </code> : to get the parent. </li>
75 public void _setParent() {
76 requiredMethod("getParent()") ;
78 String parentComment
= (String
) tEnv
.getObjRelation("cannotSwitchParent");
80 if (parentComment
!= null) {
81 log
.println(parentComment
);
82 tRes
.tested("setParent()",Status
.skipped(true));
87 oObj
.setParent(gotten
);
88 tRes
.tested("setParent()",true);
90 catch (com
.sun
.star
.lang
.NoSupportException ex
) {
91 log
.println("Exception occurred during setParent()");
92 ex
.printStackTrace(log
);
93 tRes
.tested("setParent()",false);
98 } // finish class _XChild