update dev300-m58
[ooovba.git] / ucb / qa / complex / tdoc / interfaces / _XChild.java
blob755014ec3992c8052210ce193e8c31cb4ebcdbde
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XChild.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package complex.tdoc.interfaces;
33 import lib.MultiMethodTest;
34 import lib.Status;
36 import com.sun.star.container.XChild;
37 import com.sun.star.container.XNamed;
38 import com.sun.star.uno.UnoRuntime;
39 import share.LogWriter;
42 * Testing <code>com.sun.star.container.XChild</code>
43 * interface methods :
44 * <ul>
45 * <li><code> getParent()</code></li>
46 * <li><code> setParent()</code></li>
47 * </ul>
48 * @see com.sun.star.container.XChild
50 public class _XChild {
52 public XChild oObj = null;
53 public Object gotten = null;
54 public LogWriter log = null;
57 /**
58 * Test calls the method and checks return value and that
59 * no exceptions were thrown. Parent returned is stored.<p>
60 * Has <b> OK </b> status if the method returns not null value
61 * and no exceptions were thrown. <p>
63 public boolean _getParent(boolean hasParent) {
64 gotten = oObj.getParent();
65 if (!hasParent)
66 return gotten == null;
67 XNamed the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class,gotten);
68 if (the_name != null)
69 log.println("Parent:"+the_name.getName());
70 return gotten != null;
73 /**
74 * Sets existing parent and checks that
75 * no exceptions were thrown. <p>
76 * Has <b> OK </b> status if no exceptions were thrown. <p>
77 * The following method tests are to be completed successfully before :
78 * <ul>
79 * <li> <code> getParent() </code> : to get the parent. </li>
80 * </ul>
82 public boolean _setParent(boolean supported) {
83 // requiredMethod("getParent()") ;
85 String parentComment = null;//String) tEnv.getObjRelation("cannotSwitchParent");
87 if (parentComment != null) {
88 log.println(parentComment);
89 return true;
92 try {
93 oObj.setParent(gotten);
95 catch (com.sun.star.lang.NoSupportException ex) {
96 log.println("Exception occured during setParent() - " + (supported?"FAILED":"OK"));
97 if (supported) {
98 ex.printStackTrace((java.io.PrintWriter)log);
99 return false;
102 return true;
105 } // finish class _XChild