1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package mod._fwk; 25 26 import java.io.PrintWriter; 27 28 import lib.Status; 29 import lib.StatusException; 30 import lib.TestCase; 31 import lib.TestEnvironment; 32 import lib.TestParameters; 33 import util.SOfficeFactory; 34 35 import com.sun.star.frame.XDesktop; 36 import com.sun.star.lang.XMultiServiceFactory; 37 import com.sun.star.text.XTextDocument; 38 import com.sun.star.uno.UnoRuntime; 39 import com.sun.star.uno.XInterface; 40 41 /** 42 * Test for object which is represented by service 43 * <code>com.sun.star.frame.Desktop</code>. <p> 44 * Object implements the following interfaces : 45 * <ul> 46 * <li><code>com::sun::star::beans::XPropertySet</code></li> 47 * <li><code>com::sun::star::frame::XComponentLoader</code></li> 48 * <li><code>com::sun::star::frame::XDesktop</code></li> 49 * <li><code>com::sun::star::frame::XDispatchProvider</code></li> 50 * <li><code>com::sun::star::frame::XFrame</code></li> 51 * <li><code>com::sun::star::frame::XFramesSupplier</code></li> 52 * <li><code>com::sun::star::frame::XTasksSupplier</code></li> 53 * <li><code>com::sun::star::lang::XComponent</code></li> 54 * <li><code>com::sun::star::task::XStatusIndicatorFactory</code></li> 55 * </ul><p> 56 * @see com.sun.star.beans.XPropertySet 57 * @see com.sun.star.frame.XComponentLoader 58 * @see com.sun.star.frame.XDesktop 59 * @see com.sun.star.frame.XDispatchProvider 60 * @see com.sun.star.frame.XFrame 61 * @see com.sun.star.frame.XFramesSupplier 62 * @see com.sun.star.frame.XTasksSupplier 63 * @see com.sun.star.lang.XComponent 64 * @see com.sun.star.task.XStatusIndicatorFactory 65 * @see ifc.beans._XPropertySet 66 * @see ifc.frame._XComponentLoader 67 * @see ifc.frame._XDesktop 68 * @see ifc.frame._XDispatchProvider 69 * @see ifc.frame._XFrame 70 * @see ifc.frame._XFramesSupplier 71 * @see ifc.frame._XTasksSupplier 72 * @see ifc.lang._XComponent 73 * @see ifc.task._XStatusIndicatorFactory 74 */ 75 public class Desktop extends TestCase { 76 77 XTextDocument xTextDoc; 78 79 /** 80 * Disposes the document, if exists, created in 81 * <code>createTestEnvironment</code> method. 82 */ cleanup( TestParameters Param, PrintWriter log)83 protected void cleanup( TestParameters Param, PrintWriter log) { 84 85 log.println("disposing xTextDoc"); 86 87 if (xTextDoc != null) { 88 try { 89 xTextDoc.dispose(); 90 } catch (com.sun.star.lang.DisposedException de) {} 91 } 92 } 93 94 /** 95 * Creating a Testenvironment for the interfaces to be tested. 96 * Creates service <code>com.sun.star.frame.Desktop</code>. 97 */ createTestEnvironment(TestParameters Param, PrintWriter log)98 protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { 99 100 // get a soffice factory object 101 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)Param.getMSF()); 102 103 try { 104 log.println( "creating a text document" ); 105 xTextDoc = SOF.createTextDoc(null); 106 } catch ( com.sun.star.uno.Exception e ) { 107 // Some exception occured.FAILED 108 e.printStackTrace( log ); 109 throw new StatusException( "Couldn't create document", e ); 110 } 111 112 XInterface oObj = null; 113 114 try { 115 oObj = (XInterface)((XMultiServiceFactory)Param.getMSF()).createInstance( 116 "com.sun.star.comp.framework.Desktop"); 117 } catch(com.sun.star.uno.Exception e) { 118 e.printStackTrace(log); 119 throw new StatusException( 120 Status.failed("Couldn't create instance")); 121 } 122 123 TestEnvironment tEnv = new TestEnvironment( oObj ); 124 125 tEnv.addObjRelation("XDispatchProvider.URL", ".uno:Open"); 126 127 tEnv.addObjRelation("Desktop",(XDesktop) 128 UnoRuntime.queryInterface(XDesktop.class,oObj)); 129 130 return tEnv; 131 } // finish method getTestEnvironment 132 133 } 134