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: Desktop.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 ************************************************************************/
33 import java
.io
.PrintWriter
;
36 import lib
.StatusException
;
38 import lib
.TestEnvironment
;
39 import lib
.TestParameters
;
40 import util
.SOfficeFactory
;
42 import com
.sun
.star
.frame
.XDesktop
;
43 import com
.sun
.star
.lang
.XMultiServiceFactory
;
44 import com
.sun
.star
.text
.XTextDocument
;
45 import com
.sun
.star
.uno
.UnoRuntime
;
46 import com
.sun
.star
.uno
.XInterface
;
49 * Test for object which is represented by service
50 * <code>com.sun.star.frame.Desktop</code>. <p>
51 * Object implements the following interfaces :
53 * <li><code>com::sun::star::beans::XPropertySet</code></li>
54 * <li><code>com::sun::star::frame::XComponentLoader</code></li>
55 * <li><code>com::sun::star::frame::XDesktop</code></li>
56 * <li><code>com::sun::star::frame::XDispatchProvider</code></li>
57 * <li><code>com::sun::star::frame::XFrame</code></li>
58 * <li><code>com::sun::star::frame::XFramesSupplier</code></li>
59 * <li><code>com::sun::star::frame::XTasksSupplier</code></li>
60 * <li><code>com::sun::star::lang::XComponent</code></li>
61 * <li><code>com::sun::star::task::XStatusIndicatorFactory</code></li>
63 * @see com.sun.star.beans.XPropertySet
64 * @see com.sun.star.frame.XComponentLoader
65 * @see com.sun.star.frame.XDesktop
66 * @see com.sun.star.frame.XDispatchProvider
67 * @see com.sun.star.frame.XFrame
68 * @see com.sun.star.frame.XFramesSupplier
69 * @see com.sun.star.frame.XTasksSupplier
70 * @see com.sun.star.lang.XComponent
71 * @see com.sun.star.task.XStatusIndicatorFactory
72 * @see ifc.beans._XPropertySet
73 * @see ifc.frame._XComponentLoader
74 * @see ifc.frame._XDesktop
75 * @see ifc.frame._XDispatchProvider
76 * @see ifc.frame._XFrame
77 * @see ifc.frame._XFramesSupplier
78 * @see ifc.frame._XTasksSupplier
79 * @see ifc.lang._XComponent
80 * @see ifc.task._XStatusIndicatorFactory
82 public class Desktop
extends TestCase
{
84 XTextDocument xTextDoc
;
87 * Disposes the document, if exists, created in
88 * <code>createTestEnvironment</code> method.
90 protected void cleanup( TestParameters Param
, PrintWriter log
) {
92 log
.println("disposing xTextDoc");
94 if (xTextDoc
!= null) {
97 } catch (com
.sun
.star
.lang
.DisposedException de
) {}
102 * Creating a Testenvironment for the interfaces to be tested.
103 * Creates service <code>com.sun.star.frame.Desktop</code>.
105 protected TestEnvironment
createTestEnvironment(TestParameters Param
, PrintWriter log
) {
107 // get a soffice factory object
108 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)Param
.getMSF());
111 log
.println( "creating a text document" );
112 xTextDoc
= SOF
.createTextDoc(null);
113 } catch ( com
.sun
.star
.uno
.Exception e
) {
114 // Some exception occures.FAILED
115 e
.printStackTrace( log
);
116 throw new StatusException( "Couldn't create document", e
);
119 XInterface oObj
= null;
122 oObj
= (XInterface
)((XMultiServiceFactory
)Param
.getMSF()).createInstance(
123 "com.sun.star.comp.framework.Desktop");
124 } catch(com
.sun
.star
.uno
.Exception e
) {
125 e
.printStackTrace(log
);
126 throw new StatusException(
127 Status
.failed("Couldn't create instance"));
130 TestEnvironment tEnv
= new TestEnvironment( oObj
);
132 tEnv
.addObjRelation("XDispatchProvider.URL", ".uno:Open");
134 tEnv
.addObjRelation("Desktop",(XDesktop
)
135 UnoRuntime
.queryInterface(XDesktop
.class,oObj
));
138 } // finish method getTestEnvironment