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 .
20 import com
.sun
.star
.beans
.XPropertySet
;
21 import com
.sun
.star
.frame
.XDesktop
;
22 import com
.sun
.star
.frame
.XFrame
;
23 import com
.sun
.star
.inspection
.XObjectInspectorModel
;
24 import com
.sun
.star
.uno
.UnoRuntime
;
25 import com
.sun
.star
.uno
.XComponentContext
;
26 import com
.sun
.star
.util
.CloseVetoException
;
27 import com
.sun
.star
.util
.XCloseable
;
28 import helper
.PropertyHandlerFactroy
;
29 import java
.io
.PrintWriter
;
32 import lib
.TestEnvironment
;
33 import lib
.TestParameters
;
35 import com
.sun
.star
.lang
.XMultiServiceFactory
;
36 import util
.DesktopTools
;
40 * Test for object which is represented by service
41 * <code>com.sun.star.reflection.ObjectInspectorModel</code>. <p>
42 * Object implements the following interfaces :
44 * <li> <code>com::sun::star::inspection::XObjectInspectorModel</code></li>
46 * This object test <b> is NOT </b> designed to be run in several
47 * threads concurrently.
48 * @see com.sun.star.inspection.XObjectInspectorModel
50 public class ObjectInspectorModel
extends TestCase
{
53 * module variable which holds the Desktop
54 * @see com.sun.star.frame.Desktop
56 protected static XDesktop xDesktop
= null;
59 * assign to the module variable <CODE>xDesktop</CODE> the desktop
60 * @param Param the test parameters
61 * @param log the log writer
62 * @see lib.TestParameters
63 * @see share.LogWriter
64 * @see com.sun.star.frame.Desktop
67 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
68 log
.println("create a desktop...");
69 xDesktop
= DesktopTools
.createDesktop(Param
.getMSF());
73 * Creating a TestEnvironment for the interfaces to be tested.
74 * Creates an instance of the service
75 * <code>com.sun.star.inspection.ObjectInspectorModel</code> with a <code>DefaultContext</code> and
76 * <code>PropertyHandlerFactroy[]</code> as parameter
78 * @param tParam the tests parameter
79 * @param log the logger
80 * @return the test environment
81 * @see util.DesktopTools
82 * @see helper.PropertyHandlerImpl
85 protected TestEnvironment
createTestEnvironment(TestParameters tParam
, PrintWriter log
) throws Exception
{
87 this.cleanup(tParam
, log
);
89 XMultiServiceFactory xMSF
= tParam
.getMSF();
91 XPropertySet xMSFProp
= UnoRuntime
.queryInterface(XPropertySet
.class, xMSF
);
92 XComponentContext xDefaultContext
= null;
93 // Get the default context from the office server.
94 Object oDefaultContext
= xMSFProp
.getPropertyValue("DefaultContext");
96 // Query for the interface XComponentContext.
97 xDefaultContext
= UnoRuntime
.queryInterface(
98 XComponentContext
.class, oDefaultContext
);
100 Object
[] oHandlerFactories
= new Object
[1];
101 oHandlerFactories
[0] = new PropertyHandlerFactroy();
103 int minHelpTextLines
= 200;
104 int maxHelpTextLines
= 400;
106 XObjectInspectorModel oInspectorModel
= com
.sun
.star
.inspection
.ObjectInspectorModel
.
107 createWithHandlerFactoriesAndHelpSection(xDefaultContext
, oHandlerFactories
,
108 minHelpTextLines
, maxHelpTextLines
);
110 log
.println("ImplementationName '" + utils
.getImplName(oInspectorModel
) + "'");
112 TestEnvironment tEnv
= new TestEnvironment(oInspectorModel
);
114 // com.sun.star.inspection.XObjectInspectorModel
115 tEnv
.addObjRelation("minHelpTextLines", Integer
.valueOf(minHelpTextLines
));
116 tEnv
.addObjRelation("maxHelpTextLines", Integer
.valueOf(maxHelpTextLines
));
122 * Closes the ObjectOnspector using <CODE>XCloseable</CODE>
123 * @see com.sun.star.util.XCloseable
124 * @param Param the test parameter
125 * @param log the logger
128 protected void cleanup(TestParameters Param
, PrintWriter log
) {
129 log
.println(" Closing dialog if one exists ... ");
131 XFrame existentInspector
= null;
133 XFrame xFrame
= UnoRuntime
.queryInterface(XFrame
.class, xDesktop
);
135 existentInspector
= xFrame
.findFrame( "ObjectInspector", 255 );
137 if ( existentInspector
!= null ){
138 XCloseable closer
= UnoRuntime
.queryInterface(
139 XCloseable
.class, existentInspector
);
142 } catch (CloseVetoException e
){
143 log
.println("Could not close inspector: " + e
.toString());