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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_stoc.hxx" 30 31 #include <stdio.h> 32 33 #include <sal/main.h> 34 #ifndef _OSL_MODULE_H_ 35 #include <osl/module.hxx> 36 #endif 37 #include <osl/diagnose.h> 38 39 #include <com/sun/star/loader/XImplementationLoader.hpp> 40 #include <com/sun/star/lang/XServiceInfo.hpp> 41 #include <com/sun/star/lang/XSingleServiceFactory.hpp> 42 #include <com/sun/star/lang/XSingleComponentFactory.hpp> 43 44 #include <cppuhelper/implbase1.hxx> 45 #include <cppuhelper/factory.hxx> 46 47 #if defined ( UNX ) 48 #include <limits.h> 49 #define _MAX_PATH PATH_MAX 50 #endif 51 52 using namespace com::sun::star::uno; 53 using namespace com::sun::star::loader; 54 using namespace com::sun::star::lang; 55 using namespace osl; 56 using namespace rtl; 57 using namespace cppu; 58 59 #if OSL_DEBUG_LEVEL > 0 60 #define TEST_ENSHURE(c, m) OSL_ENSURE(c, m) 61 #else 62 #define TEST_ENSHURE(c, m) OSL_VERIFY(c) 63 #endif 64 65 class EmptyComponentContext : public WeakImplHelper1< XComponentContext > 66 { 67 public: 68 virtual Any SAL_CALL getValueByName( const OUString& /*Name*/ ) 69 throw (RuntimeException) 70 { 71 return Any(); 72 } 73 virtual Reference< XMultiComponentFactory > SAL_CALL getServiceManager( ) 74 throw (RuntimeException) 75 { 76 return Reference< XMultiComponentFactory > (); 77 } 78 79 }; 80 81 82 SAL_IMPLEMENT_MAIN() 83 { 84 Reference<XInterface> xIFace; 85 86 Module module; 87 88 OUString dllName( 89 RTL_CONSTASCII_USTRINGPARAM("bootstrap.uno" SAL_DLLEXTENSION) ); 90 91 if (module.load(dllName)) 92 { 93 // try to get provider from module 94 component_getFactoryFunc pCompFactoryFunc = (component_getFactoryFunc) 95 module.getFunctionSymbol( OUString::createFromAscii(COMPONENT_GETFACTORY) ); 96 97 if (pCompFactoryFunc) 98 { 99 XSingleServiceFactory * pRet = (XSingleServiceFactory *)(*pCompFactoryFunc)( 100 "com.sun.star.comp.stoc.DLLComponentLoader", 0, 0 ); 101 if (pRet) 102 { 103 xIFace = pRet; 104 pRet->release(); 105 } 106 } 107 } 108 109 TEST_ENSHURE( xIFace.is(), "testloader error1"); 110 111 Reference<XSingleComponentFactory> xFactory( Reference<XSingleComponentFactory>::query(xIFace) ); 112 113 TEST_ENSHURE( xFactory.is(), "testloader error2"); 114 115 Reference<XInterface> xLoader = xFactory->createInstanceWithContext( new EmptyComponentContext ); 116 117 TEST_ENSHURE( xLoader.is(), "testloader error3"); 118 119 Reference<XServiceInfo> xServInfo( Reference<XServiceInfo>::query(xLoader) ); 120 121 TEST_ENSHURE( xServInfo.is(), "testloader error4"); 122 123 TEST_ENSHURE( xServInfo->getImplementationName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.comp.stoc.DLLComponentLoader") ), "testloader error5"); 124 TEST_ENSHURE( xServInfo->supportsService(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")) ), "testloader error6"); 125 TEST_ENSHURE( xServInfo->getSupportedServiceNames().getLength() == 1, "testloader error7"); 126 127 xIFace.clear(); 128 xFactory.clear(); 129 xLoader.clear(); 130 xServInfo.clear(); 131 132 printf("Test Dll ComponentLoader, OK!\n"); 133 134 return(0); 135 } 136 137 138