update dev300-m58
[ooovba.git] / stoc / test / testloader.cxx
blob3be4cdd23d355107d1437e47c7f406779ff3a16b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: testloader.cxx,v $
10 * $Revision: 1.16 $
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"
34 #include <stdio.h>
36 #include <sal/main.h>
37 #ifndef _OSL_MODULE_H_
38 #include <osl/module.hxx>
39 #endif
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>
50 #if defined ( UNX )
51 #include <limits.h>
52 #define _MAX_PATH PATH_MAX
53 #endif
55 using namespace com::sun::star::uno;
56 using namespace com::sun::star::loader;
57 using namespace com::sun::star::lang;
58 using namespace osl;
59 using namespace rtl;
60 using namespace cppu;
62 #if OSL_DEBUG_LEVEL > 0
63 #define TEST_ENSHURE(c, m) OSL_ENSURE(c, m)
64 #else
65 #define TEST_ENSHURE(c, m) OSL_VERIFY(c)
66 #endif
68 class EmptyComponentContext : public WeakImplHelper1< XComponentContext >
70 public:
71 virtual Any SAL_CALL getValueByName( const OUString& /*Name*/ )
72 throw (RuntimeException)
74 return Any();
76 virtual Reference< XMultiComponentFactory > SAL_CALL getServiceManager( )
77 throw (RuntimeException)
79 return Reference< XMultiComponentFactory > ();
85 SAL_IMPLEMENT_MAIN()
87 Reference<XInterface> xIFace;
89 Module module;
91 OUString dllName(
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 );
104 if (pRet)
106 xIFace = pRet;
107 pRet->release();
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");
130 xIFace.clear();
131 xFactory.clear();
132 xLoader.clear();
133 xServInfo.clear();
135 printf("Test Dll ComponentLoader, OK!\n");
137 return(0);