Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _fwk / Desktop.java
blob35fd5183d6e76990ebf93dd823c831adb83e14e3
1 /*
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 mod._fwk;
21 import java.io.PrintWriter;
23 import lib.Status;
24 import lib.StatusException;
25 import lib.TestCase;
26 import lib.TestEnvironment;
27 import lib.TestParameters;
28 import util.SOfficeFactory;
30 import com.sun.star.frame.XDesktop;
31 import com.sun.star.text.XTextDocument;
32 import com.sun.star.uno.UnoRuntime;
33 import com.sun.star.uno.XInterface;
35 /**
36 * Test for object which is represented by service
37 * <code>com.sun.star.frame.Desktop</code>. <p>
38 * Object implements the following interfaces :
39 * <ul>
40 * <li><code>com::sun::star::beans::XPropertySet</code></li>
41 * <li><code>com::sun::star::frame::XComponentLoader</code></li>
42 * <li><code>com::sun::star::frame::XDesktop</code></li>
43 * <li><code>com::sun::star::frame::XDispatchProvider</code></li>
44 * <li><code>com::sun::star::frame::XFrame</code></li>
45 * <li><code>com::sun::star::frame::XFramesSupplier</code></li>
46 * <li><code>com::sun::star::frame::XTasksSupplier</code></li>
47 * <li><code>com::sun::star::lang::XComponent</code></li>
48 * <li><code>com::sun::star::task::XStatusIndicatorFactory</code></li>
49 * </ul><p>
50 * @see com.sun.star.beans.XPropertySet
51 * @see com.sun.star.frame.XComponentLoader
52 * @see com.sun.star.frame.XDesktop
53 * @see com.sun.star.frame.XDispatchProvider
54 * @see com.sun.star.frame.XFrame
55 * @see com.sun.star.frame.XFramesSupplier
56 * @see com.sun.star.frame.XTasksSupplier
57 * @see com.sun.star.lang.XComponent
58 * @see com.sun.star.task.XStatusIndicatorFactory
59 * @see ifc.beans._XPropertySet
60 * @see ifc.frame._XComponentLoader
61 * @see ifc.frame._XDesktop
62 * @see ifc.frame._XDispatchProvider
63 * @see ifc.frame._XFrame
64 * @see ifc.frame._XFramesSupplier
65 * @see ifc.frame._XTasksSupplier
66 * @see ifc.lang._XComponent
67 * @see ifc.task._XStatusIndicatorFactory
69 public class Desktop extends TestCase {
71 XTextDocument xTextDoc;
73 /**
74 * Disposes the document, if exists, created in
75 * <code>createTestEnvironment</code> method.
77 @Override
78 protected void cleanup( TestParameters Param, PrintWriter log) {
80 log.println("disposing xTextDoc");
82 if (xTextDoc != null) {
83 try {
84 xTextDoc.dispose();
85 } catch (com.sun.star.lang.DisposedException de) {}
89 /**
90 * Creating a Testenvironment for the interfaces to be tested.
91 * Creates service <code>com.sun.star.frame.Desktop</code>.
93 @Override
94 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
96 // get a soffice factory object
97 SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF());
99 try {
100 log.println( "creating a text document" );
101 xTextDoc = SOF.createTextDoc(null);
102 } catch ( com.sun.star.uno.Exception e ) {
103 throw new StatusException("Couldn't create document", e);
106 XInterface oObj = null;
108 try {
109 oObj = (XInterface)Param.getMSF().createInstance(
110 "com.sun.star.comp.framework.Desktop");
111 } catch(com.sun.star.uno.Exception e) {
112 throw new StatusException(e, Status.failed("Couldn't create instance"));
115 TestEnvironment tEnv = new TestEnvironment( oObj );
117 tEnv.addObjRelation("XDispatchProvider.URL", ".uno:Open");
119 tEnv.addObjRelation("Desktop",UnoRuntime.queryInterface(XDesktop.class,oObj));
121 return tEnv;
122 } // finish method getTestEnvironment