1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
24 #include <osl/module.hxx>
25 #include <osl/diagnose.h>
27 #include <com/sun/star/loader/XImplementationLoader.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
30 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
32 #include <cppuhelper/implbase1.hxx>
33 #include <cppuhelper/factory.hxx>
37 #define _MAX_PATH PATH_MAX
40 using namespace com::sun::star::uno
;
41 using namespace com::sun::star::loader
;
42 using namespace com::sun::star::lang
;
46 using ::rtl::OUString
;
48 class EmptyComponentContext
: public WeakImplHelper1
< XComponentContext
>
51 virtual Any SAL_CALL
getValueByName( const OUString
& /*Name*/ )
52 throw (RuntimeException
)
56 virtual Reference
< XMultiComponentFactory
> SAL_CALL
getServiceManager( )
57 throw (RuntimeException
)
59 return Reference
< XMultiComponentFactory
> ();
67 Reference
<XInterface
> xIFace
;
72 "bootstrap.uno" SAL_DLLEXTENSION
);
74 if (module
.load(dllName
))
76 // try to get provider from module
77 component_getFactoryFunc pCompFactoryFunc
= (component_getFactoryFunc
)
78 module
.getFunctionSymbol( OUString(COMPONENT_GETFACTORY
) );
82 XSingleServiceFactory
* pRet
= (XSingleServiceFactory
*)(*pCompFactoryFunc
)(
83 "com.sun.star.comp.stoc.DLLComponentLoader", 0, 0 );
92 OSL_ENSURE( xIFace
.is(), "testloader error1");
94 Reference
<XSingleComponentFactory
> xFactory( Reference
<XSingleComponentFactory
>::query(xIFace
) );
96 OSL_ENSURE( xFactory
.is(), "testloader error2");
98 Reference
<XInterface
> xLoader
= xFactory
->createInstanceWithContext( new EmptyComponentContext
);
100 OSL_ENSURE( xLoader
.is(), "testloader error3");
102 Reference
<XServiceInfo
> xServInfo( Reference
<XServiceInfo
>::query(xLoader
) );
104 OSL_ENSURE( xServInfo
.is(), "testloader error4");
106 OSL_ENSURE( xServInfo
->getImplementationName() == "com.sun.star.comp.stoc.DLLComponentLoader", "testloader error5");
107 OSL_ENSURE( xServInfo
->supportsService(OUString( "com.sun.star.loader.SharedLibrary") ), "testloader error6");
108 OSL_ENSURE( xServInfo
->getSupportedServiceNames().getLength() == 1, "testloader error7");
115 printf("Test Dll ComponentLoader, OK!\n");
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */