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: _XControlContainer.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
;
35 import com
.sun
.star
.awt
.XControl
;
36 import com
.sun
.star
.awt
.XControlContainer
;
39 * Testing <code>com.sun.star.awt.XControlContainer</code>
42 * <li><code> setStatusText() </code></li>
43 * <li><code> addControl() </code></li>
44 * <li><code> removeControl() </code></li>
45 * <li><code> getControl() </code></li>
46 * <li><code> getControls() </code></li>
48 * This test needs the following object relations :
50 * <li> <code>'CONTROL1'</code> (of type <code>XControl</code>):
51 * used as a parameter to addControl(), getControl() and removeControl()</li>
52 * <li> <code>'CONTROL2'</code> (of type <code>XControl</code>):
53 * used as a parameter to addControl(), getControl() and removeControl()</li>
55 * Test is <b> NOT </b> multithread compilant. <p>
56 * @see com.sun.star.awt.XControlContainer
58 public class _XControlContainer
extends MultiMethodTest
{
59 public XControlContainer oObj
= null;
62 * Test calls the method. <p>
63 * Has <b> OK </b> status if the method successfully returns
64 * and no exceptions were thrown.
66 public void _setStatusText() {
67 oObj
.setStatusText("testing XControlContainer::setStatusText(String)");
68 tRes
.tested("setStatusText()",true);
72 * Test calls the method twice - two controls gotten from object relations
73 * 'CONTROL1' and 'CONTROL2' added to container.<p>
74 * Has <b> OK </b> status if the method successfully returns
75 * and no exceptions were thrown.
77 public void _addControl() {
78 oObj
.addControl("CONTROL1", (XControl
)tEnv
.getObjRelation("CONTROL1"));
79 oObj
.addControl("CONTROL2", (XControl
)tEnv
.getObjRelation("CONTROL2"));
80 tRes
.tested("addControl()",true);
84 * Test calls the method with object relation 'CONTROL1' as a
85 * parameter. Then control gotten from container is checked, and if returned
86 * value is null then another control 'CONTROL2' is removed from container,
87 * otherwise returned value of method test is 'false'.<p>
88 * Has <b> OK </b> status if control is removed successfully.<p>
89 * The following method tests are to be completed successfully before :
91 * <li> <code> addControl() </code> : adds control to a container </li>
92 * <li> <code> getControl() </code> : gets control from container </li>
93 * <li> <code> getControls() </code> : gets controls from container</li>
96 public void _removeControl() {
97 boolean result
= true;
99 requiredMethod("addControl()");
100 requiredMethod("getControl()");
101 requiredMethod("getControls()");
102 oObj
.removeControl( (XControl
) tEnv
.getObjRelation("CONTROL1") );
103 XControl ctrl
= oObj
.getControl("CONTROL1");
106 log
.println("'removeControl()' fails; Control still exists");
108 oObj
.removeControl( (XControl
) tEnv
.getObjRelation("CONTROL2") );
110 tRes
.tested("removeControl()", result
);
114 * Test calls the method with 'CONTROL1' as a parameter, then we just
115 * compare returned object and object relation 'CONTROL1'.<p>
116 * Has <b> OK </b> status if value returned by the method is equal to
117 * a corresponding object relation.<p>
118 * The following method tests are to be completed successfully before :
120 * <li> <code> addControl() </code> : adds control to a container </li>
123 public void _getControl() {
124 requiredMethod("addControl()");
125 XControl xCtrlComp
= oObj
.getControl("CONTROL1");
126 XControl xCl
= (XControl
) tEnv
.getObjRelation("CONTROL1");
127 tRes
.tested("getControl()", xCtrlComp
.equals(xCl
));
131 * Test calls the method, then returned value is checked.<p>
132 * Has <b> OK </b> status if returned array consists of at least two
134 * The following method tests are to be completed successfully before :
136 * <li> <code> addControl() </code> : adds control to a container </li>
139 public void _getControls() {
140 requiredMethod("addControl()");
141 XControl
[] xCtrls
= oObj
.getControls();
142 tRes
.tested("getControls()",xCtrls
.length
>= 2);