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 ifc.container;
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 
33 /*
34 * Testing <code>com.sun.star.container.XChild</code>
35 * interface methods :
36 * <ul>
37 *  <li><code> getParent()</code></li>
38 *  <li><code> setParent()</code></li>
39 * </ul>
40 * @see com.sun.star.container.XChild
41 */
42 public class _XChild extends MultiMethodTest {
43 
44     public XChild oObj = null;
45     public Object gotten = null;
46 
47 
48     /**
49     * Test calls the method and checks return value and that
50     * no exceptions were thrown. Parent returned is stored.<p>
51     * Has <b> OK </b> status if the method returns not null value
52     * and no exceptions were thrown. <p>
53     */
_getParent()54     public void _getParent() {
55         gotten = oObj.getParent();
56         XNamed the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class,gotten);
57         if (the_name != null)
58             log.println("Parent:"+the_name.getName());
59         tRes.tested("getParent()",gotten != null);
60     }
61 
62     /**
63     * Sets existing parent and checks that
64     * no exceptions were thrown. <p>
65     * Has <b> OK </b> status if no exceptions were thrown. <p>
66     * The following method tests are to be completed successfully before :
67     * <ul>
68     *  <li> <code> getParent() </code> : to get the parent. </li>
69     * </ul>
70     */
_setParent()71     public void _setParent() {
72         requiredMethod("getParent()") ;
73 
74         String parentComment = (String) tEnv.getObjRelation("cannotSwitchParent");
75 
76         if (parentComment != null) {
77             log.println(parentComment);
78             tRes.tested("setParent()",Status.skipped(true));
79             return;
80         }
81 
82         try {
83             oObj.setParent(gotten);
84             tRes.tested("setParent()",true);
85         }
86         catch (com.sun.star.lang.NoSupportException ex) {
87             log.println("Exception occured during setParent()");
88             ex.printStackTrace(log);
89             tRes.tested("setParent()",false);
90         }
91 
92     }
93 
94 }  // finish class _XChild
95 
96 
97