1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 package ifc
.inspection
;
30 import com
.sun
.star
.inspection
.XObjectInspector
;
31 import com
.sun
.star
.inspection
.XObjectInspectorModel
;
32 import com
.sun
.star
.inspection
.XObjectInspectorUI
;
33 import lib
.MultiMethodTest
;
35 import lib
.StatusException
;
39 * Testing <code>com.sun.star.inspection.XObjectInspector</code>
42 * <li><code> inspect()</code></li>
43 * <li><code> InspectorModel()</code></li>
45 * Test is <b> NOT </b> multithread compilant. <p>
47 * This test needs the following object relations :
49 * <li> <code>'XObjectInspector.toInspect'</code>
50 * (of type <code>Object []</code>):
51 * acceptable collection of one or more objects which can be inspected by <code>inspect()</code> </li>
56 public class _XObjectInspector
extends MultiMethodTest
{
61 public XObjectInspector oObj
= null;
63 * This variable was filled with the object relation
64 * <CODE>XObjectInspector.toInspect</CODE> and was used to
65 * test the method <CODE>inspect()</CODE>
67 public Object
[] oInspect
= null;
69 * This variable was filled with the object relation
70 * <CODE>XObjectInspector.InspectorModelToSet</CODE> and was used to
71 * test the method <CODE>setInspectorModel()</CODE>
73 public XObjectInspectorModel xSetModel
= null;
76 * get object relations
78 * <li>XObjectInspector.toInspect</li>
81 public void before() {
83 oInspect
= (Object
[]) tEnv
.getObjRelation("XObjectInspector.toInspect");
85 if (oInspect
== null) throw new StatusException
86 (Status
.failed("Relation 'XObjectInspector.toInspect' not found.")) ;
88 xSetModel
= (XObjectInspectorModel
) tEnv
.getObjRelation("XObjectInspector.InspectorModelToSet");
90 if (xSetModel
== null) throw new StatusException
91 (Status
.failed("Relation 'XObjectInspector.InspectorModelToSet' not found.")) ;
95 * Inspects a new collection of one or more objects given by object realtion
96 * <CODE>XObjectInspector.toInspect</CODE><br>
97 * Has <b>OK</b> status if no runtime exceptions occurred.
99 public void _inspect() {
101 boolean result
= true;
104 oObj
.inspect(oInspect
);
106 } catch (com
.sun
.star
.util
.VetoException e
){
107 log
.println("ERROR:" + e
.toString());
111 tRes
.tested("inspect()", result
) ;
115 * First call the method <CODE>getInspectorModel()</CODE> and save the value<br>
116 * Second call the method <CODE>setInspectorModel()</CODE> with the module variable
117 * <CODE>xSetModel</CODE> as parameter.<br> Then <CODE>getInspectorModel()</CODE>
118 * was called and the returned valued was compared to the saved variable
119 * <CODE>xSetModel</CODE><br>
120 * Has <CODE>OK</CODE> status if the returned value is equal to
121 * <CODE>xSetModel</CODE>.and the saved value is not null.
123 public void _InspectorModel() {
125 log
.println("testing 'getInspectorModel()'...");
126 XObjectInspectorModel xGetModel
= oObj
.getInspectorModel() ;
128 boolean result
= xGetModel
!= null;
130 log
.println(result?
"got a not null object -> OK" : "got a NULL object -> FAILED");
132 log
.println("testing 'setInspectorModel()'...");
133 oObj
.setInspectorModel(xSetModel
);
135 XObjectInspectorModel xNewModel
= oObj
.getInspectorModel();
137 if (result
) oObj
.setInspectorModel(xGetModel
);
139 result
&= xSetModel
.equals(xNewModel
);
141 tRes
.tested("InspectorModel()", result
) ;
145 * Calls the method <CODE>getInspectorUI()</CODE>
146 * Has <b>OK</b> returned value is not null
148 public void _InspectorUI() {
150 XObjectInspectorUI oUI
= oObj
.getInspectorUI();
152 tRes
.tested("InspectorUI()", oUI
!= null) ;