1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package ifc.drawing; 25 26 import lib.MultiMethodTest; 27 import util.FormTools; 28 29 import com.sun.star.awt.XControlModel; 30 import com.sun.star.drawing.XControlShape; 31 import com.sun.star.lang.XComponent; 32 import com.sun.star.uno.UnoRuntime; 33 import com.sun.star.uno.XInterface; 34 35 /** 36 * Testing <code>com.sun.star.drawing.XControlShape</code> 37 * interface methods : 38 * <ul> 39 * <li><code> getControl()</code></li> 40 * <li><code> setControl()</code></li> 41 * </ul> <p> 42 * This test needs the following object relations : 43 * <ul> 44 * <li> <code>'xDoc'</code> (of type <code>XComponent</code>): 45 * the document where shape tested is situated. This document 46 * must also implement <code>XMultiServiceFactory</code> interface 47 * to create some control model. </li> 48 * <ul> <p> 49 * Test is <b> NOT </b> multithread compilant. <p> 50 * @see com.sun.star.drawing.XControlShape 51 */ 52 public class _XControlShape extends MultiMethodTest { 53 54 public XControlShape oObj = null; 55 56 XControlModel model = null; 57 58 /** 59 * Test calls the method. <p> 60 * Has <b> OK </b> status if the method successfully returns 61 * and no exceptions were thrown. <p> 62 */ _getControl()63 public void _getControl() { 64 model = oObj.getControl() ; 65 66 tRes.tested("getControl()", true) ; 67 } 68 69 /** 70 * With the help of document passed as relation, a new button control 71 * model is created and set as a control. <p> 72 * Has <b> OK </b> status if <code>getControl()</code> method returns 73 * the same control as was set. <p> 74 * The following method tests are to be completed successfully before : 75 * <ul> 76 * <li> <code> getControl() </code> </li> 77 * </ul> 78 */ _setControl()79 public void _setControl() { 80 requiredMethod("getControl()") ; 81 82 XInterface oNewControl = FormTools.createControl 83 ((XComponent)tEnv.getObjRelation("xDoc"), "ComboBox") ; 84 85 XControlModel xControl = (XControlModel) UnoRuntime.queryInterface 86 (XControlModel.class, oNewControl) ; 87 88 oObj.setControl(xControl) ; 89 90 XControlModel gControl = oObj.getControl() ; 91 92 if (oNewControl.equals(gControl)) 93 tRes.tested("setControl()", true) ; 94 else { 95 log.println("Control set is not equal to control get") ; 96 tRes.tested("setControl()", false) ; 97 } 98 } 99 100 } // finish class _XControlShape 101 102 103