diff options
27 files changed, 0 insertions, 4386 deletions
diff --git a/cppuhelper/test/bootstrap/TestEnv.cxx b/cppuhelper/test/bootstrap/TestEnv.cxx deleted file mode 100644 index 2e239ad4864a..000000000000 --- a/cppuhelper/test/bootstrap/TestEnv.cxx +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <cppu/EnvDcp.hxx> - -#include <cppu/helper/purpenv/Environment.hxx> -#include <cppu/helper/purpenv/Mapping.hxx> - - -#define LOG_LIFECYCLE_TestEnv -#ifdef LOG_LIFECYCLE_TestEnv -# include <iostream> -# define LOG_LIFECYCLE_TestEnv_emit(x) x - -#else -# define LOG_LIFECYCLE_TestEnv_emit(x) - -#endif - - -class TestEnv : public cppu::Enterable -{ - int m_inCount; - - virtual ~TestEnv(); - -public: - explicit TestEnv(); - -protected: - virtual void v_enter(); - virtual void v_leave(); - - virtual void v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam); - virtual void v_callOut_v (uno_EnvCallee * pCallee, va_list * pParam); - - virtual bool v_isValid (rtl::OUString * pReason); -}; - -TestEnv::TestEnv() - : m_inCount(0) -{ - LOG_LIFECYCLE_TestEnv_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestEnv::TestEnv(...)", this)); -} - -TestEnv::~TestEnv() -{ - LOG_LIFECYCLE_TestEnv_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestEnv::~TestEnv()", this)); -} - - -void TestEnv::v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam) -{ - ++ m_inCount; - pCallee(pParam); - -- m_inCount; -} - -void TestEnv::v_callOut_v(uno_EnvCallee * pCallee, va_list * pParam) -{ - -- m_inCount; - pCallee(pParam); - ++ m_inCount; -} - -void TestEnv::v_enter() -{ - ++ m_inCount; -} - -void TestEnv::v_leave() -{ - -- m_inCount; -} - -bool TestEnv::v_isValid(rtl::OUString * pReason) -{ - bool result = m_inCount & 1; - - if (result) - *pReason = rtl::OUString("OK"); - - else - *pReason = rtl::OUString("not entered/invoked"); - - return result; -} - -extern "C" void SAL_CALL uno_initEnvironment(uno_Environment * pEnv) SAL_THROW_EXTERN_C() -{ - cppu::helper::purpenv::Environment_initWithEnterable(pEnv, new TestEnv()); -} - -extern "C" void uno_ext_getMapping(uno_Mapping ** ppMapping, - uno_Environment * pFrom, - uno_Environment * pTo ) -{ - cppu::helper::purpenv::createMapping(ppMapping, pFrom, pTo); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/bootstrap/TestEnv.def b/cppuhelper/test/bootstrap/TestEnv.def deleted file mode 100644 index 1444d92c13fa..000000000000 --- a/cppuhelper/test/bootstrap/TestEnv.def +++ /dev/null @@ -1,8 +0,0 @@ -HEAPSIZE 0 -EXPORTS - uno_initEnvironment - uno_ext_getMapping - - - - diff --git a/cppuhelper/test/bootstrap/bootstrap.test.cxx b/cppuhelper/test/bootstrap/bootstrap.test.cxx deleted file mode 100644 index 90c9fb3cb59e..000000000000 --- a/cppuhelper/test/bootstrap/bootstrap.test.cxx +++ /dev/null @@ -1,278 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <sal/main.h> -#include <osl/file.hxx> - -#include <typelib/typedescription.hxx> - -#include <cppuhelper/bootstrap.hxx> -#include <cppuhelper/shlib.hxx> - -#include <com/sun/star/lang/XComponent.hpp> - -#include <uno/environment.hxx> -#include <uno/lbnames.h> -#include <cppu/EnvDcp.hxx> -#include <cppu/EnvGuards.hxx> - -#include <iostream> - - -#ifndef SAL_DLLPREFIX -# define SAL_DLLPREFIX "" -#endif - - -using namespace com::sun::star; - - -static rtl::OUString s_comment; - -static bool s_check_object_is_in(void * pObject) -{ - uno::Environment currentEnv(uno::Environment::getCurrent()); - - rtl_uString * pOId = NULL; - currentEnv.get()->pExtEnv->getObjectIdentifier(currentEnv.get()->pExtEnv, &pOId, pObject); - - - uno::TypeDescription typeDescription(rtl::OUString("com.sun.star.uno.XInterface")); - - void * pRegisteredObject = NULL; - currentEnv.get()->pExtEnv->getRegisteredInterface(currentEnv.get()->pExtEnv, - &pRegisteredObject, - pOId, - (typelib_InterfaceTypeDescription *)typeDescription.get()); - - - if (pOId) rtl_uString_release(pOId); - - bool result = pRegisteredObject != NULL; - - if (result) - currentEnv.get()->pExtEnv->releaseInterface(currentEnv.get()->pExtEnv, pRegisteredObject); - - return result; -} - -static void s_test__loadSharedLibComponentFactory(rtl::OUString const & clientPurpose, - rtl::OUString const & servicePurpose) -{ - cppu::EnvGuard envGuard(uno::Environment(UNO_LB_UNO + clientPurpose, NULL)); - if (!clientPurpose.isEmpty() && !envGuard.is()) - { - s_comment += "\t\tcouldn't get purpose env: \"" + clientPurpose + "\" - FAILURE\n"; - return; - } - - rtl::OString os_clientPurpose(rtl::OUStringToOString(clientPurpose, RTL_TEXTENCODING_ASCII_US)); - - uno::Reference<uno::XInterface> xItf( - cppu::loadSharedLibComponentFactory( - rtl::OUString(SAL_DLLPREFIX "TestComponent.uno" SAL_DLLEXTENSION), -#ifdef _WIN32 - "", -#else - "file://../lib/", -#endif - "impl.test.TestComponent" + servicePurpose, - uno::Reference<lang::XMultiServiceFactory>(), - uno::Reference<registry::XRegistryKey>() - ) - ); - - if (!xItf.is()) - { - s_comment += rtl::OUString("\t\tgot no object - FAILURE\n"); - return; - } - - if (!clientPurpose.equals(servicePurpose) && !s_check_object_is_in(xItf.get())) - { - s_comment += "\t\tcouldn't find object in current purpose \"" + clientPurpose + "\" - FAILURE\n"; - } - - if (!cppu::EnvDcp::getPurpose(uno::Environment::getCurrent().getTypeName()).equals(clientPurpose)) - { - s_comment += "\t\tdid not enter client purpose \"" + clientPurpose + "\" - FAILURE\n"; - } -} - -static void s_test__loadSharedLibComponentFactory__free_free() -{ - s_comment += "\ts_test__loadSharedLibComponentFactory__free_free\n"; - - s_test__loadSharedLibComponentFactory("", ""); -} - -static void s_test__loadSharedLibComponentFactory__free_purpose() -{ - s_comment += "\ts_test__loadSharedLibComponentFactory__free_purpose\n"; - - s_test__loadSharedLibComponentFactory("", ":testenv"); -} - -static void s_test__loadSharedLibComponentFactory__purpose_free() -{ - s_comment += "\ts_test__loadSharedLibComponentFactory__purpose_free\n"; - - s_test__loadSharedLibComponentFactory(":testenv", ""); -} - -static void s_test__loadSharedLibComponentFactory__purpose_purpose() -{ - s_comment += "\ts_test__loadSharedLibComponentFactory__purpose_purpose\n"; - - s_test__loadSharedLibComponentFactory(":testenv", ":testenv"); -} - -static rtl::OUString s_getSDrive() -{ - rtl::OUString path;//("file://"); - - // FIXME no more S drive - - osl::FileBase::getFileURLFromSystemPath(path, path); - - return path; -} - -static void s_test__createSimpleRegistry(rtl::OUString const & clientPurpose) -{ - cppu::EnvGuard envGuard(uno::Environment(rtl::OUString(UNO_LB_UNO) - + clientPurpose, NULL)); - if (!clientPurpose.isEmpty() && !envGuard.is()) - { - s_comment += "\t\tcouldn't get purpose env: \"" + clientPurpose + "\" - FAILURE\n"; - return; - } - - uno::Reference<registry::XSimpleRegistry> registry(cppu::createSimpleRegistry( - s_getSDrive())); - - if (!registry.is()) - { - s_comment += "\t\tgot no object - FAILURE\n"; - return; - } - - if (!clientPurpose.isEmpty() && !s_check_object_is_in(registry.get())) - { - s_comment += "\t\tcouldn't find object in current purpose \"" + clientPurpose + "\" - FAILURE\n"; - } -} - -static void s_test__createSimpleRegistry__free() -{ - s_comment += "\ts_test__createSimpleRegistry__free\n"; - - s_test__createSimpleRegistry(rtl::OUString()); -} - -static void s_test__createSimpleRegistry__purpose() -{ - s_comment += "\ts_test__createSimpleRegistry__purpose\n"; - - s_test__createSimpleRegistry(":testenv"); -} - - -static void s_test__bootstrap_InitialComponentContext(rtl::OUString const & clientPurpose) -{ - cppu::EnvGuard envGuard(uno::Environment(rtl::OUString(UNO_LB_UNO) - + clientPurpose, NULL)); - if (!clientPurpose.isEmpty() && !envGuard.is()) - { - s_comment += "\t\tcouldn't get purpose env: \"" + clientPurpose + "\" - FAILURE\n"; - return; - } - - uno::Reference<uno::XComponentContext> xContext( - cppu::bootstrap_InitialComponentContext( - uno::Reference<registry::XSimpleRegistry>(), - s_getSDrive()) - ); - - if (!xContext.is()) - { - s_comment += "\t\tgot no object - FAILURE\n"; - return; - } - - if (!clientPurpose.isEmpty() && !s_check_object_is_in(xContext.get())) - { - s_comment += "\t\tcouldn't find object in current purpose \"" + clientPurpose + "\" - FAILURE\n"; - } - - uno::Reference<lang::XComponent> xComponent(xContext, uno::UNO_QUERY_THROW); - xComponent->dispose(); -} - -static void s_test__bootstrap_InitialComponentContext__free() -{ - s_comment += "\ts_test__bootstrap_InitialComponentContext__free\n"; - - s_test__bootstrap_InitialComponentContext(rtl::OUString()); -} - -static void s_test__bootstrap_InitialComponentContext__purpose() -{ - s_comment += "\ts_test__bootstrap_InitialComponentContext__purpose\n"; - - s_test__bootstrap_InitialComponentContext(":testenv"); -} - - -SAL_IMPLEMENT_MAIN_WITH_ARGS(/*argc*/, argv) -{ - s_test__createSimpleRegistry__free(); - s_test__createSimpleRegistry__purpose(); - - s_test__loadSharedLibComponentFactory__free_free(); - s_test__loadSharedLibComponentFactory__free_purpose(); - s_test__loadSharedLibComponentFactory__purpose_free(); - s_test__loadSharedLibComponentFactory__purpose_purpose(); - - s_test__bootstrap_InitialComponentContext__free(); - s_test__bootstrap_InitialComponentContext__purpose(); - - int ret; - if (s_comment.indexOf("FAILURE") == -1) - { - s_comment += "TESTS PASSED\n"; - ret = 0; - } - else - { - s_comment += "TESTS _NOT_ PASSED\n"; - ret = -1; - } - - std::cerr - << argv[0] - << std::endl - << rtl::OUStringToOString(s_comment, RTL_TEXTENCODING_ASCII_US).getStr() - << std::endl; - - return ret; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/bootstrap/makefile.mk b/cppuhelper/test/bootstrap/makefile.mk deleted file mode 100644 index a2d1715b397b..000000000000 --- a/cppuhelper/test/bootstrap/makefile.mk +++ /dev/null @@ -1,51 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ := ..$/.. -PRJNAME := cppuhelper -TARGET := bootstrap.test - - -ENABLE_EXCEPTIONS := TRUE -USE_DEFFILE := TRUE - - -.INCLUDE : settings.mk - - -.IF "$(OS)"!="WNT" -PURPENVHELPERLIB := -luno_purpenvhelper$(COMID) - -.ELSE -PURPENVHELPERLIB := $(LIBPRE) ipurpenvhelper$(UDK_MAJOR)$(COMID).lib - -.ENDIF - - -APP1TARGET := $(TARGET) -APP1OBJS := $(OBJ)$/bootstrap.test.obj -APP1STDLIBS := $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) - -SHL1TARGET := testenv_uno_uno -SHL1IMPLIB := i$(SHL1TARGET) -SHL1OBJS := $(SLO)$/TestEnv.obj -SHL1STDLIBS := $(PURPENVHELPERLIB) $(SALHELPERLIB) $(SALLIB) -SHL1DEF := TestEnv.def - - -.INCLUDE : target.mk diff --git a/cppuhelper/test/cfg_data/instance/uno/components.xml b/cppuhelper/test/cfg_data/instance/uno/components.xml deleted file mode 100644 index 9670078fd403..000000000000 --- a/cppuhelper/test/cfg_data/instance/uno/components.xml +++ /dev/null @@ -1,92 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<components cfg:package="uno" - xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" - xmlns:cfg="http://openoffice.org/2000/registry/instance" - xmlns="http://openoffice.org/2000/uno/Components"> - - -<services cfg:type="set" cfg:element-type="service"> - - <service cfg:name="com.sun.star.script.Converter"> - <available-implementations cfg:type="string" cfg:derivedBy="list"> - com.sun.star.comp.stoc.TypeConverter - </available-implementations> - </service> - - <service cfg:name="com.sun.star.bootstrap.TestComponent0"> - <available-implementations cfg:type="string" cfg:derivedBy="list"> - com.sun.star.comp.bootstrap.TestComponent0 - </available-implementations> - <context-properties cfg:type="set" cfg:element-type="cfg:any"> - <cfg:any cfg:name="serviceprop0" cfg:type="int">13</cfg:any> - <cfg:any cfg:name="serviceprop1" cfg:type="string">value of serviceprop1</cfg:any> - </context-properties> - </service> - -</services> - - -<implementations cfg:type="set" cfg:element-type="implementation"> - - <implementation cfg:name="com.sun.star.comp.stoc.TypeConverter"> - <activator cfg:type="string">com.sun.star.loader.SharedLibrary</activator> - <url cfg:type="string">tcv.dll</url> - <supported-services cfg:type="string" cfg:derivedBy="list">com.sun.star.script.Converter</supported-services> - </implementation> - - <implementation cfg:name="com.sun.star.comp.bootstrap.TestComponent0"> - <activator cfg:type="string">com.sun.star.loader.SharedLibrary</activator> - <url cfg:type="string">cfg_test.dll</url> - <supported-services cfg:type="string" cfg:derivedBy="list">com.sun.star.bootstrap.TestComponent0</supported-services> - <context-properties cfg:type="set" cfg:element-type="cfg:any"> - <cfg:any cfg:name="implprop0" cfg:type="int">15</cfg:any> - <cfg:any cfg:name="implprop1" cfg:type="string">value of implprop1</cfg:any> - </context-properties> - </implementation> - -</implementations> - - -<singletons cfg:type="set" cfg:element-type="singleton"> - - <singleton cfg:name="com.sun.star.script.theConverter"> - <used-service cfg:type="string">com.sun.star.script.Converter</used-service> - </singleton> - - <singleton cfg:name="com.sun.star.bootstrap.theTestComponent0"> - <used-service cfg:type="string">com.sun.star.bootstrap.TestComponent0</used-service> - <initial-arguments cfg:type="set" cfg:element-type="cfg:any"> - <cfg:any cfg:name="0" cfg:type="string">first argument</cfg:any> - <cfg:any cfg:name="1" cfg:type="string">second argument</cfg:any> - <cfg:any cfg:name="2" cfg:type="string">third argument</cfg:any> - </initial-arguments> - </singleton> - -</singletons> - - -<global-context-properties cfg:type="set" cfg:element-type="cfg:any"> - - <cfg:any cfg:name="TestValue" cfg:type="int">5</cfg:any> - -</global-context-properties> - - -</components> diff --git a/cppuhelper/test/cfg_data/template/uno/components.xml b/cppuhelper/test/cfg_data/template/uno/components.xml deleted file mode 100644 index 511db5ff1855..000000000000 --- a/cppuhelper/test/cfg_data/template/uno/components.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<components cfg:package="uno" - xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" - xmlns:cfg="http://openoffice.org/2000/registry/instance"> - -<service> - <available-implementations cfg:type="string" cfg:derivedBy="list"/> - <context-properties cfg:type="set" cfg:element-type="cfg:any"/> -</service> - -<implementation> - <activator cfg:type="string"/> - <url cfg:type="string"/> - <supported-services cfg:type="string" cfg:derivedBy="list"/> - <context-properties cfg:type="set" cfg:element-type="cfg:any"/> -</implementation> - -<singleton> - <used-service cfg:type="string"/> - <initial-arguments cfg:type="set" cfg:element-type="cfg:any"/> -</singleton> - -</components> diff --git a/cppuhelper/test/cfg_test.cxx b/cppuhelper/test/cfg_test.cxx deleted file mode 100644 index 1f17ab63d89a..000000000000 --- a/cppuhelper/test/cfg_test.cxx +++ /dev/null @@ -1,275 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -// starting the executable: -// -env:UNO_CFG_URL=local;<absolute_path>..\\..\\test\\cfg_data;<absolute_path>\\cfg_update -// -env:UNO_TYPES=cpputest.rdb - -#include <sal/main.h> - -#include <stdio.h> - -#include <rtl/strbuf.hxx> - -#include <cppuhelper/implementationentry.hxx> -#include <cppuhelper/bootstrap.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/supportsservice.hxx> - -#include <com/sun/star/lang/XMultiComponentFactory.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XComponent.hpp> - -#include <com/sun/star/registry/XImplementationRegistration.hpp> - - -using namespace ::cppu; -using namespace ::osl; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; - -namespace cfg_test -{ - - -static Sequence< OUString > impl0_getSupportedServiceNames() -{ - OUString str("com.sun.star.bootstrap.TestComponent0"); - return Sequence< OUString >( &str, 1 ); -} - -static OUString impl0_getImplementationName() -{ - return OUString("com.sun.star.comp.bootstrap.TestComponent0"); -} - -static Sequence< OUString > impl1_getSupportedServiceNames() -{ - OUString str("com.sun.star.bootstrap.TestComponent1"); - return Sequence< OUString >( &str, 1 ); -} - -static OUString impl1_getImplementationName() -{ - return OUString("com.sun.star.comp.bootstrap.TestComponent1"); -} - - -class ServiceImpl0 - : public WeakImplHelper2< lang::XServiceInfo, lang::XInitialization > -{ - Reference< XComponentContext > m_xContext; - -public: - explicit ServiceImpl0( Reference< XComponentContext > const & xContext ); - - // XInitialization - virtual void SAL_CALL initialize( const Sequence< Any >& rArgs ) throw (Exception, RuntimeException); - - // XServiceInfo - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException); - virtual OUString SAL_CALL getImplementationName() throw (RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw (RuntimeException); -}; - -ServiceImpl0::ServiceImpl0( Reference< XComponentContext > const & xContext ) - : m_xContext( xContext ) -{ - sal_Int32 n; - OUString val; - - // service properties - OSL_VERIFY( m_xContext->getValueByName( - "/services/com.sun.star.bootstrap.TestComponent0/context-properties/serviceprop0" ) >>= n ); - OSL_VERIFY( n == 13 ); - OSL_VERIFY( m_xContext->getValueByName( - "/services/com.sun.star.bootstrap.TestComponent0/context-properties/serviceprop1" ) >>= val ); - OSL_VERIFY( val == "value of serviceprop1" ); - // impl properties - OSL_VERIFY( m_xContext->getValueByName( - "/implementations/com.sun.star.comp.bootstrap.TestComponent0/context-properties/implprop0" ) >>= n ); - OSL_VERIFY( n == 15 ); - OSL_VERIFY( m_xContext->getValueByName( - "/implementations/com.sun.star.comp.bootstrap.TestComponent0/context-properties/implprop1" ) >>= val ); - OSL_VERIFY( val == "value of implprop1" ); -} -// XInitialization - -void ServiceImpl0::initialize( const Sequence< Any >& rArgs ) - throw (Exception, RuntimeException) -{ - // check args - OUString val; - OSL_VERIFY( rArgs.getLength() == 3 ); - OSL_VERIFY( rArgs[ 0 ] >>= val ); - OSL_VERIFY( val == "first argument" ); - OSL_VERIFY( rArgs[ 1 ] >>= val ); - OSL_VERIFY( val == "second argument" ); - OSL_VERIFY( rArgs[ 2 ] >>= val ); - OSL_VERIFY( val == "third argument" ); -} -// XServiceInfo - -OUString ServiceImpl0::getImplementationName() - throw(css::uno::RuntimeException) -{ - return impl0_getImplementationName(); -} - -Sequence< OUString > ServiceImpl0::getSupportedServiceNames() - throw(css::uno::RuntimeException) -{ - return impl0_getSupportedServiceNames(); -} - -sal_Bool ServiceImpl0::supportsService( const OUString & rServiceName ) - throw(css::uno::RuntimeException) -{ - return cppu::supportsService(this, rServiceName); -} - - -class ServiceImpl1 : public ServiceImpl0 -{ -public: - explicit ServiceImpl1( Reference< XComponentContext > const & xContext ) - : ServiceImpl0( xContext ) - { - } - - // XServiceInfo - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException); - virtual OUString SAL_CALL getImplementationName() throw (RuntimeException); -}; - -OUString ServiceImpl1::getImplementationName() - throw(css::uno::RuntimeException) -{ - return impl1_getImplementationName(); -} - -Sequence< OUString > ServiceImpl1::getSupportedServiceNames() - throw(css::uno::RuntimeException) -{ - return impl1_getSupportedServiceNames(); -} - - -static Reference< XInterface > SAL_CALL ServiceImpl0_create( - Reference< XComponentContext > const & xContext ) -{ - return (OWeakObject *)new ServiceImpl0( xContext ); -} - -static Reference< XInterface > SAL_CALL ServiceImpl1_create( - Reference< XComponentContext > const & xContext ) -{ - return (OWeakObject *)new ServiceImpl1( xContext ); -} - -} // namespace cfg_test - -static const struct ImplementationEntry g_entries[] = -{ - { - ::cfg_test::ServiceImpl0_create, ::cfg_test::impl0_getImplementationName, - ::cfg_test::impl0_getSupportedServiceNames, createSingleComponentFactory, - 0, 0 - }, - { - ::cfg_test::ServiceImpl1_create, ::cfg_test::impl1_getImplementationName, - ::cfg_test::impl1_getSupportedServiceNames, createSingleComponentFactory, - 0, 0 - }, - { 0, 0, 0, 0, 0, 0 } -}; - -// component exports -extern "C" -{ - -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( - pServiceManager, pRegistryKey, g_entries ); -} - -SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( - const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) -{ - return component_getFactoryHelper( - pImplName, pServiceManager, pRegistryKey , g_entries ); -} -} - - -SAL_IMPLEMENT_MAIN() -{ - try - { - Reference< XComponentContext > xContext( defaultBootstrap_InitialComponentContext() ); - Reference< lang::XMultiComponentFactory > xMgr( xContext->getServiceManager() ); - - // show what is in context - xContext->getValueByName( "dump_maps" ); - - sal_Int32 n(0); - OSL_VERIFY( xContext->getValueByName( "/global-context-properties/TestValue" ) >>= n ); - ::fprintf( stderr, "> n=%d\n", n ); - - Reference< XInterface > x; - OSL_VERIFY( !(xContext->getValueByName( "/singletons/my_converter" ) >>= x) ); - OSL_VERIFY( xContext->getValueByName( "/singletons/com.sun.star.script.theConverter" ) >>= x ); - OSL_VERIFY( xContext->getValueByName( "/singletons/com.sun.star.bootstrap.theTestComponent0" ) >>= x ); - - ::fprintf( stderr, "> registering service...\n"); -#if defined(SAL_W32) - OUString libName( "cfg_test.dll" ); -#elif defined(SAL_UNX) - OUString libName( "libcfg_test.so" ); -#endif - Reference< registry::XImplementationRegistration > xImplReg( xMgr->createInstanceWithContext( - "com.sun.star.registry.ImplementationRegistration", xContext ), UNO_QUERY ); - OSL_ENSURE( xImplReg.is(), "### no impl reg!" ); - xImplReg->registerImplementation( - "com.sun.star.loader.SharedLibrary", libName, - Reference< registry::XSimpleRegistry >() ); - - OSL_VERIFY( (x = xMgr->createInstanceWithContext( "com.sun.star.bootstrap.TestComponent0", xContext )).is() ); - OSL_VERIFY( (x = xMgr->createInstanceWithContext( "com.sun.star.bootstrap.TestComponent1", xContext )).is() ); - - Reference< lang::XComponent > xComp( xContext, UNO_QUERY ); - if (xComp.is()) - { - xComp->dispose(); - } - return 0; - } - catch (Exception & exc) - { - OString str( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) ); - ::fprintf( stderr, "# caught exception: %s\n", str.getStr() ); - return 1; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/helpertest.idl b/cppuhelper/test/helpertest.idl deleted file mode 100644 index 80d55ca78e11..000000000000 --- a/cppuhelper/test/helpertest.idl +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef _TEST_CPPUTEST_IDL_ -#define _TEST_CPPUTEST_IDL_ - -#include <com/sun/star/uno/XInterface.idl> -#include <com/sun/star/uno/TypeClass.idl> - -module test -{ - -interface A : com::sun::star::uno::XInterface -{ - string a(); -}; - -interface BA : A -{ - string ba(); -}; - -interface CA : A -{ - string ca(); -}; - -interface DBA : BA -{ - string dba(); -}; - -interface E : com::sun::star::uno::XInterface -{ - string e(); -}; - -interface FE : E -{ - string fe(); -}; - -interface G : com::sun::star::uno::XInterface -{ - string g(); - string a(); -}; - -interface H : com::sun::star::uno::XInterface -{ - string h(); -}; -interface I : com::sun::star::uno::XInterface -{ - string i(); -}; - -}; //module test - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/loader/loader.test.cxx b/cppuhelper/test/loader/loader.test.cxx deleted file mode 100644 index a24a5641de40..000000000000 --- a/cppuhelper/test/loader/loader.test.cxx +++ /dev/null @@ -1,198 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <sal/main.h> -#include <cppuhelper/shlib.hxx> -#include <cppuhelper/implbase1.hxx> -#include <cppu/EnvDcp.hxx> - -#include "../testcmp/TestComponent.hxx" - -#include <iostream> -#include <cstring> - -#ifndef SAL_DLLPREFIX -# define SAL_DLLPREFIX "" -#endif - - -using namespace ::com::sun::star; - - -class MyKey : public cppu::WeakImplHelper1<registry::XRegistryKey> - -{ -public: - virtual rtl::OUString SAL_CALL getKeyName() throw (uno::RuntimeException) { return rtl::OUString(); }; - - // Methods - virtual sal_Bool SAL_CALL isReadOnly( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return sal_False;}; - virtual sal_Bool SAL_CALL isValid( ) throw (uno::RuntimeException) {return sal_False;}; - virtual registry::RegistryKeyType SAL_CALL getKeyType( const rtl::OUString& /*rKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return registry::RegistryKeyType_KEY;}; - virtual registry::RegistryValueType SAL_CALL getValueType( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return registry::RegistryValueType_NOT_DEFINED;}; - virtual sal_Int32 SAL_CALL getLongValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return 0;}; - virtual void SAL_CALL setLongValue( sal_Int32 /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; - virtual uno::Sequence< sal_Int32 > SAL_CALL getLongListValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) { return uno::Sequence<sal_Int32>(); }; - virtual void SAL_CALL setLongListValue( const uno::Sequence< sal_Int32 >& /*seqValue*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; - virtual rtl::OUString SAL_CALL getAsciiValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return rtl::OUString();}; - virtual void SAL_CALL setAsciiValue( const rtl::OUString& /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; - virtual uno::Sequence< rtl::OUString > SAL_CALL getAsciiListValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return uno::Sequence<rtl::OUString>();}; - virtual void SAL_CALL setAsciiListValue( const uno::Sequence< rtl::OUString >& /*seqValue*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; - virtual rtl::OUString SAL_CALL getStringValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return rtl::OUString();}; - virtual void SAL_CALL setStringValue( const rtl::OUString& /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; - virtual uno::Sequence< rtl::OUString > SAL_CALL getStringListValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return uno::Sequence<rtl::OUString>();}; - virtual void SAL_CALL setStringListValue( const uno::Sequence< rtl::OUString >& /*seqValue*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; - virtual uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return uno::Sequence<sal_Int8>();}; - virtual void SAL_CALL setBinaryValue( const uno::Sequence< sal_Int8 >& /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; - virtual uno::Reference< registry::XRegistryKey > SAL_CALL openKey( const rtl::OUString& /*aKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Reference<registry::XRegistryKey>();}; - virtual uno::Reference< registry::XRegistryKey > SAL_CALL createKey( const rtl::OUString& /*aKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Reference<registry::XRegistryKey>();}; - virtual void SAL_CALL closeKey( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; - virtual void SAL_CALL deleteKey( const rtl::OUString& /*rKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; - virtual uno::Sequence< uno::Reference< registry::XRegistryKey > > SAL_CALL openKeys( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Sequence<uno::Reference<registry::XRegistryKey> >();}; - virtual uno::Sequence< rtl::OUString > SAL_CALL getKeyNames( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Sequence<rtl::OUString>();}; - virtual sal_Bool SAL_CALL createLink( const rtl::OUString& /*aLinkName*/, const rtl::OUString& /*aLinkTarget*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return sal_False;}; - virtual void SAL_CALL deleteLink( const rtl::OUString& /*rLinkName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; - virtual rtl::OUString SAL_CALL getLinkTarget( const rtl::OUString& /*rLinkName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return rtl::OUString();}; - virtual rtl::OUString SAL_CALL getResolvedName( const rtl::OUString& /*aKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return rtl::OUString();}; -}; - - -static rtl::OUString s_test__cppu_loadSharedLibComponentFactory(char const * pServicePurpose) -{ - rtl::OUString result; - - rtl::OUString servicePurpose = rtl::OUString(pServicePurpose, - rtl_str_getLength(pServicePurpose), - RTL_TEXTENCODING_ASCII_US); - - result += rtl::OUString("\ts_test__cppu_loadSharedLibComponentFactory "); - result += rtl::OUString("(\""); - result += servicePurpose; - result += rtl::OUString("\") - "); - - try { - uno::Reference<uno::XInterface> xObject( - cppu::loadSharedLibComponentFactory( - rtl::OUString(SAL_DLLPREFIX "TestComponent.uno" SAL_DLLEXTENSION), - rtl::OUString(), - rtl::OUString("impl.test.TestComponent") + servicePurpose, - uno::Reference<lang::XMultiServiceFactory>(), - uno::Reference<registry::XRegistryKey>()) - ); - - rtl::OUString envDcp_purpose(cppu::EnvDcp::getPurpose(g_envDcp)); - if (envDcp_purpose == servicePurpose) - result += rtl::OUString("passed\n"); - - else - { - result += rtl::OUString("FAILED - got: \""); - result += envDcp_purpose; - result += rtl::OUString("\"\n"); - } - } - catch(uno::Exception & exception) { - result += rtl::OUString("FAILED - got: \""); - result += exception.Message; - result += rtl::OUString("\"\n"); - } - - return result; -} - -static rtl::OUString s_test__cppu_writeSharedLibComponentInfo(char const * pServicePurpose) -{ - rtl::OUString result; - - rtl::OUString servicePurpose = rtl::OUString(pServicePurpose, - rtl_str_getLength(pServicePurpose), - RTL_TEXTENCODING_ASCII_US); - - result += rtl::OUString("\ts_test__cppu_writeSharedLibComponentInfo "); - result += rtl::OUString("(\""); - result += servicePurpose; - result += rtl::OUString("\") - "); - - char buff[256]; - strcpy(buff, "TestComponent.uno="); - strcat(buff, pServicePurpose); - - putenv(buff); - - try { - cppu::writeSharedLibComponentInfo( - rtl::OUString(SAL_DLLPREFIX "TestComponent.uno" SAL_DLLEXTENSION), - rtl::OUString(), - uno::Reference<lang::XMultiServiceFactory>(), - uno::Reference<registry::XRegistryKey>(new MyKey) - ); - - rtl::OUString envDcp_purpose(cppu::EnvDcp::getPurpose(g_envDcp)); - if (envDcp_purpose == servicePurpose) - result += rtl::OUString("passed\n"); - - else - { - result += rtl::OUString("FAILED - got: \""); - result += envDcp_purpose; - result += rtl::OUString("\"\n"); - } - } - catch(uno::Exception & exception) { - result += rtl::OUString("FAILED - got: \""); - result += exception.Message; - result += rtl::OUString("\"\n"); - } - - return result; -} - - -SAL_IMPLEMENT_MAIN_WITH_ARGS(/*argc*/, argv) -{ - int result = 0; - - rtl::OUString message; - - message += rtl::OUString(argv[0], rtl_str_getLength(argv[0]), RTL_TEXTENCODING_ASCII_US); - message += rtl::OUString("\n"); - - message += s_test__cppu_loadSharedLibComponentFactory(":unsafe"); - message += s_test__cppu_loadSharedLibComponentFactory(":affine"); - message += s_test__cppu_loadSharedLibComponentFactory(""); - - message += s_test__cppu_writeSharedLibComponentInfo(":unsafe"); - message += s_test__cppu_writeSharedLibComponentInfo(":affine"); - message += s_test__cppu_writeSharedLibComponentInfo(""); - - if (message.indexOf("FAILED") == -1) - message += rtl::OUString("TESTS PASSED\n"); - - else - { - message += rtl::OUString("TESTS _NOT_ PASSED\n"); - result = -1; - } - - std::cout << rtl::OUStringToOString(message, RTL_TEXTENCODING_ASCII_US).getStr(); - - return result; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/loader/makefile.mk b/cppuhelper/test/loader/makefile.mk deleted file mode 100644 index 73bf2ab64b3c..000000000000 --- a/cppuhelper/test/loader/makefile.mk +++ /dev/null @@ -1,42 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ := ..$/.. -PRJNAME := cppuhelper -TARGET := loader.test - - -ENABLE_EXCEPTIONS := TRUE -USE_DEFFILE := TRUE - -.INCLUDE : settings.mk - -ENVINCPRE := -I$(OUT)$/inc$/$(TARGET) - -APP1TARGET := $(TARGET) -APP1OBJS := $(OBJ)$/loader.test.obj -.IF "$(OS)"=="WNT" -APP1STDLIBS := iTestComponent.uno.lib -.ELSE -APP1STDLIBS := -lTestComponent.uno - -.ENDIF - -APP1STDLIBS += $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) - -.INCLUDE : target.mk diff --git a/cppuhelper/test/makefile.mk b/cppuhelper/test/makefile.mk deleted file mode 100644 index 7ff031004eb7..000000000000 --- a/cppuhelper/test/makefile.mk +++ /dev/null @@ -1,159 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# -PRJ=.. - -PRJNAME=cppuhelper -TARGET=testhelper -ENABLE_EXCEPTIONS=TRUE -USE_DEFFILE=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -# --- Files -------------------------------------------------------- - -UNOUCRDEP= $(SOLARBINDIR)$/udkapi.rdb -UNOUCRRDB= $(SOLARBINDIR)$/udkapi.rdb -UNOUCROUT= $(OUT)$/inc$/test -INCPRE+= $(OUT)$/inc$/test - -OBJFILES= \ - $(OBJ)$/testhelper.obj \ - $(OBJ)$/testpropshlp.obj \ - $(OBJ)$/testidlclass.obj \ - $(OBJ)$/testproptyphlp.obj \ - $(OBJ)$/testimplhelper.obj \ - $(OBJ)$/testcontainer.obj - -APP1TARGET=$(TARGET) -APP1OBJS=$(OBJFILES) - -APP1STDLIBS+= \ - $(CPPULIB) \ - $(CPPUHELPERLIB) \ - $(SALLIB) - -APP1DEF= $(MISC)$/$(APP1TARGET).def - -############################################# - -APP2OBJS = $(OBJ)$/testdefaultbootstrapping.obj -APP2STDLIBS += $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) -APP2TARGET = testdefaultbootstrapping - -############################################# - -SLOFILES= \ - $(SLO)$/cfg_test.obj -LIB1TARGET=$(SLB)$/cfg_test.lib -LIB1OBJFILES=$(SLOFILES) - - -APP3OBJS = $(OBJ)$/cfg_test.obj -APP3STDLIBS += $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) -APP3TARGET = test_cfg - -############################################# - -ALLIDLFILES:= helpertest.idl - -# --- Targets ------------------------------------------------------ - -.IF "$(depend)" == "" -ALL: $(BIN)$/cpputest.rdb \ - unoheader \ - $(BIN)$/testrc \ - $(BIN)$/testdefaultbootstrapping.pl \ - ALLTAR \ - $(BIN)$/$(APP2TARGET).bin \ - $(BIN)$/$(APP2TARGET).Bin \ - $(BIN)$/$(APP2TARGET).Exe - -.IF "$(OS)"!="WNT" -ALL: $(BIN)$/$(APP2TARGET).exe - -$(BIN)$/$(APP2TARGET).exe : $(APP2TARGETN) - cp $(APP2TARGETN) $@ - -.ENDIF - - -$(BIN)$/$(APP2TARGET).bin : $(APP2TARGETN) - cp $(APP2TARGETN) $@ - -$(BIN)$/$(APP2TARGET).Bin : $(APP2TARGETN) - cp $(APP2TARGETN) $@ - -$(BIN)$/$(APP2TARGET).Exe : $(APP2TARGETN) - cp $(APP2TARGETN) $@ - -.ELSE -ALL: ALLDEP -.ENDIF - -.INCLUDE : target.mk - -CPPUMAKERFLAGS = -.IF "$(COM)" == "MSC" -CPPUMAKERFLAGS = -L -.ENDIF - -TYPES:=test.A;test.BA;test.CA;test.DBA;test.E;test.FE;test.G;test.H;test.I -HELPERTYPES:=com.sun.star.uno.XReference;com.sun.star.uno.XAdapter;com.sun.star.uno.XAggregation;com.sun.star.uno.XWeak;com.sun.star.lang.XComponent;com.sun.star.lang.XTypeProvider;com.sun.star.lang.XEventListener;com.sun.star.lang.XSingleServiceFactory;com.sun.star.lang.XMultiServiceFactory;com.sun.star.registry.XRegistryKey;com.sun.star.lang.XInitialization;com.sun.star.lang.XServiceInfo;com.sun.star.loader.XImplementationLoader;com.sun.star.lang.IllegalAccessException;com.sun.star.beans.XVetoableChangeListener;com.sun.star.beans.XPropertySet;com.sun.star.uno.XComponentContext -FACTORYTYPES:=com.sun.star.lang.XComponent;com.sun.star.registry.XSimpleRegistry;com.sun.star.lang.XInitialization;com.sun.star.lang.XMultiServiceFactory;com.sun.star.loader.XImplementationLoader;com.sun.star.registry.XImplementationRegistration;com.sun.star.container.XSet;com.sun.star.lang.XSingleServiceFactory;com.sun.star.lang.XSingleComponentFactory;com.sun.star.lang.XMultiComponentFactory - -.IF "$(OS)" == "WNT" -UNO_PATH := $(SOLARBINDIR) -UNO_OUT := $(OUT)$/bin -EXT_SO := .dll -.ELSE -UNO_PATH := $(SOLARLIBDIR) -UNO_OUT := $(OUT)$/lib -EXT_SO := .so -.ENDIF - -$(UNO_OUT)$/%$(EXT_SO): $(UNO_PATH)$/%$(EXT_SO) - $(COPY) $^ $@ - -$(BIN)$/cpputest.rdb: $(ALLIDLFILES) $(UNO_OUT)$/invocadapt.uno$(EXT_SO) $(UNO_OUT)$/bootstrap.uno$(EXT_SO) - $(IDLC) -I$(PRJ) -I$(SOLARIDLDIR) -O$(BIN) $(ALLIDLFILES) - $(REGMERGE) $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)} - $(REGMERGE) $@ / $(UNOUCRRDB) - $(REGCOMP) -register -r $@ -c reflection.uno$(DLLPOST) - $(TOUCH) $@ - -unoheader: $(BIN)$/cpputest.rdb - $(CPPUMAKER) $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TYPES);$(HELPERTYPES)" $(BIN)$/cpputest.rdb - $(CPPUMAKER) $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(FACTORYTYPES)" $(BIN)$/cpputest.rdb - - -$(BIN)$/testdefaultbootstrapping.pl: testdefaultbootstrapping.pl - cp testdefaultbootstrapping.pl $@ - -$(BIN)$/testrc: makefile.mk -.IF "$(OS)"=="WNT" - echo [Tests] > $@ - echo TestKey1=com.sun.star.uno.NamingService.rdb >> $@ -.ELSE - echo '[Tests]' > $@ - echo 'TestKey1=file:///'$(PWD)/$(BIN)'/com.sun.star.uno.NamingService.rdb' >> $@ -.ENDIF - - - diff --git a/cppuhelper/test/testcmp/TestComponent.cxx b/cppuhelper/test/testcmp/TestComponent.cxx deleted file mode 100644 index 1b4d7854cd21..000000000000 --- a/cppuhelper/test/testcmp/TestComponent.cxx +++ /dev/null @@ -1,227 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#define CPPUHELPER_TEST_COMPONENT_IMPL -#include "TestComponent.hxx" - - -#include <string.h> - -#include <osl/thread.h> - -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implementationentry.hxx> -#include <cppuhelper/supportsservice.hxx> - -#include <com/sun/star/lang/XMultiComponentFactory.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> - -#include <com/sun/star/uno/XComponentContext.hpp> - - -#include <cppu/EnvDcp.hxx> - -#include <uno/environment.hxx> -#include <uno/lbnames.h> - -using namespace ::com::sun::star; - - -#define LOG_LIFECYCLE_TestComponent -#ifdef LOG_LIFECYCLE_TestComponent -# include <iostream> -# define LOG_LIFECYCLE_TestComponent_emit(x) x - -#else -# define LOG_LIFECYCLE_TestComponent_emit(x) - -#endif - - -class TestComponent: public cppu::WeakImplHelper1<lang::XServiceInfo> -{ - rtl::OUString m_implName; - -public: - static uno::Reference<uno::XInterface> create( - uno::Reference<uno::XComponentContext> const & xCtx - ); - - - static uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames_Static(); - - explicit TestComponent(uno::Reference<uno::XComponentContext> const & xCtx); - virtual ~TestComponent(); - - uno::Any SAL_CALL queryInterface(uno::Type const & rType ) throw (css::uno::RuntimeException); - void SAL_CALL release() throw (); - void SAL_CALL acquire() throw (); - - // lang::XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName() throw (uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) - throw (uno::RuntimeException); - virtual uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames() - throw (uno::RuntimeException); - -protected: - uno::Reference<uno::XComponentContext> m_xComponentContext; -}; - - -uno::Reference<uno::XInterface> SAL_CALL TestComponent::create( - uno::Reference<uno::XComponentContext> const & xCtx) -{ - try - { - return static_cast<cppu::OWeakObject *>(new TestComponent(xCtx)); - } - catch (std::bad_alloc &) - { - throw uno::RuntimeException("std::bad_alloc"); - } -} - -uno::Sequence<rtl::OUString> SAL_CALL TestComponent::getSupportedServiceNames_Static() -{ - uno::Sequence<OUString> serviceNames { rtl::OUString("com.sun.star.lang.ServiceInfo") }; - - return serviceNames; -} - - -TestComponent::TestComponent(uno::Reference<uno::XComponentContext> const & xCtx) - : m_xComponentContext(xCtx) -{ - LOG_LIFECYCLE_TestComponent_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestComponent::TestComponent()", this)); -} - -TestComponent::~TestComponent() -{ - LOG_LIFECYCLE_TestComponent_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestComponent::~TestComponent", this)); -} - -rtl::OUString SAL_CALL TestComponent::getImplementationName() - throw (uno::RuntimeException) -{ - return m_implName; -} - -void SAL_CALL TestComponent::acquire() throw () -{ - cppu::WeakImplHelper1<lang::XServiceInfo>::acquire(); -} - -void SAL_CALL TestComponent::release() throw () -{ - cppu::WeakImplHelper1<lang::XServiceInfo>::release(); -} - -uno::Any SAL_CALL TestComponent::queryInterface(uno::Type const & rType ) throw (css::uno::RuntimeException) -{ - return cppu::WeakImplHelper1<lang::XServiceInfo>::queryInterface(rType); -} - -sal_Bool SAL_CALL TestComponent::supportsService(rtl::OUString const & ServiceName) - throw (uno::RuntimeException) -{ - return cppu::supportsService(this, ServiceName); -} - -uno::Sequence<rtl::OUString> SAL_CALL TestComponent::getSupportedServiceNames() - throw (uno::RuntimeException) -{ - return getSupportedServiceNames_Static(); -} - -extern "C" sal_Bool SAL_CALL component_writeInfo( - void * /*serviceManager*/, - void * /*registryKey*/ -) -{ - g_envDcp = uno::Environment::getCurrent().getTypeName(); - - return true; -} - -extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( - char const * pImplName, - void * /*serviceManager*/, - void * /*registryKey*/ -) -{ - g_envDcp = uno::Environment::getCurrent().getTypeName(); - - uno::Reference< lang::XSingleComponentFactory > xFactory; - - rtl::OUString uTmp(pImplName, rtl_str_getLength(pImplName), RTL_TEXTENCODING_ASCII_US); - - rtl::OUString uImplName(cppu::EnvDcp::getTypeName(uTmp)); - rtl::OUString cmpName("impl.test.TestComponent"); - - if (uImplName.equals(cmpName)) - { - xFactory = cppu::createSingleComponentFactory( - TestComponent::create, - uImplName, - TestComponent::getSupportedServiceNames_Static()); - - xFactory->acquire(); - } - - return xFactory.get(); -} - -extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironmentExt( - sal_Char const ** envTypeName, - uno_Environment ** /*ppEnv*/, - sal_Char const * pImplName, - uno_Environment * /*pSrcEnv*/ -) -{ - rtl::OString purpose; - - if (pImplName) // this is the purpose for a specified impl - { - rtl::OUString uImplName(pImplName, rtl_str_getLength(pImplName), RTL_TEXTENCODING_ASCII_US); - purpose = rtl::OUStringToOString(cppu::EnvDcp::getPurpose(uImplName), RTL_TEXTENCODING_ASCII_US); - } - - if (!purpose.getLength()) - { - char * pPurpose = getenv("TestComponent.uno"); - if (pPurpose) - purpose = rtl::OString(pPurpose); - } - - if (purpose.getLength() == 0) - *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; - - else - { - char buff[256]; - strcpy(buff, CPPU_CURRENT_LANGUAGE_BINDING_NAME); - strcat(buff, purpose.getStr()); - - *envTypeName = strdup(buff); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testcmp/TestComponent.hxx b/cppuhelper/test/testcmp/TestComponent.hxx deleted file mode 100644 index 66979bf1ca67..000000000000 --- a/cppuhelper/test/testcmp/TestComponent.hxx +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CPPUHELPER_TEST_TESTCMP_TESTCOMPONENT_HXX -#define INCLUDED_CPPUHELPER_TEST_TESTCMP_TESTCOMPONENT_HXX - -#include <sal/types.h> -#include <rtl/ustring.hxx> - -#ifdef CPPUHELPER_TEST_COMPONENT_IMPL -# define CPPUHELPER_TEST_COMPONENT_EXPORT SAL_DLLPUBLIC_EXPORT - -#elif defined(CPPUHELPER_TEST_COMPONENT_LIB) -# define CPPUHELPER_TEST_COMPONENT_EXPORT extern - -#elif defined(__GNUC__) -# define CPPUHELPER_TEST_COMPONENT_EXPORT extern __attribute__ ((weak)) - -#else -# define CPPUHELPER_TEST_COMPONENT_EXPORT SAL_DLLPUBLIC_IMPORT - -#endif - -CPPUHELPER_TEST_COMPONENT_EXPORT rtl::OUString g_envDcp; - - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testcmp/TestComponent.uno.def b/cppuhelper/test/testcmp/TestComponent.uno.def deleted file mode 100644 index 8c1906e67459..000000000000 --- a/cppuhelper/test/testcmp/TestComponent.uno.def +++ /dev/null @@ -1,11 +0,0 @@ -HEAPSIZE 0 -EXPORTS - component_getImplementationEnvironmentExt; - component_getFactory; - component_writeInfo; - ?g_envDcp@@3VOUString@rtl@@A; - - - - - diff --git a/cppuhelper/test/testcmp/makefile.mk b/cppuhelper/test/testcmp/makefile.mk deleted file mode 100644 index a59657e64fde..000000000000 --- a/cppuhelper/test/testcmp/makefile.mk +++ /dev/null @@ -1,40 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ := ..$/.. -PRJNAME := cppuhelper -TARGET := TestComponent.uno -ENABLE_EXCEPTIONS := TRUE - - -.INCLUDE: settings.mk - - -SHL1TARGET := $(TARGET) -SHL1OBJS := $(SLO)$/TestComponent.obj -SHL1STDLIBS := $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) -SHL1IMPLIB := i$(SHL1TARGET) -.IF "$(OS)"=="WNT" -SHL1DEF := TestComponent.uno.def -.ELSE -DEF1NAME := $(SHL1TARGET) -.ENDIF - - -.INCLUDE: target.mk - diff --git a/cppuhelper/test/testcontainer.cxx b/cppuhelper/test/testcontainer.cxx deleted file mode 100644 index 7533695640d0..000000000000 --- a/cppuhelper/test/testcontainer.cxx +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <osl/mutex.hxx> - -#include <cppuhelper/interfacecontainer.hxx> -#include <cppuhelper/implbase1.hxx> - -#include <com/sun/star/beans/XVetoableChangeListener.hpp> - -using namespace ::cppu; -using namespace ::osl; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::uno; - - -class TestListener : public WeakImplHelper1< XVetoableChangeListener > -{ -public: - // Methods - virtual void SAL_CALL disposing( const css::lang::EventObject& /*Source*/ ) throw(css::uno::RuntimeException) - { - - } - - virtual void SAL_CALL vetoableChange( const css::beans::PropertyChangeEvent& /*aEvent*/ ) - throw(css::beans::PropertyVetoException, css::uno::RuntimeException) - { - - } -}; - -void test_interfacecontainer() -{ - Mutex mutex; - - { - OInterfaceContainerHelper helper( mutex ); - - Reference< XVetoableChangeListener > r1 = new TestListener(); - Reference< XVetoableChangeListener > r2 = new TestListener(); - Reference< XVetoableChangeListener > r3 = new TestListener(); - - helper.addInterface( r1 ); - helper.addInterface( r2 ); - helper.addInterface( r3 ); - - helper.disposeAndClear( EventObject() ); - } - - { - OInterfaceContainerHelper helper( mutex ); - - Reference< XVetoableChangeListener > r1 = new TestListener(); - Reference< XVetoableChangeListener > r2 = new TestListener(); - Reference< XVetoableChangeListener > r3 = new TestListener(); - - helper.addInterface( r1 ); - helper.addInterface( r2 ); - helper.addInterface( r3 ); - - OInterfaceIteratorHelper iterator( helper ); - - while( iterator.hasMoreElements() ) - ((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() ); - - helper.disposeAndClear( EventObject() ); - } - - { - OInterfaceContainerHelper helper( mutex ); - - Reference< XVetoableChangeListener > r1 = new TestListener(); - Reference< XVetoableChangeListener > r2 = new TestListener(); - Reference< XVetoableChangeListener > r3 = new TestListener(); - - helper.addInterface( r1 ); - helper.addInterface( r2 ); - helper.addInterface( r3 ); - - OInterfaceIteratorHelper iterator( helper ); - - ((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() ); - iterator.remove(); - ((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() ); - iterator.remove(); - ((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() ); - iterator.remove(); - - OSL_ASSERT( helper.getLength() == 0 ); - helper.disposeAndClear( EventObject() ); - } - - { - OInterfaceContainerHelper helper( mutex ); - - Reference< XVetoableChangeListener > r1 = new TestListener(); - Reference< XVetoableChangeListener > r2 = new TestListener(); - Reference< XVetoableChangeListener > r3 = new TestListener(); - - helper.addInterface( r1 ); - helper.addInterface( r2 ); - helper.addInterface( r3 ); - - { - OInterfaceIteratorHelper iterator( helper ); - while( iterator.hasMoreElements() ) - { - Reference< XVetoableChangeListener > r = ((XVetoableChangeListener*)iterator.next()); - if( r == r1 ) - iterator.remove(); - } - } - OSL_ASSERT( helper.getLength() == 2 ); - { - OInterfaceIteratorHelper iterator( helper ); - while( iterator.hasMoreElements() ) - { - Reference< XVetoableChangeListener > r = ((XVetoableChangeListener*)iterator.next()); - OSL_ASSERT( r != r1 && ( r == r2 || r == r3 ) ); - } - } - - helper.disposeAndClear( EventObject() ); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testdefaultbootstrapping.cxx b/cppuhelper/test/testdefaultbootstrapping.cxx deleted file mode 100644 index 4e40d252105d..000000000000 --- a/cppuhelper/test/testdefaultbootstrapping.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <sal/main.h> - - -#include <cstdio> - -#include <rtl/process.h> -#include <cppuhelper/bootstrap.hxx> - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> - -using namespace ::cppu; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; - - -SAL_IMPLEMENT_MAIN() -{ - sal_Bool result = sal_True; - - try { - Reference<XComponentContext> xComponentContext = defaultBootstrap_InitialComponentContext(); - - Reference<XMultiServiceFactory> smgr(xComponentContext->getServiceManager(), UNO_QUERY); - - for(sal_uInt32 i = 0; i < rtl_getAppCommandArgCount(); ++ i) { - OUString arg; - - rtl_getAppCommandArg(i, &arg.pData); - if (!arg.isEmpty()) - { - Reference<XInterface> xInterface = smgr->createInstance(arg); - SAL_INFO("cppuhelper", "got the " << arg << " service " << xInterface.get()); - - result = result && (xInterface.get() != 0); - } - } - } - catch(Exception & exception) { - OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US); - - fprintf(stderr, "an exception occurred: %s\n", message.getStr()); - } - - SAL_INFO("extensions", "---------------------------------- " << result); - - return result; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testdefaultbootstrapping.pl b/cppuhelper/test/testdefaultbootstrapping.pl deleted file mode 100644 index 278e759fb44c..000000000000 --- a/cppuhelper/test/testdefaultbootstrapping.pl +++ /dev/null @@ -1,268 +0,0 @@ -: -eval 'exec perl -wS $0 ${1+"$@"}' - if 0; -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -# -# deliver.pl - copy from module output tree to solver -# - -my $progname = "testdefaultbootstrapping"; -my $defExeExt; - -if ($ENV{OS} eq "WNT") { - %services = ( - 'com.sun.star.uno.NamingService' => 'namingservice.uno.dll', - 'com.sun.star.reflection.CoreReflection' => 'reflection.uno.dll', - 'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.dll', - ); - - $defExeExt = ".exe"; - -} -else { - %services = ( - 'com.sun.star.uno.NamingService' => 'namingservice.uno.so', - 'com.sun.star.reflection.CoreReflection' => 'reflection.uno.so', - 'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.so' - ); - - $defExeExt = ""; -} - -sub extendProgName($) { - my $_extension = shift; - my $_result; - - if ($ENV{OS} eq "WNT") { - $_result = $progname . $_extension; - } - else { - $_result = $ENV{PWD} . "/" . $progname . $_extension; - } - - return $_result; -} - - -sub rmDefRDB() { - unlink $progname . "_services.rdb"; -} - - -sub unregisterService($){ - my $service_name = shift; - - my $rdb_name = $service_name . '.rdb'; - - unlink $rdb_name; - - return 1; -} - -sub testForServices($$$) { - my $_services = shift; - my $_pars = shift; - my $_testexe = shift; - - -# my $_rc = system 'echo', $_testexe, @{$_services}, $_pars; - my $_rc = system $_testexe, @{$_services}, $_pars; - - return $_rc >> 8; -} - - -sub registerService($$){ - my $service_lib = shift; - my $rdb_name = shift; - -# system 'echo', "regcomp -register -r " . $rdb_name . " -c $service_lib"; - my $rc = system "regcomp -register -r " . $rdb_name . " -c $service_lib"; - - - return ! ( $rc >> 8 ); -} - - - -my $state = 1; -my @allservices; -my $allservices_rdbs=""; -my $rc; -my $comment; -my $testexe; - - -sub registerServices() { - use Cwd; - - # ensure that services can not be instantiated - foreach $service ( keys %services ) { - # ensure that the current service is not reachable - unregisterService($service); - $rc = !testForServices([$service], "", $testexe); - if(!$rc) { - $comment = $comment . "\tcouldn't unregister service " . $service . "\n"; - $state = 0; - } - - - # register the service and ensure that it is reachable - $rc = registerService($services{$service}, $service . '.rdb'); - if(!$rc) { - $comment = $comment . "\tcouldn't register service " . $service . "\n"; - $state = 0; - } - - $rc = testForServices([$service], "-env:UNO_SERVICES=" . $service . ".rdb", $testexe); - if(!$rc) { - $comment = $comment . "\tcouldn't reach service " . $service . "\n"; - $state = 0; - } - - # memorize all services - if (length($allservices_rdbs)) { - $allservices_rdbs = $allservices_rdbs . " "; - } - $allservices_rdbs = $allservices_rdbs . "file://" . getcwd() . "/" . $service . ".rdb"; - push @allservices, $service; - } -} - -sub testIndirection() { - #test indirection - $rc = testForServices(['com.sun.star.uno.NamingService'], '-env:UNO_SERVICES=${testrc:Tests:TestKey1}', $testexe); - if (!$rc) { - $comment = $comment . "\tindirection test not passed\n"; - $state = 0; - } -} - - -sub testBeneathExe() { - my $service = 'com.sun.star.reflection.CoreReflection'; - my $_testexe; - - my @_exes = (extendProgName(".exe"), - extendProgName(".Exe"), - extendProgName(".bin"), - extendProgName(".Bin")); - - foreach $_testexe ( @_exes ) { - #test rdb found beneath executable - registerService($services{$service}, $progname . "_services.rdb"); - my $_rc = testForServices([$service], "", $_testexe); - if (!$_rc) { - $comment = $comment . "\tbeneath executable test not passed: " . $_testexe . "\n"; - $state = 0; - } - } -} - -sub testBeneathLib_rdb() { - my $_service = 'com.sun.star.uno.NamingService'; - - use UNO; - - my $_rdb_name; - - if ($ENV{OS} eq "WNT") { - $_rdb_name = "UNO" . "_services.rdb"; - } - else { - $_rdb_name = "../lib/UNO" . "_services.rdb"; - } - - registerService($services{$_service}, $_rdb_name); - my $_rc = UNO::tryService($_service); - if (!$_rc) { - $comment = $comment . "\tbeneath lib test not passed\n"; - $state = 0; - } - unlink $_rdb_name; -} - -sub testBeneathLib_rc() { - my $_service = 'com.sun.star.uno.NamingService'; - - use UNO; - - my $_rc_name; - - if ($ENV{OS} eq "WNT") { - $_rc_name = "UNO.ini"; - } - else { - $_rc_name = "../lib/UNOrc"; - } - - my $_rdb_name = "../lib/test.rdb"; - - my $_handle; - open $_handle, ">" . $_rc_name; - print $_handle "UNO_SERVICES=" . $_rdb_name . "\n"; - close $_handle; - - registerService($services{$_service}, $_rdb_name); - my $_rc = UNO::tryService($_service); - if (!$_rc) { - $comment = $comment . "\tbeneath lib rc test not passed\n"; - $state = 0; - } - unlink $_rdb_name; - unlink $_rc_name; -} - -sub testAllAvailable() { - # test that all services are reachable through different rdbs - # change the directory to ensure, that all paths become expanded - chdir ".."; - - $rc = testForServices(\@allservices, "-env:UNO_SERVICES=" . $allservices_rdbs, $testexe); - if (!$rc) { - $comment = $comment . "\tmulti rdb test not passed\n"; - $state = 0; - } -} - -$testexe = extendProgName($defExeExt); - -rmDefRDB(); -registerServices(); -#print "alls:", @allservices, $allservices_rdbs, "\n"; - -testIndirection(); -testBeneathExe(); -testBeneathLib_rc(); -testBeneathLib_rdb(); -testAllAvailable(); - -print "**************************\n"; -if($state) { - print "****** tests passed ******\n"; -} -else { - print "**** tests NOT passed ****\n"; - print "Commnent:\n", $comment, "\n"; -} -print "**************************\n"; - - - diff --git a/cppuhelper/test/testhelper.cxx b/cppuhelper/test/testhelper.cxx deleted file mode 100644 index 0fbd0caf96aa..000000000000 --- a/cppuhelper/test/testhelper.cxx +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0 -# undef OSL_DEBUG_LEVEL -# define OSL_DEBUG_LEVEL 2 -#endif - - -#include <sal/main.h> - -#include <stdio.h> -#include <rtl/ustrbuf.hxx> -#include <osl/diagnose.h> - -#include <cppuhelper/component_context.hxx> -#include <cppuhelper/servicefactory.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/registry/XSimpleRegistry.hpp> -#include <com/sun/star/registry/XImplementationRegistration.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XComponent.hpp> - -#include "testhelper.hxx" - -using namespace cppu; -using namespace com::sun::star::uno; -using namespace com::sun::star; -using namespace com::sun::star::lang; -using namespace com::sun::star::registry; - -using ::rtl::OUString; -using ::rtl::OString; -using ::rtl::OUStringToOString; - -SAL_IMPLEMENT_MAIN() -{ - try - { - Reference< XMultiComponentFactory > xMgr( createRegistryServiceFactory( - OUString("cpputest.rdb") ), UNO_QUERY ); - Reference< XComponentContext > xInitialContext; - OSL_VERIFY( Reference< beans::XPropertySet >( xMgr, UNO_QUERY )->getPropertyValue( - OUString("DefaultContext") ) >>= xInitialContext ); - - ContextEntry_Init aEntry; - aEntry.bLateInitService = false; - aEntry.name = "bla, bla"; - aEntry.value = makeAny( (sal_Int32)5 ); - Reference< XComponentContext > xContext( createComponentContext( &aEntry, 1, xInitialContext ) ); - OSL_ASSERT( xContext->getServiceManager() != xMgr ); // must be wrapped one - OSL_ASSERT( - Reference< beans::XPropertySet >( - xContext->getServiceManager(), UNO_QUERY )->getPropertyValue( - OUString("DefaultContext") ) != xInitialContext ); - - Reference< XMultiServiceFactory > x( xMgr, UNO_QUERY ); - test_ImplHelper( x ); - testPropertyTypeHelper(); - testidlclass( x ); - test_PropertySetHelper(); - test_interfacecontainer(); - - OSL_VERIFY( xContext->getValueByName( - OUString("bla, bla") ) == (sal_Int32)5 ); - OSL_VERIFY( ! xInitialContext->getValueByName( - OUString("bla, bla") ).hasValue() ); - Reference< XComponent >( xInitialContext, UNO_QUERY )->dispose(); - xMgr.clear(); - xContext.clear(); - xInitialContext.clear(); - } - catch (Exception & exc) - { - OString cstr_msg( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) ); - OSL_ENSURE( ! "exception occurred: ", cstr_msg.getStr() ); - } - - printf( "Test finished\n" ); - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testhelper.hxx b/cppuhelper/test/testhelper.hxx deleted file mode 100644 index dfc4a6fff21c..000000000000 --- a/cppuhelper/test/testhelper.hxx +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_CPPUHELPER_TEST_TESTHELPER_HXX -#define INCLUDED_CPPUHELPER_TEST_TESTHELPER_HXX - -void testidlclass( const css::uno::Reference < css::lang::XMultiServiceFactory > &r); -void testPropertyTypeHelper(); -void test_PropertySetHelper(); -void test_ImplHelper( const css::uno::Reference < css::lang::XMultiServiceFactory > & xSF ); -void test_interfacecontainer(); - -#endif // INCLUDED_CPPUHELPER_TEST_TESTHELPER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testimplhelper.cxx b/cppuhelper/test/testimplhelper.cxx deleted file mode 100644 index 3ff0ccd7d969..000000000000 --- a/cppuhelper/test/testimplhelper.cxx +++ /dev/null @@ -1,569 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0 -# undef OSL_DEBUG_LEVEL -# define OSL_DEBUG_LEVEL 2 -#endif - - -#include <stdio.h> - -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> -#include <cppuhelper/implbase4.hxx> -#include <cppuhelper/implbase5.hxx> -#include <cppuhelper/implbase6.hxx> -#include <cppuhelper/implbase7.hxx> -#include <cppuhelper/implbase8.hxx> -#include <cppuhelper/implbase9.hxx> -#include <cppuhelper/implbase10.hxx> -#include <cppuhelper/implbase11.hxx> -#include <cppuhelper/implbase12.hxx> - -#include <cppuhelper/compbase1.hxx> -#include <cppuhelper/compbase2.hxx> -#include <cppuhelper/compbase3.hxx> -#include <cppuhelper/compbase4.hxx> -#include <cppuhelper/compbase5.hxx> -#include <cppuhelper/compbase6.hxx> -#include <cppuhelper/compbase7.hxx> -#include <cppuhelper/compbase8.hxx> -#include <cppuhelper/compbase9.hxx> -#include <cppuhelper/compbase10.hxx> -#include <cppuhelper/compbase11.hxx> -#include <cppuhelper/compbase12.hxx> - -#include <osl/diagnose.h> -#include <cppuhelper/servicefactory.hxx> -#include <cppuhelper/exc_hlp.hxx> - -#include <test/A.hpp> -#include <test/BA.hpp> -#include <test/CA.hpp> -#include <test/DBA.hpp> -#include <test/E.hpp> -#include <test/FE.hpp> -#include <test/G.hpp> -#include <test/H.hpp> -#include <test/I.hpp> - -#include <com/sun/star/lang/IllegalAccessException.hpp> - -using namespace test; -using namespace osl; -using namespace cppu; -using namespace com::sun::star; -using namespace com::sun::star::uno; - -using ::rtl::OUString; -using ::rtl::OUStringToOString; -using ::rtl::OString; - - -struct TestImpl : public ImplHelper4< CA, DBA, FE, G > -{ - sal_Int32 nRef; - - virtual ~TestImpl() - { OSL_TRACE( "> TestImpl dtor called... <\n" ); } - - virtual Any SAL_CALL queryInterface( const Type & rType ) throw(RuntimeException) - { return ImplHelper4< CA, DBA, FE, G >::queryInterface( rType ); } - virtual void SAL_CALL acquire( ) throw() - { ++nRef; } - virtual void SAL_CALL release( ) throw() - { if (! --nRef) delete this; } - - // A - virtual OUString SAL_CALL a() throw(RuntimeException) - { return OUString("a"); } - // BA - virtual OUString SAL_CALL ba() throw(RuntimeException) - { return OUString("ba"); } - // CA - virtual OUString SAL_CALL ca() throw(RuntimeException) - { return OUString("ca"); } - // DBA - virtual OUString SAL_CALL dba() throw(RuntimeException) - { return OUString("dba"); } - // E - virtual OUString SAL_CALL e() throw(RuntimeException) - { return OUString("e"); } - // FE - virtual OUString SAL_CALL fe() throw(RuntimeException) - { return OUString("fe"); } - // G - virtual OUString SAL_CALL g() throw(RuntimeException) - { return OUString("g"); } -}; - - -struct TestWeakAggImpl : public WeakAggImplHelper4< CA, DBA, FE, G > -{ - virtual ~TestWeakAggImpl() - { OSL_TRACE( "> TestWeakAggImpl dtor called... <\n" ); } - - // A - virtual OUString SAL_CALL a() throw(RuntimeException) - { return OUString("a"); } - // BA - virtual OUString SAL_CALL ba() throw(RuntimeException) - { return OUString("ba"); } - // CA - virtual OUString SAL_CALL ca() throw(RuntimeException) - { return OUString("ca"); } - // DBA - virtual OUString SAL_CALL dba() throw(RuntimeException) - { return OUString("dba"); } - // E - virtual OUString SAL_CALL e() throw(RuntimeException) - { return OUString("e"); } - // FE - virtual OUString SAL_CALL fe() throw(RuntimeException) - { return OUString("fe"); } - // G - virtual OUString SAL_CALL g() throw(RuntimeException) - { return OUString("g"); } -}; - - -struct TestWeakImpl : public WeakImplHelper4< CA, DBA, FE, G > -{ - TestWeakImpl() {} - - virtual ~TestWeakImpl() - { OSL_TRACE( "> TestWeakImpl dtor called... <\n" ); } - - // A - virtual OUString SAL_CALL a() throw(RuntimeException) - { return OUString("a"); } - // BA - virtual OUString SAL_CALL ba() throw(RuntimeException) - { return OUString("ba"); } - // CA - virtual OUString SAL_CALL ca() throw(RuntimeException) - { return OUString("ca"); } - // DBA - virtual OUString SAL_CALL dba() throw(RuntimeException) - { return OUString("dba"); } - // E - virtual OUString SAL_CALL e() throw(RuntimeException) - { return OUString("e"); } - // FE - virtual OUString SAL_CALL fe() throw(RuntimeException) - { return OUString("fe"); } - // G - virtual OUString SAL_CALL g() throw(RuntimeException) - { return OUString("g"); } - -protected: - explicit TestWeakImpl(int) {} - - TestWeakImpl(int, int) {} - - TestWeakImpl(int, int, int) {} - - TestWeakImpl(int, int, int, int) {} - - TestWeakImpl(int, int, int, int, int) {} - - TestWeakImpl(int, int, int, int, int, int, int = 0) {} -}; - - -struct TestWeakComponentImpl : public WeakComponentImplHelper4< CA, DBA, FE, G > -{ - Mutex m; - TestWeakComponentImpl() - : WeakComponentImplHelper4< CA, DBA, FE, G >( m ) - {} - virtual ~TestWeakComponentImpl() - { OSL_TRACE( "> TestWeakComponentImpl dtor called... <\n" ); } - - void SAL_CALL disposing() - { OSL_TRACE( "> TestWeakComponentImpl disposing called... <\n" ); } - - // A - virtual OUString SAL_CALL a() throw(RuntimeException) - { return OUString("a"); } - // BA - virtual OUString SAL_CALL ba() throw(RuntimeException) - { return OUString("ba"); } - // CA - virtual OUString SAL_CALL ca() throw(RuntimeException) - { return OUString("ca"); } - // DBA - virtual OUString SAL_CALL dba() throw(RuntimeException) - { return OUString("dba"); } - // E - virtual OUString SAL_CALL e() throw(RuntimeException) - { return OUString("e"); } - // FE - virtual OUString SAL_CALL fe() throw(RuntimeException) - { return OUString("fe"); } - // G - virtual OUString SAL_CALL g() throw(RuntimeException) - { return OUString("g"); } -}; - - -struct TestWeakAggComponentImpl : public WeakAggComponentImplHelper4< CA, DBA, FE, G > -{ - Mutex m; - TestWeakAggComponentImpl() - : WeakAggComponentImplHelper4< CA, DBA, FE, G >( m ) - {} - virtual ~TestWeakAggComponentImpl() - { OSL_TRACE( "> TestWeakAggComponentImpl dtor called... <\n" ); } - - void SAL_CALL disposing() - { OSL_TRACE( "> TestWeakAggComponentImpl disposing called... <\n" ); } - - // A - virtual OUString SAL_CALL a() throw(RuntimeException) - { return OUString("a"); } - // BA - virtual OUString SAL_CALL ba() throw(RuntimeException) - { return OUString("ba"); } - // CA - virtual OUString SAL_CALL ca() throw(RuntimeException) - { return OUString("ca"); } - // DBA - virtual OUString SAL_CALL dba() throw(RuntimeException) - { return OUString("dba"); } - // E - virtual OUString SAL_CALL e() throw(RuntimeException) - { return OUString("e"); } - // FE - virtual OUString SAL_CALL fe() throw(RuntimeException) - { return OUString("fe"); } - // G - virtual OUString SAL_CALL g() throw(RuntimeException) - { return OUString("g"); } -}; - - -struct TestImplInh : public ImplInheritanceHelper2< TestWeakImpl, H, I > -{ - TestImplInh() {} - - explicit TestImplInh(int): - ImplInheritanceHelper2< TestWeakImpl, H, I >(1) {} - - TestImplInh(int, int): - ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2) {} - - TestImplInh(int, int, int): - ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3) {} - - TestImplInh(int, int, int, int): - ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4) {} - - TestImplInh(int, int, int, int, int): - ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5) {} - - TestImplInh(int, int, int, int, int, int): - ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5, 6) {} - - virtual ~TestImplInh() - { OSL_TRACE( "> TestWeakImplInh dtor called... <\n" ); } - - // H - virtual OUString SAL_CALL h() throw(RuntimeException) - { return OUString("h"); } - // I - virtual OUString SAL_CALL i() throw(RuntimeException) - { return OUString("i"); } -}; - - -struct TestAggImplInh : public AggImplInheritanceHelper2< TestWeakAggImpl, H, I > -{ - virtual ~TestAggImplInh() - { OSL_TRACE( "> TestAggImplInh dtor called... <\n" ); } - - // H - virtual OUString SAL_CALL h() throw(RuntimeException) - { return OUString("h2"); } - // I - virtual OUString SAL_CALL i() throw(RuntimeException) - { return OUString("i2"); } -}; - - -static bool isIn( Sequence< Type > const & rTypes, char const * name ) -{ - OUString str( OUString::createFromAscii( name ) ); - Type const * pTypes = rTypes.getConstArray(); - for ( sal_Int32 nPos = rTypes.getLength(); nPos--; ) - { - if (pTypes[ nPos ].getTypeName().equals( str )) - return true; - } - return false; -} - - -static void dotest( const Reference< XInterface > & xOriginal ) -{ - Reference< lang::XTypeProvider > xTP( xOriginal, UNO_QUERY ); - Sequence< sal_Int8 > id( xTP->getImplementationId() ); - Sequence< Type > types( xTP->getTypes() ); - ::fprintf( stderr, "> supported types: " ); - long n = 0; - for ( ; n < types.getLength(); ++n ) - { - OString str( OUStringToOString( types[ n ].getTypeName(), RTL_TEXTENCODING_ASCII_US ) ); - ::fprintf( stderr, (n < (types.getLength()-1)) ? "%s, " : "%s; type-id=\n", str.getStr() ); - } - for ( n = 0; n < 16; ++n ) - { - ::fprintf( stderr, n < 15 ? "%x " : "%x \n", id[ n ] ); - } - - Reference< A > xa( xOriginal, UNO_QUERY ); - OSL_ENSURE( xa->a() == "a", "### A failed!" ); - Reference< BA > xba( xa, UNO_QUERY ); - OSL_ENSURE( xba->ba() == "ba", "### BA failed!" ); - OSL_ENSURE( xba->a() == "a", "### BA failed!" ); - Reference< CA > xca( xba, UNO_QUERY ); - OSL_ENSURE( xca->ca() == "ca", "### CA failed!" ); - OSL_ENSURE( xca->a() == "a", "### CA failed!" ); - Reference< DBA > xdba( xca, UNO_QUERY ); - OSL_ENSURE( xdba->dba() == "dba", "### DBA failed!" ); - OSL_ENSURE( xdba->ba() == "ba", "### DBA failed!" ); - OSL_ENSURE( xdba->a() == "a", "### DBA failed!" ); - Reference< E > xe( xdba, UNO_QUERY ); - OSL_ENSURE( xe->e() == "e", "### E failed!" ); - Reference< FE > xfe( xe, UNO_QUERY ); - OSL_ENSURE( xfe->fe() == "fe", "### FE failed!" ); - Reference< G > xg( xfe, UNO_QUERY ); - OSL_ENSURE( xg->g() == "g", "### G failed!" ); - OSL_ENSURE( xg->a() == "a", "### G failed!" ); - - // type provider - Reference< lang::XTypeProvider > xProv( xg, UNO_QUERY ); - Sequence< Type > aTypes( xProv->getTypes() ); - - // CA, DBA, FE, G, XTypeProvider - OSL_ASSERT( isIn( aTypes, "test.CA" ) ); - OSL_ASSERT( isIn( aTypes, "test.DBA" ) ); - OSL_ASSERT( isIn( aTypes, "test.FE") ); - OSL_ASSERT( isIn( aTypes, "test.G") ); - OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XTypeProvider") ); - - Reference< XWeak > xWeak( xg, UNO_QUERY ); - if (xWeak.is()) - { - OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XWeak") ); - } - Reference< lang::XComponent > xComp( xg, UNO_QUERY ); - if (xComp.is()) - { - OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XComponent") ); - } - - Reference< XAggregation > xAgg( xg, UNO_QUERY ); - if (xAgg.is()) - { - OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XAggregation") ); - } - Reference< H > xH( xg, UNO_QUERY ); - if (xH.is()) - { - OSL_ASSERT( isIn( aTypes, "test.H") ); - } - Reference< I > xI( xg, UNO_QUERY ); - if (xI.is()) - { - OSL_ASSERT( isIn( aTypes, "test.I") ); - } - - OSL_ENSURE( xg == xOriginal, "### root!" ); -} - -void rethrow() -{ - throw; -} - -void throw_one( - lang::IllegalAccessException exc ) -{ - try - { - throw exc; - } - catch (...) - { - rethrow(); - } -} - - -void test_ImplHelper( const Reference< lang::XMultiServiceFactory > & /*xSF*/ ) -{ - Reference< XInterface > xImpl( (lang::XTypeProvider *)new TestImpl() ); - Reference< lang::XTypeProvider > xTP1( xImpl, UNO_QUERY ); - Reference< XInterface > xWeakImpl( (OWeakObject *)new TestWeakImpl() ); - Reference< lang::XTypeProvider > xTP2( xWeakImpl, UNO_QUERY ); - Reference< XInterface > xWeakAggImpl( (OWeakObject *)new TestWeakAggImpl() ); - Reference< lang::XTypeProvider > xTP3( xWeakAggImpl, UNO_QUERY ); - Reference< XInterface > xWeakComponentImpl( (OWeakObject *)new TestWeakComponentImpl() ); - Reference< lang::XTypeProvider > xTP4( xWeakComponentImpl, UNO_QUERY ); - Reference< XInterface > xWeakAggComponentImpl( (OWeakObject *)new TestWeakAggComponentImpl() ); - Reference< lang::XTypeProvider > xTP5( xWeakAggComponentImpl, UNO_QUERY ); - - OSL_ASSERT( - xTP1->getImplementationId() != xTP2->getImplementationId() && - xTP1->getImplementationId() != xTP3->getImplementationId() && - xTP1->getImplementationId() != xTP4->getImplementationId() && - xTP1->getImplementationId() != xTP5->getImplementationId() && - xTP2->getImplementationId() != xTP3->getImplementationId() && - xTP2->getImplementationId() != xTP4->getImplementationId() && - xTP2->getImplementationId() != xTP5->getImplementationId() && - xTP3->getImplementationId() != xTP4->getImplementationId() && - xTP3->getImplementationId() != xTP5->getImplementationId() && - xTP4->getImplementationId() != xTP5->getImplementationId() ); - - - dotest( xImpl ); - dotest( xWeakImpl ); - dotest( xWeakAggImpl ); - dotest( xWeakComponentImpl ); - dotest( xWeakAggComponentImpl ); - - xWeakImpl = (OWeakObject *)new TestImplInh(); - Reference< lang::XTypeProvider > xTP6( xWeakImpl, UNO_QUERY ); - dotest( xWeakImpl ); - Reference< H > xH( xWeakImpl, UNO_QUERY ); - Reference< I > xI( xH, UNO_QUERY ); - OSL_ASSERT( xH->h() == "h" ); - OSL_ASSERT( xI->i() == "i" ); - - xWeakAggImpl = (OWeakObject *)new TestAggImplInh(); - Reference< lang::XTypeProvider > xTP7( xWeakAggImpl, UNO_QUERY ); - dotest( xWeakAggImpl ); - xH.set( xWeakAggImpl, UNO_QUERY ); - xI.set( xH, UNO_QUERY ); - OSL_ASSERT( xH->h() == "h2" ); - OSL_ASSERT( xI->i() == "i2" ); - - - OSL_ASSERT( - xTP6->getImplementationId() != xTP1->getImplementationId() && - xTP6->getImplementationId() != xTP2->getImplementationId() && - xTP6->getImplementationId() != xTP3->getImplementationId() && - xTP6->getImplementationId() != xTP4->getImplementationId() && - xTP6->getImplementationId() != xTP5->getImplementationId() && - xTP6->getImplementationId() != xTP7->getImplementationId() && - xTP7->getImplementationId() != xTP1->getImplementationId() && - xTP7->getImplementationId() != xTP2->getImplementationId() && - xTP7->getImplementationId() != xTP3->getImplementationId() && - xTP7->getImplementationId() != xTP4->getImplementationId() && - xTP7->getImplementationId() != xTP5->getImplementationId() ); - - - bool exc_succ = false; - lang::IllegalAccessException exc( - OUString("testtest"), - xWeakAggImpl ); - // exception helper tests - try - { - throw exc; - } - catch (Exception &) - { - Any a( getCaughtException() ); - OSL_ASSERT( a == exc ); - - try - { - throwException( a ); - } - catch (lang::IllegalAccessException & e) - { - OSL_ASSERT( exc.Message == e.Message && exc.Context == e.Context ); - - try - { - throw_one( exc ); - } - catch (Exception &) - { - Any a2( getCaughtException() ); - OSL_ASSERT( (a2 == a) && (a2 == exc) ); - - try - { - throw_one( exc ); - } - catch (lang::IllegalAccessException &) - { - Any a3( getCaughtException() ); - OSL_ASSERT( (a3 == a) && (a3 == a2) && (a3 == exc) ); - exc_succ = true; - } - } - } - } - OSL_ASSERT( exc_succ ); - - try - { - throwException( makeAny( RuntimeException( - OUString("runtime exc"), xImpl ) ) ); - } - catch (RuntimeException & rExc) - { - OSL_ENSURE( rExc.Message == "runtime exc" && rExc.Context == xImpl, "### unexpected exception content!" ); - try - { - throwException( makeAny( Exception( - OUString("exc"), rExc.Context ) ) ); - } - catch (lang::IllegalAccessException &) - { - OSL_FAIL( "### unexpected IllegalAccessException exception caught!" ); - } - catch (Exception & rExc2) - { - OSL_ENSURE( rExc2.Message == "exc" && rExc2.Context == xImpl, "### unexpected exception content!" ); - try - { - throwException( makeAny( lang::IllegalAccessException( - OUString("axxess exc"), rExc2.Context ) ) ); - } - catch (lang::IllegalAccessException & rExc3) - { - OSL_ENSURE( rExc3.Message == "axxess exc" && rExc3.Context == xImpl, "### unexpected exception content!" ); - return; - } - } - } - catch (...) - { - } - OSL_FAIL( "### exception test failed!" ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testlib/UNO.pm b/cppuhelper/test/testlib/UNO.pm deleted file mode 100644 index 245dc2073550..000000000000 --- a/cppuhelper/test/testlib/UNO.pm +++ /dev/null @@ -1,85 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# -package UNO; - -require 5.005_62; -use strict; -use warnings; - -require Exporter; -require DynaLoader; - -our @ISA = qw(Exporter DynaLoader); - -# Items to export into callers namespace by default. Note: do not export -# names by default without a very good reason. Use EXPORT_OK instead. -# Do not simply export all your public functions/methods/constants. - -# This allows declaration use UNO ':all'; -# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK -# will save memory. -our %EXPORT_TAGS = ( 'all' => [ qw( - -) ] ); - -our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); - -our @EXPORT = qw( - -); -our $VERSION = '0.01'; - -bootstrap UNO $VERSION; - -# Preloaded methods go here. - -1; -__END__ -# Below is stub documentation for your module. You better edit it! - -=head1 NAME - -UNO - Perl extension for blah blah blah - -=head1 SYNOPSIS - - use UNO; - blah blah blah - -=head1 DESCRIPTION - -Stub documentation for UNO, created by h2xs. It looks like the -author of the extension was negligent enough to leave the stub -unedited. - -Blah blah blah. - -=head2 EXPORT - -None by default. - - -=head1 AUTHOR - -A. U. Thor, a.u.thor@a.galaxy.far.far.away - -=head1 SEE ALSO - -perl(1). - -=cut diff --git a/cppuhelper/test/testlib/defbootstrap.map b/cppuhelper/test/testlib/defbootstrap.map deleted file mode 100644 index 8ba8e105a184..000000000000 --- a/cppuhelper/test/testlib/defbootstrap.map +++ /dev/null @@ -1,26 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -UDK_3_0_0 { - global: - - boot_UNO; - - local: - *; -}; diff --git a/cppuhelper/test/testlib/defbootstrap_lib.cxx b/cppuhelper/test/testlib/defbootstrap_lib.cxx deleted file mode 100644 index 26d229f689d7..000000000000 --- a/cppuhelper/test/testlib/defbootstrap_lib.cxx +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "EXTERN.h" -#include "perl.h" -#include "XSUB.h" - -#include <cstdio> - -#include <osl/module.hxx> -#include <rtl/process.h> -#include <cppuhelper/bootstrap.hxx> - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - -using namespace ::cppu; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::uno; - -static sal_Bool tryService(const char * serviceName) -{ - // use micro deployment to create initial context - OUString libraryFileUrl; - ::osl::Module::getUrlFromAddress((void *)tryService, libraryFileUrl); - - OUString iniName = libraryFileUrl.copy(0, libraryFileUrl.lastIndexOf((sal_Unicode)'.')); // cut the library extension - iniName += SAL_CONFIGFILE(""); // add the rc file extension - - SAL_INFO("cppuhelper", "using ini: " << iniName); - - sal_Bool result = sal_True; - - try { - Reference<XComponentContext> xComponentContext = defaultBootstrap_InitialComponentContext(iniName); - Reference<XMultiServiceFactory> smgr(xComponentContext->getServiceManager(), UNO_QUERY); - - OUString arg = OUString::createFromAscii(serviceName); - Reference<XInterface> xInterface = smgr->createInstance(arg); - - SAL_INFO("cppuhelper", "got the " << serviceName << " service " << xInterface.get()); - result = result && (xInterface.get() != 0); - } - catch(Exception & exception) { - OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US); - - fprintf(stderr, "an exception occurred: %s\n", message.getStr()); - } - - SAL_INFO("cppuhelper", "---------------------------------- " << result); - - return result; -} - -XS(XS_UNO_tryService) -{ - dXSARGS; - if (items != 1) - Perl_croak(aTHX_ "Usage: UNO::tryService(input)"); - { - const char * input = (const char *)SvPV(ST(0),PL_na); - int RETVAL; - dXSTARG; - - RETVAL = tryService(input); - XSprePUSH; PUSHi((IV)RETVAL); - } - XSRETURN(1); -} - -extern "C" { -XS(boot_UNO) -{ - dXSARGS; - char* file = __FILE__; - -/* XS_VERSION_BOOTCHECK ;*/ - - newXS("UNO::tryService", XS_UNO_tryService, file); - XSRETURN_YES; -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testlib/makefile.mk b/cppuhelper/test/testlib/makefile.mk deleted file mode 100644 index cbf30f08d323..000000000000 --- a/cppuhelper/test/testlib/makefile.mk +++ /dev/null @@ -1,92 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -LINKFLAGSDEFS="" - -PRJ=..$/.. - -PRJNAME=cppuhelper -TARGET=defbootstrap -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -PERLINST1:=$(shell @+$(PERL) -V:installarchlib) -PERLINST2:=$(subst,installarchlib=, $(PERLINST1)) -PERLINST3:=$(PERLINST2:s/'//) -PERLINST :=$(PERLINST3:s/;//) - -PERLLIBS:=$(PERLINST)$/CORE -PERLINCS:=$(PERLINST)$/CORE - -CFLAGS += -I$(PERLINCS) - -.IF "$(OS)"=="WNT" -PERLLIB=perl58.lib - -LIB!:=$(LIB);$(PERLLIBS) -.EXPORT : LIB - -.ENDIF - -# --- Files -------------------------------------------------------- - -SLOFILES= $(SLO)$/defbootstrap_lib.obj - -SHL1TARGET=$(TARGET) - -SHL1STDLIBS= \ - $(PERLLIB) \ - $(CPPUHELPERLIB) \ - $(CPPULIB) \ - $(SALLIB) - -SHL1DEPN= -SHL1IMPLIB=i$(TARGET) -SHL1LIBS=$(SLB)$/$(TARGET).lib -SHL1DEF=$(MISC)$/$(SHL1TARGET).def - -DEF1NAME=$(SHL1TARGET) -SHL1VERSIONMAP=defbootstrap.map - - -.IF "$(OS)"=="WNT" -UNODLL=$(DLLDEST)$/UNO.dll -.ELSE -UNODLL=$(DLLDEST)$/UNO.so -.ENDIF - -# --- Targets ------------------------------------------------------ - -.IF "$(depend)" == "" -ALL: \ - ALLTAR \ - $(UNODLL) \ - $(BIN)$/UNO.pm -.ENDIF - -$(BIN)$/UNO.pm: UNO.pm - cp UNO.pm $@ - -$(UNODLL): $(SHL1TARGETN) - cp $(SHL1TARGETN) $@ - -.INCLUDE : target.mk - diff --git a/cppuhelper/test/testpropshlp.cxx b/cppuhelper/test/testpropshlp.cxx deleted file mode 100644 index bde76c7dca67..000000000000 --- a/cppuhelper/test/testpropshlp.cxx +++ /dev/null @@ -1,1162 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0 -# undef OSL_DEBUG_LEVEL -# define OSL_DEBUG_LEVEL 2 -#endif - - -#include <osl/mutex.hxx> -#include <osl/diagnose.h> - -#include <cppuhelper/propshlp.hxx> -#include <cppuhelper/weak.hxx> - -#include <cppuhelper/proptypehlp.hxx> - -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/beans/PropertyAttribute.hpp> - -#include <cppuhelper/implbase3.hxx> - -using namespace ::cppu; -using namespace ::osl; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::lang; - -static Property * getPropertyTable1() -{ - static Property *pTable = 0; - - if( ! pTable ) { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pTable ) { - static Property aTable[] = - { - Property( OUString("a"), 0, cppu::UnoType<OUString>::get() , - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //OUString - Property( OUString("b"), 1, cppu::UnoType<cppu::UnoCharType>::get() , - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //Char - Property( OUString("c"), 2, cppu::UnoType<sal_Int32>::get(), - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //sal_Int32 - Property( OUString("d"), 5, cppu::UnoType<double>::get() , - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //double - Property( OUString("e"), 7, cppu::UnoType<bool>::get(), - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //BOOL - Property( OUString("f"), 8, cppu::UnoType<Any>::get() , - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) //Any - }; - pTable = aTable; - } - } - return pTable; -} - - -static Property * getPropertyTable2() -{ - static Property *pTable = 0; - - if( ! pTable ) { - MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); - if( ! pTable ) { - static Property aTable[] = - { - Property( OUString("f"), 8, cppu::UnoType<Any>::get() , - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Any - Property( OUString("b"), 1, cppu::UnoType<cppu::UnoCharType>::get(), - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char - Property( OUString("a"), 0, cppu::UnoType<OUString>::get(), - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString - Property( OUString("d"), 5, cppu::UnoType<double>::get() , - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Double - Property( OUString("c"), 2, cppu::UnoType<sal_Int32>::get(), - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // sal_Int32 - Property( OUString("e"), 7, cppu::UnoType<bool>::get(), - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Bool - }; - pTable = aTable; - } - } - return pTable; -} - -static Property * getPropertyTable3() -{ - static Property *pTable = 0; - - if( ! pTable ) { - MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); - if( ! pTable ) { - static Property aTable[] = - { - Property( OUString("b"), 1, cppu::UnoType<cppu::UnoCharType>::get(), - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char - Property( OUString("f"), 8, cppu::UnoType<Any>::get() , - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // any - Property( OUString("a"), 0, cppu::UnoType<OUString>::get(), - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // OUString - }; - pTable = aTable; - } - } - return pTable; -} - - -static Property * getPropertyTable4() -{ - static Property *pTable = 0; - - if( ! pTable ) { - MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); - if( ! pTable ) { - static Property aTable[] = - { - Property( OUString("a"), 0, cppu::UnoType<OUString>::get(), - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString - Property( OUString("b"), 1, cppu::UnoType<cppu::UnoCharType>::get(), - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char - Property( OUString("f"), 2, cppu::UnoType<Any>::get() , - PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Any - }; - pTable = aTable; - } - } - return pTable; -} - - -/********************** -* -* Note : all Property names must be in the 127 ASCII subset ! -* -**********************/ - - -void test_PropertyArrayHelper() -{ - // Test getProperties() and getCount() - { - OPropertyArrayHelper a1( getPropertyTable1(), 6 ); - OSL_ENSURE( 6 == a1.getCount(), "not all properties inserted" ); - Sequence< Property > aProps = a1.getProperties(); - Property * pP = aProps.getArray(); - OSL_ENSURE( 6 == aProps.getLength(), "getProperties() gives not all properties" ); - for( int i = 0; i < 6; i++ ) - { - OSL_ENSURE( pP[i].Name == getPropertyTable1()[i].Name , "Name not correct" ); - OSL_ENSURE( pP[i].Handle == getPropertyTable1()[i].Handle, "Handle not correct" ); - OSL_ENSURE( pP[i].Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" ); - OSL_ENSURE( pP[i].Type == getPropertyTable1()[i].Type, "Type not correct" ); - } - } - - // Test sorting - { - OPropertyArrayHelper a1( getPropertyTable2(), 6, sal_False ); - Sequence< Property > aProps = a1.getProperties(); - Property * pP = aProps.getArray(); - OSL_ENSURE( 6 == aProps.getLength(), "getProperties() gives not all properties" ); - - // table to switch to sorted - int a[] = { 2 , 1 , 4, 3, 5, 0 }; - for( int i = 0; i < 6; i++ ) - { - OSL_ENSURE( pP[i].Name == getPropertyTable2()[a[i]].Name , "Name not correct" ); - OSL_ENSURE( pP[i].Handle == getPropertyTable2()[a[i]].Handle, "Handle not correct" ); - OSL_ENSURE( pP[i].Attributes == getPropertyTable2()[a[i]].Attributes, "Attributes not correct" ); - OSL_ENSURE( pP[i].Type == getPropertyTable2()[a[i]].Type, "Type not correct" ); - } - } - - // Test sorting - { - OPropertyArrayHelper a1( getPropertyTable3(), 3, sal_False ); - Sequence< Property > aProps = a1.getProperties(); - Property * pP = aProps.getArray(); - OSL_ENSURE( 3 == aProps.getLength(), "getProperties() gives not all properties" ); - // table to switch to sorted - int a[] = { 2 , 0 , 1 }; - for( int i = 0; i < 3; i++ ) - { - OSL_ENSURE( pP[i].Name == getPropertyTable3()[a[i]].Name , "Name not correct" ); - OSL_ENSURE( pP[i].Handle == getPropertyTable3()[a[i]].Handle, "Handle not correct" ); - OSL_ENSURE( pP[i].Attributes == getPropertyTable3()[a[i]].Attributes, "Attributes not correct" ); - OSL_ENSURE( pP[i].Type == getPropertyTable3()[a[i]].Type, "Type not correct" ); - } - } - - // Test getPropertyByName and hasPropertyByName - { - OPropertyArrayHelper a1( getPropertyTable1(), 6 ); - for( int i = 0; i < 6; i++ ) - { - OSL_ENSURE( a1.hasPropertyByName( getPropertyTable1()[i].Name ), "hasPropertyByName not correct" ); - Property aP = a1.getPropertyByName( getPropertyTable1()[i].Name ); - OSL_ENSURE( aP.Name == getPropertyTable1()[i].Name , "Name not correct" ); - OSL_ENSURE( aP.Handle == getPropertyTable1()[i].Handle, "Handle not correct" ); - OSL_ENSURE( aP.Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" ); - OSL_ENSURE( aP.Type == getPropertyTable1()[i].Type, "Type not correct" ); - } - - OSL_ENSURE( !a1.hasPropertyByName("never exist"), "hasPropertyByName not correct" ); - try - { - a1.getPropertyByName( OUString("never exist") ); - OSL_FAIL( "exception not thrown" ); - } - catch( UnknownPropertyException & ) - { - } - } - - // Test getHandleByName - { - OPropertyArrayHelper a1( getPropertyTable1(), 6 ); - for( int i = 0; i < 6; i++ ) - { - sal_Int32 Handle = a1.getHandleByName( getPropertyTable1()[i].Name ); - OSL_ENSURE( Handle == getPropertyTable1()[i].Handle, "Handle not correct" ); - } - sal_Int32 Handle = a1.getHandleByName( OUString("asdaf") ); - OSL_ENSURE( Handle == -1, "Handle not correct" ); - } - - // Test fillPropertyMembersByHandle - { - OPropertyArrayHelper a1( getPropertyTable1(), 6 ); - int i; - for( i = 0; i < 6; i++ ) - { - sal_Int16 nAttributes; - OUString aPropName; - sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable1()[i].Handle ); - OSL_ENSURE( b, "fillPropertyMembersByHandle: handle not found" ); - OSL_ENSURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" ); - OSL_ENSURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" ); - } - OSL_ENSURE( !a1.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" ); - // optimized table - OPropertyArrayHelper a4( getPropertyTable4(), 3 ); - for( i = 0; i < 3; i++ ) - { - sal_Int16 nAttributes; - OUString aPropName; - sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable4()[i].Handle ); - OSL_ENSURE( b, "fillPropertyMembersByHandle: handle not found" ); - OSL_ENSURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" ); - OSL_ENSURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" ); - } - OSL_ENSURE( !a4.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" ); - } - - // Test fillHandles - { - OPropertyArrayHelper a1( getPropertyTable1(), 6 ); - Sequence< OUString > aS( 4 ); - sal_Int32 Handles[4]; - // muss sortiert sein - aS[0] = "a"; - aS[1] = "d"; - aS[2] = "f"; - aS[3] = "t"; - sal_Int32 nHitCount = a1.fillHandles( Handles, aS ); - OSL_ENSURE( nHitCount == 3, "wrong number of hits " ); - OSL_ENSURE( Handles[0] == getPropertyTable1()[0].Handle, "Handle not correct" ); - OSL_ENSURE( Handles[1] == getPropertyTable1()[3].Handle, "Handle not correct" ); - OSL_ENSURE( Handles[2] == getPropertyTable1()[5].Handle, "Handle not correct" ); - OSL_ENSURE( Handles[3] == -1, "Handle not correct" ); - } -} - - -// test_OPropertySetHelper - -struct MutexContainer -{ - Mutex aMutex; -}; -class test_OPropertySetHelper : - public MutexContainer, - public OBroadcastHelper , - public OPropertySetHelper, - public OWeakObject -{ -public: - - test_OPropertySetHelper( Property * p, sal_Int32 n ) - : MutexContainer() - , OBroadcastHelper( ((MutexContainer *)this)->aMutex ) -// , OPropertySetHelper( *(static_cast< OBroadcastHelper * >(this))) - // MSCI 4 bug ! : - // OBroadcastHelper == OBroadcastHelperVar<OMultiTypeInterfaceContainerHelper> - , OPropertySetHelper( - *(static_cast< OBroadcastHelper * >(this))) - , bBOOL( sal_False ) - , nINT16( 0 ) - , nINT32( 0 ) - , pBasicProps( p ) - , nPropCount( n ) - { - } - - - ~test_OPropertySetHelper() - { - } - - void dispose() - { - // see comphlp.cxx - sal_Bool bDoDispose = sal_False; - { - MutexGuard aGuard( rBHelper.rMutex ); - if( !rBHelper.bDisposed && !rBHelper.bInDispose ) - { - rBHelper.bInDispose = sal_True; - bDoDispose = sal_True; - } - } - if( bDoDispose ) - { - disposing(); - EventObject aEvt; - aEvt.Source.set( (static_cast< OWeakObject * >(this)) ); - - rBHelper.aLC.disposeAndClear( aEvt ); - rBHelper.bDisposed = sal_True; - rBHelper.bInDispose = sal_False; - } - } - - // XInterface - Any SAL_CALL queryInterface( const css::uno::Type & rType ) throw(RuntimeException) - { - Any aRet( OPropertySetHelper::queryInterface( rType ) ); - return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); - } - void SAL_CALL acquire() throw() - { OWeakObject::acquire(); } - void SAL_CALL release() throw() - { OWeakObject::release(); } - - // XPropertySet - Reference < XPropertySetInfo > SAL_CALL getPropertySetInfo()throw(RuntimeException); - - using OPropertySetHelper::getFastPropertyValue; - - sal_Bool bBOOL; - sal_Int16 nINT16; - sal_Int32 nINT32; - Property * pBasicProps; - sal_Int32 nPropCount; -protected: - IPropertyArrayHelper & SAL_CALL getInfoHelper() throw(RuntimeException); - sal_Bool SAL_CALL convertFastPropertyValue( - Any & rConvertedValue, Any & rOldValue, - sal_Int32 nHandle, const Any& rValue ) - throw(IllegalArgumentException); - void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(RuntimeException); - void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw(RuntimeException); -}; - - -//------ The Properties of this implementation ------------------------- - -// Id must be the index into the array -#define PROPERTY_BOOL 0 -#define PROPERTY_INT16 1 -#define PROPERTY_INT32 2 - -// Max number of properties -#define PROPERTY_COUNT 4 -// Names of Properties -/** - * All Properties of this implementation. Must be sorted by name. - */ -Property * getBasicProps() -{ - static Property *pTable = 0; - - if( ! pTable ) { - MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); - if( ! pTable ) { - - static Property aBasicProps[PROPERTY_COUNT] = - { - Property( OUString("BOOL") , PROPERTY_BOOL , cppu::UnoType<bool>::get(), PropertyAttribute::READONLY ), - Property( OUString("INT16") , PROPERTY_INT16, - cppu::UnoType<sal_Int16>::get(), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ), - Property( OUString("INT32") , PROPERTY_INT32, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::BOUND ), - Property( OUString("TEST") , 55 , cppu::UnoType<sal_Int32>::get(), PropertyAttribute::BOUND ) - }; - pTable = aBasicProps; - } - } - return pTable; -} - - -// test_OPropertySetHelper_Listener - -class test_OPropertySetHelper_Listener - : public WeakImplHelper3< XPropertyChangeListener, XPropertiesChangeListener, XVetoableChangeListener > -{ -public: - sal_Int32 nDisposing; - Mutex aMutex; - Any * pExceptedListenerValues; - sal_Int32 nCount; - sal_Int32 nCurrent; - - test_OPropertySetHelper_Listener( Any * p = 0, sal_Int32 n = 0 ) - : nDisposing( 0 ) - , pExceptedListenerValues( p ) - , nCount( n ) - , nCurrent( 0 ) - { - } - ~test_OPropertySetHelper_Listener() - { - } - - sal_Int32 getRefCount() const - { return m_refCount; } - - // XEventListener - void SAL_CALL disposing(const EventObject& /*evt*/) throw ( RuntimeException) - { - MutexGuard aGuard( aMutex ); - nDisposing++; - } - - // XPropertyChangeListener - void SAL_CALL propertyChange(const PropertyChangeEvent& evt) throw (RuntimeException) - { - if( !pExceptedListenerValues ) - return; - MutexGuard aGuard( aMutex ); - OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" ); - - switch( evt.PropertyHandle ) - { - case PROPERTY_BOOL: - { - OSL_FAIL( "PropertySetHelper: BOOL cannot change" ); - OSL_ENSURE( evt.PropertyName == "BOOL", "PropertySetHelper: wrong name" ); - } - break; - - case PROPERTY_INT16: - { - OSL_ENSURE( evt.PropertyName == "INT16", "PropertySetHelper: wrong name" ); - - OSL_ENSURE( pExceptedListenerValues[nCurrent].getValueType().getTypeClass() == TypeClass_SHORT , - "PropertySetHelper: wrong data type" ); - - sal_Int16 nInt16(0), nOldInt16(0); - pExceptedListenerValues[nCurrent] >>= nInt16; - evt.OldValue >>= nOldInt16; - OSL_ENSURE( nInt16 == nOldInt16, "PropertySetHelper: wrong old value" ); - - - pExceptedListenerValues[nCurrent+1] >>= nInt16; - evt.NewValue >>= nOldInt16; - OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" ); - } - break; - - case PROPERTY_INT32: - { - OSL_ENSURE( evt.PropertyName == "INT32", "PropertySetHelper: wrong name" ); - - sal_Int32 nInt32(0),nOldInt32(0); - - pExceptedListenerValues[nCurrent] >>= nInt32; - evt.OldValue >>= nOldInt32; - OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" ); - - pExceptedListenerValues[nCurrent+1] >>= nInt32; - evt.NewValue >>= nOldInt32; - OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" ); - } - break; - - default: - OSL_FAIL( "XPropeSetHelper: invalid property handle" ); - } - nCurrent += 2; - } - - // XVetoableChangeListener - void SAL_CALL vetoableChange(const PropertyChangeEvent& evt) throw (PropertyVetoException, RuntimeException) - { - if( !pExceptedListenerValues ) - return; - MutexGuard aGuard( aMutex ); - OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" ); - - switch( evt.PropertyHandle ) - { - case PROPERTY_BOOL: - { - OSL_FAIL( "PropertySetHelper: BOOL cannot change" ); - OSL_ENSURE( evt.PropertyName == "BOOL", "PropertySetHelper: wrong name" ); - } - break; - - case PROPERTY_INT16: - { - OSL_ENSURE( evt.PropertyName == "INT16", "PropertySetHelper: wrong name" ); - - sal_Int16 nInt16(0), nOldInt16(0); - pExceptedListenerValues[nCurrent] >>= nInt16; - evt.OldValue >>= nOldInt16; - - OSL_ENSURE( nInt16 == nOldInt16,"PropertySetHelper: wrong old value" ); - - pExceptedListenerValues[nCurrent+1] >>= nInt16; - evt.NewValue >>= nOldInt16; - OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" ); - - if( nOldInt16 == 100 ) - { - nCurrent += 2; - throw PropertyVetoException(); - } - } - break; - - case PROPERTY_INT32: - { - OSL_ENSURE( evt.PropertyName == "INT32", "PropertySetHelper: wrong name" ); - - sal_Int32 nInt32(0),nOldInt32(0); - pExceptedListenerValues[nCurrent] >>= nInt32; - evt.OldValue >>= nOldInt32; - OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" ); - - pExceptedListenerValues[nCurrent+1] >>= nInt32; - evt.NewValue >>= nOldInt32; - OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" ); - } - break; - - default: - OSL_FAIL( "XPropeSetHelper: invalid property handle" ); - } - nCurrent += 2; - } - - // XPropertiesChangeListener - void SAL_CALL propertiesChange(const Sequence< PropertyChangeEvent >& evtSeq) throw (RuntimeException) - { - if( !pExceptedListenerValues ) - return; - MutexGuard aGuard( aMutex ); - for( sal_Int32 i = 0; i < evtSeq.getLength(); i++ ) - { - const PropertyChangeEvent & evt = evtSeq.getConstArray()[i]; - OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" ); - - switch( evt.PropertyHandle ) - { - case PROPERTY_BOOL: - { - OSL_FAIL( "PropertySetHelper: BOOL cannot change" ); - OSL_ENSURE( evt.PropertyName == "BOOL", "PropertySetHelper: wrong name" ); - } - break; - - case PROPERTY_INT16: - { - OSL_ENSURE( evt.PropertyName == "INT16", "PropertySetHelper: wrong name" ); - - sal_Int16 nInt16(0), nOldInt16(0); - pExceptedListenerValues[nCurrent] >>= nInt16; - evt.OldValue >>= nOldInt16; - OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong old value" ); - - - pExceptedListenerValues[nCurrent+1] >>= nInt16; - evt.NewValue >>= nOldInt16; - OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" ); - } - break; - - case PROPERTY_INT32: - { - OSL_ENSURE( evt.PropertyName == "INT32", "PropertySetHelper: wrong name" ); - - - sal_Int32 nInt32(0),nOldInt32(0); - pExceptedListenerValues[nCurrent] >>= nInt32; - evt.OldValue >>= nOldInt32; - OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" ); - - pExceptedListenerValues[nCurrent+1] >>= nInt32; - evt.NewValue >>= nOldInt32; - OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" ); - } - break; - - default: - OSL_FAIL( "XPropeSetHelper: invalid property handle" ); - } - nCurrent += 2; - } - } -}; - -/** - * Create a table that map names to index values. - */ -IPropertyArrayHelper & test_OPropertySetHelper::getInfoHelper() throw(RuntimeException) -{ - // no multi thread protection - static OPropertyArrayHelper aInfo( pBasicProps, nPropCount ); - return aInfo; -} - -// XPropertySet -Reference < XPropertySetInfo > test_OPropertySetHelper::getPropertySetInfo() - throw(RuntimeException) -{ - // no multi thread protection - static Reference < XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); - return xInfo; -} - -// Return sal_True, value changed -sal_Bool test_OPropertySetHelper::convertFastPropertyValue -( - Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue -)throw(IllegalArgumentException) -{ - switch( nHandle ) - { - case PROPERTY_BOOL: - { - sal_Bool b; - convertPropertyValue( b , rValue ); - if( b != bBOOL ) - { - - rConvertedValue.setValue( &b , cppu::UnoType<bool>::get() ); - rOldValue.setValue( & bBOOL , cppu::UnoType<bool>::get() ); - return sal_True; - } - else - return sal_False; - } - - case PROPERTY_INT16: - { - sal_Int16 n16; - convertPropertyValue( n16 , rValue ); - - if( n16 != nINT16 ) - { - rConvertedValue <<= n16; - rOldValue <<= nINT16; - return sal_True; - } - else - return sal_False; - } - - case PROPERTY_INT32: - { - sal_Int32 n32; - convertPropertyValue( n32 , rValue ); - if( n32 != nINT32 ) - { - rConvertedValue <<= n32; - rOldValue <<= nINT32; - return sal_True; - } - else - return sal_False; - } - - default: - OSL_ENSURE( nHandle == -1, "invalid property handle" ); - return sal_False; - } -} - -/** - * only set the value. - */ -void test_OPropertySetHelper::setFastPropertyValue_NoBroadcast -( - sal_Int32 nHandle, - const Any& rValue -)throw(RuntimeException) -{ - switch( nHandle ) - { - case PROPERTY_BOOL: - OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_BOOLEAN, "invalid type" ); - bBOOL = *((sal_Bool*)rValue.getValue()); - break; - - case PROPERTY_INT16: - OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_SHORT, "invalid type" ); - rValue >>= nINT16; - break; - - case PROPERTY_INT32: - OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_LONG, "invalid type" ); - rValue >>= nINT32; - break; - - default: - OSL_ENSURE( nHandle == -1, "invalid property handle" ); - } -} - - -void test_OPropertySetHelper::getFastPropertyValue( Any & rRet, sal_Int32 nHandle ) const - throw(RuntimeException) -{ - switch( nHandle ) - { - case PROPERTY_BOOL: - rRet.setValue( &bBOOL , cppu::UnoType<bool>::get() ); - break; - - case PROPERTY_INT16: - rRet <<= nINT16; - break; - - case PROPERTY_INT32: - rRet <<= nINT32; - break; - - default: - OSL_ENSURE( nHandle == -1, "invalid property handle" ); - } -} - - -void test_PropertySetHelper() -{ - test_PropertyArrayHelper(); - - test_OPropertySetHelper * pPS; - - Reference < XPropertySet > xPS; - Reference < XPropertyChangeListener > xPS_L; - test_OPropertySetHelper_Listener * pPS_L; - - Reference < XInterface > x; - - for( int z = 0; z < 2; z++ ) - { - // first test aBasicProps Handles are { 0, 1, 2, 55 } - // first test getBasicProps() Handles are { 0, 1, 2 } - xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z ); - xPS_L = static_cast< XPropertyChangeListener * >( pPS_L = new test_OPropertySetHelper_Listener() ); - - // Test queryInterface - Reference < XPropertySet > rProp( xPS , UNO_QUERY ); - OSL_ENSURE( rProp.is() , "PropertySetHelper: XPropertySet nor supported" ); - - Reference < XMultiPropertySet > rMulti( xPS , UNO_QUERY ); - OSL_ENSURE( rMulti.is() , "PropertySetHelper: XMultiPropertySet nor supported" ); - - Reference < XFastPropertySet > rFast( xPS , UNO_QUERY ); - OSL_ENSURE( rFast.is() , "PropertySetHelper: XFastPropertySet nor supported" ); - - x.clear(); - - // Test add-remove listener - { - Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY ); - Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY ); - - xPS->addPropertyChangeListener( OUString("INT16"), xPS_L ); - Sequence<OUString> szPN( 3 ); - szPN[0] = "BOOL"; - szPN[1] = "INT32"; - szPN[2] = "Does not exist"; // must ne ignored by the addPropertiesChangeListener method - pPS->addPropertiesChangeListener( szPN, x1 ); - - szPN = Sequence<OUString>(); - pPS->addPropertiesChangeListener( szPN, x1 ); - pPS->addVetoableChangeListener( OUString("INT16"), x2 ); - - xPS->removePropertyChangeListener( OUString("INT16"), xPS_L ); - pPS->removePropertiesChangeListener( x1 ); - pPS->removePropertiesChangeListener( x1 ); - pPS->removeVetoableChangeListener( OUString("INT16"), x2 ); - - // this exception must thrown - try - { - xPS->addPropertyChangeListener( OUString("Does not exist"), xPS_L ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( UnknownPropertyException & /*e*/ ) - { - - } - - try - { - xPS->addVetoableChangeListener( OUString("Does not exist"), x2 ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( UnknownPropertyException & /*e*/ ) - { - - } - - } - OSL_ENSURE( pPS_L->getRefCount() == 1, "PropertySetHelper: wrong reference count" ); - - // Test disposing - { - Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY ); - Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY ); - - xPS->addPropertyChangeListener( OUString("INT16"), xPS_L ); - Sequence<OUString> szPN( 2 ); - szPN[0] = "BOOL"; - szPN[1] = "INT32"; - pPS->addPropertiesChangeListener( szPN, x1 ); - szPN = Sequence<OUString>(); - pPS->addPropertiesChangeListener( szPN, x1 ); - pPS->addVetoableChangeListener( OUString("INT16"), x2 ); - pPS->dispose(); - } - OSL_ENSURE( pPS_L->nDisposing == 4 , "PropertySetHelper: wrong disposing count" ); - OSL_ENSURE( pPS_L->getRefCount() == 1 , "PropertySetHelper: wrong reference count" ); - pPS_L->nDisposing = 0; - xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z ); - - // Test set- and get- (Fast) propertyValue - { - // set read only property - try - { - // Readonly raises a vetoable exception - sal_Bool b = sal_True; - Any aBool; - aBool.setValue( &b , cppu::UnoType<bool>::get() ); - xPS->setPropertyValue("BOOL", aBool ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( PropertyVetoException & /*e*/ ) - { - } - - try - { - // Readonly raises a vetoable exception - sal_Bool b = sal_True; - Any aBool; - aBool.setValue( &b , cppu::UnoType<bool>::get() ); - // BOOL i s0 - pPS->setFastPropertyValue( PROPERTY_BOOL, aBool ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( PropertyVetoException & /*e*/ ) - { - } - - // set unknown property - try - { - sal_Bool b = sal_True; - Any aBool; - aBool.setValue( &b , cppu::UnoType<bool>::get() ); - xPS->setPropertyValue("Does not exist", aBool ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( UnknownPropertyException & /*e*/ ) - { - } - - try - { - sal_Bool b = sal_True; - Any aBool; - aBool.setValue( &b , cppu::UnoType<bool>::get() ); - pPS->setFastPropertyValue( 3, aBool ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( UnknownPropertyException & /*e*/ ) - { - } - - // get unknown property - try - { - Any aBool; - aBool = xPS->getPropertyValue("Does not exist"); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( UnknownPropertyException & /*e*/ ) - { - } - - try - { - Any aBool; - aBool = ((XFastPropertySet *)pPS)->getFastPropertyValue( 3 ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( UnknownPropertyException & /*e*/ ) - { - } - - // set property with invalid type - try - { - Any aBool; - xPS->setPropertyValue("INT32", aBool ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( IllegalArgumentException & /*e*/ ) - { - } - - try - { - Any aBool; - pPS->setFastPropertyValue( PROPERTY_INT32, aBool ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( IllegalArgumentException & /*e*/ ) - { - } - - // narrowing conversion is not allowed! - try - { - Any aINT32; - aINT32 <<= (sal_Int32 ) 16; - xPS->setPropertyValue("INT16", aINT32 ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( IllegalArgumentException & /*e*/ ) - { - } - - - try - { - Any aINT32; - aINT32 <<= (sal_Int32) 16; - pPS->setFastPropertyValue( PROPERTY_INT16, aINT32 ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( IllegalArgumentException & /*e*/ ) - { - } - - - Any aValue; - aValue = xPS->getPropertyValue("BOOL"); - sal_Bool b = *( (sal_Bool*)aValue.getValue()); - OSL_ENSURE( ! b, "PropertySetHelper: wrong BOOL value" ); - aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_BOOL ); - - b = *((sal_Bool*)aValue.getValue()); - OSL_ENSURE( !b, "PropertySetHelper: wrong BOOL value" ); - - sal_Int16 n16(0); - aValue <<=(sal_Int16)22; - xPS->setPropertyValue("INT16", aValue ); - aValue = xPS->getPropertyValue("INT16"); - aValue >>= n16; - OSL_ENSURE( 22 == n16 , "PropertySetHelper: wrong INT16 value" ); - aValue <<= (sal_Int16)44; - ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue ); - - aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT16 ); - aValue >>= n16; - OSL_ENSURE( 44 == n16, "PropertySetHelper: wrong INT16 value" ); - - // widening conversion - aValue <<= (sal_Int16)55; - xPS->setPropertyValue("INT32", aValue ); - aValue = xPS->getPropertyValue("INT32"); - sal_Int32 n32(0); - aValue >>= n32; - OSL_ENSURE( 55 == n32 , "PropertySetHelper: wrong INT32 value" ); - aValue <<= (sal_Int16)66; - ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT32, aValue ); - aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT32 ); - aValue >>= n32; - OSL_ENSURE( 66 == n32, "PropertySetHelper: wrong INT32 value" ); - - Sequence< OUString >valueNames = Sequence<OUString>( 3 ); - valueNames[0] = "BOOL"; - valueNames[1] = "INT16"; - valueNames[2] = "INT32"; - Sequence< Any > aValues = pPS->getPropertyValues( valueNames ); - - b = *((sal_Bool*)aValues.getConstArray()[0].getValue()); - aValues.getConstArray()[1] >>= n16; - aValues.getConstArray()[2] >>= n32; - - OSL_ENSURE( !b, "PropertySetHelper: wrong BOOL value" ); - OSL_ENSURE( 44 == n16, "PropertySetHelper: wrong INT16 value" ); - OSL_ENSURE( 66 == n32, "PropertySetHelper: wrong INT32 value" ); - } - pPS->nINT32 = 0; - pPS->nINT16 = 0; - - // Test add-remove listener - { - Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY ); - - xPS->addPropertyChangeListener( OUString("INT16"), xPS_L ); - pPS->addVetoableChangeListener( OUString("INT16"), x2 ); - - pPS_L->nCount = 10; - Sequence< Any > aSeq( pPS_L->nCount ); - pPS_L->nCurrent = 0; - - pPS_L->pExceptedListenerValues = aSeq.getArray(); - - pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable - pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 22; // new value vetoable - pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound - pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound - pPS_L->pExceptedListenerValues[4] <<= (sal_Int16) 22; // old value vetoable - pPS_L->pExceptedListenerValues[5] <<= (sal_Int16) 44; // new value vetoable - pPS_L->pExceptedListenerValues[6] <<= (sal_Int16) 22; // old value bound - pPS_L->pExceptedListenerValues[7] <<= (sal_Int16) 44; // new value bound - pPS_L->pExceptedListenerValues[8] <<= (sal_Int16) 44; // old value vetoable - pPS_L->pExceptedListenerValues[9] <<= (sal_Int16) 100; // new value vetoable exception - - Any aValue; - aValue <<= (sal_Int16)22; - xPS->setPropertyValue("INT16", aValue ); - aValue <<= (sal_Int16) 44; - ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue ); - aValue <<= (sal_Int16)100;// exception - - try - { - ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch( PropertyVetoException & /*e*/ ) - { - } - - OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" ); - pPS->nINT32 = 0; - pPS->nINT16 = 0; - pPS_L->nCount = 0; - pPS_L->nCurrent = 0; - pPS_L->pExceptedListenerValues = NULL; - xPS->removePropertyChangeListener( OUString("INT16"), xPS_L ); - pPS->removeVetoableChangeListener( OUString("INT16"), x2 ); - } - - // Test multi property set listener - { - Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY ); - Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY ); - - pPS->addVetoableChangeListener( OUString("INT16") , x2 ); - Sequence<OUString> szPN( 4 ); - szPN[0] = "BOOL"; - szPN[1] = "INT32"; - szPN[2] = "Does not exist"; // must ne ignored by the addPropertiesChangeListener method - szPN[3] = "INT16"; - pPS->addPropertiesChangeListener( szPN, x1 ); - - pPS_L->nCount = 6; - Sequence< Any > aSeq( pPS_L->nCount ); - pPS_L->nCurrent = 0; - pPS_L->pExceptedListenerValues = aSeq.getArray(); - pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable - pPS_L->pExceptedListenerValues[1] <<= (sal_Int16 ) 22; // new value vetoable - // INT32 is not constrained - pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound - pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound - pPS_L->pExceptedListenerValues[4] <<= (sal_Int32) 0; // old value bound - pPS_L->pExceptedListenerValues[5] <<= (sal_Int32) 44; // new value bound - - szPN = Sequence<OUString>( 2 ); - szPN[0] = "INT16"; - szPN[1] = "INT32"; - Sequence< Any > aValues( 2 ); - aValues.getArray()[0] <<= (sal_Int16) 22; - aValues.getArray()[1] <<= (sal_Int16) 44; - pPS->setPropertyValues( szPN, aValues ); - OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" ); - - //firePropertiesChangeEvent - pPS->nINT16 = 8; - pPS->nINT32 = 5; - pPS_L->nCount = 4; - pPS_L->nCurrent = 0; - pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 8; // old value - pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 8; // new value - pPS_L->pExceptedListenerValues[2] <<= (sal_Int32) 5; // old value - pPS_L->pExceptedListenerValues[3] <<= (sal_Int32) 5; // new value - pPS->firePropertiesChangeEvent( szPN, pPS_L ); - OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" ); - - - //vetoable exception with multiple - szPN[0] = "INT16"; - szPN[1] = "INT16"; - pPS->nINT32 = 0; - pPS->nINT16 = 0; - pPS_L->nCount = 4; - pPS_L->nCurrent = 0; - pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable - pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 44; // new value vetoable - pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value vetoable - pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 100; // new value vetoable - - try - { - aValues.getArray()[0] <<= (sal_Int16)44; - aValues.getArray()[1] <<= (sal_Int16)100; - pPS->setPropertyValues( szPN, aValues ); - OSL_FAIL( "PropertySetHelper: exception not thrown" ); - } - catch ( PropertyVetoException & /*e*/ ) - { - } - - OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" ); - pPS->removePropertiesChangeListener( x1 ); - pPS->removeVetoableChangeListener( OUString("INT16"), x2 ); - } - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testproptyphlp.cxx b/cppuhelper/test/testproptyphlp.cxx deleted file mode 100644 index ad67617e7095..000000000000 --- a/cppuhelper/test/testproptyphlp.cxx +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <cppuhelper/proptypehlp.hxx> - -#include <com/sun/star/beans/Property.hpp> - -using namespace ::com::sun::star::uno; -using namespace ::cppu; - -void testPropertyTypeHelper() -{ - Any a; - - a <<= ( sal_Int8 ) 25; - - sal_Int32 i; - convertPropertyValue( i , a ); - OSL_ASSERT( 25 == i ); - - sal_Int16 i16; - convertPropertyValue( i16 , a ); - OSL_ASSERT( 25 == i16 ); - - sal_Int8 i8; - convertPropertyValue( i8 , a ); - OSL_ASSERT( 25 == i8 ); - - sal_uInt32 i32; - convertPropertyValue( i32 , a ); - OSL_ASSERT( 25 == i32 ); - - double d; - convertPropertyValue( d , a ); - OSL_ASSERT( 25. == d ); - - float f; - convertPropertyValue( f , a ); - OSL_ASSERT( 25. == f ); - - css::beans::Property prop; - - prop.Name = rtl::OUString("Huhu"); - prop.Handle = 5; - prop.Attributes = 3; - - a <<= prop; - - css::beans::Property prop2; - convertPropertyValue( prop2 , a ); - OSL_ASSERT( prop.Handle == prop2.Handle && prop.Name == prop2.Name && prop.Attributes == prop2.Attributes ); - - - ::rtl::OUString ow; - a <<= prop.Name; - convertPropertyValue( ow , a ); - OSL_ASSERT( ow == prop.Name ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |