1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _XObjectInspector.java,v $
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
.inspection
;
33 import com
.sun
.star
.inspection
.XObjectInspector
;
34 import com
.sun
.star
.inspection
.XObjectInspectorModel
;
35 import com
.sun
.star
.inspection
.XObjectInspectorUI
;
36 import lib
.MultiMethodTest
;
38 import lib
.StatusException
;
42 * Testing <code>com.sun.star.inspection.XObjectInspector</code>
45 * <li><code> inspect()</code></li>
46 * <li><code> InspectorModel()</code></li>
48 * Test is <b> NOT </b> multithread compilant. <p>
50 * This test needs the following object relations :
52 * <li> <code>'XObjectInspector.toInspect'</code>
53 * (of type <code>Object []</code>):
54 * acceptable collection of one or more objects which can be inspected by <code>inspect()</code> </li>
59 public class _XObjectInspector
extends MultiMethodTest
{
64 public XObjectInspector oObj
= null;
66 * This variable was filled with the object relation
67 * <CODE>XObjectInspector.toInspect</CODE> and was used to
68 * test the method <CODE>inspect()</CODE>
70 public Object
[] oInspect
= null;
72 * This variable was filled with the object relation
73 * <CODE>XObjectInspector.InspectorModelToSet</CODE> and was used to
74 * test the method <CODE>setInspectorModel()</CODE>
76 public XObjectInspectorModel xSetModel
= null;
79 * get object relations
81 * <li>XObjectInspector.toInspect</li>
84 public void before() {
86 oInspect
= (Object
[]) tEnv
.getObjRelation("XObjectInspector.toInspect");
88 if (oInspect
== null) throw new StatusException
89 (Status
.failed("Relation 'XObjectInspector.toInspect' not found.")) ;
91 xSetModel
= (XObjectInspectorModel
) tEnv
.getObjRelation("XObjectInspector.InspectorModelToSet");
93 if (xSetModel
== null) throw new StatusException
94 (Status
.failed("Relation 'XObjectInspector.InspectorModelToSet' not found.")) ;
98 * Inspects a new collection of one or more objects given by object realtion
99 * <CODE>XObjectInspector.toInspect</CODE><br>
100 * Has <b>OK</b> status if no runtime exceptions occured.
102 public void _inspect() {
104 boolean result
= true;
107 oObj
.inspect(oInspect
);
109 } catch (com
.sun
.star
.util
.VetoException e
){
110 log
.println("ERROR:" + e
.toString());
114 tRes
.tested("inspect()", result
) ;
118 * First call the method <CODE>getInspectorModel()</CODE> and save the value<br>
119 * Second call the method <CODE>setInspectorModel()</CODE> with the module variable
120 * <CODE>xSetModel</CODE> as parameter.<br> Then <CODE>getInspectorModel()</CODE>
121 * was called and the returned valued was compared to the saved variable
122 * <CODE>xSetModel</CODE><br>
123 * Has <CODE>OK</CODE> status if the returned value is equal to
124 * <CODE>xSetModel</CODE>.and the saved value is not null.
126 public void _InspectorModel() {
128 log
.println("testing 'getInspectorModel()'...");
129 XObjectInspectorModel xGetModel
= oObj
.getInspectorModel() ;
131 boolean result
= xGetModel
!= null;
133 log
.println(result?
"got a not null object -> OK" : "got a NULL object -> FAILED");
135 log
.println("testing 'setInspectorModel()'...");
136 oObj
.setInspectorModel(xSetModel
);
138 XObjectInspectorModel xNewModel
= oObj
.getInspectorModel();
140 if (result
) oObj
.setInspectorModel(xGetModel
);
142 result
&= xSetModel
.equals(xNewModel
);
144 tRes
.tested("InspectorModel()", result
) ;
148 * Calls the method <CODE>getInspectorUI()</CODE>
149 * Has <b>OK</b> returned value is not null
151 public void _InspectorUI() {
153 XObjectInspectorUI oUI
= oObj
.getInspectorUI();
155 tRes
.tested("InspectorUI()", oUI
!= null) ;