1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testloader.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_stoc.hxx"
37 #ifndef _OSL_MODULE_H_
38 #include <osl/module.hxx>
40 #include <osl/diagnose.h>
42 #include <com/sun/star/loader/XImplementationLoader.hpp>
43 #include <com/sun/star/lang/XServiceInfo.hpp>
44 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
45 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
47 #include <cppuhelper/implbase1.hxx>
48 #include <cppuhelper/factory.hxx>
52 #define _MAX_PATH PATH_MAX
55 using namespace com::sun::star::uno
;
56 using namespace com::sun::star::loader
;
57 using namespace com::sun::star::lang
;
62 #if OSL_DEBUG_LEVEL > 0
63 #define TEST_ENSHURE(c, m) OSL_ENSURE(c, m)
65 #define TEST_ENSHURE(c, m) OSL_VERIFY(c)
68 class EmptyComponentContext
: public WeakImplHelper1
< XComponentContext
>
71 virtual Any SAL_CALL
getValueByName( const OUString
& /*Name*/ )
72 throw (RuntimeException
)
76 virtual Reference
< XMultiComponentFactory
> SAL_CALL
getServiceManager( )
77 throw (RuntimeException
)
79 return Reference
< XMultiComponentFactory
> ();
87 Reference
<XInterface
> xIFace
;
92 RTL_CONSTASCII_USTRINGPARAM("bootstrap.uno" SAL_DLLEXTENSION
) );
94 if (module
.load(dllName
))
96 // try to get provider from module
97 component_getFactoryFunc pCompFactoryFunc
= (component_getFactoryFunc
)
98 module
.getFunctionSymbol( OUString::createFromAscii(COMPONENT_GETFACTORY
) );
100 if (pCompFactoryFunc
)
102 XSingleServiceFactory
* pRet
= (XSingleServiceFactory
*)(*pCompFactoryFunc
)(
103 "com.sun.star.comp.stoc.DLLComponentLoader", 0, 0 );
112 TEST_ENSHURE( xIFace
.is(), "testloader error1");
114 Reference
<XSingleComponentFactory
> xFactory( Reference
<XSingleComponentFactory
>::query(xIFace
) );
116 TEST_ENSHURE( xFactory
.is(), "testloader error2");
118 Reference
<XInterface
> xLoader
= xFactory
->createInstanceWithContext( new EmptyComponentContext
);
120 TEST_ENSHURE( xLoader
.is(), "testloader error3");
122 Reference
<XServiceInfo
> xServInfo( Reference
<XServiceInfo
>::query(xLoader
) );
124 TEST_ENSHURE( xServInfo
.is(), "testloader error4");
126 TEST_ENSHURE( xServInfo
->getImplementationName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.comp.stoc.DLLComponentLoader") ), "testloader error5");
127 TEST_ENSHURE( xServInfo
->supportsService(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")) ), "testloader error6");
128 TEST_ENSHURE( xServInfo
->getSupportedServiceNames().getLength() == 1, "testloader error7");
135 printf("Test Dll ComponentLoader, OK!\n");