tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / qadevOOo / tests / java / ifc / awt / _XControl.java
blobffb9bcbaa2685edb23e49c404ef823a7cbfaf648
1 /*
2 * This file is part of the LibreOffice project.
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/.
8 * This file incorporates work covered by the following license notice:
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 .
19 package ifc.awt;
21 import lib.MultiMethodTest;
23 import com.sun.star.awt.XControl;
24 import com.sun.star.awt.XControlModel;
25 import com.sun.star.awt.XToolkit;
26 import com.sun.star.awt.XView;
27 import com.sun.star.awt.XWindowPeer;
28 import com.sun.star.uno.XInterface;
30 /**
31 * Testing <code>com.sun.star.awt.XControl</code>
32 * interface methods:
33 * <ul>
34 * <li><code> setContext() </code></li>
35 * <li><code> getContext() </code></li>
36 * <li><code> createPeer() </code></li>
37 * <li><code> getPeer() </code></li>
38 * <li><code> setModel() </code></li>
39 * <li><code> getModel() </code></li>
40 * <li><code> setDesignMode() </code></li>
41 * <li><code> isDesignMode() </code></li>
42 * <li><code> isTransparent() </code></li>
43 * <li><code> getView() </code></li>
44 * </ul><p>
45 * This test needs the following object relations :
46 * <ul>
47 * <li> <code>'CONTEXT'</code> (of type <code>XInterface</code>):
48 * used as a parameter to setContext() and for testing getContext().</li>
49 * <li> <code>'WINPEER'</code> (of type <code>XWindowPeer</code>):
50 * used as a parameter to createPeer() and for testing getPeer()</li>
51 * <li> <code>'TOOLKIT'</code> (of type <code>XToolkit</code>):
52 * used as a parameter to createPeer()</li>
53 * <li> <code>'MODEL'</code> (of type <code>XControlModel</code>):
54 * used as a parameter to setModel() and for testing getModel()</li>
55 * <ul> <p>
56 * Test is <b> NOT </b> multithread compliant. <p>
57 * @see com.sun.star.awt.XControl
59 public class _XControl extends MultiMethodTest {
60 public XControl oObj = null;
61 public XControlModel aModel = null;
62 public boolean desMode;
64 /**
65 * After test calls the method, the Context is set to a corresponding
66 * object relation.<p>
67 * Has <b> OK </b> status if the method successfully returns
68 * and no exceptions were thrown. <p>
70 public void _setContext() {
71 XInterface cont = (XInterface) tEnv.getObjRelation("CONTEXT");
72 oObj.setContext(cont);
73 tRes.tested("setContext()",true);
76 /**
77 * After test calls the method, the Context is gotten and compared
78 * with object relation 'CONTEXT'.<p>
79 * Has <b> OK </b> status if get value is equals to value set before.<p>
80 * The following method tests are to be completed successfully before:
81 * <ul>
82 * <li> <code> setContext() </code> : set Context to a corresponding
83 * object relation</li>
84 * </ul>
86 public void _getContext() {
87 requiredMethod("setContext()");
88 XInterface cont = (XInterface) tEnv.getObjRelation("CONTEXT");
89 Object get = oObj.getContext();
90 boolean res = get.equals(cont);
91 if (!res) {
92 log.println("!!! Error: getting: "+get.toString());
93 log.println("!!! expected: "+cont.toString());
95 tRes.tested("getContext()",res);
99 /**
100 * The objects needed to create peer are obtained
101 * from corresponding object relations, then the peer is created.
102 * <p>
103 * Has <b> OK </b> status if the method successfully returns
104 * and no exceptions were thrown.
106 public void _createPeer() {
107 XWindowPeer the_win = (XWindowPeer) tEnv.getObjRelation("WINPEER");
108 XToolkit the_kit = (XToolkit) tEnv.getObjRelation("TOOLKIT");
109 oObj.createPeer(the_kit,the_win);
110 tRes.tested("createPeer()",true);
114 * Test calls the method. Then the object relation 'WINPEER' is
115 * obtained, and compared with the peer, gotten from (XControl) oObj
116 * variable.<p>
117 * Has <b> OK </b> status if peer gotten isn't null
118 * The following method tests are to be completed successfully before:
120 public void _getPeer() {
121 requiredMethod("createPeer()");
122 boolean res = false;
123 XWindowPeer get = oObj.getPeer();
124 if (get == null) {
125 log.println("The method 'getPeer' returns NULL");
126 } else {
127 res = true;
129 tRes.tested("getPeer()",res);
134 * At first current model is obtained and saved to variable aModel.
135 * Then object relation 'MODEL' is gotten and test calls the method. <p>
136 * Has <b> OK </b> status if the method successfully returns
137 * and no exceptions were thrown.
139 public void _setModel() {
140 aModel = oObj.getModel();
141 XControlModel the_model = (XControlModel) tEnv.getObjRelation("MODEL");
142 oObj.setModel(the_model);
143 tRes.tested("setModel()",true);
147 * Test calls the method, then object relation 'MODEL' is gotten and
148 * compared with object returned by the method. Then previously saved
149 * value of model (aModel) restored to (XControl) oObj<p>
150 * Has <b> OK </b> status if models set and get are equal. <p>
151 * The following method tests are to be completed successfully before :
152 * <ul>
153 * <li> <code> setModel() </code> : setting model from corresponding
154 * object relation </li>
155 * </ul>
157 public void _getModel() {
158 requiredMethod("setModel()");
159 XControlModel the_model = (XControlModel) tEnv.getObjRelation("MODEL");
160 XControlModel get = oObj.getModel();
161 boolean res = get.equals(the_model);
162 if (!res) {
163 log.println("getting: "+get.toString());
164 log.println("expected: "+the_model.toString());
166 if (aModel != null) {
167 oObj.setModel(aModel);
169 tRes.tested("getModel()",res);
173 * Test calls the method. Then mode is checked using isDesignMode().<p>
174 * Has <b> OK </b> status if mode is switched.
176 public void _setDesignMode() {
177 desMode = oObj.isDesignMode();
178 oObj.setDesignMode(!desMode);
179 tRes.tested("setDesignMode()",oObj.isDesignMode() == !desMode);
183 * The mode is changed and result is checked.<p>
184 * Has <b> OK </b> status if the mode changed successfully.
186 public void _isDesignMode() {
187 requiredMethod("setDesignMode()");
188 oObj.setDesignMode(desMode);
189 tRes.tested("isDesignMode()", oObj.isDesignMode() == desMode);
193 * Test calls the method.<p>
194 * Has <b> OK </b> status if the method successfully returns
195 * and no exceptions were thrown. <p>
197 public void _isTransparent() {
198 oObj.isTransparent();
199 tRes.tested("isTransparent()",true );
203 * Test calls the method.<p>
204 * Has <b> OK </b> status if the method returns not null. <p>
206 public void _getView() {
207 XView the_view = oObj.getView();
208 tRes.tested("getView()", the_view != null);