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 lib.MultiMethodTest; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import com.sun.star.awt.XControl; 29cdf0e10cSrcweir import com.sun.star.awt.XControlContainer; 30cdf0e10cSrcweir 31cdf0e10cSrcweir /** 32cdf0e10cSrcweir * Testing <code>com.sun.star.awt.XControlContainer</code> 33cdf0e10cSrcweir * interface methods: 34cdf0e10cSrcweir * <ul> 35cdf0e10cSrcweir * <li><code> setStatusText() </code></li> 36cdf0e10cSrcweir * <li><code> addControl() </code></li> 37cdf0e10cSrcweir * <li><code> removeControl() </code></li> 38cdf0e10cSrcweir * <li><code> getControl() </code></li> 39cdf0e10cSrcweir * <li><code> getControls() </code></li> 40cdf0e10cSrcweir * </ul><p> 41cdf0e10cSrcweir * This test needs the following object relations : 42cdf0e10cSrcweir * <ul> 43cdf0e10cSrcweir * <li> <code>'CONTROL1'</code> (of type <code>XControl</code>): 44cdf0e10cSrcweir * used as a parameter to addControl(), getControl() and removeControl()</li> 45cdf0e10cSrcweir * <li> <code>'CONTROL2'</code> (of type <code>XControl</code>): 46cdf0e10cSrcweir * used as a parameter to addControl(), getControl() and removeControl()</li> 47cdf0e10cSrcweir * <ul> <p> 48cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p> 49cdf0e10cSrcweir * @see com.sun.star.awt.XControlContainer 50cdf0e10cSrcweir */ 51cdf0e10cSrcweir public class _XControlContainer extends MultiMethodTest { 52cdf0e10cSrcweir public XControlContainer oObj = null; 53cdf0e10cSrcweir 54cdf0e10cSrcweir /** 55cdf0e10cSrcweir * Test calls the method. <p> 56cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 57cdf0e10cSrcweir * and no exceptions were thrown. 58cdf0e10cSrcweir */ _setStatusText()59cdf0e10cSrcweir public void _setStatusText() { 60cdf0e10cSrcweir oObj.setStatusText("testing XControlContainer::setStatusText(String)"); 61cdf0e10cSrcweir tRes.tested("setStatusText()",true); 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir /** 65cdf0e10cSrcweir * Test calls the method twice - two controls gotten from object relations 66cdf0e10cSrcweir * 'CONTROL1' and 'CONTROL2' added to container.<p> 67cdf0e10cSrcweir * Has <b> OK </b> status if the method successfully returns 68cdf0e10cSrcweir * and no exceptions were thrown. 69cdf0e10cSrcweir */ _addControl()70cdf0e10cSrcweir public void _addControl() { 71cdf0e10cSrcweir oObj.addControl("CONTROL1", (XControl)tEnv.getObjRelation("CONTROL1")); 72cdf0e10cSrcweir oObj.addControl("CONTROL2", (XControl)tEnv.getObjRelation("CONTROL2")); 73cdf0e10cSrcweir tRes.tested("addControl()",true); 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76cdf0e10cSrcweir /** 77cdf0e10cSrcweir * Test calls the method with object relation 'CONTROL1' as a 78cdf0e10cSrcweir * parameter. Then control gotten from container is checked, and if returned 79cdf0e10cSrcweir * value is null then another control 'CONTROL2' is removed from container, 80cdf0e10cSrcweir * otherwise returned value of method test is 'false'.<p> 81cdf0e10cSrcweir * Has <b> OK </b> status if control is removed successfully.<p> 82cdf0e10cSrcweir * The following method tests are to be completed successfully before : 83cdf0e10cSrcweir * <ul> 84cdf0e10cSrcweir * <li> <code> addControl() </code> : adds control to a container </li> 85cdf0e10cSrcweir * <li> <code> getControl() </code> : gets control from container </li> 86cdf0e10cSrcweir * <li> <code> getControls() </code> : gets controls from container</li> 87cdf0e10cSrcweir * </ul> 88cdf0e10cSrcweir */ _removeControl()89cdf0e10cSrcweir public void _removeControl() { 90cdf0e10cSrcweir boolean result = true; 91cdf0e10cSrcweir 92cdf0e10cSrcweir requiredMethod("addControl()"); 93cdf0e10cSrcweir requiredMethod("getControl()"); 94cdf0e10cSrcweir requiredMethod("getControls()"); 95cdf0e10cSrcweir oObj.removeControl( (XControl) tEnv.getObjRelation("CONTROL1") ); 96cdf0e10cSrcweir XControl ctrl = oObj.getControl("CONTROL1"); 97cdf0e10cSrcweir if (ctrl != null) { 98cdf0e10cSrcweir result = false; 99cdf0e10cSrcweir log.println("'removeControl()' fails; Control still exists"); 100cdf0e10cSrcweir } else { 101cdf0e10cSrcweir oObj.removeControl( (XControl) tEnv.getObjRelation("CONTROL2") ); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir tRes.tested("removeControl()", result); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir /** 107cdf0e10cSrcweir * Test calls the method with 'CONTROL1' as a parameter, then we just 108cdf0e10cSrcweir * compare returned object and object relation 'CONTROL1'.<p> 109cdf0e10cSrcweir * Has <b> OK </b> status if value returned by the method is equal to 110cdf0e10cSrcweir * a corresponding object relation.<p> 111cdf0e10cSrcweir * The following method tests are to be completed successfully before : 112cdf0e10cSrcweir * <ul> 113cdf0e10cSrcweir * <li> <code> addControl() </code> : adds control to a container </li> 114cdf0e10cSrcweir * </ul> 115cdf0e10cSrcweir */ _getControl()116cdf0e10cSrcweir public void _getControl() { 117cdf0e10cSrcweir requiredMethod("addControl()"); 118cdf0e10cSrcweir XControl xCtrlComp = oObj.getControl("CONTROL1"); 119cdf0e10cSrcweir XControl xCl = (XControl) tEnv.getObjRelation("CONTROL1"); 120cdf0e10cSrcweir tRes.tested("getControl()", xCtrlComp.equals(xCl)); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir /** 124cdf0e10cSrcweir * Test calls the method, then returned value is checked.<p> 125cdf0e10cSrcweir * Has <b> OK </b> status if returned array consists of at least two 126cdf0e10cSrcweir * elements.<p> 127cdf0e10cSrcweir * The following method tests are to be completed successfully before : 128cdf0e10cSrcweir * <ul> 129cdf0e10cSrcweir * <li> <code> addControl() </code> : adds control to a container </li> 130cdf0e10cSrcweir * </ul> 131cdf0e10cSrcweir */ _getControls()132cdf0e10cSrcweir public void _getControls() { 133cdf0e10cSrcweir requiredMethod("addControl()"); 134cdf0e10cSrcweir XControl[] xCtrls = oObj.getControls(); 135cdf0e10cSrcweir tRes.tested("getControls()",xCtrls.length >= 2); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139