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/implbase.hxx>
33 #include <cppuhelper/factory.hxx>
37 #define _MAX_PATH PATH_MAX
40 using namespace css::uno
;
41 using namespace css::loader
;
42 using namespace css::lang
;
47 class EmptyComponentContext
: public WeakImplHelper
< XComponentContext
>
50 virtual Any SAL_CALL
getValueByName( const OUString
& /*Name*/ )
51 throw (RuntimeException
)
55 virtual Reference
< XMultiComponentFactory
> SAL_CALL
getServiceManager( )
56 throw (RuntimeException
)
58 return Reference
< XMultiComponentFactory
> ();
66 Reference
<XInterface
> xIFace
;
71 "bootstrap.uno" SAL_DLLEXTENSION
);
73 if (module
.load(dllName
))
75 // try to get provider from module
76 component_getFactoryFunc pCompFactoryFunc
= (component_getFactoryFunc
)
77 module
.getFunctionSymbol( OUString(COMPONENT_GETFACTORY
) );
81 XSingleServiceFactory
* pRet
= (XSingleServiceFactory
*)(*pCompFactoryFunc
)(
82 "com.sun.star.comp.stoc.DLLComponentLoader", 0, 0 );
91 OSL_ENSURE( xIFace
.is(), "testloader error1");
93 Reference
<XSingleComponentFactory
> xFactory( Reference
<XSingleComponentFactory
>::query(xIFace
) );
95 OSL_ENSURE( xFactory
.is(), "testloader error2");
97 Reference
<XInterface
> xLoader
= xFactory
->createInstanceWithContext( new EmptyComponentContext
);
99 OSL_ENSURE( xLoader
.is(), "testloader error3");
101 Reference
<XServiceInfo
> xServInfo( Reference
<XServiceInfo
>::query(xLoader
) );
103 OSL_ENSURE( xServInfo
.is(), "testloader error4");
105 OSL_ENSURE( xServInfo
->getImplementationName() == "com.sun.star.comp.stoc.DLLComponentLoader", "testloader error5");
106 OSL_ENSURE( xServInfo
->supportsService("com.sun.star.loader.SharedLibrary"), "testloader error6");
107 OSL_ENSURE( xServInfo
->getSupportedServiceNames().getLength() == 1, "testloader error7");
114 printf("Test Dll ComponentLoader, OK!\n");
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */