1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 package ifc.container; 29 30 import lib.MultiMethodTest; 31 import lib.Status; 32 33 import com.sun.star.container.XChild; 34 import com.sun.star.container.XNamed; 35 import com.sun.star.uno.UnoRuntime; 36 37 /* 38 * Testing <code>com.sun.star.container.XChild</code> 39 * interface methods : 40 * <ul> 41 * <li><code> getParent()</code></li> 42 * <li><code> setParent()</code></li> 43 * </ul> 44 * @see com.sun.star.container.XChild 45 */ 46 public class _XChild extends MultiMethodTest { 47 48 public XChild oObj = null; 49 public Object gotten = null; 50 51 52 /** 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> 57 */ 58 public void _getParent() { 59 gotten = oObj.getParent(); 60 XNamed the_name = (XNamed) UnoRuntime.queryInterface(XNamed.class,gotten); 61 if (the_name != null) 62 log.println("Parent:"+the_name.getName()); 63 tRes.tested("getParent()",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 */ 75 public void _setParent() { 76 requiredMethod("getParent()") ; 77 78 String parentComment = (String) tEnv.getObjRelation("cannotSwitchParent"); 79 80 if (parentComment != null) { 81 log.println(parentComment); 82 tRes.tested("setParent()",Status.skipped(true)); 83 return; 84 } 85 86 try { 87 oObj.setParent(gotten); 88 tRes.tested("setParent()",true); 89 } 90 catch (com.sun.star.lang.NoSupportException ex) { 91 log.println("Exception occured during setParent()"); 92 ex.printStackTrace(log); 93 tRes.tested("setParent()",false); 94 } 95 96 } 97 98 } // finish class _XChild 99 100 101