1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XControlShape.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
34 import util
.FormTools
;
36 import com
.sun
.star
.awt
.XControlModel
;
37 import com
.sun
.star
.drawing
.XControlShape
;
38 import com
.sun
.star
.lang
.XComponent
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
40 import com
.sun
.star
.uno
.XInterface
;
43 * Testing <code>com.sun.star.drawing.XControlShape</code>
46 * <li><code> getControl()</code></li>
47 * <li><code> setControl()</code></li>
49 * This test needs the following object relations :
51 * <li> <code>'xDoc'</code> (of type <code>XComponent</code>):
52 * the document where shape tested is situated. This document
53 * must also implement <code>XMultiServiceFactory</code> interface
54 * to create some control model. </li>
56 * Test is <b> NOT </b> multithread compilant. <p>
57 * @see com.sun.star.drawing.XControlShape
59 public class _XControlShape
extends MultiMethodTest
{
61 public XControlShape oObj
= null;
63 XControlModel model
= null;
66 * Test calls the method. <p>
67 * Has <b> OK </b> status if the method successfully returns
68 * and no exceptions were thrown. <p>
70 public void _getControl() {
71 model
= oObj
.getControl() ;
73 tRes
.tested("getControl()", true) ;
77 * With the help of document passed as relation, a new button control
78 * model is created and set as a control. <p>
79 * Has <b> OK </b> status if <code>getControl()</code> method returns
80 * the same control as was set. <p>
81 * The following method tests are to be completed successfully before :
83 * <li> <code> getControl() </code> </li>
86 public void _setControl() {
87 requiredMethod("getControl()") ;
89 XInterface oNewControl
= FormTools
.createControl
90 ((XComponent
)tEnv
.getObjRelation("xDoc"), "ComboBox") ;
92 XControlModel xControl
= (XControlModel
) UnoRuntime
.queryInterface
93 (XControlModel
.class, oNewControl
) ;
95 oObj
.setControl(xControl
) ;
97 XControlModel gControl
= oObj
.getControl() ;
99 if (oNewControl
.equals(gControl
))
100 tRes
.tested("setControl()", true) ;
102 log
.println("Control set is not equal to control get") ;
103 tRes
.tested("setControl()", false) ;
107 } // finish class _XControlShape