1*ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ef39d40dSAndrew Rist  * distributed with this work for additional information
6*ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9*ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ef39d40dSAndrew Rist  *
11*ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ef39d40dSAndrew Rist  *
13*ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15*ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18*ef39d40dSAndrew Rist  * under the License.
19*ef39d40dSAndrew Rist  *
20*ef39d40dSAndrew Rist  *************************************************************/
21*ef39d40dSAndrew Rist 
22*ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.awt;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import com.sun.star.awt.XTabController;
27cdf0e10cSrcweir import com.sun.star.awt.XUnoControlContainer;
28cdf0e10cSrcweir import lib.MultiMethodTest;
29cdf0e10cSrcweir 
30cdf0e10cSrcweir /**
31cdf0e10cSrcweir  * Testing <code>com.sun.star.awt.XUnoControlContainer</code>
32cdf0e10cSrcweir  * interface methods :
33cdf0e10cSrcweir  * <ul>
34cdf0e10cSrcweir  *  <li><code> addTabController()</code></li>
35cdf0e10cSrcweir  *  <li><code> removeTabController()</code></li>
36cdf0e10cSrcweir  *  <li><code> getTabControllers()</code></li>
37cdf0e10cSrcweir  *  <li><code> setTabControllers()</code></li>
38cdf0e10cSrcweir  * </ul> <p>
39cdf0e10cSrcweir  *
40cdf0e10cSrcweir * This test needs the following object relations :
41cdf0e10cSrcweir * <ul>
42cdf0e10cSrcweir *  <li> <code>'TABCONTROL1'</code> (of type <code>XTabController</code>)</li>
43cdf0e10cSrcweir *  <li> <code>'TABCONTROL2'</code> (of type <code>XTabController</code>)</li>
44cdf0e10cSrcweir  *</ul>
45cdf0e10cSrcweir  *
46cdf0e10cSrcweir  * Test is <b> NOT </b> multithread compilant. <p>
47cdf0e10cSrcweir  */
48cdf0e10cSrcweir 
49cdf0e10cSrcweir public class _XUnoControlContainer extends MultiMethodTest {
50cdf0e10cSrcweir     public XUnoControlContainer oObj = null;
51cdf0e10cSrcweir     private XTabController[] TabControllers = new XTabController[2];
52cdf0e10cSrcweir     private XTabController tabControl1 = null;
53cdf0e10cSrcweir     private XTabController tabControl2 = null;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir     /**
56cdf0e10cSrcweir      * This method gets the object relations.
57cdf0e10cSrcweir      *
58cdf0e10cSrcweir      */
before()59cdf0e10cSrcweir     protected void before() {
60cdf0e10cSrcweir 
61cdf0e10cSrcweir         tabControl1 = (XTabController) tEnv.getObjRelation("TABCONTROL1");
62cdf0e10cSrcweir         tabControl2 = (XTabController) tEnv.getObjRelation("TABCONTROL2");
63cdf0e10cSrcweir         if ((tabControl1 == null) || (tabControl2 == null)){
64cdf0e10cSrcweir             log.println("ERROR: Needed object realtions 'TABCONTROL1' and "
65cdf0e10cSrcweir             + "'TABCONTROL2' are not found.");
66cdf0e10cSrcweir         }
67cdf0e10cSrcweir         TabControllers[0] = tabControl1;
68cdf0e10cSrcweir         TabControllers[1] = tabControl2;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     }
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     /**
75cdf0e10cSrcweir     * This tests removes the object relations <code>TABCONTROL1</code> and
76cdf0e10cSrcweir     * <code>TABCONTROL1</code>.
77cdf0e10cSrcweir     * Has <b> OK </b> status if the sequenze of <code>XTabController[]</code>
78cdf0e10cSrcweir     * get before calling method is smaller then sequenze of
79cdf0e10cSrcweir     * <code>XTabController[]</code> get after calling method.<p>
80cdf0e10cSrcweir     *
81cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
82cdf0e10cSrcweir     * <ul>
83cdf0e10cSrcweir     *  <li> <code> getTabControllers() </code> </li>
84cdf0e10cSrcweir     *  <li> <code> removeTabController() </code> </li>
85cdf0e10cSrcweir     * </ul>
86cdf0e10cSrcweir     */
_setTabControllers()87cdf0e10cSrcweir     public void _setTabControllers() {
88cdf0e10cSrcweir         requiredMethod( "getTabControllers()");
89cdf0e10cSrcweir         requiredMethod( "removeTabController()");
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         log.println("removing TABCONTROL1 and TABCONTROL2");
92cdf0e10cSrcweir         oObj.removeTabController(tabControl1);
93cdf0e10cSrcweir         oObj.removeTabController(tabControl2);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir         log.println("get current controllers");
96cdf0e10cSrcweir         XTabController[] myTabControllers = oObj.getTabControllers();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         log.println("set new controllers");
99cdf0e10cSrcweir         oObj.setTabControllers( TabControllers );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir         log.println("get new current controllers");
102cdf0e10cSrcweir         XTabController[] myNewTabControllers = oObj.getTabControllers();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         tRes.tested("setTabControllers()",
105cdf0e10cSrcweir                     (myTabControllers.length < myNewTabControllers.length ));
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     /**
110cdf0e10cSrcweir     * Test calls the method, then checks returned value.<p>
111cdf0e10cSrcweir     * Has <b> OK </b> status if method returns a value that greater then zerro.<p>
112cdf0e10cSrcweir     *
113cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
114cdf0e10cSrcweir     * <ul>
115cdf0e10cSrcweir     *  <li> <code> addTabController() </code></li>
116cdf0e10cSrcweir     * </ul>
117cdf0e10cSrcweir     */
_getTabControllers()118cdf0e10cSrcweir     public void _getTabControllers() {
119cdf0e10cSrcweir         requiredMethod( "addTabController()");
120cdf0e10cSrcweir         XTabController[] myTabControllers = oObj.getTabControllers();
121cdf0e10cSrcweir         tRes.tested("getTabControllers()", ( myTabControllers.length > 0));
122cdf0e10cSrcweir     }
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     /**
125cdf0e10cSrcweir     * Test calls the method with object relation 'TABCONTROL1' as a parameter.<p>
126cdf0e10cSrcweir     * Has <b> OK </b> status if the sequenze of <code>XTabController[]</code>
127cdf0e10cSrcweir     * get before calling method is smaller then sequenze of
128cdf0e10cSrcweir     * <code>XTabController[]</code> get after calling method.<p>
129cdf0e10cSrcweir     */
_addTabController()130cdf0e10cSrcweir     public void _addTabController() {
131cdf0e10cSrcweir         log.println("get current controllers");
132cdf0e10cSrcweir         XTabController[] myTabControllers = oObj.getTabControllers();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         log.println("add TABCONTROL1");
135cdf0e10cSrcweir         oObj.addTabController( tabControl1 );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir         log.println("get new current controllers");
138cdf0e10cSrcweir         XTabController[] myNewTabControllers = oObj.getTabControllers();
139cdf0e10cSrcweir 
140cdf0e10cSrcweir         tRes.tested("addTabController()",
141cdf0e10cSrcweir                     (myTabControllers.length < myNewTabControllers.length ));
142cdf0e10cSrcweir     }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     /**
145cdf0e10cSrcweir     * Test calls the method with object relation 'TABCONTROL2' as a parameter.<p>
146cdf0e10cSrcweir     * Has <b> OK </b> status if the sequenze of <code>XTabController[]</code>
147cdf0e10cSrcweir     * get before calling method is smaller then sequenze of
148cdf0e10cSrcweir     * <code>XTabController[]</code> get after calling method.<p>
149cdf0e10cSrcweir     *
150cdf0e10cSrcweir     * The following method tests are to be completed successfully before :
151cdf0e10cSrcweir     * <ul>
152cdf0e10cSrcweir     *  <li> <code> getTabControllers() </code></li>
153cdf0e10cSrcweir     *  <li> <code> addTabController() </code></li>
154cdf0e10cSrcweir     * </ul>
155cdf0e10cSrcweir     */
_removeTabController()156cdf0e10cSrcweir     public void _removeTabController() {
157cdf0e10cSrcweir         requiredMethod( "getTabControllers()");
158cdf0e10cSrcweir         requiredMethod( "addTabController()");
159cdf0e10cSrcweir 
160cdf0e10cSrcweir         log.println("add TABCONTROL2");
161cdf0e10cSrcweir         oObj.addTabController( tabControl2 );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir         log.println("get current controllers");
164cdf0e10cSrcweir         XTabController[] myTabControllers = oObj.getTabControllers();
165cdf0e10cSrcweir 
166cdf0e10cSrcweir         log.println("remove TABCONTROL2");
167cdf0e10cSrcweir         oObj.removeTabController(tabControl2);
168cdf0e10cSrcweir 
169cdf0e10cSrcweir         log.println("get new current controllers");
170cdf0e10cSrcweir         XTabController[] myNewTabControllers = oObj.getTabControllers();
171cdf0e10cSrcweir 
172cdf0e10cSrcweir         tRes.tested("removeTabController()",
173cdf0e10cSrcweir                     (myTabControllers.length > myNewTabControllers.length ));
174cdf0e10cSrcweir     }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178