crashtesting: assert on reimport of docx export of ooo102874-2.doc
[LibreOffice.git] / stoc / test / testloader.cxx
blobbeb77e7d96f7a83bde0ac5160df9bf777a33a181
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include <stdio.h>
23 #include <sal/main.h>
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>
35 #if defined ( UNX )
36 #include <limits.h>
37 #define _MAX_PATH PATH_MAX
38 #endif
40 using namespace css::uno;
41 using namespace css::loader;
42 using namespace css::lang;
43 using namespace osl;
44 using namespace cppu;
47 class EmptyComponentContext : public WeakImplHelper< XComponentContext >
49 public:
50 virtual Any SAL_CALL getValueByName( const OUString& /*Name*/ )
51 throw (RuntimeException)
53 return Any();
55 virtual Reference< XMultiComponentFactory > SAL_CALL getServiceManager( )
56 throw (RuntimeException)
58 return Reference< XMultiComponentFactory > ();
64 SAL_IMPLEMENT_MAIN()
66 Reference<XInterface> xIFace;
68 Module module;
70 OUString dllName(
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) );
79 if (pCompFactoryFunc)
81 XSingleServiceFactory * pRet = (XSingleServiceFactory *)(*pCompFactoryFunc)(
82 "com.sun.star.comp.stoc.DLLComponentLoader", 0, 0 );
83 if (pRet)
85 xIFace = pRet;
86 pRet->release();
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");
109 xIFace.clear();
110 xFactory.clear();
111 xLoader.clear();
112 xServInfo.clear();
114 printf("Test Dll ComponentLoader, OK!\n");
116 return 0;
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */