Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / ifc / awt / _XControl.java
blob94bded181aeb4d7e2610fad2f62988db54e49bda
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XControl.java,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
31 package ifc.awt;
33 import lib.MultiMethodTest;
35 import com.sun.star.awt.XControl;
36 import com.sun.star.awt.XControlModel;
37 import com.sun.star.awt.XToolkit;
38 import com.sun.star.awt.XView;
39 import com.sun.star.awt.XWindowPeer;
40 import com.sun.star.uno.XInterface;
42 /**
43 * Testing <code>com.sun.star.awt.XControl</code>
44 * interface methods:
45 * <ul>
46 * <li><code> setContext() </code></li>
47 * <li><code> getContext() </code></li>
48 * <li><code> createPeer() </code></li>
49 * <li><code> getPeer() </code></li>
50 * <li><code> setModel() </code></li>
51 * <li><code> getModel() </code></li>
52 * <li><code> setDesignMode() </code></li>
53 * <li><code> isDesignMode() </code></li>
54 * <li><code> isTransparent() </code></li>
55 * <li><code> getView() </code></li>
56 * </ul><p>
57 * This test needs the following object relations :
58 * <ul>
59 * <li> <code>'CONTEXT'</code> (of type <code>XInterface</code>):
60 * used as a parameter to setContext() and for testing getContext().</li>
61 * <li> <code>'WINPEER'</code> (of type <code>XWindowPeer</code>):
62 * used as a parameter to createPeer() and for testing getPeer()</li>
63 * <li> <code>'TOOLKIT'</code> (of type <code>XToolkit</code>):
64 * used as a parameter to createPeer()</li>
65 * <li> <code>'MODEL'</code> (of type <code>XControlModel</code>):
66 * used as a parameter to setModel() and for testing getModel()</li>
67 * <ul> <p>
68 * Test is <b> NOT </b> multithread compilant. <p>
69 * @see com.sun.star.awt.XControl
71 public class _XControl extends MultiMethodTest {
72 public XControl oObj = null;
73 public XControlModel aModel = null;
74 public boolean desMode;
76 /**
77 * After test calls the method, the Context is set to a corresponding
78 * object relation.<p>
79 * Has <b> OK </b> status if the method successfully returns
80 * and no exceptions were thrown. <p>
82 public void _setContext() {
83 XInterface cont = (XInterface) tEnv.getObjRelation("CONTEXT");
84 oObj.setContext(cont);
85 tRes.tested("setContext()",true);
88 /**
89 * After test calls the method, the Context is gotten and compared
90 * with object relation 'CONTEXT'.<p>
91 * Has <b> OK </b> status if get value is equals to value set before.<p>
92 * The following method tests are to be completed successfully before:
93 * <ul>
94 * <li> <code> setContext() </code> : set Context to a corresponding
95 * object relation</li>
96 * </ul>
98 public void _getContext() {
99 requiredMethod("setContext()");
100 XInterface cont = (XInterface) tEnv.getObjRelation("CONTEXT");
101 Object get = oObj.getContext();
102 boolean res = get.equals(cont);
103 if (!res) {
104 log.println("!!! Error: getting: "+get.toString());
105 log.println("!!! expected: "+cont.toString());
107 tRes.tested("getContext()",res);
112 * The objects needed to create peer are obtained
113 * from corresponding object relations, then the peer is created.
114 * <p>
115 * Has <b> OK </b> status if the method successfully returns
116 * and no exceptions were thrown.
118 public void _createPeer() {
119 XWindowPeer the_win = (XWindowPeer) tEnv.getObjRelation("WINPEER");
120 XToolkit the_kit = (XToolkit) tEnv.getObjRelation("TOOLKIT");
121 oObj.createPeer(the_kit,the_win);
122 tRes.tested("createPeer()",true);
126 * Test calls the method. Then the the object ralation 'WINPEER' is
127 * obtained, and compared with the peer, gotten from (XControl) oObj
128 * variable.<p>
129 * Has <b> OK </b> status if peer gotten isn't null
130 * The following method tests are to be completed successfully before :
132 public void _getPeer() {
133 requiredMethod("createPeer()");
134 boolean res = false;
135 XWindowPeer get = oObj.getPeer();
136 if (get == null) {
137 log.println("The method 'getPeer' returns NULL");
138 } else {
139 res = true;
141 tRes.tested("getPeer()",res);
146 * At first current model is obtained and saved to variable aModel.
147 * Then object relation 'MODEL' is gotten and test calls the method. <p>
148 * Has <b> OK </b> status if the method successfully returns
149 * and no exceptions were thrown.
151 public void _setModel() {
152 aModel = oObj.getModel();
153 XControlModel the_model = (XControlModel) tEnv.getObjRelation("MODEL");
154 oObj.setModel(the_model);
155 tRes.tested("setModel()",true);
159 * Test calls the method, then object relation 'MODEL' is gotten and
160 * compared with object returned by the method. Then previously saved
161 * value of model (aModel) restored to (XControl) oObj<p>
162 * Has <b> OK </b> status if models set and get are equal. <p>
163 * The following method tests are to be completed successfully before :
164 * <ul>
165 * <li> <code> setModel() </code> : setting model from corresponding
166 * object relation </li>
167 * </ul>
169 public void _getModel() {
170 requiredMethod("setModel()");
171 XControlModel the_model = (XControlModel) tEnv.getObjRelation("MODEL");
172 XControlModel get = oObj.getModel();
173 boolean res = (get.equals(the_model));
174 if (!res) {
175 log.println("getting: "+get.toString());
176 log.println("expected: "+the_model.toString());
178 if (aModel != null) {
179 oObj.setModel(aModel);
181 tRes.tested("getModel()",res);
185 * Test calls the method. Then mode is checked using isDesignMode().<p>
186 * Has <b> OK </b> status if mode is swithed.
188 public void _setDesignMode() {
189 desMode = oObj.isDesignMode();
190 oObj.setDesignMode(!desMode);
191 tRes.tested("setDesignMode()",oObj.isDesignMode() == !desMode);
195 * The mode is changed and result is checked.<p>
196 * Has <b> OK </b> status if the mode changed successfully.
198 public void _isDesignMode() {
199 requiredMethod("setDesignMode()");
200 oObj.setDesignMode(desMode);
201 tRes.tested("isDesignMode()", oObj.isDesignMode() == desMode);
205 * Test calls the method.<p>
206 * Has <b> OK </b> status if the method successfully returns
207 * and no exceptions were thrown. <p>
209 public void _isTransparent() {
210 boolean isT = oObj.isTransparent();
211 tRes.tested("isTransparent()",true );
215 * Test calls the method.<p>
216 * Has <b> OK </b> status if the method returns not null. <p>
218 public void _getView() {
219 XView the_view = oObj.getView();
220 tRes.tested("getView()", the_view != null);