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 ContentHandlerFactory 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.ContentHandlerFactory</code>. <p> 69 */ 70 protected TestEnvironment createTestEnvironment 71 (TestParameters Param, PrintWriter log) { 72 XInterface oObj = null; 73 Object oInterface = null ; 74 75 //now get the OButtonControl 76 try { 77 oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance 78 ("com.sun.star.frame.ContentHandlerFactory") ; 79 } catch (com.sun.star.uno.Exception e) { 80 log.println("Couldn't get service"); 81 e.printStackTrace(log); 82 throw new StatusException("Couldn't get ContentHandlerFactory", e ); 83 } 84 85 if (oInterface == null) { 86 log.println("Service wasn't created") ; 87 throw new StatusException(Status.failed("Service wasn't created")) ; 88 } 89 90 oObj = (XInterface) oInterface ; 91 log.println("ImplName: "+utils.getImplName(oObj)); 92 93 log.println( "creating a new environment for object" ); 94 TestEnvironment tEnv = new TestEnvironment( oObj ); 95 96 XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface 97 (XNameAccess.class, oObj); 98 tEnv.addObjRelation("XMSF.serviceNames", xNA.getElementNames()); 99 String[] dummy = xNA.getElementNames(); 100 101 // com.sun.star.container.XContainerQuery 102 NamedValue[] querySequenze = new NamedValue[1]; 103 NamedValue query = new NamedValue(); 104 query.Name = "Name"; 105 query.Value = "com.sun.star.comp.framework.SoundHandler"; 106 querySequenze[0] = query; 107 108 tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties", 109 querySequenze); 110 111 return tEnv; 112 } // finish method getTestEnvironment 113 114 } 115 116