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 .
21 import java
.io
.PrintWriter
;
24 import lib
.StatusException
;
26 import lib
.TestEnvironment
;
27 import lib
.TestParameters
;
28 import util
.SOfficeFactory
;
30 import com
.sun
.star
.frame
.XDesktop
;
31 import com
.sun
.star
.lang
.XMultiServiceFactory
;
32 import com
.sun
.star
.text
.XTextDocument
;
33 import com
.sun
.star
.uno
.UnoRuntime
;
34 import com
.sun
.star
.uno
.XInterface
;
37 * Test for object which is represented by service
38 * <code>com.sun.star.frame.Desktop</code>. <p>
39 * Object implements the following interfaces :
41 * <li><code>com::sun::star::beans::XPropertySet</code></li>
42 * <li><code>com::sun::star::frame::XComponentLoader</code></li>
43 * <li><code>com::sun::star::frame::XDesktop</code></li>
44 * <li><code>com::sun::star::frame::XDispatchProvider</code></li>
45 * <li><code>com::sun::star::frame::XFrame</code></li>
46 * <li><code>com::sun::star::frame::XFramesSupplier</code></li>
47 * <li><code>com::sun::star::frame::XTasksSupplier</code></li>
48 * <li><code>com::sun::star::lang::XComponent</code></li>
49 * <li><code>com::sun::star::task::XStatusIndicatorFactory</code></li>
51 * @see com.sun.star.beans.XPropertySet
52 * @see com.sun.star.frame.XComponentLoader
53 * @see com.sun.star.frame.XDesktop
54 * @see com.sun.star.frame.XDispatchProvider
55 * @see com.sun.star.frame.XFrame
56 * @see com.sun.star.frame.XFramesSupplier
57 * @see com.sun.star.frame.XTasksSupplier
58 * @see com.sun.star.lang.XComponent
59 * @see com.sun.star.task.XStatusIndicatorFactory
60 * @see ifc.beans._XPropertySet
61 * @see ifc.frame._XComponentLoader
62 * @see ifc.frame._XDesktop
63 * @see ifc.frame._XDispatchProvider
64 * @see ifc.frame._XFrame
65 * @see ifc.frame._XFramesSupplier
66 * @see ifc.frame._XTasksSupplier
67 * @see ifc.lang._XComponent
68 * @see ifc.task._XStatusIndicatorFactory
70 public class Desktop
extends TestCase
{
72 XTextDocument xTextDoc
;
75 * Disposes the document, if exists, created in
76 * <code>createTestEnvironment</code> method.
78 protected void cleanup( TestParameters Param
, PrintWriter log
) {
80 log
.println("disposing xTextDoc");
82 if (xTextDoc
!= null) {
85 } catch (com
.sun
.star
.lang
.DisposedException de
) {}
90 * Creating a Testenvironment for the interfaces to be tested.
91 * Creates service <code>com.sun.star.frame.Desktop</code>.
93 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
95 // get a soffice factory object
96 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF());
99 log
.println( "creating a text document" );
100 xTextDoc
= SOF
.createTextDoc(null);
101 } catch ( com
.sun
.star
.uno
.Exception e
) {
102 // Some exception occurs.FAILED
103 e
.printStackTrace( log
);
104 throw new StatusException( "Couldn't create document", e
);
107 XInterface oObj
= null;
110 oObj
= (XInterface
)((XMultiServiceFactory
)Param
.getMSF()).createInstance(
111 "com.sun.star.comp.framework.Desktop");
112 } catch(com
.sun
.star
.uno
.Exception e
) {
113 e
.printStackTrace(log
);
114 throw new StatusException(
115 Status
.failed("Couldn't create instance"));
118 TestEnvironment tEnv
= new TestEnvironment( oObj
);
120 tEnv
.addObjRelation("XDispatchProvider.URL", ".uno:Open");
122 tEnv
.addObjRelation("Desktop",UnoRuntime
.queryInterface(XDesktop
.class,oObj
));
125 } // finish method getTestEnvironment