1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package mod._fwl; 29 30 import com.sun.star.beans.NamedValue; 31 import java.io.PrintWriter; 32 33 import lib.Status; 34 import lib.StatusException; 35 import lib.TestCase; 36 import lib.TestEnvironment; 37 import lib.TestParameters; 38 import util.utils; 39 40 import com.sun.star.container.XNameAccess; 41 import com.sun.star.lang.XMultiServiceFactory; 42 import com.sun.star.uno.UnoRuntime; 43 import com.sun.star.uno.XInterface; 44 45 /** 46 * Test for object which is represented by service 47 * <code>com.sun.star.frame.FrameLoaderFactory</code>. <p> 48 * 49 * Object implements the following interfaces : 50 * <ul> 51 * <li> <code>com::sun::star::container::XNameAccess</code></li> 52 * <li> <code>com::sun::star::container::XElementAccess</code></li> 53 * <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li> 54 * </ul> <p> 55 * 56 * @see com.sun.star.container.XNameAccess 57 * @see com.sun.star.container.XElementAccess 58 * @see com.sun.star.lang.XMultiServiceFactory 59 * @see ifc.container._XNameAccess 60 * @see ifc.container._XElementAccess 61 * @see ifc.lang._XMultiServiceFactory 62 */ 63 public class FrameLoaderFactory extends TestCase { 64 65 /** 66 * Creating a Testenvironment for the interfaces to be tested. 67 * Creates an instance of the service 68 * <code>com.sun.star.frame.FrameLoaderFactory</code>. <p> 69 */ 70 protected TestEnvironment createTestEnvironment 71 (TestParameters Param, PrintWriter log) { 72 XInterface oObj = null; 73 Object oInterface = null ; 74 75 try { 76 oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance 77 ("com.sun.star.frame.FrameLoaderFactory") ; 78 } catch (com.sun.star.uno.Exception e) { 79 log.println("Couldn't get service"); 80 e.printStackTrace(log); 81 throw new StatusException("Couldn't get FrameLoaderFactory", e ); 82 } 83 84 if (oInterface == null) { 85 log.println("Service wasn't created") ; 86 throw new StatusException(Status.failed("Service wasn't created")) ; 87 } 88 89 oObj = (XInterface) oInterface ; 90 log.println("ImplName: "+utils.getImplName(oObj)); 91 92 log.println( "creating a new environment for object" ); 93 TestEnvironment tEnv = new TestEnvironment( oObj ); 94 95 XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface 96 (XNameAccess.class, oObj); 97 tEnv.addObjRelation("XMSF.serviceNames", xNA.getElementNames()); 98 99 // com.sun.star.container.XContainerQuery 100 NamedValue[] querySequenze = new NamedValue[1]; 101 NamedValue query = new NamedValue(); 102 query.Name = "Name"; 103 query.Value = "com.sun.star.frame.Bibliography"; 104 querySequenze[0] = query; 105 106 tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties", 107 querySequenze); 108 109 return tEnv; 110 } // finish method getTestEnvironment 111 112 } 113 114