2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package ifc
.inspection
;
21 import com
.sun
.star
.inspection
.XObjectInspector
;
22 import com
.sun
.star
.inspection
.XObjectInspectorModel
;
23 import com
.sun
.star
.inspection
.XObjectInspectorUI
;
24 import lib
.MultiMethodTest
;
26 import lib
.StatusException
;
30 * Testing <code>com.sun.star.inspection.XObjectInspector</code>
33 * <li><code> inspect()</code></li>
34 * <li><code> InspectorModel()</code></li>
36 * Test is <b> NOT </b> multithread compliant. <p>
38 * This test needs the following object relations :
40 * <li> <code>'XObjectInspector.toInspect'</code>
41 * (of type <code>Object []</code>):
42 * acceptable collection of one or more objects which can be inspected by <code>inspect()</code> </li>
47 public class _XObjectInspector
extends MultiMethodTest
{
52 public XObjectInspector oObj
= null;
54 * This variable was filled with the object relation
55 * <CODE>XObjectInspector.toInspect</CODE> and was used to
56 * test the method <CODE>inspect()</CODE>
58 public Object
[] oInspect
= null;
60 * This variable was filled with the object relation
61 * <CODE>XObjectInspector.InspectorModelToSet</CODE> and was used to
62 * test the method <CODE>setInspectorModel()</CODE>
64 public XObjectInspectorModel xSetModel
= null;
67 * get object relations
69 * <li>XObjectInspector.toInspect</li>
73 public void before() {
75 oInspect
= (Object
[]) tEnv
.getObjRelation("XObjectInspector.toInspect");
77 if (oInspect
== null) throw new StatusException
78 (Status
.failed("Relation 'XObjectInspector.toInspect' not found.")) ;
80 xSetModel
= (XObjectInspectorModel
) tEnv
.getObjRelation("XObjectInspector.InspectorModelToSet");
82 if (xSetModel
== null) throw new StatusException
83 (Status
.failed("Relation 'XObjectInspector.InspectorModelToSet' not found.")) ;
87 * Inspects a new collection of one or more objects given by object relation
88 * <CODE>XObjectInspector.toInspect</CODE><br>
89 * Has <b>OK</b> status if no runtime exceptions occurred.
91 public void _inspect() {
93 boolean result
= true;
96 oObj
.inspect(oInspect
);
98 } catch (com
.sun
.star
.util
.VetoException e
){
99 log
.println("ERROR:" + e
.toString());
103 tRes
.tested("inspect()", result
) ;
107 * First call the method <CODE>getInspectorModel()</CODE> and save the value<br>
108 * Second call the method <CODE>setInspectorModel()</CODE> with the module variable
109 * <CODE>xSetModel</CODE> as parameter.<br> Then <CODE>getInspectorModel()</CODE>
110 * was called and the returned valued was compared to the saved variable
111 * <CODE>xSetModel</CODE><br>
112 * Has <CODE>OK</CODE> status if the returned value is equal to
113 * <CODE>xSetModel</CODE>.and the saved value is not null.
115 public void _InspectorModel() {
117 log
.println("testing 'getInspectorModel()'...");
118 XObjectInspectorModel xGetModel
= oObj
.getInspectorModel() ;
120 boolean result
= xGetModel
!= null;
122 log
.println(result?
"got a not null object -> OK" : "got a NULL object -> FAILED");
124 log
.println("testing 'setInspectorModel()'...");
125 oObj
.setInspectorModel(xSetModel
);
127 XObjectInspectorModel xNewModel
= oObj
.getInspectorModel();
129 if (result
) oObj
.setInspectorModel(xGetModel
);
131 result
&= xSetModel
.equals(xNewModel
);
133 tRes
.tested("InspectorModel()", result
) ;
137 * Calls the method <CODE>getInspectorUI()</CODE>
138 * Has <b>OK</b> returned value is not null
140 public void _InspectorUI() {
142 XObjectInspectorUI oUI
= oObj
.getInspectorUI();
144 tRes
.tested("InspectorUI()", oUI
!= null) ;