/* -*- 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 . */ //------------------------------------------------------ // testcomponent - Loads a service and its testcomponent from dlls performs a test. // Expands the dll-names depending on the actual environment. // Example : testcomponent stardiv.uno.io.Pipe stm // // Therefor the testcode must exist in teststm and the testservice must be named test.stardiv.uno.io.Pipe // #include #include #include #include #include #include using namespace ::rtl; using namespace ::cppu; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::test; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::registry; // Needed to switch on solaris threads #ifdef SOLARIS extern "C" void ChangeGlobalInit(); #endif int main (int argc, char **argv) { if( argc < 3) { printf( "usage : testcomponent service dll [additional dlls]\n" ); exit( 0 ); } #ifdef SOLARIS // switch on threads in solaris ChangeGlobalInit(); #endif // create service manager Reference< XMultiServiceFactory > xSMgr = createRegistryServiceFactory( OUString( "applicat.rdb") ); Reference < XImplementationRegistration > xReg; Reference < XSimpleRegistry > xSimpleReg; try { // Create registration service Reference < XInterface > x = xSMgr->createInstance( OUString("com.sun.star.registry.ImplementationRegistration") ); xReg = Reference< XImplementationRegistration > ( x , UNO_QUERY ); } catch (const Exception&) { printf( "Couldn't create ImplementationRegistration service\n" ); exit(1); } sal_Char szBuf[1024]; OString sTestName; try { // Load dll for the tested component for( int n = 2 ; n registerImplementation( OUString("com.sun.star.loader.SharedLibrary"), aDllName, xSimpleReg ); } } catch (const Exception &e) { printf( "Couldn't reach dll %s\n" , szBuf ); printf( "%s\n" , OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() ); exit(1); } try { // Load dll for the test component sTestName = "test"; sTestName += argv[2]; #ifdef SAL_W32 OUString aDllName = OStringToOUString( sTestName , RTL_TEXTENCODING_ASCII_US ); #else OUString aDllName = OUString( "lib"); aDllName += OStringToOUString( sTestName , RTL_TEXTENCODING_ASCII_US ); aDllName += ".so"; #endif xReg->registerImplementation( OUString("com.sun.star.loader.SharedLibrary") , aDllName, xSimpleReg ); } catch (const Exception&) { printf( "Couldn't reach dll %s\n" , szBuf ); exit(1); } // Instantiate test service sTestName = "test."; sTestName += argv[1]; Reference < XInterface > xIntTest = xSMgr->createInstance( OStringToOUString( sTestName , RTL_TEXTENCODING_ASCII_US ) ); Reference< XSimpleTest > xTest( xIntTest , UNO_QUERY ); if( ! xTest.is() ) { printf( "Couldn't instantiate test service \n" ); exit( 1 ); } sal_Int32 nHandle = 0; sal_Int32 nNewHandle; sal_Int32 nErrorCount = 0; sal_Int32 nWarningCount = 0; // loop until all test are performed while( nHandle != -1 ) { // Instantiate serivce Reference< XInterface > x = xSMgr->createInstance( OStringToOUString( argv[1] , RTL_TEXTENCODING_ASCII_US ) ); if( ! x.is() ) { printf( "Couldn't instantiate service !\n" ); exit( 1 ); } // do the test try { nNewHandle = xTest->test( OStringToOUString( argv[1] , RTL_TEXTENCODING_ASCII_US ) , x , nHandle ); } catch (const Exception &e) { OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ); printf( "testcomponent : uncaught exception %s\n" , o.getStr() ); exit(1); } catch (...) { printf( "testcomponent : uncaught unknown exception\n" ); exit(1); } // print errors and warning Sequence seqErrors = xTest->getErrors(); Sequence seqWarnings = xTest->getWarnings(); if( seqWarnings.getLength() > nWarningCount ) { printf( "Warnings during test %" SAL_PRIxUINT32 "!\n" , nHandle ); for( ; nWarningCount < seqWarnings.getLength() ; nWarningCount ++ ) { OString o = OUStringToOString( seqWarnings.getArray()[nWarningCount], RTL_TEXTENCODING_ASCII_US ); printf( "Warning\n%s\n---------\n" , o.getStr() ); } } if( seqErrors.getLength() > nErrorCount ) { printf( "Errors during test %" SAL_PRIxUINT32 "!\n" , nHandle ); for( ; nErrorCount < seqErrors.getLength() ; nErrorCount ++ ) { OString o = OUStringToOString( seqErrors.getArray()[nErrorCount], RTL_TEXTENCODING_ASCII_US ); printf( "%s\n" , o.getStr() ); } } nHandle = nNewHandle; } if( xTest->testPassed() ) { printf( "Test passed !\n" ); } else { printf( "Test failed !\n" ); } Reference rComp( xSMgr , UNO_QUERY ); rComp->dispose(); return 0; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ s LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2015-10-05optipng icon themesChristian Lohmaier
2015-06-17Restore lc_styleupdatebyexample.pngJan Holesovsky
2015-06-01tdf#88276: Add background colour toolbar and sidebar buttonsKatarina Behrens
2015-05-12tdf#68871: Remove the old Elements panel from MathJulien Nabet
2015-04-22Optimization of icon themes.Andrew
2015-03-18Icon files optimizedAndrew
2015-02-26tdf#30425 Remove old icons -2Andrew
2015-02-25ICONS: Fix icons in sifr and tango in CalcYousuf Philips
2015-02-24OXYGEN: Minor fixes to last commitYousuf Philips
2015-02-23Revert "tdf30425 Remove old icons -2"Adolfo Jayme Barrientos
2015-02-23tdf#30425 Remove old icons -2Andrew
2015-02-23OXYGEN: Added sidebar icons as well as add icons from the original setYousuf Philips
2015-02-16Remove old icons.Andrew
2015-02-10Remove duplicate L10n icons.Andrew
2015-02-06Tidy up HC icons.Andrew
2015-02-05Icon theme compressionAndrew
2015-01-30Delete useless “-old” copies of iconsAdolfo Jayme Barrientos
2014-12-03fdo#86472 fix icons on dark theme in oxygen and sifrYousuf Philips
2014-11-23icons: optipng the oxygen icons.Jan Holesovsky
2014-11-20TANGO: fix galaxy so print preview single page view icon showsYousuf Philips
2014-11-18OXYGEN: Replaced icons with icons from the icon set sourcesYousuf Philips
2014-11-12fdo#80651 replaced oxygen icon and added new tango icon for single pageYousuf Philips
2014-11-04line spacing: Introduce an icon for that.Jan Holesovsky
2014-11-04fdo#80161 Add an icon to the 'Export as PDF' commandYousuf Philips
2014-11-03OXYGEN: fixes to font color iconsYousuf Philips
2014-10-29OXYGEN: Refreshing icons from main source and added a few new onesYousuf Philips
2014-10-27fdo#85500 - TOOLBAR: Use insert page number icon for insert field controlYousuf Philips