autodoc/source/display/inc/toolkit/hf_navi_sub.hxx | 2 comphelper/inc/comphelper/stillreadwriteinteraction.hxx | 2 cui/source/inc/cuires.hrc | 2 oox/source/ppt/animvariantcontext.hxx | 2 sal/qa/osl/file/makefile.mk | 54 sal/qa/osl/file/osl_File.cxx | 6126 ++++++---------- sal/qa/osl/file/osl_File_Const.h | 4 sal/qa/osl/file/osl_old_test_file.cxx | 59 sal/qa/osl/file/test_cpy_wrt_file.cxx | 76 sc/source/ui/vba/vbaaxis.hxx | 2 sdext/source/minimizer/pppoptimizerdialog.hxx | 2 sdext/source/presenter/PresenterPaneAnimator.hxx | 2 svl/source/inc/fsfactory.hxx | 2 writerfilter/source/doctok/WW8PropertySetImpl.hxx | 2 14 files changed, 2773 insertions(+), 3564 deletions(-)
New commits: commit 8f75789da0997aee11e4fabceebce1eee3106984 Author: Pedro Giffuni <p...@apache.org> Date: Sun Sep 6 23:45:01 2015 +0000 Clean up all of typos that cause header guard warnings when building the OpenOffice source with clang. Submitted by: Don Lewis Notes: prefer: 35acb8a54171eb14555632179e69cbb9cf28f9e8 diff --git a/autodoc/source/display/inc/toolkit/hf_navi_sub.hxx b/autodoc/source/display/inc/toolkit/hf_navi_sub.hxx index 989e91f..6a040ff 100644 --- a/autodoc/source/display/inc/toolkit/hf_navi_sub.hxx +++ b/autodoc/source/display/inc/toolkit/hf_navi_sub.hxx @@ -22,7 +22,7 @@ #ifndef ADC_DISPLAY_HF_NAVI_SUB_HXX -#define ADC_DISPLAY_HFI_NAVI_SUB_HXX +#define ADC_DISPLAY_HF_NAVI_SUB_HXX diff --git a/comphelper/inc/comphelper/stillreadwriteinteraction.hxx b/comphelper/inc/comphelper/stillreadwriteinteraction.hxx index a9f2f8a..9787b18 100644 --- a/comphelper/inc/comphelper/stillreadwriteinteraction.hxx +++ b/comphelper/inc/comphelper/stillreadwriteinteraction.hxx @@ -22,7 +22,7 @@ #ifndef _COMPHELPER_STILLREADWRITEINTERACTION_HXX_ -#define _COMPHELPER_STRILLREADWRITEINTERACTION_HXX_ +#define _COMPHELPER_STILLREADWRITEINTERACTION_HXX_ //_______________________________________________ // includes diff --git a/cui/source/inc/cuires.hrc b/cui/source/inc/cuires.hrc index 17f5fc7..32c938f 100755 --- a/cui/source/inc/cuires.hrc +++ b/cui/source/inc/cuires.hrc @@ -21,7 +21,7 @@ #ifndef _CUI_RESID_HRC -#define _CUI_REDID_HRC +#define _CUI_RESID_HRC // include ------------------------------------------------------------------ diff --git a/oox/source/ppt/animvariantcontext.hxx b/oox/source/ppt/animvariantcontext.hxx index d1e307e..90368d2 100644 --- a/oox/source/ppt/animvariantcontext.hxx +++ b/oox/source/ppt/animvariantcontext.hxx @@ -24,7 +24,7 @@ #ifndef OOX_PPT_ANIMVARIANTCONTEXT -#define OOX_PPT_ANIMVERIANTCONTEXT +#define OOX_PPT_ANIMVARIANTCONTEXT #include <com/sun/star/uno/Any.hxx> diff --git a/sc/source/ui/vba/vbaaxis.hxx b/sc/source/ui/vba/vbaaxis.hxx index 7f24d78..fa1f9ac 100644 --- a/sc/source/ui/vba/vbaaxis.hxx +++ b/sc/source/ui/vba/vbaaxis.hxx @@ -21,7 +21,7 @@ #ifndef SC_VBA_AXIS_HXX -#define SC_VBA_AXOS_HXX +#define SC_VBA_AXIS_HXX #include <com/sun/star/beans/XPropertySet.hpp> #include <ooo/vba/excel/XAxis.hpp> #include <ooo/vba/excel/XChart.hpp> diff --git a/sdext/source/minimizer/pppoptimizerdialog.hxx b/sdext/source/minimizer/pppoptimizerdialog.hxx index decb083..2e7be6a 100644 --- a/sdext/source/minimizer/pppoptimizerdialog.hxx +++ b/sdext/source/minimizer/pppoptimizerdialog.hxx @@ -22,7 +22,7 @@ #ifndef PPPOPTIMIZERDIALOG_HXX -#define PPPOPTIMIZERDIALOGOG_HXX +#define PPPOPTIMIZERDIALOG_HXX #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/document/XExporter.hpp> diff --git a/sdext/source/presenter/PresenterPaneAnimator.hxx b/sdext/source/presenter/PresenterPaneAnimator.hxx index 92a7f05..4ebb3e8 100644 --- a/sdext/source/presenter/PresenterPaneAnimator.hxx +++ b/sdext/source/presenter/PresenterPaneAnimator.hxx @@ -21,7 +21,7 @@ -#ifndef SDEXT_PRESENTER_PRESENTER_PANE_ANIMATOR_HXXs +#ifndef SDEXT_PRESENTER_PRESENTER_PANE_ANIMATOR_HXX #define SDEXT_PRESENTER_PRESENTER_PANE_ANIMATOR_HXX #include <com/sun/star/awt/Point.hpp> diff --git a/svl/source/inc/fsfactory.hxx b/svl/source/inc/fsfactory.hxx index fdc55ee..761268d 100644 --- a/svl/source/inc/fsfactory.hxx +++ b/svl/source/inc/fsfactory.hxx @@ -22,7 +22,7 @@ #ifndef __FSFACTORY_HXX_ -#define __FSACTORY_HXX_ +#define __FSFACTORY_HXX_ #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> diff --git a/writerfilter/source/doctok/WW8PropertySetImpl.hxx b/writerfilter/source/doctok/WW8PropertySetImpl.hxx index 5f58781..04a7c52 100644 --- a/writerfilter/source/doctok/WW8PropertySetImpl.hxx +++ b/writerfilter/source/doctok/WW8PropertySetImpl.hxx @@ -22,7 +22,7 @@ #ifndef INCLUDED_WW8_PROPERTY_SET_IMPL_HXX -#define INCLUDED_WW8_PROEPRTY_SET_IMPL_HXX +#define INCLUDED_WW8_PROPERTY_SET_IMPL_HXX #include <resourcemodel/WW8ResourceModel.hxx> #include <doctok/WW8Document.hxx> commit e44f7fe8b1e6be0f1e0719f378fa94e0cda9e75e Author: Damjan Jovanovic <dam...@apache.org> Date: Sat Sep 5 19:30:51 2015 +0000 #i125003# migrate main/sal/qa/osl/file from cppunit to Google Test, get tests to compile, but not all of them pass. Notes: ignore: googletest diff --git a/sal/qa/osl/file/makefile.mk b/sal/qa/osl/file/makefile.mk index faab0d9..b19dae7 100644 --- a/sal/qa/osl/file/makefile.mk +++ b/sal/qa/osl/file/makefile.mk @@ -32,50 +32,42 @@ 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) # --- BEGIN -------------------------------------------------------- -SHL1OBJS= \ +APP1OBJS= \ $(SLO)$/osl_File.obj -SHL1TARGET= osl_File -SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) - -SHL1IMPLIB= i$(SHL1TARGET) - -DEF1NAME =$(SHL1TARGET) -SHL1VERSIONMAP = $(PRJ)$/qa$/export.map - +APP1TARGET= osl_File +APP1STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB) +APP1RPATH = NONE +APP1TEST = enabled #------------------------------------------------------------------- -SHL2OBJS=$(SLO)$/test_cpy_wrt_file.obj -SHL2TARGET=tcwf -SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) -SHL2IMPLIB=i$(SHL2TARGET) -SHL2DEF=$(MISC)$/$(SHL2TARGET).def -SHL2VERSIONMAP = $(PRJ)$/qa$/export.map -DEF2NAME =$(SHL2TARGET) - - +APP2OBJS=$(SLO)$/test_cpy_wrt_file.obj +APP2TARGET=tcwf +APP2STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB) +APP2RPATH = NONE +APP2TEST = enabled # END -------------------------------------------------------------- # --- BEGIN -------------------------------------------------------- -SHL3OBJS= \ +APP3OBJS= \ $(SLO)$/osl_old_test_file.obj -SHL3TARGET= osl_old_test_file -SHL3STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTSHL2LIB) - -SHL3IMPLIB= i$(SHL3TARGET) - -DEF3NAME =$(SHL3TARGET) -SHL3VERSIONMAP = $(PRJ)$/qa$/export.map +APP3TARGET= osl_old_test_file +APP3STDLIBS= $(SALLIB) $(GTESTLIB) $(TESTSHL2LIB) +APP3RPATH = NONE +APP3TEST = enabled # END -------------------------------------------------------------- -#------------------------------- All object files ------------------------------- -# do this here, so we get right dependencies -SLOFILES=$(SHL1OBJS) - # --- Targets ------------------------------------------------------ .INCLUDE : target.mk -.INCLUDE : _cppunit.mk + +.ENDIF # "$(ENABLE_UNIT_TESTS)" != "YES" diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx index eee364a..0a4967d 100644 --- a/sal/qa/osl/file/osl_File.cxx +++ b/sal/qa/osl/file/osl_File.cxx @@ -37,7 +37,7 @@ #include <osl/file.hxx> #include <osl_File_Const.h> -#include <testshl/simpleheader.hxx> +#include "gtest/gtest.h" // #ifdef WNT // # define UNICODE @@ -110,31 +110,31 @@ rtl::OUString errorToStr( ::osl::FileBase::RC const& nError) */ inline void printFileType( const ::osl::FileStatus::Type nType ) { - t_print( "#printFileType# " ); + printf( "#printFileType# " ); switch ( nType ) { case ::osl::FileStatus::Directory: - t_print( "This file is a: Directory.\n" ); + printf( "This file is a: Directory.\n" ); break; case ::osl::FileStatus::Volume: - t_print( "This file is a: volume device.\n" ); + printf( "This file is a: volume device.\n" ); break; case ::osl::FileStatus::Regular: - t_print( "This file is a: regular file.\n" ); + printf( "This file is a: regular file.\n" ); break; case ::osl::FileStatus::Fifo: - t_print( "This file is a: fifo.\n" ); + printf( "This file is a: fifo.\n" ); break; case ::osl::FileStatus::Socket: - t_print( "This file is a: socket.\n" ); + printf( "This file is a: socket.\n" ); break; case ::osl::FileStatus::Link: - t_print( "This file is a: link file.\n" ); + printf( "This file is a: link file.\n" ); break; case ::osl::FileStatus::Special: - t_print( "This file is a: special.\n" ); + printf( "This file is a: special.\n" ); break; case ::osl::FileStatus::Unknown: - t_print( "The file type is unknown %d \n", nType ); + printf( "The file type is unknown %d \n", nType ); break; } } @@ -143,32 +143,32 @@ inline void printFileType( const ::osl::FileStatus::Type nType ) */ inline void printFileAttributes( const sal_Int64 nAttributes ) { - t_print( "#printFileAttributes# This file is a: (" ); + printf( "#printFileAttributes# This file is a: (" ); if ( ( nAttributes | Attribute_ReadOnly ) == nAttributes ) - t_print( " ReadOnly " ); + printf( " ReadOnly " ); if ( ( nAttributes | Attribute_Hidden ) == nAttributes ) - t_print( " Hidden " ); + printf( " Hidden " ); if ( ( nAttributes | Attribute_Executable ) == nAttributes ) - t_print( " Executable " ); + printf( " Executable " ); if ( ( nAttributes | Attribute_GrpWrite ) == nAttributes ) - t_print( " GrpWrite " ); + printf( " GrpWrite " ); if ( ( nAttributes | Attribute_GrpRead ) == nAttributes ) - t_print( " GrpRead " ); + printf( " GrpRead " ); if ( ( nAttributes | Attribute_GrpExe ) == nAttributes ) - t_print( " GrpExe " ); + printf( " GrpExe " ); if ( ( nAttributes | Attribute_OwnWrite ) == nAttributes ) - t_print( " OwnWrite " ); + printf( " OwnWrite " ); if ( ( nAttributes | Attribute_OwnRead ) == nAttributes ) - t_print( " OwnRead " ); + printf( " OwnRead " ); if ( ( nAttributes | Attribute_OwnExe ) == nAttributes ) - t_print( " OwnExe " ); + printf( " OwnExe " ); if ( ( nAttributes | Attribute_OthWrite ) == nAttributes ) - t_print( " OthWrite " ); + printf( " OthWrite " ); if ( ( nAttributes | Attribute_OthRead ) == nAttributes ) - t_print( " OthRead " ); + printf( " OthRead " ); if ( ( nAttributes | Attribute_OthExe ) == nAttributes ) - t_print( " OthExe " ); - t_print( ") file!\n" ); + printf( " OthExe " ); + printf( ") file!\n" ); } /** print a UNI_CODE file name. @@ -177,24 +177,24 @@ 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( ) ); } /** print a ASCII_CODE file name. */ inline void printFileName( const sal_Char * str ) { - t_print( "#printFileName_a# " ); - t_print( "%s\n", str ); + printf( "#printFileName_a# " ); + printf( "%s\n", str ); } /** print an output wrong message. */ inline void printError( const ::osl::FileBase::RC nError ) { - t_print( "#printError# " ); + printf( "#printError# " ); printFileName( errorToStr(nError) ); } @@ -202,24 +202,24 @@ inline void printError( const ::osl::FileBase::RC nError ) */ inline void printInt( sal_Int64 i ) { - t_print( "#printInt_i64# " ); - t_print( "The Integer64 is %lld\n", i); + printf( "#printInt_i64# " ); + printf( "The Integer64 is %lld\n", i); } /** print an unsigned Integer Number. */ inline void printInt( sal_uInt64 i ) { - t_print( "#printInt_u64# " ); - t_print( "The unsigned Integer64 is %llu\n", i); + printf( "#printInt_u64# " ); + printf( "The unsigned Integer64 is %llu\n", i); } /** print Boolean value. */ inline void printBool( sal_Bool bOk ) { - t_print( "#printBool# " ); - ( sal_True == bOk ) ? t_print( "YES!\n" ): t_print( "NO!\n" ); + printf( "#printBool# " ); + ( sal_True == bOk ) ? printf( "YES!\n" ): printf( "NO!\n" ); } /** print struct TimeValue in local time format. @@ -227,26 +227,26 @@ inline void printBool( sal_Bool bOk ) inline void printTime( TimeValue *tv ) { oslDateTime *pDateTime = ( oslDateTime* )malloc( sizeof( oslDateTime ) ) ; - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,malloc ", pDateTime != NULL ); + ASSERT_TRUE(pDateTime != NULL) << "Error in printTime() function,malloc "; TimeValue *pLocalTV = ( TimeValue* )malloc( sizeof( TimeValue ) ); - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,malloc ", pLocalTV != NULL ); + ASSERT_TRUE(pLocalTV != NULL) << "Error in printTime() function,malloc "; - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,osl_getLocalTimeFromSystemTime ",sal_True == osl_getLocalTimeFromSystemTime( tv, pLocalTV ) ); - CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,osl_gepDateTimeFromTimeValue ",sal_True == osl_getDateTimeFromTimeValue( pLocalTV, pDateTime ) ); + ASSERT_TRUE(sal_True == osl_getLocalTimeFromSystemTime( tv, pLocalTV )) << "Error in printTime() function,osl_getLocalTimeFromSystemTime "; + ASSERT_TRUE(sal_True == osl_getDateTimeFromTimeValue( pLocalTV, pDateTime )) << "Error in printTime() function,osl_gepDateTimeFromTimeValue "; - t_print( "#printTime# " ); - t_print( " Time is: %d/%d/%d ", pDateTime->Month, pDateTime->Day, pDateTime->Year); + printf( "#printTime# " ); + printf( " Time is: %d/%d/%d ", pDateTime->Month, pDateTime->Day, pDateTime->Year); switch ( pDateTime->DayOfWeek ) { - case 0: t_print("Sun. "); break; - case 1: t_print("Mon. "); break; - case 2: t_print("Tue. "); break; - case 3: t_print("Thr. "); break; - case 4: t_print("Wen. "); break; - case 5: t_print("Fri. "); break; - case 6: t_print("Sat. "); break; + case 0: printf("Sun. "); break; + case 1: printf("Mon. "); break; + case 2: printf("Tue. "); break; + case 3: printf("Thr. "); break; + case 4: printf("Wen. "); break; + case 5: printf("Fri. "); break; + case 6: printf("Sat. "); break; } - t_print( " %d:%d:%d %d nsecs\n", pDateTime->Hours, pDateTime->Minutes, pDateTime->Seconds, pDateTime->NanoSeconds); + printf( " %d:%d:%d %d nsecs\n", pDateTime->Hours, pDateTime->Minutes, pDateTime->Seconds, pDateTime->NanoSeconds); free( pDateTime ); free( pLocalTV ); @@ -265,8 +265,8 @@ inline sal_Int64 t_abs64(sal_Int64 _nValue) { // std::abs() seems to have some ambiguity problems (so-texas) // return abs(_nValue); - t_print("t_abs64(%ld)\n", _nValue); - // CPPUNIT_ASSERT(_nValue < 2147483647); + printf("t_abs64(%ld)\n", _nValue); + // ASSERT_TRUE(_nValue < 2147483647); if (_nValue < 0) { @@ -381,10 +381,10 @@ inline void createTestFile( const ::rtl::OUString filename ) File aFile(aPathURL); //nError = pFile->open( OpenFlag_Read | OpenFlag_Write | OpenFlag_Create ); nError = aFile.open( OpenFlag_Read | OpenFlag_Write | OpenFlag_Create ); - //CPPUNIT_ASSERT_MESSAGE( "In createTestFile 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 createTestFile Function: creation "; if ( ( ::osl::FileBase::E_None != nError ) && ( nError != ::osl::FileBase::E_EXIST )) { - t_print("createTestFile failed!\n"); + printf("createTestFile failed!\n"); } aFile.close(); @@ -404,7 +404,7 @@ inline void createTestFile( const ::rtl::OUString basename, const ::rtl::OUStrin */ inline void deleteTestFile( const ::rtl::OUString filename ) { - // LLA: t_print("deleteTestFile\n"); + // LLA: printf("deleteTestFile\n"); ::rtl::OUString aPathURL = filename.copy( 0 ); ::osl::FileBase::RC nError; @@ -412,10 +412,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 "; } /** delete a temp test file using OUString name of full qualified URL or system path in a base directory. @@ -438,9 +438,9 @@ 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: "; if ( ( ::osl::FileBase::E_None != nError ) && ( nError != ::osl::FileBase::E_EXIST )) - t_print("createTestDirectory failed!\n"); + printf("createTestDirectory failed!\n"); } /** create a temp test directory using OUString name of full qualified URL or system path in a base directory. @@ -458,7 +458,7 @@ inline void createTestDirectory( const ::rtl::OUString basename, const ::rtl::OU */ inline void deleteTestDirectory( const ::rtl::OUString dirname ) { - // LLA: t_print("deleteTestDirectory\n"); + // LLA: printf("deleteTestDirectory\n"); ::rtl::OUString aPathURL = dirname.copy( 0 ); ::osl::FileBase::RC nError; // LLA: printFileName(aPathURL); @@ -468,7 +468,7 @@ inline void deleteTestDirectory( const ::rtl::OUString dirname ) ::osl::Directory testDir( aPathURL ); if ( testDir.isOpen( ) == sal_True ) { - // LLA: t_print("#close Dir\n"); + // LLA: printf("#close Dir\n"); testDir.close( ); //close if still open. } @@ -476,22 +476,22 @@ inline void deleteTestDirectory( const ::rtl::OUString dirname ) // LLA: printError(nError); // LLA: if (( ::osl::FileBase::E_None == nError )) // LLA: { - // LLA: t_print("nError == E_None\n"); + // LLA: printf("nError == E_None\n"); // LLA: } // LLA: else if ( ( nError == ::osl::FileBase::E_NOENT )) // LLA: { - // LLA: t_print("nError == E_NOENT\n"); + // LLA: printf("nError == E_NOENT\n"); // LLA: } // LLA: else // LLA: { - // LLA: // t_print("nError == %d\n", nError); + // LLA: // printf("nError == %d\n", nError); // LLA: } rtl::OUString strError = rtl::OUString::createFromAscii( "In deleteTestDirectory function: remove Directory "); strError += aPathURL; - CPPUNIT_ASSERT_MESSAGE( strError, ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) ); + EXPECT_TRUE(( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT )) << strError.pData; // LLA: if (! ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT )) // LLA: { - // LLA: t_print("In deleteTestDirectory function: remove\n"); + // LLA: printf("In deleteTestDirectory function: remove\n"); // LLA: } } @@ -553,7 +553,7 @@ inline sal_Bool checkFile( const ::rtl::OUString & str, oslCheckMode nCheckMode }/// swith nError2 = testFile.close( ); - CPPUNIT_ASSERT_MESSAGE( " in CheckFile() function, close file ", nError2 == FileBase::E_None ); + EXPECT_TRUE(nError2 == FileBase::E_None) << " in CheckFile() function, close file "; } @@ -580,9 +580,9 @@ inline sal_Bool ifFileExist( const ::rtl::OUString & str ) ::osl::File testFile( str ); bCheckResult = ( osl::FileBase::E_None == testFile.open( OpenFlag_Read ) ); //if (bCheckResult) - //t_print("%s exist!\n", path); + //printf("%s exist!\n", path); //else - //t_print("%s not exist!\n", path); + //printf("%s not exist!\n", path); //#endif return bCheckResult; @@ -648,7 +648,7 @@ inline sal_Bool checkDirectory( const ::rtl::OUString & str, oslCheckMode nCheck bCheckResult = sal_True; //rc = pDir->remove( aUString ); rc = Directory::remove( aUString ); - CPPUNIT_ASSERT( rc == ::osl::FileBase::E_None ); + EXPECT_TRUE( rc == ::osl::FileBase::E_None ); } else bCheckResult = sal_False; @@ -659,7 +659,7 @@ inline sal_Bool checkDirectory( const ::rtl::OUString & str, oslCheckMode nCheck }// switch rc = aDir.close( ); - CPPUNIT_ASSERT( rc == FileBase::E_None ); + EXPECT_TRUE( rc == FileBase::E_None ); }//if @@ -700,7 +700,7 @@ inline void changeFileMode( ::rtl::OUString & filepath, sal_Int32 mode ) { (void)filepath; (void)mode; - t_print("this method is not implemented yet"); + printf("this method is not implemented yet"); } #endif @@ -723,48 +723,39 @@ namespace osl_FileBase // because getCanonicalName method is not implemented yet and will be deprecated in the future, this test is not necessary. //--------------------------------------------------------------------- - class getCanonicalName:public CppUnit::TestFixture + class getCanonicalName:public ::testing::Test { public: ::osl::FileBase::RC nError; + };// class getCanonicalName - void getCanonicalName_001( ) - { - ::rtl::OUString aUStr_ValidURL; - nError = ::osl::FileBase::getCanonicalName( aCanURL1, aUStr_ValidURL ); - - CPPUNIT_ASSERT_MESSAGE("test for getCanonicalName function: check valid and unused file name", - ( osl::FileBase::E_None == nError ) && aUStr_ValidURL.equalsIgnoreAsciiCase( aCanURL1 ) ); - } + TEST_F(getCanonicalName, getCanonicalName_001 ) + { + ::rtl::OUString aUStr_ValidURL; + nError = ::osl::FileBase::getCanonicalName( aCanURL1, aUStr_ValidURL ); - void getCanonicalName_002( ) - { - ::rtl::OUString aUStr_ValidURL; + ASSERT_TRUE(( osl::FileBase::E_None == nError ) && aUStr_ValidURL.equalsIgnoreAsciiCase( aCanURL1 )) << "test for getCanonicalName function: check valid and unused file name"; + } - createTestFile( aCanURL1 ); - nError = ::osl::FileBase::getCanonicalName( aCanURL1, aUStr_ValidURL ); - deleteTestFile( aCanURL1 ); + TEST_F(getCanonicalName, getCanonicalName_002 ) + { + ::rtl::OUString aUStr_ValidURL; - CPPUNIT_ASSERT_MESSAGE( " test for getCanonicalName function: an existed file name, should different from the request, it did not passed(W32)(UNX)", - ( osl::FileBase::E_None == nError ) && aUStr_ValidURL.equalsIgnoreAsciiCase( aCanURL1 ) ); - } + createTestFile( aCanURL1 ); + nError = ::osl::FileBase::getCanonicalName( aCanURL1, aUStr_ValidURL ); + deleteTestFile( aCanURL1 ); - void getCanonicalName_003( ) - { - ::rtl::OUString aUStr_ValidURL; - nError = ::osl::FileBase::getCanonicalName ( aCanURL2, aUStr_ValidURL ); + ASSERT_TRUE(( osl::FileBase::E_None == nError ) && aUStr_ValidURL.equalsIgnoreAsciiCase( aCanURL1 )) << " test for getCanonicalName function: an existed file name, should different from the request, it did not passed(W32)(UNX)"; + } - CPPUNIT_ASSERT_MESSAGE( " test for getCanonicalName function: invalid file name, should different from the request, it did not passed(W32)(UNX)", - ( osl::FileBase::E_None == nError ) && aUStr_ValidURL.equalsIgnoreAsciiCase( aCanURL2 ) ); - } + TEST_F(getCanonicalName, getCanonicalName_003 ) + { + ::rtl::OUString aUStr_ValidURL; + nError = ::osl::FileBase::getCanonicalName ( aCanURL2, aUStr_ValidURL ); - CPPUNIT_TEST_SUITE( getCanonicalName ); - CPPUNIT_TEST( getCanonicalName_001 ); - CPPUNIT_TEST( getCanonicalName_002 ); - CPPUNIT_TEST( getCanonicalName_003 ); - CPPUNIT_TEST_SUITE_END( ); - };// class getCanonicalName + ASSERT_TRUE(( osl::FileBase::E_None == nError ) && aUStr_ValidURL.equalsIgnoreAsciiCase( aCanURL2 )) << " test for getCanonicalName function: invalid file name, should different from the request, it did not passed(W32)(UNX)"; + } #endif //--------------------------------------------------------------------- @@ -774,7 +765,7 @@ namespace osl_FileBase // ::rtl::OUString& ustrAbsoluteFileURL ) //--------------------------------------------------------------------- - class getAbsoluteFileURL:public CppUnit::TestFixture + class getAbsoluteFileURL:public ::testing::Test { //::osl::FileBase aFileBase; ::rtl::OUString aResultURL1, aResultURL2, aResultURL3, aResultURL4, aResultURL5, aResultURL6; @@ -796,22 +787,7 @@ namespace osl_FileBase void getAbsoluteFileURL_002(); void getAbsoluteFileURL_003(); void getAbsoluteFileURL_004(); - - CPPUNIT_TEST_SUITE( getAbsoluteFileURL ); - CPPUNIT_TEST( getAbsoluteFileURL_001_1 ); - CPPUNIT_TEST( getAbsoluteFileURL_001_2 ); - CPPUNIT_TEST( getAbsoluteFileURL_001_3 ); - CPPUNIT_TEST( getAbsoluteFileURL_001_4 ); - CPPUNIT_TEST( getAbsoluteFileURL_001_5 ); - CPPUNIT_TEST( getAbsoluteFileURL_001_6 ); - CPPUNIT_TEST( getAbsoluteFileURL_001_7 ); - CPPUNIT_TEST( getAbsoluteFileURL_001_8 ); - CPPUNIT_TEST( getAbsoluteFileURL_002 ); - CPPUNIT_TEST( getAbsoluteFileURL_003 ); - CPPUNIT_TEST( getAbsoluteFileURL_004 ); - CPPUNIT_TEST_SUITE_END( ); - - }; //class getAbsoluteFileURL + }; //class getAbsoluteFileURL /* use coding format as same as getSystemPathFromFileURL // initialization @@ -861,12 +837,11 @@ namespace osl_FileBase printFileName( aUStr_AbsURL ); printFileName( aResultURL6 ); - CPPUNIT_ASSERT_MESSAGE("test for getAbsoluteFileURL function: valid file name with valid directory", - ( ::osl::FileBase::E_None == nError11 ) && ( sal_True == nError12 ) && + ASSERT_TRUE(( ::osl::FileBase::E_None == nError11 ) && ( sal_True == nError12 ) && ( ::osl::FileBase::E_None == nError21 ) && ( sal_True == nError22 ) && ( ::osl::FileBase::E_None == nError31 ) && ( sal_True == nError32 ) && ( ::osl::FileBase::E_None == nError41 ) && ( sal_True == nError42 ) && - ( ::osl::FileBase::E_None == nError61 ) && ( sal_True == nError62 ) ); + ( ::osl::FileBase::E_None == nError61 ) && ( sal_True == nError62 )) << "test for getAbsoluteFileURL function: valid file name with valid directory"; } @@ -883,7 +858,7 @@ namespace osl_FileBase createTestFile( aCanURL1 ); sal_Int32 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() ); - CPPUNIT_ASSERT( fd == 0 ); + ASSERT_TRUE( fd == 0 ); nError = aFileBase.getAbsoluteFileURL( aUserDirectoryURL, aLnkURL1, aUStr_AbsURL ); bOk = aUStr_AbsURL.equals( aResultURL5 ); @@ -899,16 +874,14 @@ namespace osl_FileBase deleteTestFile( aCanURL1 ); fd = remove( strLinkFileName.getStr() ); - CPPUNIT_ASSERT( fd == 0 ); + ASSERT_TRUE( fd == 0 ); - CPPUNIT_ASSERT_MESSAGE("test for getAbsoluteFileURL function: URL contain link( Solaris version )", - ( ::osl::FileBase::E_None == nError ) && ( sal_True == bOk ) ); + ASSERT_TRUE(( ::osl::FileBase::E_None == nError ) && ( sal_True == bOk )) << "test for getAbsoluteFileURL function: URL contain link( Solaris version )"; } #else //Windows version void getAbsoluteFileURL_002( ) { - CPPUNIT_ASSERT_MESSAGE("test for getAbsoluteFileURL function: URL contain link( Windows version )", - 1 ); + ASSERT_TRUE(1) << "test for getAbsoluteFileURL function: URL contain link( Windows version )"; } #endif @@ -927,7 +900,7 @@ namespace osl_FileBase suError += aUStr_AbsURL; suError += ::rtl::OUString::createFromAscii("' ),Parameter is invalid. it ignore the invalid base in Windows, did not pass in (W32), the reason maybe caused by the similar bug with getSystemPathFromFileURL() "); - CPPUNIT_ASSERT_MESSAGE( suError, ( ::osl::FileBase::E_INVAL == nError ) ); + ASSERT_TRUE(( ::osl::FileBase::E_INVAL == nError )) << suError; #endif } @@ -957,7 +930,7 @@ namespace osl_FileBase deleteTestDirectory( aUStrBase ); deleteTestDirectory( aUStrUpBase ); - CPPUNIT_ASSERT_MESSAGE( suError, ( ::osl::FileBase::E_None == nError ) && ( sal_True == bOk ) ); + ASSERT_TRUE(( ::osl::FileBase::E_None == nError ) && ( sal_True == bOk )) << suError; } CPPUNIT_TEST_SUITE( getAbsoluteFileURL ); @@ -976,36 +949,36 @@ namespace osl_FileBase osl::FileBase::RC nError = FileBase::getAbsoluteFileURL( _suBaseURL, suRelativeURL, suResultURL ); rtl::OString sResultURL = rtl::OUStringToOString( suResultURL, RTL_TEXTENCODING_UTF8); rtl::OString sError = errorToString(nError); - t_print("getAbsoluteFileURL('%s','%s') deliver absolute URL: '%s', error '%s'\n", sBaseURL.getStr(), _sRelativeURL.getStr(),sResultURL.getStr(), sError.getStr() ); - CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong: error number is wrong", nError == _nAssumeError ); + printf("getAbsoluteFileURL('%s','%s') deliver absolute URL: '%s', error '%s'\n", sBaseURL.getStr(), _sRelativeURL.getStr(),sResultURL.getStr(), sError.getStr() ); + ASSERT_TRUE(nError == _nAssumeError) << "Assumption is wrong: error number is wrong"; if ( nError == ::osl::FileBase::E_None ) { sal_Bool bStrAreEqual = _suAssumeResultStr.equals( suResultURL ); - CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong: ResultURL is not equal to expected URL ", bStrAreEqual == sal_True ); + ASSERT_TRUE(bStrAreEqual == sal_True) << "Assumption is wrong: ResultURL is not equal to expected URL "; } } - void getAbsoluteFileURL::getAbsoluteFileURL_001_1() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_001_1) { rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/relative/file1") ); check_getAbsoluteFileURL( aUserDirectoryURL, "relative/file1",::osl::FileBase::E_None, suAssume ); } - void getAbsoluteFileURL::getAbsoluteFileURL_001_2() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_001_2) { rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/relative/file2") ); check_getAbsoluteFileURL( aUserDirectoryURL, "relative/./file2",::osl::FileBase::E_None, suAssume ); } - void getAbsoluteFileURL::getAbsoluteFileURL_001_3() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_001_3) { rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/file3") ); check_getAbsoluteFileURL( aUserDirectoryURL, "relative/../file3",::osl::FileBase::E_None, suAssume ); } - void getAbsoluteFileURL::getAbsoluteFileURL_001_4() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_001_4) { rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/file4") ); check_getAbsoluteFileURL( aUserDirectoryURL, "././relative/../file4",::osl::FileBase::E_None, suAssume ); } - void getAbsoluteFileURL::getAbsoluteFileURL_001_5() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_001_5) { rtl::OUString suAssume; #if ( defined UNX ) @@ -1015,12 +988,12 @@ namespace osl_FileBase #endif check_getAbsoluteFileURL( aUserDirectoryURL, "././relative/.",::osl::FileBase::E_None, suAssume ); } - void getAbsoluteFileURL::getAbsoluteFileURL_001_6() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_001_6) { rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/.relative") ); check_getAbsoluteFileURL( aUserDirectoryURL, "./.relative",::osl::FileBase::E_None, suAssume ); } - void getAbsoluteFileURL::getAbsoluteFileURL_001_7() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_001_7) { rtl::OUString suAssume; #if (defined UNX ) @@ -1030,7 +1003,7 @@ namespace osl_FileBase #endif check_getAbsoluteFileURL( aUserDirectoryURL, "./.a/mydir/..",::osl::FileBase::E_None, suAssume ); } - void getAbsoluteFileURL::getAbsoluteFileURL_001_8() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_001_8) { rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/tmp/ok") ); #if ( defined UNX ) || ( defined OS2 ) @@ -1039,7 +1012,7 @@ namespace osl_FileBase check_getAbsoluteFileURL( aUserDirectoryURL, "tmp//ok",::osl::FileBase::E_INVAL, suAssume ); #endif } - void getAbsoluteFileURL::getAbsoluteFileURL_002() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_002) { #if ( defined UNX ) || ( defined OS2 ) //Link is not defined in Windows ::rtl::OUString aUStr_AbsURL, aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys ); @@ -1052,20 +1025,20 @@ namespace osl_FileBase createTestFile( aCanURL1 ); sal_Int32 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() ); - CPPUNIT_ASSERT( fd == 0 ); + ASSERT_TRUE( fd == 0 ); rtl::OString sLnkURL = OUStringToOString( aLnkURL1, RTL_TEXTENCODING_ASCII_US ); rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString::createFromAscii("/canonical.name") ); check_getAbsoluteFileURL( aUserDirectoryURL, sLnkURL, ::osl::FileBase::E_None, suAssume ); deleteTestFile( aCanURL1 ); fd = remove( strLinkFileName.getStr() ); - CPPUNIT_ASSERT( fd == 0 ); + ASSERT_TRUE( fd == 0 ); #endif } //please see line# 930 - void getAbsoluteFileURL::getAbsoluteFileURL_003() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_003) { } - void getAbsoluteFileURL::getAbsoluteFileURL_004() + TEST_F(getAbsoluteFileURL, getAbsoluteFileURL_004) { //create two level directories under $Temp/PID/ ::rtl::OUString aUStrUpBase = aUserDirectoryURL + ::rtl::OUString::createFromAscii("/test1"); @@ -1085,8 +1058,9 @@ namespace osl_FileBase // static RC getFileURLFromSystemPath( const ::rtl::OUString & ustrSystemPath, // ::rtl::OUString & ustrFileURL ); //--------------------------------------------------------------------- - class SystemPath_FileURL:public CppUnit::TestFixture + class SystemPath_FileURL:public ::testing::Test { + protected: //::osl::FileBase aFileBase; // ::rtl::OUString aUStr; // ::osl::FileBase::RC nError; @@ -1098,69 +1072,6 @@ namespace osl_FileBase void checkWNTBehaviour_getFileURLFromSystemPath(rtl::OString const& _sSysPath, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sWNTAssumeResultString); void checkUNXBehaviour_getFileURLFromSystemPath(rtl::OString const& _sSysPath, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sUnixAssumeResultString); - public: - // test code. - void getSystemPathFromFileURL_001_1( ); - void getSystemPathFromFileURL_001_2( ); - void getSystemPathFromFileURL_001_21( ); - void getSystemPathFromFileURL_001_22( ); - void getSystemPathFromFileURL_001_3( ); - void getSystemPathFromFileURL_001_31( ); - void getSystemPathFromFileURL_001_4( ); - void getSystemPathFromFileURL_001_41( ); - void getSystemPathFromFileURL_001_5( ); - void getSystemPathFromFileURL_001_51( ); - void getSystemPathFromFileURL_001_52( ); - void getSystemPathFromFileURL_001_53( ); - void getSystemPathFromFileURL_001_6( ); - void getSystemPathFromFileURL_001_61( ); - void getSystemPathFromFileURL_001_7( ); - void getSystemPathFromFileURL_001_71( ); - void getSystemPathFromFileURL_001_8( ); - void getSystemPathFromFileURL_001_81( ); - void getSystemPathFromFileURL_001_9( ); - void getSystemPathFromFileURL_001_91( ); - void getSystemPathFromFileURL_001_92( ); - void getSystemPathFromFileURL_004( ); - void getSystemPathFromFileURL_005( ); - - //test case fot getFileURLFromSystemPath - void getFileURLFromSystemPath_001( ); - void getFileURLFromSystemPath_002( ); - void getFileURLFromSystemPath_003( ); - void getFileURLFromSystemPath_004( ); - void getFileURLFromSystemPath_005( ); - - CPPUNIT_TEST_SUITE( SystemPath_FileURL ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_1 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_2 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_21 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_22 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_3 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_31 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_4 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_41 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_5 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_51 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_52 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_53 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_6 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_61 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_7 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_71 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_8 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_81 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_9 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_91 ); - CPPUNIT_TEST( getSystemPathFromFileURL_001_92 ); - CPPUNIT_TEST( getSystemPathFromFileURL_004 ); - CPPUNIT_TEST( getSystemPathFromFileURL_005 ); - CPPUNIT_TEST( getFileURLFromSystemPath_001 ); - CPPUNIT_TEST( getFileURLFromSystemPath_002 ); - CPPUNIT_TEST( getFileURLFromSystemPath_003 ); - CPPUNIT_TEST( getFileURLFromSystemPath_004 ); - CPPUNIT_TEST( getFileURLFromSystemPath_005 ); - CPPUNIT_TEST_SUITE_END( ); };// class SystemPath_FileURL @@ -1178,21 +1089,20 @@ namespace osl_FileBase // we check also this string rtl::OString sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8); rtl::OString sError = errorToString(nError); - t_print("getSystemPathFromFileURL('%s') deliver system path: '%s', error '%s'\n", _sURL.getStr(), sStr.getStr(), sError.getStr() ); + printf("getSystemPathFromFileURL('%s') deliver system path: '%s', error '%s'\n", _sURL.getStr(), sStr.getStr(), sError.getStr() ); // rtl::OUString suStrEncode = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8); // sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8); - // t_print("UTF8: %s\n", sStr.getStr() ); + // printf("UTF8: %s\n", sStr.getStr() ); if (_sAssumeResultStr.getLength() > 0) { sal_Bool bStrAreEqual = _sAssumeResultStr.equals(sStr); - CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong", - nError == _nAssumeError && bStrAreEqual == sal_True ); + ASSERT_TRUE(nError == _nAssumeError && bStrAreEqual == sal_True) << "Assumption is wrong"; } else { - CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong", nError == _nAssumeError ); + ASSERT_TRUE(nError == _nAssumeError) << "Assumption is wrong"; } }*/ @@ -1215,23 +1125,22 @@ namespace osl_FileBase rtl::OString sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8); rtl::OString sError = errorToString(nError); if ( bDirection == sal_True ) - t_print("getSystemPathFromFileURL('%s') deliver system path: '%s', error '%s'\n", _sSource.getStr(), sStr.getStr(), sError.getStr() ); + printf("getSystemPathFromFileURL('%s') deliver system path: '%s', error '%s'\n", _sSource.getStr(), sStr.getStr(), sError.getStr() ); else - t_print("getFileURLFromSystemPath('%s') deliver File URL: '%s', error '%s'\n", _sSource.getStr(), sStr.getStr(), sError.getStr() ); + printf("getFileURLFromSystemPath('%s') deliver File URL: '%s', error '%s'\n", _sSource.getStr(), sStr.getStr(), sError.getStr() ); // rtl::OUString suStrEncode = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8); // sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8); - // t_print("UTF8: %s\n", sStr.getStr() ); + // printf("UTF8: %s\n", sStr.getStr() ); if (_sAssumeResultStr.getLength() > 0) { sal_Bool bStrAreEqual = _sAssumeResultStr.equals(sStr); - CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong", - nError == _nAssumeError && bStrAreEqual == sal_True ); + ASSERT_TRUE(nError == _nAssumeError && bStrAreEqual == sal_True) << "Assumption is wrong"; } else { - CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong", nError == _nAssumeError ); + ASSERT_TRUE(nError == _nAssumeError) << "Assumption is wrong"; } } void SystemPath_FileURL::checkWNTBehaviour_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sWNTAssumeResultString) @@ -1287,112 +1196,112 @@ namespace osl_FileBase the third parameter is the assumed result string, the string will only test, if it's length is greater 0 */ - void SystemPath_FileURL::getSystemPathFromFileURL_001_1() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_1) { rtl::OString sURL(""); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_2() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_2) { rtl::OString sURL("/"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "\\"); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_21() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_21) { // rtl::OString sURL("%2f"); rtl::OString sURL("%2F"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/"); // LLA: this is may be a BUG checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_22() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_22) { rtl::OString sURL("file:///tmp%2Fmydir"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_3() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_3) { rtl::OString sURL("a"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "a"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "a"); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_31() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_31) { rtl::OString sURL("tmpname"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "tmpname"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "tmpname"); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_4() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_4) { rtl::OString sURL("file://"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, ""); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_41() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_41) { rtl::OString sURL("file://localhost/tmp"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, ""); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_5() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_5) { rtl::OString sURL("file:///tmp"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_51() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_51) { rtl::OString sURL("file://c:/tmp"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:/tmp"); // LLA: this is may be a BUG checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_52() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_52) { rtl::OString sURL("file:///c:/tmp"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp"); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_53() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_53) { // LLA: is this a legal file path? rtl::OString sURL("file:///c|/tmp"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c|/tmp"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp"); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_6() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_6) { rtl::OString sURL("file:///tmp/first"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp/first"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_61() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_61) { rtl::OString sURL("file:///c:/tmp/first"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp/first"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp\\first"); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_7() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_7) { rtl::OString sURL("file:///tmp/../second"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp/../second"); // LLA: may be a BUG checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_71() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_71) { rtl::OString sURL("file:///c:/tmp/../second"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp/../second"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp\\..\\second"); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_8() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_8) { rtl::OString sURL("../tmp"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "../tmp"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "..\\tmp"); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_81() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_81) { rtl::OString sURL("file://~/tmp"); char* home_path; @@ -1402,20 +1311,20 @@ namespace osl_FileBase checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, expResult ); // checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "\\tmp"); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_9() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_9) { rtl::OString sURL("file:///tmp/first%20second"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp/first second"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_91() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_91) { rtl::OString sURL("file:///c:/tmp/first%20second"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp/first second"); checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp\\first second"); } - void SystemPath_FileURL::getSystemPathFromFileURL_001_92() + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_001_92) { rtl::OString sURL("ca@#;+.,$///78no%01ni..name"); checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, ""); @@ -1423,7 +1332,7 @@ namespace osl_FileBase } #if 0 - void SystemPath_FileURL::getSystemPathFromFileURL_003( ) + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_003) { // LLA: ??? //!! seams to be, that the directories do not pass together @@ -1438,12 +1347,12 @@ namespace osl_FileBase suError += aRelativeURL; suError += ::rtl::OUString::createFromAscii(") function:use a relative file URL, did not pass in(W32), it did not specified in method declaration of relative path issue, "); suError += outputError(aUStr, aResultURL); - CPPUNIT_ASSERT_MESSAGE( suError, ( osl::FileBase::E_None == nError ) && ( sal_True == bOk ) ); + ASSERT_TRUE(( osl::FileBase::E_None == nError ) && ( sal_True == bOk )) << suError; } #endif //normal legal case - void SystemPath_FileURL::getSystemPathFromFileURL_004( ) + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_004) { ::rtl::OUString aUStr; ::rtl::OUString aNormalURL( aTmpName6 ); @@ -1457,12 +1366,12 @@ namespace osl_FileBase suError += ::rtl::OUString::createFromAscii(" ') function:use an absolute file URL, "); suError += outputError(aUStr, aResultURL); - CPPUNIT_ASSERT_MESSAGE( suError, ( osl::FileBase::E_None == nError ) && ( sal_True == bOk ) ); + ASSERT_TRUE(( osl::FileBase::E_None == nError ) && ( sal_True == bOk )) << suError.pData; } //CJK characters case - void SystemPath_FileURL::getSystemPathFromFileURL_005( ) + TEST_F(SystemPath_FileURL, getSystemPathFromFileURL_005) { ::rtl::OUString aUStr; createTestDirectory( aTmpName10 ); @@ -1479,9 +1388,9 @@ namespace osl_FileBase suError += outputError(aUStr, aResultURL); deleteTestDirectory( aTmpName10 ); - CPPUNIT_ASSERT_MESSAGE( suError, ( osl::FileBase::E_None == nError ) && ( sal_True == bOk ) ); + ASSERT_TRUE(( osl::FileBase::E_None == nError ) && ( sal_True == bOk )) << suError.pData; } - void SystemPath_FileURL::getFileURLFromSystemPath_001() + TEST_F(SystemPath_FileURL, getFileURLFromSystemPath_001) { rtl::OString sSysPath("~/tmp"); char* home_path; @@ -1491,25 +1400,25 @@ namespace osl_FileBase checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, expResult ); checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "~/tmp"); } - void SystemPath_FileURL::getFileURLFromSystemPath_002() + TEST_F(SystemPath_FileURL, getFileURLFromSystemPath_002) { rtl::OString sSysPath("c:/tmp"); checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "c:/tmp"); checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "file:///c:/tmp"); } - void SystemPath_FileURL::getFileURLFromSystemPath_003() + TEST_F(SystemPath_FileURL, getFileURLFromSystemPath_003) { rtl::OString sSysPath("file:///temp"); checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, ""); checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getFileURLFromSystemPath_004() + TEST_F(SystemPath_FileURL, getFileURLFromSystemPath_004) { rtl::OString sSysPath("//tmp//first start"); checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "file:///tmp/first%20start"); checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, ""); } - void SystemPath_FileURL::getFileURLFromSystemPath_005() + TEST_F(SystemPath_FileURL, getFileURLFromSystemPath_005) { rtl::OString sSysPath(""); checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, ""); @@ -1527,141 +1436,120 @@ namespace osl_FileBase // const ::rtl::OUString& ustrSearchPath, // ::rtl::OUString& ustrFileURL ) //--------------------------------------------------------------------- - class searchFileURL:public CppUnit::TestFixture + class searchFileURL:public ::testing::Test { + protected: //::osl::FileBase aFileBase; ::rtl::OUString aUStr; ::osl::FileBase::RC nError1, nError2, nError3,nError4; public: + };// class searchFileURL - // test code. - void searchFileURL_001( ) - { - /* search file is passed by system filename */ - nError1 = ::osl::FileBase::searchFileURL( aTmpName1, aUserDirectorySys, aUStr ); - /* search file is passed by full qualified file URL */ - nError2 = ::osl::FileBase::searchFileURL( aCanURL1, aUserDirectorySys, aUStr ); - /* search file is passed by relative file path */ - nError3 = ::osl::FileBase::searchFileURL( aRelURL4, aUserDirectorySys, aUStr ); - - CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) ", - ( osl::FileBase::E_NOENT == nError1 ) && - ( osl::FileBase::E_NOENT == nError2 ) && - ( osl::FileBase::E_NOENT == nError3 )); - } - - void searchFileURL_002( ) - { - /* search file is passed by system filename */ - nError1 = ::osl::FileBase::searchFileURL( aTempDirectorySys, aRootSys, aUStr ); - sal_Bool bOk1 = compareFileName( aUStr, aTempDirectoryURL ); - /* search file is passed by full qualified file URL */ - nError2 = ::osl::FileBase::searchFileURL( aTempDirectoryURL, aRootSys, aUStr ); - sal_Bool bOk2 = compareFileName( aUStr, aTempDirectoryURL ); - /* search file is passed by relative file path */ - nError3 = ::osl::FileBase::searchFileURL( aRelURL5, aRootSys, aUStr ); - sal_Bool bOk3 = compareFileName( aUStr, aTempDirectoryURL ); - /* search file is passed by an exist file */ - createTestFile( aCanURL1 ); - nError4 = ::osl::FileBase::searchFileURL( aCanURL4, aUserDirectorySys, aUStr ); - sal_Bool bOk4 = compareFileName( aUStr, aCanURL1 ); - deleteTestFile( aCanURL1 ); - - CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.", - ( osl::FileBase::E_None == nError1 ) && - ( osl::FileBase::E_None == nError2 ) && - ( osl::FileBase::E_None == nError3 ) && - ( osl::FileBase::E_None == nError4 ) && - ( sal_True == bOk1 ) && - ( sal_True == bOk2 ) && - ( sal_True == bOk3 ) && - ( sal_True == bOk4 ) ); - } + // test code. + TEST_F(searchFileURL, searchFileURL_001 ) + { + /* search file is passed by system filename */ + nError1 = ::osl::FileBase::searchFileURL( aTmpName1, aUserDirectorySys, aUStr ); + /* search file is passed by full qualified file URL */ + nError2 = ::osl::FileBase::searchFileURL( aCanURL1, aUserDirectorySys, aUStr ); + /* search file is passed by relative file path */ + nError3 = ::osl::FileBase::searchFileURL( aRelURL4, aUserDirectorySys, aUStr ); + + ASSERT_TRUE(( osl::FileBase::E_NOENT == nError1 ) && + ( osl::FileBase::E_NOENT == nError2 ) && + ( osl::FileBase::E_NOENT == nError3 )) << "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) "; + } + TEST_F(searchFileURL, searchFileURL_002 ) + { + /* search file is passed by system filename */ + nError1 = ::osl::FileBase::searchFileURL( aTempDirectorySys, aRootSys, aUStr ); + sal_Bool bOk1 = compareFileName( aUStr, aTempDirectoryURL ); + /* search file is passed by full qualified file URL */ + nError2 = ::osl::FileBase::searchFileURL( aTempDirectoryURL, aRootSys, aUStr ); + sal_Bool bOk2 = compareFileName( aUStr, aTempDirectoryURL ); + /* search file is passed by relative file path */ + nError3 = ::osl::FileBase::searchFileURL( aRelURL5, aRootSys, aUStr ); + sal_Bool bOk3 = compareFileName( aUStr, aTempDirectoryURL ); + /* search file is passed by an exist file */ + createTestFile( aCanURL1 ); + nError4 = ::osl::FileBase::searchFileURL( aCanURL4, aUserDirectorySys, aUStr ); + sal_Bool bOk4 = compareFileName( aUStr, aCanURL1 ); + deleteTestFile( aCanURL1 ); - void searchFileURL_003( ) - { - OSLTEST_DECLARE( SystemPathList, TEST_PLATFORM_ROOT":"TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP":"TEST_PLATFORM_ROOT"system/path" ); - nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aSystemPathList, aUStr ); - sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL ); - CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is a list of system paths", - ( osl::FileBase::E_None == nError1 ) && - ( sal_True == bOk ) ); - } + ASSERT_TRUE(( osl::FileBase::E_None == nError1 ) && + ( osl::FileBase::E_None == nError2 ) && + ( osl::FileBase::E_None == nError3 ) && + ( osl::FileBase::E_None == nError4 ) && + ( sal_True == bOk1 ) && + ( sal_True == bOk2 ) && + ( sal_True == bOk3 ) && + ( sal_True == bOk4 )) << "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist."; + } - void searchFileURL_004( ) - { - OSLTEST_DECLARE( SystemPathList, TEST_PLATFORM_ROOT PATH_LIST_DELIMITER TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP PATH_LIST_DELIMITER TEST_PLATFORM_ROOT "system/path/../name" ); - nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aSystemPathList, aUStr ); - sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL ); - CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is a list of system paths", - ( osl::FileBase::E_None == nError1 ) && - ( sal_True == bOk ) ); - } - void searchFileURL_005( ) - { - nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aNullURL, aUStr ); - sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL ); - CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is NULL", - ( osl::FileBase::E_None == nError1 ) && - ( sal_True == bOk ) ); - } + TEST_F(searchFileURL, searchFileURL_003 ) + { + OSLTEST_DECLARE( SystemPathList, TEST_PLATFORM_ROOT":"TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP":"TEST_PLATFORM_ROOT"system/path" ); + nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aSystemPathList, aUStr ); + sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL ); + ASSERT_TRUE(( osl::FileBase::E_None == nError1 ) && + ( sal_True == bOk )) << "test for searchFileURL function: search directory is a list of system paths"; + } - CPPUNIT_TEST_SUITE( searchFileURL ); - CPPUNIT_TEST( searchFileURL_001 ); - CPPUNIT_TEST( searchFileURL_002 ); - CPPUNIT_TEST( searchFileURL_003 ); - CPPUNIT_TEST( searchFileURL_004 ); - CPPUNIT_TEST( searchFileURL_005 ); - CPPUNIT_TEST_SUITE_END( ); - };// class searchFileURL + TEST_F(searchFileURL, searchFileURL_004 ) + { + OSLTEST_DECLARE( SystemPathList, TEST_PLATFORM_ROOT PATH_LIST_DELIMITER TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP PATH_LIST_DELIMITER TEST_PLATFORM_ROOT "system/path/../name" ); + nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aSystemPathList, aUStr ); + sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL ); + ASSERT_TRUE(( osl::FileBase::E_None == nError1 ) && + ( sal_True == bOk )) << "test for searchFileURL function: search directory is a list of system paths"; + } + TEST_F(searchFileURL, searchFileURL_005 ) + { + nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aNullURL, aUStr ); + sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL ); + ASSERT_TRUE(( osl::FileBase::E_None == nError1 ) && + ( sal_True == bOk )) << "test for searchFileURL function: search directory is NULL"; + } //--------------------------------------------------------------------- // testing the method // static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL ) //--------------------------------------------------------------------- - class getTempDirURL:public CppUnit::TestFixture + class getTempDirURL:public ::testing::Test { + protected: //::osl::FileBase aFileBase; ::rtl::OUString aUStr; ::osl::FileBase::RC nError; public: // initialization - void setUp( ) + void SetUp( ) { nError = FileBase::getTempDirURL( aUStr ); } - void tearDown( ) - { - } - - // test code. - void getTempDirURL_001( ) + void TearDown( ) { - - CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: excution", - ( osl::FileBase::E_None == nError ) ); } + };// class getTempDirURL - void getTempDirURL_002( ) - { - CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: test for open and write access rights", - checkDirectory( aUStr, osl_Check_Mode_OpenAccess ) && - checkDirectory( aUStr, osl_Check_Mode_ReadAccess ) && - checkDirectory( aUStr,osl_Check_Mode_WriteAccess ) ); - } + TEST_F(getTempDirURL, getTempDirURL_001 ) + { - CPPUNIT_TEST_SUITE( getTempDirURL ); - CPPUNIT_TEST( getTempDirURL_001 ); - CPPUNIT_TEST( getTempDirURL_002 ); - CPPUNIT_TEST_SUITE_END( ); - };// class getTempDirURL + ASSERT_TRUE(( osl::FileBase::E_None == nError )) << "test for getTempDirURL function: excution"; + } + TEST_F(getTempDirURL, getTempDirURL_002 ) + { + ASSERT_TRUE(checkDirectory( aUStr, osl_Check_Mode_OpenAccess ) && + checkDirectory( aUStr, osl_Check_Mode_ReadAccess ) && + checkDirectory( aUStr,osl_Check_Mode_WriteAccess )) << "test for getTempDirURL function: test for open and write access rights"; + } //--------------------------------------------------------------------- // testing the method @@ -1669,8 +1557,9 @@ namespace osl_FileBase // oslFileHandle* pHandle, // ::rtl::OUString* pustrTempFileURL) //--------------------------------------------------------------------- - class createTempFile:public CppUnit::TestFixture + class createTempFile:public ::testing::Test { + protected: //::osl::FileBase aFileBase; ::osl::FileBase::RC nError1, nError2; sal_Bool bOK; @@ -1682,7 +1571,7 @@ namespace osl_FileBase public: // initialization - void setUp( ) + void SetUp( ) { pHandle = new oslFileHandle(); pUStr_DirURL = new ::rtl::OUString( aUserDirectoryURL ); @@ -1690,92 +1579,69 @@ namespace osl_FileBase //*pUStr_DirURL = aUserDirectoryURL; /// create temp file in /tmp/PID or c:\temp\PID.*/ } - void tearDown( ) + void TearDown( ) { delete pUStr_DirURL; delete pUStr_FileURL; delete pHandle; } + };// class createTempFile - // test code. - void createTempFile_001( ) - { - nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL ); - ::osl::File testFile( *pUStr_FileURL ); - //printFileName(*pUStr_FileURL); - nError2 = testFile.open( OpenFlag_Create ); - if ( osl::FileBase::E_EXIST == nError2 ) { - osl_closeFile( *pHandle ); - deleteTestFile( *pUStr_FileURL ); - } - - CPPUNIT_ASSERT_MESSAGE( "test for createTempFile function: create temp file and test the existence", - ( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && ( osl::FileBase::E_EXIST== nError2 ) ); + TEST_F(createTempFile, createTempFile_001 ) + { + nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL ); + ::osl::File testFile( *pUStr_FileURL ); + //printFileName(*pUStr_FileURL); + nError2 = testFile.open( OpenFlag_Create ); + if ( osl::FileBase::E_EXIST == nError2 ) { + osl_closeFile( *pHandle ); + deleteTestFile( *pUStr_FileURL ); } - void createTempFile_002( ) - { - bOK = sal_False; - nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL ); - ::osl::File testFile( *pUStr_FileURL ); - nError2 = testFile.open( OpenFlag_Create ); - - CPPUNIT_ASSERT_MESSAGE( "createTempFile function: create a temp file, but it does not exist", - ( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && - ( osl::FileBase::E_EXIST == nError2 ) ); - - //check file if have the write permission - if ( osl::FileBase::E_EXIST == nError2 ) { - bOK = ifFileCanWrite( *pUStr_FileURL ); - osl_closeFile( *pHandle ); - deleteTestFile( *pUStr_FileURL ); - } + ASSERT_TRUE(( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && ( osl::FileBase::E_EXIST== nError2 )) << "test for createTempFile function: create temp file and test the existence"; + } - CPPUNIT_ASSERT_MESSAGE( "test for open and write access rights, in (W32), it did not have write access right, but it should be writtenable.", - ( sal_True == bOK ) ); + TEST_F(createTempFile, createTempFile_002 ) + { + bOK = sal_False; + nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL ); + ::osl::File testFile( *pUStr_FileURL ); + nError2 = testFile.open( OpenFlag_Create ); + + ASSERT_TRUE(( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && + ( osl::FileBase::E_EXIST == nError2 )) << "createTempFile function: create a temp file, but it does not exist"; + + //check file if have the write permission + if ( osl::FileBase::E_EXIST == nError2 ) { + bOK = ifFileCanWrite( *pUStr_FileURL ); + osl_closeFile( *pHandle ); + deleteTestFile( *pUStr_FileURL ); } - void createTempFile_003( ) - { - nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, 0 ); - //the temp file will be removed when return from createTempFile - bOK = ( pHandle != NULL && pHandle != 0); - if ( sal_True == bOK ) - osl_closeFile( *pHandle ); - - CPPUNIT_ASSERT_MESSAGE( "test for createTempFile function: set pUStrFileURL to 0 to let it remove the file after call.", - ( ::osl::FileBase::E_None == nError1 ) &&( sal_True == bOK ) ); - } - void createTempFile_004( ) - { - nError1 = FileBase::createTempFile( pUStr_DirURL, 0, pUStr_FileURL ); - bOK = ( pUStr_FileURL != 0); - ::osl::File testFile( *pUStr_FileURL ); - nError2 = testFile.open( OpenFlag_Create ); - deleteTestFile( *pUStr_FileURL ); - CPPUNIT_ASSERT_MESSAGE( "createTempFile function: create a temp file, but it does not exist", - ( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_EXIST == nError2 ) &&( sal_True == bOK ) ); + ASSERT_TRUE(( sal_True == bOK )) << "test for open and write access rights, in (W32), it did not have write access right, but it should be writtenable."; + } - } + TEST_F(createTempFile, createTempFile_003 ) + { + nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, 0 ); + //the temp file will be removed when return from createTempFile + bOK = ( pHandle != NULL && pHandle != 0); + if ( sal_True == bOK ) + osl_closeFile( *pHandle ); - CPPUNIT_TEST_SUITE( createTempFile ); - CPPUNIT_TEST( createTempFile_001 ); - CPPUNIT_TEST( createTempFile_002 ); - CPPUNIT_TEST( createTempFile_003 ); - CPPUNIT_TEST( createTempFile_004 ); - CPPUNIT_TEST_SUITE_END( ); - };// class createTempFile + ASSERT_TRUE(( ::osl::FileBase::E_None == nError1 ) &&( sal_True == bOK )) << "test for createTempFile function: set pUStrFileURL to 0 to let it remove the file after call."; + } + TEST_F(createTempFile, createTempFile_004 ) + { + nError1 = FileBase::createTempFile( pUStr_DirURL, 0, pUStr_FileURL ); + bOK = ( pUStr_FileURL != 0); + ::osl::File testFile( *pUStr_FileURL ); + nError2 = testFile.open( OpenFlag_Create ); + deleteTestFile( *pUStr_FileURL ); + ASSERT_TRUE(( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_EXIST == nError2 ) &&( sal_True == bOK )) << "createTempFile function: create a temp file, but it does not exist"; + + } - // ----------------------------------------------------------------------------- -#if 0 //~ this function has been deprecated. - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getCanonicalName, "osl_FileBase" ); -#endif - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getAbsoluteFileURL, "osl_FileBase" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::SystemPath_FileURL, "osl_FileBase" ); - // CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getFileURLFromSystemPath, "osl_FileBase" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::searchFileURL, "osl_FileBase" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getTempDirURL, "osl_FileBase" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::createTempFile, "osl_FileBase" ); }// namespace osl_FileBase @@ -1791,119 +1657,98 @@ namespace osl_VolumeDevice // testing the method // VolumeDevice() : _aHandle( NULL ) //--------------------------------------------------------------------- - class ctors : public CppUnit::TestFixture + class VolumeDeviceCtors : public ::testing::Test { + protected: ::osl::VolumeDevice aVolumeDevice; ::rtl::OUString aUStr; ::osl::FileBase::RC nError1, nError2; public: // initialization - void setUp( ) + void SetUp( ) { } - void tearDown( ) + void TearDown( ) { } + };// class ctors - // test code. - void ctors_001( ) - { - ::osl::VolumeDevice aVolumeDevice1; + TEST_F(VolumeDeviceCtors, ctors_001 ) + { + ::osl::VolumeDevice aVolumeDevice1; - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: Constructor for VolumeDevice with no args.", - ( osl::FileBase::E_None != aVolumeDevice1.automount( ) ) && - ( osl::FileBase::E_None != aVolumeDevice1.unmount( ) ) && - ( aNullURL.equals( aVolumeDevice1.getMountPath( ) ) ) ); - } + ASSERT_TRUE(( osl::FileBase::E_None != aVolumeDevice1.automount( ) ) && + ( osl::FileBase::E_None != aVolumeDevice1.unmount( ) ) && + ( aNullURL.equals( aVolumeDevice1.getMountPath( ) ) )) << "test for ctors function: Constructor for VolumeDevice with no args."; + } - void ctors_002( ) - { - ::osl::VolumeInfo aVolumeInfo( VolumeInfoMask_Attributes ); - nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - ::osl::VolumeDevice aVolumeDevice1( aVolumeInfo.getDeviceHandle( ) ); - sal_Bool bOk = compareFileName( aNullURL, aVolumeDevice1.getMountPath( ) ); - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: Copy constructor for VolumeDevice, the copied VolumeDevice should have a mount path file:///, but it returned an empty OUString, it also may be the error from getDeviceHandle(), it did not pass in (UNX), (W32).", - sal_False == bOk ); - } + TEST_F(VolumeDeviceCtors, ctors_002 ) + { + ::osl::VolumeInfo aVolumeInfo( VolumeInfoMask_Attributes ); + nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); - void ctors_003( ) - { - ::osl::VolumeInfo aVolumeInfo( VolumeInfoMask_Attributes ); - nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - ::osl::VolumeDevice aVolumeDevice1 = aVolumeInfo.getDeviceHandle( ); - sal_Bool bOk = compareFileName( aNullURL, aVolumeDevice1.getMountPath( ) ); - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: Assigned operator for VolumeDevice, the assigned VolumeDevice should have a mount path file:///, but it returned an empty OUString, it also may be the error from getDeviceHandle(),it did not pass in (UNX), (W32).", - sal_False == bOk ); - } + ::osl::VolumeDevice aVolumeDevice1( aVolumeInfo.getDeviceHandle( ) ); + sal_Bool bOk = compareFileName( aNullURL, aVolumeDevice1.getMountPath( ) ); + ASSERT_TRUE(sal_False == bOk) << "test for ctors function: Copy constructor for VolumeDevice, the copied VolumeDevice should have a mount path file:///, but it returned an empty OUString, it also may be the error from getDeviceHandle(), it did not pass in (UNX), (W32)."; + } - CPPUNIT_TEST_SUITE( ctors ); - CPPUNIT_TEST( ctors_001 ); - CPPUNIT_TEST( ctors_002 ); - CPPUNIT_TEST( ctors_003 ); - CPPUNIT_TEST_SUITE_END( ); - };// class ctors + TEST_F(VolumeDeviceCtors, ctors_003 ) + { + ::osl::VolumeInfo aVolumeInfo( VolumeInfoMask_Attributes ); + nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); + ::osl::VolumeDevice aVolumeDevice1 = aVolumeInfo.getDeviceHandle( ); + sal_Bool bOk = compareFileName( aNullURL, aVolumeDevice1.getMountPath( ) ); + ASSERT_TRUE(sal_False == bOk) << "test for ctors function: Assigned operator for VolumeDevice, the assigned VolumeDevice should have a mount path file:///, but it returned an empty OUString, it also may be the error from getDeviceHandle(),it did not pass in (UNX), (W32)."; + } //--------------------------------------------------------------------- // testing the method // inline RC automount() //--------------------------------------------------------------------- - class automount : public CppUnit::TestFixture + class automount : public ::testing::Test { + protected: ::osl::VolumeDevice aVolumeDevice; ::rtl::OUString aUStr; ::osl::FileBase::RC nError1, nError2; public: // initialization - void setUp( ) + void SetUp( ) { } - void tearDown( ) - { - - } - - // test code. - void automount_001( ) + void TearDown( ) { - ::osl::VolumeDevice aVolumeDevice1; - nError1 = aVolumeDevice1.automount( ); - CPPUNIT_ASSERT_MESSAGE( "test for automount function: invalid parameter.", - ( osl::FileBase::E_INVAL == nError1 ) ); } + };// class automount - void automount_002( ) - { - ::osl::VolumeInfo aVolumeInfo( VolumeInfoMask_Attributes ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - ::osl::VolumeDevice aVolumeDevice1( aVolumeInfo.getDeviceHandle( ) ); - nError1 = aVolumeDevice1.unmount( ); - nError1 = aVolumeDevice1.automount( ); - CPPUNIT_ASSERT_MESSAGE( "test for automount function: this test is not implemented yet, it did not pass in (UNX), (W32).", - ( osl::FileBase::E_None == nError1 ) ); - } + TEST_F(automount, automount_001 ) + { + ::osl::VolumeDevice aVolumeDevice1; + nError1 = aVolumeDevice1.automount( ); - CPPUNIT_TEST_SUITE( automount ); - CPPUNIT_TEST( automount_001 ); - CPPUNIT_TEST( automount_002 ); - CPPUNIT_TEST_SUITE_END( ); - };// class automount + ASSERT_TRUE(( osl::FileBase::E_INVAL == nError1 )) << "test for automount function: invalid parameter."; + } + TEST_F(automount, automount_002 ) + { + ::osl::VolumeInfo aVolumeInfo( VolumeInfoMask_Attributes ); + nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); + + ::osl::VolumeDevice aVolumeDevice1( aVolumeInfo.getDeviceHandle( ) ); + nError1 = aVolumeDevice1.unmount( ); + nError1 = aVolumeDevice1.automount( ); + ASSERT_TRUE(( osl::FileBase::E_None == nError1 )) << "test for automount function: this test is not implemented yet, it did not pass in (UNX), (W32)."; + } - // ----------------------------------------------------------------------------- - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeDevice::ctors, "osl_VolumeDevice" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeDevice::automount, "osl_VolumeDevice" ); }// namespace osl_VolumeDevice #endif @@ -1918,8 +1763,9 @@ namespace osl_VolumeInfo // testing the method // VolumeInfo( sal_uInt32 nMask ): _nMask( nMask ) //--------------------------------------------------------------------- - class ctors : public CppUnit::TestFixture + class VolumeInfoCtors : public ::testing::Test { + protected: ::rtl::OUString aUStr; ::osl::FileBase::RC nError1, nError2; @@ -1927,879 +1773,716 @@ namespace osl_VolumeInfo public: // initialization - void setUp( ) + void SetUp( ) { } void tearDown( ) { } + };// class ctors - // test code. - void ctors_001( ) - { - ::osl::VolumeInfo aVolumeInfo( 0 ); - nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace( ); - sal_uInt32 uiMaxPathLength = aVolumeInfo.getMaxPathLength( ); - aUStr = aVolumeInfo.getFileSystemName( ); - - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is empty", - ( 0 == uiTotalSpace ) && - ( 0 == uiMaxPathLength ) && - sal_True == compareFileName( aUStr, aNullURL ) ); - } + TEST_F(VolumeInfoCtors, ctors_001 ) + { + ::osl::VolumeInfo aVolumeInfo( 0 ); + nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); + sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace( ); + sal_uInt32 uiMaxPathLength = aVolumeInfo.getMaxPathLength( ); + aUStr = aVolumeInfo.getFileSystemName( ); + + ASSERT_TRUE(( 0 == uiTotalSpace ) && + ( 0 == uiMaxPathLength ) && + sal_True == compareFileName( aUStr, aNullURL )) << "test for ctors function: mask is empty"; + } #if ( defined UNX ) || ( defined OS2 ) - void ctors_002( ) - { - ::osl::VolumeInfo aVolumeInfo( VolumeInfoMask_TotalSpace | - VolumeInfoMask_UsedSpace | - VolumeInfoMask_FileSystemName ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - //CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) ); - sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace( ); - sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace( ); - aUStr = aVolumeInfo.getFileSystemName( ); - - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, and get the masked fields", - ( 0 != uiTotalSpace ) && - ( 0 != uiUsedSpace ) && - sal_True == compareFileName( aUStr, "nfs" ) ); - } + TEST_F(VolumeInfoCtors, ctors_002 ) + { + ::osl::VolumeInfo aVolumeInfo( VolumeInfoMask_TotalSpace | + VolumeInfoMask_UsedSpace | + VolumeInfoMask_FileSystemName ); + nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); + //ASSERT_TRUE( aVolumeInfo.isValid( mask ) ); + sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace( ); + sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace( ); + aUStr = aVolumeInfo.getFileSystemName( ); + + ASSERT_TRUE(( 0 != uiTotalSpace ) && + ( 0 != uiUsedSpace ) && + sal_True == compareFileName( aUStr, "nfs" )) << "test for ctors function: mask is specified as certain valid fields, and get the masked fields"; + } #else /// Windows version,here we can not determine whichvolume in Windows is serve as an nfs volume. - void ctors_002( ) - { - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, and get the masked fields( Windows version )", - 1 == 1 ); - } + TEST_F(VolumeInfoCtors, ctors_002 ) + { + ASSERT_TRUE(1 == 1) << "test for ctors function: mask is specified as certain valid fields, and get the masked fields( Windows version )"; + } #endif - void ctors_003( ) - { - - sal_Int32 mask1 = VolumeInfoMask_FreeSpace; - ::osl::VolumeInfo aVolumeInfo1( mask1 ); - nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo1 ); - CPPUNIT_ASSERT( sal_True == aVolumeInfo1.isValid( mask1 ) ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - sal_uInt64 uiTotalSpace1 = aVolumeInfo1.getTotalSpace( ); - aUStr = aVolumeInfo1.getFileSystemName( ); + TEST_F(VolumeInfoCtors, ctors_003 ) + { - sal_Int32 mask2 = VolumeInfoMask_TotalSpace; - ::osl::VolumeInfo aVolumeInfo2( mask2 ); - nError2 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo2 ); - CPPUNIT_ASSERT( sal_True == aVolumeInfo2.isValid( mask2 ) ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError2 ); + sal_Int32 mask1 = VolumeInfoMask_FreeSpace; + ::osl::VolumeInfo aVolumeInfo1( mask1 ); + nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo1 ); + ASSERT_TRUE( sal_True == aVolumeInfo1.isValid( mask1 ) ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); - sal_uInt64 uiTotalSpace2 = aVolumeInfo2.getTotalSpace( ); + sal_uInt64 uiTotalSpace1 = aVolumeInfo1.getTotalSpace( ); + aUStr = aVolumeInfo1.getFileSystemName( ); - CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, but get unmasked fields, use mask to FreeSpace, but I can get TotalSpace, did not pass in (UNX)(W32)", - ( 0 == uiTotalSpace1 ) && ( 0 != uiTotalSpace2 ) && - sal_True == compareFileName( aUStr, aNullURL ) ); - } + sal_Int32 mask2 = VolumeInfoMask_TotalSpace; + ::osl::VolumeInfo aVolumeInfo2( mask2 ); + nError2 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo2 ); + ASSERT_TRUE( sal_True == aVolumeInfo2.isValid( mask2 ) ); + ASSERT_TRUE( osl::FileBase::E_None == nError2 ); - CPPUNIT_TEST_SUITE( ctors ); - CPPUNIT_TEST( ctors_001 ); - CPPUNIT_TEST( ctors_002 ); - CPPUNIT_TEST( ctors_003 ); - CPPUNIT_TEST_SUITE_END( ); - };// class ctors + sal_uInt64 uiTotalSpace2 = aVolumeInfo2.getTotalSpace( ); + ASSERT_TRUE(( 0 == uiTotalSpace1 ) && ( 0 != uiTotalSpace2 ) && + sal_True == compareFileName( aUStr, aNullURL )) << "test for ctors function: mask is specified as certain valid fields, but get unmasked fields, use mask to FreeSpace, but I can get TotalSpace, did not pass in (UNX)(W32)"; + } //--------------------------------------------------------------------- // testing the method // inline sal_Bool isValid( sal_uInt32 nMask ) const //--------------------------------------------------------------------- - class isValid : public CppUnit::TestFixture + class VolumeInfoIsValid : public ::testing::Test { + protected: ::osl::VolumeDevice aVolumeDevice; ::rtl::OUString aUStr; ::osl::FileBase::RC nError1, nError2; public: // initialization - void setUp( ) + void SetUp( ) { } - void tearDown( ) + void TearDown( ) { } + };// class isValid - // test code. - void isValid_001( ) - { - sal_Int32 mask = 0; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); + TEST_F(VolumeInfoIsValid, isValid_001 ) + { + sal_Int32 mask = 0; + ::osl::VolumeInfo aVolumeInfo( mask ); + nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: no fields specified.", - sal_True == aVolumeInfo.isValid( mask ) ); - } + ASSERT_TRUE(sal_True == aVolumeInfo.isValid( mask )) << "test for isValid function: no fields specified."; + } #if ( defined UNX ) || ( defined OS2 ) - void isValid_002( ) - { - sal_Int32 mask = VolumeInfoMask_Attributes | VolumeInfoMask_TotalSpace | osl_VolumeInfo_Mask_UsedSpace | - osl_VolumeInfo_Mask_FreeSpace | osl_VolumeInfo_Mask_MaxNameLength | - osl_VolumeInfo_Mask_MaxPathLength | osl_VolumeInfo_Mask_FileSystemName; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: all valid fields specified for a nfs volume.", - sal_True == aVolumeInfo.isValid( mask ) ); - } + TEST_F(VolumeInfoIsValid, isValid_002 ) + { + sal_Int32 mask = VolumeInfoMask_Attributes | VolumeInfoMask_TotalSpace | osl_VolumeInfo_Mask_UsedSpace | + osl_VolumeInfo_Mask_FreeSpace | osl_VolumeInfo_Mask_MaxNameLength | + osl_VolumeInfo_Mask_MaxPathLength | osl_VolumeInfo_Mask_FileSystemName; + ::osl::VolumeInfo aVolumeInfo( mask ); + nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); + + ASSERT_TRUE(sal_True == aVolumeInfo.isValid( mask )) << "test for isValid function: all valid fields specified for a nfs volume."; + } #else /// Windows version,here we can not determine whichvolume in Windows is serve as an nfs volume. - void isValid_002( ) - { - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: all valid fields specified for a nfs volume.( Windows version )", - 1 == 1 ); - } + TEST_F(VolumeInfoIsValid, isValid_002 ) + { + ASSERT_TRUE(1 == 1) << "test for isValid function: all valid fields specified for a nfs volume.( Windows version )"; + } #endif - void isValid_003( ) - { - ::osl::VolumeDevice aVolumeDevice1; - sal_Int32 mask = VolumeInfoMask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - sal_Bool bOk1 = aVolumeInfo.isValid( mask ); - - nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - sal_Bool bOk2 = aVolumeInfo.isValid( mask ); + TEST_F(VolumeInfoIsValid, isValid_003 ) + { + ::osl::VolumeDevice aVolumeDevice1; + sal_Int32 mask = VolumeInfoMask_Attributes; + ::osl::VolumeInfo aVolumeInfo( mask ); + nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); + sal_Bool bOk1 = aVolumeInfo.isValid( mask ); - CPPUNIT_ASSERT_MESSAGE( "test for isValid function: VolumeInfoMask_Attributes, it should be valid for some volume such as /, floppy, cdrom, etc. but it did not pass", - ( sal_True == bOk1 ) && ( sal_True == bOk2 ) ); - } + nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); + sal_Bool bOk2 = aVolumeInfo.isValid( mask ); - CPPUNIT_TEST_SUITE( isValid ); - CPPUNIT_TEST( isValid_001 ); - CPPUNIT_TEST( isValid_002 ); - CPPUNIT_TEST( isValid_003 ); - CPPUNIT_TEST_SUITE_END( ); - };// class isValid + ASSERT_TRUE(( sal_True == bOk1 ) && ( sal_True == bOk2 )) << "test for isValid function: VolumeInfoMask_Attributes, it should be valid for some volume such as /, floppy, cdrom, etc. but it did not pass"; + } //--------------------------------------------------------------------- // testing the method // inline sal_Bool getRemoteFlag() const //--------------------------------------------------------------------- - class getRemoteFlag : public CppUnit::TestFixture + class getRemoteFlag : public ::testing::Test { + protected: ::osl::VolumeDevice aVolumeDevice; ::rtl::OUString aUStr; ::osl::FileBase::RC nError1, nError2; + };// class getRemoteFlag - public: - // test code. - void getRemoteFlag_001( ) - { - sal_Int32 mask = VolumeInfoMask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - sal_Bool bOk = aVolumeInfo.getRemoteFlag( ); + TEST_F(getRemoteFlag, getRemoteFlag_001 ) + { + sal_Int32 mask = VolumeInfoMask_Attributes; + ::osl::VolumeInfo aVolumeInfo( mask ); + nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); + sal_Bool bOk = aVolumeInfo.getRemoteFlag( ); - CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is not remote.", - ( sal_False == bOk ) ); - } + ASSERT_TRUE(( sal_False == bOk )) << "test for getRemoteFlag function: get a volume device which is not remote."; + } #if ( defined UNX ) || ( defined OS2 ) //remote Volume is different in Solaris and Windows - void getRemoteFlag_002( ) - { - sal_Int32 mask = VolumeInfoMask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); - CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 ); - sal_Bool bOk = aVolumeInfo.getRemoteFlag( ); + TEST_F(getRemoteFlag, getRemoteFlag_002 ) + { + sal_Int32 mask = VolumeInfoMask_Attributes; + ::osl::VolumeInfo aVolumeInfo( mask ); + nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo ); + ASSERT_TRUE( osl::FileBase::E_None == nError1 ); + sal_Bool bOk = aVolumeInfo.getRemoteFlag( ); - CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is remote( Solaris version ).", - ( sal_True == bOk ) ); - } + ASSERT_TRUE(( sal_True == bOk )) << "test for getRemoteFlag function: get a volume device which is remote( Solaris version )."; + } #else //Windows version - void getRemoteFlag_002( ) - { - CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is remote( Windows version )", - 1 == 1 ); - } + TEST_F(getRemoteFlag, getRemoteFlag_002 ) + { + ASSERT_TRUE(1 == 1) << "test for getRemoteFlag function: get a volume device which is remote( Windows version )"; + } #endif - CPPUNIT_TEST_SUITE( getRemoteFlag ); - CPPUNIT_TEST( getRemoteFlag_001 ); - CPPUNIT_TEST( getRemoteFlag_002 ); - CPPUNIT_TEST_SUITE_END( ); - };// class getRemoteFlag - //--------------------------------------------------------------------- // testing the method // inline sal_Bool getRemoveableFlag() const //--------------------------------------------------------------------- - class getRemoveableFlag : public CppUnit::TestFixture + class getRemoveableFlag : public ::testing::Test { + protected: ::osl::FileBase::RC nError1, nError2; + };// class getRemoveableFlag - public: - // test code. - void getRemoveableFlag_001( ) - { - sal_Int32 mask = VolumeInfoMask_Attributes; - ::osl::VolumeInfo aVolumeInfo( mask ); - nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo ); ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits