1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 package ifc.awt;
29 
30 import com.sun.star.awt.XTabController;
31 import com.sun.star.awt.XUnoControlContainer;
32 import lib.MultiMethodTest;
33 
34 /**
35  * Testing <code>com.sun.star.awt.XUnoControlContainer</code>
36  * interface methods :
37  * <ul>
38  *  <li><code> addTabController()</code></li>
39  *  <li><code> removeTabController()</code></li>
40  *  <li><code> getTabControllers()</code></li>
41  *  <li><code> setTabControllers()</code></li>
42  * </ul> <p>
43  *
44 * This test needs the following object relations :
45 * <ul>
46 *  <li> <code>'TABCONTROL1'</code> (of type <code>XTabController</code>)</li>
47 *  <li> <code>'TABCONTROL2'</code> (of type <code>XTabController</code>)</li>
48  *</ul>
49  *
50  * Test is <b> NOT </b> multithread compilant. <p>
51  */
52 
53 public class _XUnoControlContainer extends MultiMethodTest {
54     public XUnoControlContainer oObj = null;
55     private XTabController[] TabControllers = new XTabController[2];
56     private XTabController tabControl1 = null;
57     private XTabController tabControl2 = null;
58 
59     /**
60      * This method gets the object relations.
61      *
62      */
63     protected void before() {
64 
65         tabControl1 = (XTabController) tEnv.getObjRelation("TABCONTROL1");
66         tabControl2 = (XTabController) tEnv.getObjRelation("TABCONTROL2");
67         if ((tabControl1 == null) || (tabControl2 == null)){
68             log.println("ERROR: Needed object realtions 'TABCONTROL1' and "
69             + "'TABCONTROL2' are not found.");
70         }
71         TabControllers[0] = tabControl1;
72         TabControllers[1] = tabControl2;
73 
74     }
75 
76 
77 
78     /**
79     * This tests removes the object relations <code>TABCONTROL1</code> and
80     * <code>TABCONTROL1</code>.
81     * Has <b> OK </b> status if the sequenze of <code>XTabController[]</code>
82     * get before calling method is smaller then sequenze of
83     * <code>XTabController[]</code> get after calling method.<p>
84     *
85     * The following method tests are to be completed successfully before :
86     * <ul>
87     *  <li> <code> getTabControllers() </code> </li>
88     *  <li> <code> removeTabController() </code> </li>
89     * </ul>
90     */
91     public void _setTabControllers() {
92         requiredMethod( "getTabControllers()");
93         requiredMethod( "removeTabController()");
94 
95         log.println("removing TABCONTROL1 and TABCONTROL2");
96         oObj.removeTabController(tabControl1);
97         oObj.removeTabController(tabControl2);
98 
99         log.println("get current controllers");
100         XTabController[] myTabControllers = oObj.getTabControllers();
101 
102         log.println("set new controllers");
103         oObj.setTabControllers( TabControllers );
104 
105         log.println("get new current controllers");
106         XTabController[] myNewTabControllers = oObj.getTabControllers();
107 
108         tRes.tested("setTabControllers()",
109                     (myTabControllers.length < myNewTabControllers.length ));
110 
111     }
112 
113     /**
114     * Test calls the method, then checks returned value.<p>
115     * Has <b> OK </b> status if method returns a value that greater then zerro.<p>
116     *
117     * The following method tests are to be completed successfully before :
118     * <ul>
119     *  <li> <code> addTabController() </code></li>
120     * </ul>
121     */
122     public void _getTabControllers() {
123         requiredMethod( "addTabController()");
124         XTabController[] myTabControllers = oObj.getTabControllers();
125         tRes.tested("getTabControllers()", ( myTabControllers.length > 0));
126     }
127 
128     /**
129     * Test calls the method with object relation 'TABCONTROL1' as a parameter.<p>
130     * Has <b> OK </b> status if the sequenze of <code>XTabController[]</code>
131     * get before calling method is smaller then sequenze of
132     * <code>XTabController[]</code> get after calling method.<p>
133     */
134     public void _addTabController() {
135         log.println("get current controllers");
136         XTabController[] myTabControllers = oObj.getTabControllers();
137 
138         log.println("add TABCONTROL1");
139         oObj.addTabController( tabControl1 );
140 
141         log.println("get new current controllers");
142         XTabController[] myNewTabControllers = oObj.getTabControllers();
143 
144         tRes.tested("addTabController()",
145                     (myTabControllers.length < myNewTabControllers.length ));
146     }
147 
148     /**
149     * Test calls the method with object relation 'TABCONTROL2' as a parameter.<p>
150     * Has <b> OK </b> status if the sequenze of <code>XTabController[]</code>
151     * get before calling method is smaller then sequenze of
152     * <code>XTabController[]</code> get after calling method.<p>
153     *
154     * The following method tests are to be completed successfully before :
155     * <ul>
156     *  <li> <code> getTabControllers() </code></li>
157     *  <li> <code> addTabController() </code></li>
158     * </ul>
159     */
160     public void _removeTabController() {
161         requiredMethod( "getTabControllers()");
162         requiredMethod( "addTabController()");
163 
164         log.println("add TABCONTROL2");
165         oObj.addTabController( tabControl2 );
166 
167         log.println("get current controllers");
168         XTabController[] myTabControllers = oObj.getTabControllers();
169 
170         log.println("remove TABCONTROL2");
171         oObj.removeTabController(tabControl2);
172 
173         log.println("get new current controllers");
174         XTabController[] myNewTabControllers = oObj.getTabControllers();
175 
176         tRes.tested("removeTabController()",
177                     (myTabControllers.length > myNewTabControllers.length ));
178     }
179 
180 }
181 
182