diff options
author | Damjan Jovanovic <damjan@apache.org> | 2015-09-04 18:33:14 +0000 |
---|---|---|
committer | Damjan Jovanovic <damjan@apache.org> | 2015-09-04 18:33:14 +0000 |
commit | 06474710a5810a69c3a76be15dcda1b5d8789711 (patch) | |
tree | e587270510b0c8533897ffa65bf000bd4ec1a70c /sal | |
parent | 43fbebfbe5d14054c72486aed92f9702367406f8 (diff) |
#i125003# migrate main/sal/qa/osl/module from cppunit to Google Test.
Notes
Notes:
ignore: googletest
Diffstat (limited to 'sal')
-rw-r--r-- | sal/qa/osl/module/makefile.mk | 30 | ||||
-rw-r--r-- | sal/qa/osl/module/osl_Module.cxx | 440 | ||||
-rw-r--r-- | sal/qa/osl/module/osl_Module_Const.h | 1 | ||||
-rw-r--r-- | sal/qa/osl/module/osl_Module_DLL.cxx | 1 |
4 files changed, 205 insertions, 267 deletions
diff --git a/sal/qa/osl/module/makefile.mk b/sal/qa/osl/module/makefile.mk index 609db6d82e4d..78a510e805fd 100644 --- a/sal/qa/osl/module/makefile.mk +++ b/sal/qa/osl/module/makefile.mk @@ -32,6 +32,12 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk +.IF "$(ENABLE_UNIT_TESTS)" != "YES" +all: + @echo unit tests are disabled. Nothing to do. + +.ELSE + CFLAGS+= $(LFS_CFLAGS) CXXFLAGS+= $(LFS_CFLAGS) @@ -48,28 +54,28 @@ SHL1VERSIONMAP = export_dll.map # --- main l ------------------------------------------------------ -SHL2OBJS= $(SLO)$/osl_Module.obj - -SHL2TARGET= osl_Module -SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) +APP2OBJS= $(SLO)$/osl_Module.obj +APP2TARGET= osl_Module +APP2STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB) .IF "$(GUI)" == "WNT" -SHL2STDLIBS+=i$(SHL2TARGET).lib +APP2STDLIBS+=i$(SHL1TARGET).lib .ENDIF .IF "$(GUI)" == "UNX" -APP3STDLIBS+=-l$(SHL2TARGET) +APP2STDLIBS+=-l$(SHL1TARGET) .ENDIF -SHL2DEPN= $(SHL1OBJS) -SHL2IMPLIB= i$(SHL2TARGET) -SHL2DEF= $(MISC)$/$(SHL2TARGET).def +APP2DEPN= $(SHL1OBJS) +APP2TEST = enabled +#SHL2IMPLIB= i$(SHL2TARGET) +#SHL2DEF= $(MISC)$/$(SHL2TARGET).def -DEF2NAME =$(SHL2TARGET) -SHL2VERSIONMAP= $(PRJ)$/qa$/export.map +#DEF2NAME =$(SHL2TARGET) +#SHL2VERSIONMAP= $(PRJ)$/qa$/export.map # END ------------------------------------------------------------------ # --- Targets ------------------------------------------------------ .INCLUDE : target.mk -.INCLUDE : _cppunit.mk +.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES"
\ No newline at end of file diff --git a/sal/qa/osl/module/osl_Module.cxx b/sal/qa/osl/module/osl_Module.cxx index eba1ab2d4194..97a0f3ab6338 100644 --- a/sal/qa/osl/module/osl_Module.cxx +++ b/sal/qa/osl/module/osl_Module.cxx @@ -28,6 +28,7 @@ // include files //------------------------------------------------------------------------ #include <osl_Module_Const.h> +#include "gtest/gtest.h" using namespace osl; using namespace rtl; @@ -41,8 +42,8 @@ using namespace rtl; */ inline void printBool( sal_Bool bOk ) { - t_print("#printBool# " ); - ( sal_True == bOk ) ? t_print("TRUE!\n" ): t_print("FALSE!\n" ); + printf("#printBool# " ); + ( sal_True == bOk ) ? printf("TRUE!\n" ): printf("FALSE!\n" ); } /** print a UNI_CODE String. @@ -51,9 +52,9 @@ inline void printUString( const ::rtl::OUString & str ) { rtl::OString aString; - t_print("#printUString_u# " ); + printf("#printUString_u# " ); aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - t_print("%s\n", aString.getStr( ) ); + printf("%s\n", aString.getStr( ) ); } /** get dll file URL. @@ -68,9 +69,17 @@ inline ::rtl::OUString getDllURL( void ) ::rtl::OUString dirPath, dllPath; osl::Module::getUrlFromAddress( ( void* ) &getDllURL, dirPath ); + // file:///aoo/main/sal/unx/bin/osl_Module + dirPath = dirPath.copy( 0, dirPath.lastIndexOf('/')); + // file:///aoo/main/sal/unx/bin dirPath = dirPath.copy( 0, dirPath.lastIndexOf('/') + 1); + // file:///aoo/main/sal/unx/ + dirPath = dirPath + rtl::OUString::createFromAscii( "lib/" ); + // file:///aoo/main/sal/unx/lib/ osl::FileBase::getAbsoluteFileURL( dirPath, libPath, dllPath ); +rtl::OString aOString = ::rtl::OUStringToOString (dllPath, RTL_TEXTENCODING_UTF8); +printf("getDllURL() returning %s\n", aOString.getStr()); return dllPath; } @@ -80,9 +89,9 @@ inline void printFileName( const ::rtl::OUString & str ) { rtl::OString aString; - t_print("#printFileName_u# " ); + printf("#printFileName_u# " ); aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ); - t_print("%s\n", aString.getStr( ) ); + printf("%s\n", aString.getStr( ) ); } inline sal_Bool isURL( const ::rtl::OUString pathname ) @@ -101,7 +110,7 @@ inline void createTestDirectory( const ::rtl::OUString dirname ) if ( !isURL( dirname ) ) ::osl::FileBase::getFileURLFromSystemPath( dirname, aPathURL ); //convert if not full qualified URL nError = ::osl::Directory::create( aPathURL ); - CPPUNIT_ASSERT_MESSAGE( "In createTestDirectory Function: creation: ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_EXIST ) ); + ASSERT_TRUE(( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_EXIST )) << "In createTestDirectory Function: creation: "; } /** delete a temp test directory using OUString name of full qualified URL or system path. @@ -120,7 +129,7 @@ inline void deleteTestDirectory( const ::rtl::OUString dirname ) } nError = ::osl::Directory::remove( aPathURL ); - CPPUNIT_ASSERT_MESSAGE( "In deleteTestDirectory function: remove ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) ); + ASSERT_TRUE(( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT )) << "In deleteTestDirectory function: remove "; } //check if the file exist @@ -153,10 +162,10 @@ inline void deleteTestFile( const ::rtl::OUString filename ) ::osl::FileBase::getFileURLFromSystemPath( filename, aPathURL ); //convert if not full qualified URL nError = ::osl::File::setAttributes( aPathURL, Attribute_GrpWrite| Attribute_OwnWrite| Attribute_OthWrite ); // if readonly, make writtenable. - CPPUNIT_ASSERT_MESSAGE( "In deleteTestFile Function: set writtenable ", ( ::osl::FileBase::E_None == nError ) || ( ::osl::FileBase::E_NOENT == nError ) ); + ASSERT_TRUE(( ::osl::FileBase::E_None == nError ) || ( ::osl::FileBase::E_NOENT == nError )) << "In deleteTestFile Function: set writtenable "; nError = ::osl::File::remove( aPathURL ); - CPPUNIT_ASSERT_MESSAGE( "In deleteTestFile Function: remove ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) ); + ASSERT_TRUE(( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT )) << "In deleteTestFile Function: remove "; } @@ -175,7 +184,7 @@ namespace osl_Module public: static void myFunc() { - t_print("#Sun Microsystem\n"); + printf("#Sun Microsystem\n"); }; }; @@ -184,335 +193,260 @@ namespace osl_Module Module(); Module( const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT); */ - class ctors : public CppUnit::TestFixture + class ctors : public ::testing::Test { public: sal_Bool bRes, bRes1; + }; // class ctors - void ctors_none( ) - { - ::osl::Module aMod; - bRes = aMod.is(); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor without parameter.", - sal_False == bRes ); - } - - void ctors_name_mode( ) - { - OUString aFileURL; - bRes = osl::Module::getUrlFromAddress( ( void* ) &::osl_Module::testClass::myFunc, aFileURL ); - - if ( !( bRes ) ) - { - CPPUNIT_ASSERT_MESSAGE("Cannot locate current module.", sal_False ); - } - ::osl::Module aMod( aFileURL ); - bRes = aMod.is( ); - aMod.unload( ); + TEST_F(ctors, ctors_none) + { + ::osl::Module aMod; + bRes = aMod.is(); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with load action.", - sal_True == bRes ); - } + ASSERT_TRUE( sal_False == bRes ) << "#test comment#: test constructor without parameter."; + } - CPPUNIT_TEST_SUITE( ctors ); - CPPUNIT_TEST( ctors_none ); - CPPUNIT_TEST( ctors_name_mode ); - CPPUNIT_TEST_SUITE_END( ); - }; // class ctors + TEST_F(ctors, ctors_name_mode) + { + ::osl::Module aMod( getDllURL( ) ); + bRes = aMod.is( ); + aMod.unload( ); + ASSERT_TRUE( sal_True == bRes ) << "#test comment#: test constructor with load action."; + } /** testing the methods: static sal_Bool getUrlFromAddress(void * addr, ::rtl::OUString & libraryUrl) */ - class getUrlFromAddress : public CppUnit::TestFixture + class getUrlFromAddress : public ::testing::Test { public: sal_Bool bRes, bRes1; + }; // class getUrlFromAddress - void getUrlFromAddress_001( ) - { - OUString aFileURL; - bRes = osl::Module::getUrlFromAddress( ( void* ) &::osl_Module::testClass::myFunc, aFileURL ) ; - if ( !( bRes ) ) - { - CPPUNIT_ASSERT_MESSAGE("Cannot locate current module.", sal_False ); - } - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test get Module URL from address.", - sal_True == bRes && 0 < aFileURL.lastIndexOf('/') ); - } + /* tester comments: another case is getFunctionSymbol_001*/ - void getUrlFromAddress_002( ) + TEST_F(getUrlFromAddress, getUrlFromAddress_001 ) + { + OUString aFileURL; + bRes = osl::Module::getUrlFromAddress( ( void* ) &::osl_Module::testClass::myFunc, aFileURL ) ; + if ( !( bRes ) ) { - ::osl::Module aMod( getDllURL( ) ); - FuncPtr pFunc = ( FuncPtr ) aMod.getSymbol( rtl::OUString::createFromAscii( "firstfunc" ) ); - - OUString aFileURL; - bRes = osl::Module::getUrlFromAddress( ( void* )pFunc, aFileURL ); - if ( !( bRes ) ) - { - CPPUNIT_ASSERT_MESSAGE("Cannot locate current module.", sal_False ); - } - aMod.unload( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: load an external library, get its function address and get its URL.", - sal_True == bRes && 0 < aFileURL.lastIndexOf('/') && aFileURL.equalsIgnoreAsciiCase( getDllURL( ) ) ); + ASSERT_TRUE(sal_False) << "Cannot locate current module."; } - /* tester comments: another case is getFunctionSymbol_001*/ + ASSERT_TRUE(sal_True == bRes && 0 < aFileURL.lastIndexOf('/')) << "#test comment#: test get Module URL from address."; + } - CPPUNIT_TEST_SUITE( getUrlFromAddress ); - CPPUNIT_TEST( getUrlFromAddress_001 ); - CPPUNIT_TEST( getUrlFromAddress_002 ); - CPPUNIT_TEST_SUITE_END( ); - }; // class getUrlFromAddress + TEST_F(getUrlFromAddress, getUrlFromAddress_002 ) + { + ::osl::Module aMod( getDllURL( ) ); + FuncPtr pFunc = ( FuncPtr ) aMod.getSymbol( rtl::OUString::createFromAscii( "firstfunc" ) ); + OUString aFileURL; + bRes = osl::Module::getUrlFromAddress( ( void* )pFunc, aFileURL ); + if ( !( bRes ) ) + { + ASSERT_TRUE(sal_False) << "Cannot locate current module."; + } + aMod.unload( ); + + ASSERT_TRUE( sal_True == bRes && 0 < aFileURL.lastIndexOf('/') && aFileURL.equalsIgnoreAsciiCase( getDllURL( ) ) ) + << "#test comment#: load an external library, get its function address and get its URL."; + } /** testing the method: sal_Bool SAL_CALL load( const ::rtl::OUString& strModuleName, sal_Int32 nRtldMode = SAL_LOADMODULE_DEFAULT) */ - class load : public CppUnit::TestFixture + class load : public ::testing::Test { public: sal_Bool bRes, bRes1; + }; // class load - void load_001( ) - { - ::osl::Module aMod( getDllURL( ) ); - ::osl::Module aMod1; + TEST_F(load, load_001 ) + { + ::osl::Module aMod( getDllURL( ) ); + ::osl::Module aMod1; - aMod1.load( getDllURL( ) ); - bRes = oslModule(aMod) == oslModule(aMod1); - aMod.unload( ); - aMod1.unload( ); + aMod1.load( getDllURL( ) ); + bRes = oslModule(aMod) == oslModule(aMod1); + aMod.unload( ); + aMod1.unload( ); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: load function should do the same thing as constructor with library name.", - sal_True == bRes ); - } - // load lib which is under a CJK directory - void load_002( ) - { + ASSERT_TRUE(sal_True == bRes) << "#test comment#: load function should do the same thing as constructor with library name."; + } + // load lib which is under a CJK directory + TEST_F(load, load_002 ) + { #ifdef UNX - //Can not get a CJK directory already exist, so here create one. Perhaps reason is encoding problem. - ::rtl::OUString aPidDirURL = rtl::OUString::createFromAscii( "file:///tmp/" ) + ::rtl::OUString::valueOf( ( long )getpid( ) ); - ::rtl::OUString aMyDirURL = aPidDirURL + aKname; - createTestDirectory( aPidDirURL ); - createTestDirectory( aMyDirURL ); - - ::rtl::OUString aDLLURL = aMyDirURL + rtl::OUString::createFromAscii( "/libModule_DLL.so" ); - //check if the lib exist. - //FIXME: if assert condition is false, the case will return, so the directory will not be clean-up - CPPUNIT_ASSERT_MESSAGE( "#Source file is not exist. please manually clean-up directory and file under /tmp", ifFileExist( getDllURL( ) ) == sal_True ); - ::osl::FileBase::RC nError = ::osl::File::copy( getDllURL( ), aDLLURL ); - CPPUNIT_ASSERT_MESSAGE( "#copy failed. please manually clean-up directory and file under /tmp", nError == ::osl::FileBase::E_None ); - //ifFileExist returned false but the file exist - CPPUNIT_ASSERT_MESSAGE( "#This file is not exist, copy failed. please manually clean-up directory and file under /tmp", ifFileExist( aDLLURL ) == sal_True ); - - //test if can create a normal file - ::rtl::OUString aFileURL = aMyDirURL + rtl::OUString::createFromAscii( "/test_file" ); - ::osl::File testFile( aFileURL ); - nError = testFile.open( OpenFlag_Create ); - CPPUNIT_ASSERT_MESSAGE( "#create failed. please manually clean-up directory and file under /tmp", nError == ::osl::FileBase::E_None ); - CPPUNIT_ASSERT_MESSAGE( "#This file is not exist, create failed. please manually clean-up directory and file under /tmp", ifFileExist( aFileURL ) == sal_True ); - - //load the copied dll - ::osl::Module aMod( aDLLURL ); - ::osl::Module aMod1; - - sal_Bool bOK = aMod1.load( aDLLURL ); - bRes = oslModule(aMod) == oslModule(aMod1); - aMod.unload( ); - aMod1.unload( ); - deleteTestFile( aFileURL ); - deleteTestFile( aDLLURL ); - deleteTestDirectory( aMyDirURL ); - deleteTestDirectory( aPidDirURL ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: load lib which is under a CJK directory.", - sal_True == bRes && bOK == sal_True ); + //Can not get a CJK directory already exist, so here create one. Perhaps reason is encoding problem. + ::rtl::OUString aPidDirURL = rtl::OUString::createFromAscii( "file:///tmp/" ) + ::rtl::OUString::valueOf( ( long )getpid( ) ); + ::rtl::OUString aMyDirURL = aPidDirURL + aKname; + createTestDirectory( aPidDirURL ); + createTestDirectory( aMyDirURL ); + + ::rtl::OUString aDLLURL = aMyDirURL + rtl::OUString::createFromAscii( "/libModule_DLL.so" ); + //check if the lib exist. + //FIXME: if assert condition is false, the case will return, so the directory will not be clean-up + ASSERT_TRUE(ifFileExist( getDllURL( ) ) == sal_True) << "#Source file is not exist. please manually clean-up directory and file under /tmp"; + ::osl::FileBase::RC nError = ::osl::File::copy( getDllURL( ), aDLLURL ); + ASSERT_TRUE(nError == ::osl::FileBase::E_None) << "#copy failed. please manually clean-up directory and file under /tmp"; + //ifFileExist returned false but the file exist + ASSERT_TRUE( ifFileExist( aDLLURL ) == sal_True ) + << "#This file is not exist, copy failed. please manually clean-up directory and file under /tmp"; + + //test if can create a normal file + ::rtl::OUString aFileURL = aMyDirURL + rtl::OUString::createFromAscii( "/test_file" ); + ::osl::File testFile( aFileURL ); + nError = testFile.open( OpenFlag_Create ); + ASSERT_TRUE(nError == ::osl::FileBase::E_None) << "#create failed. please manually clean-up directory and file under /tmp"; + ASSERT_TRUE( ifFileExist( aFileURL ) == sal_True ) + << "#This file is not exist, create failed. please manually clean-up directory and file under /tmp"; + + //load the copied dll + ::osl::Module aMod( aDLLURL ); + ::osl::Module aMod1; + + sal_Bool bOK = aMod1.load( aDLLURL ); + bRes = oslModule(aMod) == oslModule(aMod1); + aMod.unload( ); + aMod1.unload( ); + deleteTestFile( aFileURL ); + deleteTestFile( aDLLURL ); + deleteTestDirectory( aMyDirURL ); + deleteTestDirectory( aPidDirURL ); + + ASSERT_TRUE(sal_True == bRes && bOK == sal_True) << "#test comment#: load lib which is under a CJK directory."; #endif - } - - CPPUNIT_TEST_SUITE( load ); - CPPUNIT_TEST( load_001 ); - CPPUNIT_TEST( load_002 ); - CPPUNIT_TEST_SUITE_END( ); - }; // class load - + } /** testing the method: void SAL_CALL unload() */ - class unload : public CppUnit::TestFixture + class unload : public ::testing::Test { public: sal_Bool bRes, bRes1; + }; // class unload - void unload_001( ) - { - ::osl::Module aMod( getDllURL( ) ); - - aMod.unload( ); - bRes = oslModule(aMod) ==NULL; - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: unload function should do the same thing as destructor.", - sal_True == bRes ); - } + TEST_F(unload, unload_001) + { + ::osl::Module aMod( getDllURL( ) ); - CPPUNIT_TEST_SUITE( unload ); - CPPUNIT_TEST( unload_001 ); - CPPUNIT_TEST_SUITE_END( ); - }; // class unload + aMod.unload( ); + bRes = oslModule(aMod) ==NULL; + ASSERT_TRUE(sal_True == bRes) << "#test comment#: unload function should do the same thing as destructor."; + } /** testing the methods: sal_Bool SAL_CALL is() const */ - class is : public CppUnit::TestFixture + class is : public ::testing::Test { public: sal_Bool bRes, bRes1; - - void is_001( ) - { - OUString aFileURL; - bRes = osl::Module::getUrlFromAddress( ( void* ) &::osl_Module::testClass::myFunc, aFileURL ); - if ( !( bRes ) ) - { - CPPUNIT_ASSERT_MESSAGE("Cannot locate current module - using executable instead", sal_False ); - } - - ::osl::Module aMod; - bRes = aMod.is( ); - aMod.load( aFileURL ); - bRes1 = aMod.is( ); - aMod.unload( ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: test if a module is a loaded module.", - sal_False == bRes && sal_True == bRes1); - } - CPPUNIT_TEST_SUITE( is ); - CPPUNIT_TEST( is_001 ); - CPPUNIT_TEST_SUITE_END( ); }; // class is + TEST_F(is, is_001) + { + ::osl::Module aMod; + bRes = aMod.is( ); + aMod.load( getDllURL( ) ); + bRes1 = aMod.is( ); + aMod.unload( ); + + ASSERT_TRUE(sal_False == bRes && sal_True == bRes1) << "#test comment#: test if a module is a loaded module."; + } /** testing the methods: void* SAL_CALL getSymbol( const ::rtl::OUString& strSymbolName) */ - class getSymbol : public CppUnit::TestFixture + class getSymbol : public ::testing::Test { public: sal_Bool bRes; - - void getSymbol_001( ) - { - ::osl::Module aMod( getDllURL( ) ); - FuncPtr pFunc = ( FuncPtr ) aMod.getSymbol( rtl::OUString::createFromAscii( "firstfunc" ) ); - bRes = sal_False; - if ( pFunc ) - bRes = pFunc( bRes ); - aMod.unload(); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: load a dll and call one function in it.", - sal_True == bRes ); - } - - CPPUNIT_TEST_SUITE( getSymbol ); - CPPUNIT_TEST( getSymbol_001 ); - CPPUNIT_TEST_SUITE_END( ); }; // class getSymbol + TEST_F(getSymbol, getSymbol_001) + { + ::osl::Module aMod( getDllURL( ) ); + FuncPtr pFunc = ( FuncPtr ) aMod.getSymbol( rtl::OUString::createFromAscii( "firstfunc" ) ); + bRes = sal_False; + if ( pFunc ) + bRes = pFunc( bRes ); + aMod.unload(); + + ASSERT_TRUE(sal_True == bRes) << "#test comment#: load a dll and call one function in it."; + } /** testing the methods: operator oslModule() const */ - class optr_oslModule : public CppUnit::TestFixture + class optr_oslModule : public ::testing::Test { public: sal_Bool bRes, bRes1; + }; // class optr_oslModule - void optr_oslModule_001( ) - { - ::osl::Module aMod; - bRes = ( (oslModule)aMod == NULL ); - - aMod.load( getDllURL( ) ); - bRes1 = (oslModule)aMod != NULL; + TEST_F(optr_oslModule, optr_oslModule_001 ) + { + ::osl::Module aMod; + bRes = ( (oslModule)aMod == NULL ); - aMod.unload( ); + aMod.load( getDllURL( ) ); + bRes1 = (oslModule)aMod != NULL; - CPPUNIT_ASSERT_MESSAGE( "#test comment#: the m_Module of a Module instance will be NULL when is not loaded, it will not be NULL after loaded.", - sal_True == bRes && sal_True == bRes1); - } + aMod.unload( ); - void optr_oslModule_002( ) - { - ::osl::Module aMod( getDllURL( ) ); - ::rtl::OUString funcName(::rtl::OUString::createFromAscii( "firstfunc" ) ); + ASSERT_TRUE(sal_True == bRes && sal_True == bRes1) + << "#test comment#: the m_Module of a Module instance will be NULL when is not loaded, it will not be NULL after loaded."; + } - FuncPtr pFunc = ( FuncPtr ) osl_getSymbol( (oslModule)aMod, funcName.pData ); - bRes = sal_False; - if ( pFunc ) - bRes = pFunc( bRes ); + TEST_F(optr_oslModule, optr_oslModule_002 ) + { + ::osl::Module aMod( getDllURL( ) ); + ::rtl::OUString funcName(::rtl::OUString::createFromAscii( "firstfunc" ) ); - aMod.unload(); + FuncPtr pFunc = ( FuncPtr ) osl_getSymbol( (oslModule)aMod, funcName.pData ); + bRes = sal_False; + if ( pFunc ) + bRes = pFunc( bRes ); - CPPUNIT_ASSERT_MESSAGE( "#test comment#: use m_Module to call osl_getSymbol() function.", - sal_True == bRes ); - } + aMod.unload(); - CPPUNIT_TEST_SUITE( optr_oslModule ); - CPPUNIT_TEST( optr_oslModule_001 ); - CPPUNIT_TEST( optr_oslModule_002 ); - CPPUNIT_TEST_SUITE_END( ); - }; // class optr_oslModule + ASSERT_TRUE(sal_True == bRes) << "#test comment#: use m_Module to call osl_getSymbol() function."; + } /** testing the methods: oslGenericFunction SAL_CALL getFunctionSymbol( const ::rtl::OUString& ustrFunctionSymbolName ) */ - class getFunctionSymbol : public CppUnit::TestFixture + class getFunctionSymbol : public ::testing::Test { public: sal_Bool bRes, bRes1; - - void getFunctionSymbol_001( ) - { - ::osl::Module aMod( getDllURL( ) ); - oslGenericFunction oslFunc = aMod.getFunctionSymbol( rtl::OUString::createFromAscii( "firstfunc" ) ); - ::rtl::OUString aLibraryURL; - bRes = ::osl::Module::getUrlFromAddress( oslFunc, aLibraryURL); - aMod.unload(); - printFileName( aLibraryURL ); - - CPPUNIT_ASSERT_MESSAGE( "#test comment#: load a dll and get its function addr and get its URL.", - sal_True == bRes && aLibraryURL.equalsIgnoreAsciiCase( getDllURL() ) ); - } - - CPPUNIT_TEST_SUITE( getFunctionSymbol ); - CPPUNIT_TEST( getFunctionSymbol_001 ); - //CPPUNIT_TEST( getFunctionSymbol_002 ); - CPPUNIT_TEST_SUITE_END( ); }; // class getFunctionSymbol -// ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Module::ctors, "osl_Module"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Module::getUrlFromAddress, "osl_Module"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Module::load, "osl_Module"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Module::unload, "osl_Module"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Module::is, "osl_Module"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Module::getSymbol, "osl_Module"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Module::optr_oslModule, "osl_Module"); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(osl_Module::getFunctionSymbol, "osl_Module"); -// ----------------------------------------------------------------------------- + TEST_F(getFunctionSymbol, getFunctionSymbol_001) + { + ::osl::Module aMod( getDllURL( ) ); + oslGenericFunction oslFunc = aMod.getFunctionSymbol( rtl::OUString::createFromAscii( "firstfunc" ) ); + ::rtl::OUString aLibraryURL; + bRes = ::osl::Module::getUrlFromAddress( oslFunc, aLibraryURL); + aMod.unload(); + printFileName( aLibraryURL ); + + ASSERT_TRUE(sal_True == bRes && aLibraryURL.equalsIgnoreAsciiCase( getDllURL() )) << "#test comment#: load a dll and get its function addr and get its URL."; + } } // namespace osl_Module -// ----------------------------------------------------------------------------- - -// this macro creates an empty function, which will called by the RegisterAllFunctions() -// to let the user the possibility to also register some functions by hand. -NOADDITIONAL; +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/sal/qa/osl/module/osl_Module_Const.h b/sal/qa/osl/module/osl_Module_Const.h index d3268ee78ec5..3eb90e712837 100644 --- a/sal/qa/osl/module/osl_Module_Const.h +++ b/sal/qa/osl/module/osl_Module_Const.h @@ -30,7 +30,6 @@ #include <osl/module.hxx> #include <osl/file.hxx> -#include <testshl/simpleheader.hxx> #if ( defined UNX ) || ( defined OS2 ) //Unix # include <unistd.h> diff --git a/sal/qa/osl/module/osl_Module_DLL.cxx b/sal/qa/osl/module/osl_Module_DLL.cxx index a4a18de8a7af..f640558f0c63 100644 --- a/sal/qa/osl/module/osl_Module_DLL.cxx +++ b/sal/qa/osl/module/osl_Module_DLL.cxx @@ -26,7 +26,6 @@ #include <stdio.h> #include <sal/types.h> -#include <testshl/simpleheader.hxx> extern "C" sal_Bool SAL_CALL firstfunc( sal_Bool bRes ) { |