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 .
21 import lib
.MultiMethodTest
;
22 import util
.FormTools
;
24 import com
.sun
.star
.awt
.XControlModel
;
25 import com
.sun
.star
.drawing
.XControlShape
;
26 import com
.sun
.star
.lang
.XComponent
;
27 import com
.sun
.star
.uno
.UnoRuntime
;
28 import com
.sun
.star
.uno
.XInterface
;
31 * Testing <code>com.sun.star.drawing.XControlShape</code>
34 * <li><code> getControl()</code></li>
35 * <li><code> setControl()</code></li>
37 * This test needs the following object relations :
39 * <li> <code>'xDoc'</code> (of type <code>XComponent</code>):
40 * the document where shape tested is situated. This document
41 * must also implement <code>XMultiServiceFactory</code> interface
42 * to create some control model. </li>
44 * Test is <b> NOT </b> multithread compliant. <p>
45 * @see com.sun.star.drawing.XControlShape
47 public class _XControlShape
extends MultiMethodTest
{
49 public XControlShape oObj
= null;
52 * Test calls the method. <p>
53 * Has <b> OK </b> status if the method successfully returns
54 * and no exceptions were thrown. <p>
56 public void _getControl() {
58 tRes
.tested("getControl()", true) ;
62 * With the help of document passed as relation, a new button control
63 * model is created and set as a control. <p>
64 * Has <b> OK </b> status if <code>getControl()</code> method returns
65 * the same control as was set. <p>
66 * The following method tests are to be completed successfully before :
68 * <li> <code> getControl() </code> </li>
71 public void _setControl()
72 throws com
.sun
.star
.uno
.Exception
74 requiredMethod("getControl()") ;
76 XInterface oNewControl
= FormTools
.createControl
77 ((XComponent
)tEnv
.getObjRelation("xDoc"), "ComboBox") ;
79 XControlModel xControl
= UnoRuntime
.queryInterface
80 (XControlModel
.class, oNewControl
) ;
82 oObj
.setControl(xControl
) ;
84 XControlModel gControl
= oObj
.getControl() ;
86 if (oNewControl
.equals(gControl
))
87 tRes
.tested("setControl()", true) ;
89 log
.println("Control set is not equal to control get") ;
90 tRes
.tested("setControl()", false) ;
94 } // finish class _XControlShape