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