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.inspection; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import com.sun.star.inspection.XObjectInspector; 27cdf0e10cSrcweir import com.sun.star.inspection.XObjectInspectorModel; 28cdf0e10cSrcweir import com.sun.star.inspection.XObjectInspectorUI; 29cdf0e10cSrcweir import lib.MultiMethodTest; 30cdf0e10cSrcweir import lib.Status; 31cdf0e10cSrcweir import lib.StatusException; 32cdf0e10cSrcweir 33cdf0e10cSrcweir 34cdf0e10cSrcweir /** 35cdf0e10cSrcweir * Testing <code>com.sun.star.inspection.XObjectInspector</code> 36cdf0e10cSrcweir * interface methods : 37cdf0e10cSrcweir * <ul> 38cdf0e10cSrcweir * <li><code> inspect()</code></li> 39cdf0e10cSrcweir * <li><code> InspectorModel()</code></li> 40cdf0e10cSrcweir * </ul> <p> 41cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p> 42cdf0e10cSrcweir * 43cdf0e10cSrcweir * This test needs the following object relations : 44cdf0e10cSrcweir * <ul> 45cdf0e10cSrcweir * <li> <code>'XObjectInspector.toInspect'</code> 46cdf0e10cSrcweir * (of type <code>Object []</code>): 47cdf0e10cSrcweir * acceptable collection of one or more objects which can be inspected by <code>inspect()</code> </li> 48cdf0e10cSrcweir * <ul> <p> 49cdf0e10cSrcweir * 50cdf0e10cSrcweir */ 51cdf0e10cSrcweir 52cdf0e10cSrcweir public class _XObjectInspector extends MultiMethodTest { 53cdf0e10cSrcweir 54cdf0e10cSrcweir /** 55cdf0e10cSrcweir * the test object 56cdf0e10cSrcweir */ 57cdf0e10cSrcweir public XObjectInspector oObj = null; 58cdf0e10cSrcweir /** 59cdf0e10cSrcweir * This variable was filled with the object relation 60cdf0e10cSrcweir * <CODE>XObjectInspector.toInspect</CODE> and was used to 61cdf0e10cSrcweir * test the method <CODE>inspect()</CODE> 62cdf0e10cSrcweir */ 63cdf0e10cSrcweir public Object[] oInspect = null; 64cdf0e10cSrcweir /** 65cdf0e10cSrcweir * This variable was filled with the object relation 66cdf0e10cSrcweir * <CODE>XObjectInspector.InspectorModelToSet</CODE> and was used to 67cdf0e10cSrcweir * test the method <CODE>setInspectorModel()</CODE> 68cdf0e10cSrcweir */ 69cdf0e10cSrcweir public XObjectInspectorModel xSetModel = null; 70cdf0e10cSrcweir 71cdf0e10cSrcweir /** 72cdf0e10cSrcweir * get object relations 73cdf0e10cSrcweir * <ul> 74cdf0e10cSrcweir * <li>XObjectInspector.toInspect</li> 75cdf0e10cSrcweir * </ul> 76cdf0e10cSrcweir */ before()77cdf0e10cSrcweir public void before() { 78cdf0e10cSrcweir 79cdf0e10cSrcweir oInspect = (Object[]) tEnv.getObjRelation("XObjectInspector.toInspect"); 80cdf0e10cSrcweir 81cdf0e10cSrcweir if (oInspect == null) throw new StatusException 82cdf0e10cSrcweir (Status.failed("Relation 'XObjectInspector.toInspect' not found.")) ; 83cdf0e10cSrcweir 84cdf0e10cSrcweir xSetModel = (XObjectInspectorModel) tEnv.getObjRelation("XObjectInspector.InspectorModelToSet"); 85cdf0e10cSrcweir 86cdf0e10cSrcweir if (xSetModel == null) throw new StatusException 87cdf0e10cSrcweir (Status.failed("Relation 'XObjectInspector.InspectorModelToSet' not found.")) ; 88cdf0e10cSrcweir } 89cdf0e10cSrcweir 90cdf0e10cSrcweir /** 91cdf0e10cSrcweir * Inspects a new collection of one or more objects given by object realtion 92cdf0e10cSrcweir * <CODE>XObjectInspector.toInspect</CODE><br> 93cdf0e10cSrcweir * Has <b>OK</b> status if no runtime exceptions occured. 94cdf0e10cSrcweir */ _inspect()95cdf0e10cSrcweir public void _inspect() { 96cdf0e10cSrcweir 97cdf0e10cSrcweir boolean result = true; 98cdf0e10cSrcweir 99cdf0e10cSrcweir try { 100cdf0e10cSrcweir oObj.inspect(oInspect); 101cdf0e10cSrcweir 102cdf0e10cSrcweir } catch (com.sun.star.util.VetoException e){ 103cdf0e10cSrcweir log.println("ERROR:" + e.toString()); 104cdf0e10cSrcweir result = false; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir tRes.tested("inspect()", result) ; 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir /** 111cdf0e10cSrcweir * First call the method <CODE>getInspectorModel()</CODE> and save the value<br> 112cdf0e10cSrcweir * Second call the method <CODE>setInspectorModel()</CODE> with the module variable 113cdf0e10cSrcweir * <CODE>xSetModel</CODE> as parameter.<br> Then <CODE>getInspectorModel()</CODE> 114cdf0e10cSrcweir * was called and the returned valued was compared to the saved variable 115cdf0e10cSrcweir * <CODE>xSetModel</CODE><br> 116cdf0e10cSrcweir * Has <CODE>OK</CODE> status if the returned value is equal to 117cdf0e10cSrcweir * <CODE>xSetModel</CODE>.and the saved value is not null. 118cdf0e10cSrcweir */ _InspectorModel()119cdf0e10cSrcweir public void _InspectorModel() { 120cdf0e10cSrcweir 121cdf0e10cSrcweir log.println("testing 'getInspectorModel()'..."); 122cdf0e10cSrcweir XObjectInspectorModel xGetModel = oObj.getInspectorModel() ; 123cdf0e10cSrcweir 124cdf0e10cSrcweir boolean result = xGetModel != null; 125cdf0e10cSrcweir 126cdf0e10cSrcweir log.println(result? "got a not null object -> OK" : "got a NULL object -> FAILED"); 127cdf0e10cSrcweir 128cdf0e10cSrcweir log.println("testing 'setInspectorModel()'..."); 129cdf0e10cSrcweir oObj.setInspectorModel(xSetModel); 130cdf0e10cSrcweir 131cdf0e10cSrcweir XObjectInspectorModel xNewModel = oObj.getInspectorModel(); 132cdf0e10cSrcweir 133cdf0e10cSrcweir if (result) oObj.setInspectorModel(xGetModel); 134cdf0e10cSrcweir 135cdf0e10cSrcweir result &= xSetModel.equals(xNewModel); 136cdf0e10cSrcweir 137cdf0e10cSrcweir tRes.tested("InspectorModel()", result) ; 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir /** 141cdf0e10cSrcweir * Calls the method <CODE>getInspectorUI()</CODE> 142cdf0e10cSrcweir * Has <b>OK</b> returned value is not null 143cdf0e10cSrcweir */ _InspectorUI()144cdf0e10cSrcweir public void _InspectorUI() { 145cdf0e10cSrcweir 146cdf0e10cSrcweir XObjectInspectorUI oUI = oObj.getInspectorUI(); 147cdf0e10cSrcweir 148cdf0e10cSrcweir tRes.tested("InspectorUI()", oUI != null) ; 149cdf0e10cSrcweir 150cdf0e10cSrcweir } 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir 154