Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / ucb / qa / complex / tdoc / _XChild.java
blobab59933117e0e78e136719e83c68b08cdaa5cefb
1 /*
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 .
19 package complex.tdoc;
21 import com.sun.star.container.XChild;
22 import com.sun.star.container.XNamed;
23 import com.sun.star.uno.UnoRuntime;
24 import share.LogWriter;
27 * Testing <code>com.sun.star.container.XChild</code>
28 * interface methods :
29 * <ul>
30 * <li><code> getParent()</code></li>
31 * <li><code> setParent()</code></li>
32 * </ul>
33 * @see com.sun.star.container.XChild
35 public class _XChild {
37 public XChild oObj = null;
38 public Object gotten = null;
39 public LogWriter log = null;
42 /**
43 * Test calls the method and checks return value and that
44 * no exceptions were thrown. Parent returned is stored.<p>
45 * Has <b> OK </b> status if the method returns not null value
46 * and no exceptions were thrown. <p>
48 public boolean _getParent(boolean hasParent) {
49 gotten = oObj.getParent();
50 if (!hasParent)
51 return gotten == null;
52 XNamed the_name = UnoRuntime.queryInterface(XNamed.class,gotten);
53 if (the_name != null)
54 log.println("Parent:"+the_name.getName());
55 return gotten != null;
58 /**
59 * Sets existing parent and checks that
60 * no exceptions were thrown. <p>
61 * Has <b> OK </b> status if no exceptions were thrown. <p>
62 * The following method tests are to be completed successfully before :
63 * <ul>
64 * <li> <code> getParent() </code> : to get the parent. </li>
65 * </ul>
67 public boolean _setParent(boolean supported) {
68 // requiredMethod("getParent()") ;
70 String parentComment = null;//String) tEnv.getObjRelation("cannotSwitchParent");
72 if (parentComment != null) {
73 log.println(parentComment);
74 return true;
77 try {
78 oObj.setParent(gotten);
80 catch (com.sun.star.lang.NoSupportException ex) {
81 log.println("Exception occurred during setParent() - " + (supported?"FAILED":"OK"));
82 if (supported) {
83 ex.printStackTrace((java.io.PrintWriter)log);
84 return false;
87 return true;
90 } // finish class _XChild