xref: /aoo41x/main/ucb/qa/complex/tdoc/_XChild.java (revision 67e470da)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package complex.tdoc;
25 
26 import lib.MultiMethodTest;
27 import lib.Status;
28 
29 import com.sun.star.container.XChild;
30 import com.sun.star.container.XNamed;
31 import com.sun.star.uno.UnoRuntime;
32 import share.LogWriter;
33 
34 /*
35 * Testing <code>com.sun.star.container.XChild</code>
36 * interface methods :
37 * <ul>
38 *  <li><code> getParent()</code></li>
39 *  <li><code> setParent()</code></li>
40 * </ul>
41 * @see com.sun.star.container.XChild
42 */
43 public class _XChild {
44 
45     public XChild oObj = null;
46     public Object gotten = null;
47     public LogWriter log = null;
48 
49 
50     /**
51     * Test calls the method and checks return value and that
52     * no exceptions were thrown. Parent returned is stored.<p>
53     * Has <b> OK </b> status if the method returns not null value
54     * and no exceptions were thrown. <p>
55     */
_getParent(boolean hasParent)56     public boolean _getParent(boolean hasParent) {
57         gotten = oObj.getParent();
58         if (!hasParent)
59             return gotten == null;
60         XNamed the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class,gotten);
61         if (the_name != null)
62             log.println("Parent:"+the_name.getName());
63         return gotten != null;
64     }
65 
66     /**
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 :
71     * <ul>
72     *  <li> <code> getParent() </code> : to get the parent. </li>
73     * </ul>
74     */
_setParent(boolean supported)75     public boolean _setParent(boolean supported) {
76 //        requiredMethod("getParent()") ;
77 
78         String parentComment = null;//String) tEnv.getObjRelation("cannotSwitchParent");
79 
80         if (parentComment != null) {
81             log.println(parentComment);
82             return true;
83         }
84 
85         try {
86             oObj.setParent(gotten);
87         }
88         catch (com.sun.star.lang.NoSupportException ex) {
89             log.println("Exception occured during setParent() - " + (supported?"FAILED":"OK"));
90             if (supported) {
91                 ex.printStackTrace((java.io.PrintWriter)log);
92                 return false;
93             }
94         }
95         return true;
96     }
97 
98 }  // finish class _XChild
99 
100 
101