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.drawing; 29 30 import lib.MultiMethodTest; 31 import util.FormTools; 32 33 import com.sun.star.awt.XControlModel; 34 import com.sun.star.drawing.XControlShape; 35 import com.sun.star.lang.XComponent; 36 import com.sun.star.uno.UnoRuntime; 37 import com.sun.star.uno.XInterface; 38 39 /** 40 * Testing <code>com.sun.star.drawing.XControlShape</code> 41 * interface methods : 42 * <ul> 43 * <li><code> getControl()</code></li> 44 * <li><code> setControl()</code></li> 45 * </ul> <p> 46 * This test needs the following object relations : 47 * <ul> 48 * <li> <code>'xDoc'</code> (of type <code>XComponent</code>): 49 * the document where shape tested is situated. This document 50 * must also implement <code>XMultiServiceFactory</code> interface 51 * to create some control model. </li> 52 * <ul> <p> 53 * Test is <b> NOT </b> multithread compilant. <p> 54 * @see com.sun.star.drawing.XControlShape 55 */ 56 public class _XControlShape extends MultiMethodTest { 57 58 public XControlShape oObj = null; 59 60 XControlModel model = null; 61 62 /** 63 * Test calls the method. <p> 64 * Has <b> OK </b> status if the method successfully returns 65 * and no exceptions were thrown. <p> 66 */ 67 public void _getControl() { 68 model = oObj.getControl() ; 69 70 tRes.tested("getControl()", true) ; 71 } 72 73 /** 74 * With the help of document passed as relation, a new button control 75 * model is created and set as a control. <p> 76 * Has <b> OK </b> status if <code>getControl()</code> method returns 77 * the same control as was set. <p> 78 * The following method tests are to be completed successfully before : 79 * <ul> 80 * <li> <code> getControl() </code> </li> 81 * </ul> 82 */ 83 public void _setControl() { 84 requiredMethod("getControl()") ; 85 86 XInterface oNewControl = FormTools.createControl 87 ((XComponent)tEnv.getObjRelation("xDoc"), "ComboBox") ; 88 89 XControlModel xControl = (XControlModel) UnoRuntime.queryInterface 90 (XControlModel.class, oNewControl) ; 91 92 oObj.setControl(xControl) ; 93 94 XControlModel gControl = oObj.getControl() ; 95 96 if (oNewControl.equals(gControl)) 97 tRes.tested("setControl()", true) ; 98 else { 99 log.println("Control set is not equal to control get") ; 100 tRes.tested("setControl()", false) ; 101 } 102 } 103 104 } // finish class _XControlShape 105 106 107