1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
30 import lib
.MultiMethodTest
;
31 import util
.FormTools
;
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
;
40 * Testing <code>com.sun.star.drawing.XControlShape</code>
43 * <li><code> getControl()</code></li>
44 * <li><code> setControl()</code></li>
46 * This test needs the following object relations :
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>
53 * Test is <b> NOT </b> multithread compilant. <p>
54 * @see com.sun.star.drawing.XControlShape
56 public class _XControlShape
extends MultiMethodTest
{
58 public XControlShape oObj
= null;
60 XControlModel model
= null;
63 * Test calls the method. <p>
64 * Has <b> OK </b> status if the method successfully returns
65 * and no exceptions were thrown. <p>
67 public void _getControl() {
68 model
= oObj
.getControl() ;
70 tRes
.tested("getControl()", true) ;
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 :
80 * <li> <code> getControl() </code> </li>
83 public void _setControl() {
84 requiredMethod("getControl()") ;
86 XInterface oNewControl
= FormTools
.createControl
87 ((XComponent
)tEnv
.getObjRelation("xDoc"), "ComboBox") ;
89 XControlModel xControl
= (XControlModel
) UnoRuntime
.queryInterface
90 (XControlModel
.class, oNewControl
) ;
92 oObj
.setControl(xControl
) ;
94 XControlModel gControl
= oObj
.getControl() ;
96 if (oNewControl
.equals(gControl
))
97 tRes
.tested("setControl()", true) ;
99 log
.println("Control set is not equal to control get") ;
100 tRes
.tested("setControl()", false) ;
104 } // finish class _XControlShape