diff options
Diffstat (limited to 'stoc/test/testsmgr_cpnt.cxx')
-rw-r--r-- | stoc/test/testsmgr_cpnt.cxx | 158 |
1 files changed, 20 insertions, 138 deletions
diff --git a/stoc/test/testsmgr_cpnt.cxx b/stoc/test/testsmgr_cpnt.cxx index 6df5a6c06..22b6a000e 100644 --- a/stoc/test/testsmgr_cpnt.cxx +++ b/stoc/test/testsmgr_cpnt.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -74,9 +75,12 @@ using namespace com::sun::star::registry; using namespace com::sun::star::lang; using namespace com::sun::star::container; using namespace osl; -using namespace rtl; using namespace cppu; +using ::rtl::OUString; +using ::rtl::OUStringToOString; +using ::rtl::OString; + Reference<XMultiServiceFactory> getProcessServiceManager() { @@ -85,7 +89,7 @@ Reference<XMultiServiceFactory> getProcessServiceManager() { MutexGuard aGuard( Mutex::getGlobalMutex() ); if (! s_x.is()) - s_x = createRegistryServiceFactory( OUString::createFromAscii( "stoctest.rdb" ), sal_False ); + s_x = createRegistryServiceFactory( OUString(RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb")), sal_False ); } return s_x; } @@ -149,7 +153,7 @@ Reference < XInterface > SAL_CALL Test_Manager_Impl_CreateInstance( // OUString Test_Manager_Impl::getImplementationName() throw() { - return OUString::createFromAscii(IMPLEMENTATION_NAME); + return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLEMENTATION_NAME)); } //************************************************************************* @@ -179,8 +183,8 @@ Sequence< OUString > Test_Manager_Impl::getSupportedServiceNames(void) throw () Sequence< OUString > Test_Manager_Impl::getSupportedServiceNames_Static(void) throw () { Sequence< OUString > aSNS( 2 ); - aSNS.getArray()[0] = OUString::createFromAscii(SERVICE_NAME); - aSNS.getArray()[1] = OUString::createFromAscii("com.sun.star.bridge.Bridge"); + aSNS.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICE_NAME)); + aSNS.getArray()[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.Bridge")); return aSNS; } @@ -217,7 +221,7 @@ extern "C" void SAL_CALL test_ServiceManager() Reference<XContentEnumerationAccess> xContEnum(xSMgr, UNO_QUERY); TEST_ENSHURE( xContEnum.is() , "query on XContentEnumerationAccess failed" ); - Reference<XEnumeration > xEnum(xContEnum->createContentEnumeration(OUString::createFromAscii("com.sun.star.registry.SimpleRegistry"))); + Reference<XEnumeration > xEnum(xContEnum->createContentEnumeration(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.SimpleRegistry")))); TEST_ENSHURE( xEnum.is() , "createContentEnumeration failed" ); sal_Int32 nLen = 0; while( xEnum->hasMoreElements() ) @@ -242,33 +246,33 @@ extern "C" void SAL_CALL test_ServiceManager() TEST_ENSHURE( nLen == 8, "more than 6 factories" ); // try to get an instance for a unknown service - TEST_ENSHURE( !xSMgr->createInstance(OUString::createFromAscii("bla.blup.Q")).is(), "unknown service provider found" ); + TEST_ENSHURE( !xSMgr->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("bla.blup.Q"))).is(), "unknown service provider found" ); // // First test : register service via the internal function of the component itself // { Reference< XImplementationRegistration > - xInst( xSMgr->createInstance(OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration")), UNO_QUERY ); + xInst( xSMgr->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.ImplementationRegistration"))), UNO_QUERY ); TEST_ENSHURE( xInst.is(), "no ImplementationRegistration" ); try { // register the services via writeComponentRegInfo (see at end of this file) - xInst->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), atUModule2, Reference< XSimpleRegistry >() ); + xInst->registerImplementation(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")), atUModule2, Reference< XSimpleRegistry >() ); } catch( CannotRegisterImplementationException e ) { TEST_ENSHURE( 0, "register implementation failed" ); } // getImplementations() check - Sequence<OUString> seqImpl = xInst->getImplementations(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), atUModule2); + Sequence<OUString> seqImpl = xInst->getImplementations(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary")), atUModule2); TEST_ENSHURE( seqImpl.getLength() == 1, "count of implementantions is wrong" ); - TEST_ENSHURE( seqImpl.getConstArray()[0] == OUString::createFromAscii("com.sun.star.DummyService.V10"), "implementation name is not equal" ); + TEST_ENSHURE( seqImpl.getConstArray()[0] == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.DummyService.V10")), "implementation name is not equal" ); // tests, if a service provider can be instantiated. - Reference< XInterface > xIFace(xSMgr->createInstance(OUString::createFromAscii("com.sun.star.ts.TestManagerImpl"))); + Reference< XInterface > xIFace(xSMgr->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ts.TestManagerImpl")))); TEST_ENSHURE( xIFace.is(), "loadable service not found" ); // remove the service @@ -276,129 +280,6 @@ extern "C" void SAL_CALL test_ServiceManager() "revoke implementation failed" ); } - -// Reference < XSimpleRegistry > xSReg( xSMgr->createInstance(OUString::createFromAscii("com::sun::star.uno.repos.SimpleRegistry")), UNO_QUERY ); -// TEST_ENSHURE( xSReg.is() , "Simple registry couldn't be instantiated" ); - -// xSReg->open(OUString::createFromAscii("dummy.reg"), sal_False, sal_True); -// xSReg->close(); - - // laut dbo : C-API muss nicht mehr unterstuezt werden - //TEST_ENSHURE( registerExternService(atModule, "dummy.reg"), "install failed" ); - //TEST_ENSHURE( deregisterExternService(atModule, "dummy.reg"), "deinstall failed" ); - - -// UNO_INTERFACE(XMultiServiceFactory) xUnoSMgr = {0,0}; -// smart2uno(xSMgr, xUnoSMgr); - -// TEST_ENSHURE(registerExternImplementation(xUnoSMgr, "com::sun::star.loader.SharedLibrary", atModule2, "dummy.reg"), "install failed" ); -// TEST_ENSHURE(revokeExternImplementation(xUnoSMgr, atModule2, "dummy.reg"), "deinstall failed" ); - -// TEST_ENSHURE(registerExternImplementation(xUnoSMgr, "com::sun::star.loader.SharedLibrary", atModule2, "dummy2.reg"), "install failed" ); - -//TODO : Java loader test -// String testUrl(getTestJarUrl()); -// TEST_ENSHURE(registerExternImplementation(xUnoSMgr, "com::sun::star.loader.Java", testUrl, "dummy.reg"), "install failed" ); -// TEST_ENSHURE(revokeExternImplementation(xUnoSMgr, testUrl, "dummy.reg"), "deinstall failed" ); - -// if (!UNO_isNull((UNO_Ifc*)&xUnoSMgr)) -// xUnoSMgr.m_pVmt->release(xUnoSMgr.m_pCtx); - -// xSReg->open(OUString::createFromAscii("dummy.reg"), sal_True, sal_False); -// TEST_ENSHURE(!xSReg->getRootKey()->openKey(OUString::createFromAscii("/SERVICES/com::sun::star/ts/TestManagerImpl/URL")).is(), -// "deinstall failed" ); - -// xSReg->close(); - -// xSReg->open(OUString::createFromAscii("dummy.reg"), sal_False, sal_False); -// xSReg->destroy(); -// xSReg->open(OUString::createFromAscii("dummy2.reg"), sal_False, sal_False); -// xSReg->destroy(); - - - // Test initialisieren -/* - XServiceProviderRef xSiSP1 = createSimpleServiceProvider( OUString::createFromAscii("com::sun::star.usr.Test_Manager_Impl1"), Test_Manager_Impl_getReflection ); - XServiceProviderRef xSiSP11 = createSimpleServiceProvider( OUString::createFromAscii("com::sun::star.usr.Test_Manager_Impl1"), Test_Manager_Impl_getReflection ); - XServiceProviderRef xSiSP2 = createSimpleServiceProvider( OUString::createFromAscii("com::sun::star.usr.Test_Manager_Impl2"), Test_Manager_Impl_getReflection ); -*/ -/* - // second test - // create XServiceProvider via createSingleFactory and write them directly into the registry - // For this is needed a sequence of supported servicenames and a createComponent function pointer - { - Reference< XServiceProvider > xSiSP1(createSingleFactory( - xSMgr, - OUString::createFromAscii("com::sun::star.usr.Test_Manager_Impl1), - Test_Manager_Impl_CreateInstance, - Test_Manager_Impl::getSupportedServiceNames_Static() ), UNO_QUERY); - Reference< XServiceProvider > xSiSP11(createSingleFactory( - xSMgr, - OUString::createFromAscii("com::sun::star.usr.Test_Manager_Impl1"), - Test_Manager_Impl_CreateInstance, - Test_Manager_Impl::getSupportedServiceNames_Static() ),UNO_QUERY); - Reference< XServiceProvider > xSiSP2(createSingleFactory( - xSMgr, - L"com::sun::star.usr.Test_Manager_Impl2", - Test_Manager_Impl_CreateInstance, - Test_Manager_Impl::getSupportedServiceNames_Static() ), UNO_QUERY); - - // put the service providers into the registry - xReg->registerServiceProvider( L"com::sun::star.test.TestManager1", xSiSP1 ); - xReg->registerServiceProvider( L"com::sun::star.test.TestManager1", xSiSP11 ); - xReg->registerServiceProvider( L"com::sun::star.test.TestManager2", xSiSP2 ); - - // TestManager1 - Reference< XServiceProvider > xProv = xSMgr->queryServiceProvider( L"com::sun::star.test.TestManager1"); - Reference< XSingleServiceFactory > xFact( xProv, UNO_QUERY ); - TEST_ENSHURE( xFact.is(), "Service com::sun::star.test.TestManager1 not found" ); - - Reference< XInterface > xTest1 = xFact->createInstance(); - TEST_ENSHURE( nInstanceCount == 1, "wrong service instanciated" ); - - // TestManager2 - xProv = xSMgr->queryServiceProvider( L"com::sun::star.test.TestManager2"); - xFact = Reference < XSingleServiceFactory > ( xProv , UNO_QUERY ); - TEST_ENSHURE( xFact.is(), "Service com::sun::star.test.TestManager2 not found" ); - - Reference < XInterface > xTest2 = xFact->createInstance(); - TEST_ENSHURE( nInstanceCount == 2, "wrong service instanciated" ); - - xTest1 = Reference< XInterface >(); - xTest2 = Reference< XInterface >(); - TEST_ENSHURE( nInstanceCount == 0, "wrong service deleted" ); - - Reference< XEnumeration > xEnum = xSMgr->createProviderEnumeration( L"com::sun::star.test.TestManager1"); - TEST_ENSHURE( xEnum.is() , "no provider enumeration" ); - - sal_Int32 nSPTestManagerImplLen2 = 0; - - while (xEnum.is() && xEnum->hasMoreElements()) - { - nSPTestManagerImplLen2++; - xEnum->nextElement(); - - } - TEST_ENSHURE( nSPTestManagerImplLen2 == 2, "queryServiceProviders() wrong length" ); - - sal_Int32 nCount = 0; - xEnum = xSMgr->createProviderEnumeration( L"com::sun::star.test.TestManager1"); - while (xEnum->hasMoreElements()) - { - Reference< XServiceProvider > xProv; - xEnum->nextElement() >>= xProv; - if (xProv == xSiSP1 || xProv == xSiSP11) - nCount++; - } - - TEST_ENSHURE( nCount == 2 , "not all com::sun::star.testimpl.TestManagerImpl registered" ); -*/ -/* - { - Reference< XMultiServiceFactory > xTestManager(createRegistryServiceManager(L"testmanager.rdb")); - TEST_ENSHURE( xTestManager.is(), "create Test ServiceManager failed!" ); - } -*/ Reference<XComponent> xComp(xSMgr, UNO_QUERY); xComp->dispose(); @@ -411,7 +292,7 @@ extern "C" void SAL_CALL test_ServiceManager() extern "C" { //================================================================================================== -void SAL_CALL component_getImplementationEnvironment( +SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) { *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; @@ -438,13 +319,13 @@ sal_Bool SAL_CALL component_writeInfo( } catch (InvalidRegistryException &) { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); + OSL_FAIL( "### InvalidRegistryException!" ); } } return sal_False; } //================================================================================================== -void * SAL_CALL component_getFactory( +SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) { void * pRet = 0; @@ -470,3 +351,4 @@ void * SAL_CALL component_getFactory( +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |