diff options
Diffstat (limited to 'sal/qa/osl/file/osl_File.cxx')
-rw-r--r-- | sal/qa/osl/file/osl_File.cxx | 410 |
1 files changed, 0 insertions, 410 deletions
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx index f9fde3f1c528..276ee03626c6 100644 --- a/sal/qa/osl/file/osl_File.cxx +++ b/sal/qa/osl/file/osl_File.cxx @@ -719,59 +719,6 @@ inline ::rtl::OUString getCurrentPID( void ); namespace osl_FileBase { -#if 0 //~ this function has been deprecated - //--------------------------------------------------------------------- - // testing the method - // static inline RC getCanonicalName( const ::rtl::OUString& ustrRequestedURL, ::rtl::OUString& ustrValidURL ) - // - // The illegal characters are ;+=[]',\"*\\<>/?:|. - // because getCanonicalName method is not implemented yet and will be deprecated in the future, this test is not necessary. - //--------------------------------------------------------------------- - - class getCanonicalName:public CppUnit::TestFixture - { - - public: - ::osl::FileBase::RC nError; - - 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 ) ); - } - - void getCanonicalName_002( ) - { - ::rtl::OUString aUStr_ValidURL; - - createTestFile( aCanURL1 ); - nError = ::osl::FileBase::getCanonicalName( aCanURL1, aUStr_ValidURL ); - deleteTestFile( aCanURL1 ); - - 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 ) ); - } - - void getCanonicalName_003( ) - { - ::rtl::OUString aUStr_ValidURL; - nError = ::osl::FileBase::getCanonicalName ( aCanURL2, aUStr_ValidURL ); - - 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 ) ); - } - - CPPUNIT_TEST_SUITE( getCanonicalName ); - CPPUNIT_TEST( getCanonicalName_001 ); - CPPUNIT_TEST( getCanonicalName_002 ); - CPPUNIT_TEST( getCanonicalName_003 ); - CPPUNIT_TEST_SUITE_END( ); - };// class getCanonicalName -#endif - //--------------------------------------------------------------------- // testing the method // static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL, @@ -818,161 +765,6 @@ namespace osl_FileBase }; //class getAbsoluteFileURL -/* use coding format as same as getSystemPathFromFileURL - // initialization - void setUp( ) - { - sal_Char pResultURL1[] = "/relative/file1"; - sal_Char pResultURL2[] = "/relative/file2"; - sal_Char pResultURL3[] = "/file3"; - sal_Char pResultURL4[] = "/file4"; - sal_Char pResultURL5[] = "/canonical.name"; - sal_Char pResultURL6[] = "/relative/"; - aResultURL1 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL1 ) ); - aResultURL2 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL2 ) ); - aResultURL3 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL3 ) ); - aResultURL4 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL4 ) ); - aResultURL5 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL5 ) ); - aResultURL6 = aUserDirectoryURL.concat( rtl::OUString::createFromAscii( pResultURL6 ) ); - } - - void tearDown( ) - { - } - - // test code - void getAbsoluteFileURL_001( ) - { - ::rtl::OUString aUStr_AbsURL; - - ::osl::FileBase::RC nError11 = aFileBase.getAbsoluteFileURL( aUserDirectoryURL, aRelURL1, aUStr_AbsURL ); - ::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getAbsoluteFileURL(' "); - suError += aUserDirectoryURL; - suError += ::rtl::OUString::createFromAscii("', '"); - suError += aRelURL1; - suError += ::rtl::OUString::createFromAscii("', '"); - suError += aUStr_AbsURL; - suError += outputError( aUStr_AbsURL, aResultURL1, "' ),"); - - sal_Bool nError12 = aUStr_AbsURL.equals( aResultURL1 ); - ::osl::FileBase::RC nError21 = aFileBase.getAbsoluteFileURL( aUserDirectoryURL, aRelURL2, aUStr_AbsURL ); - sal_Bool nError22 = aUStr_AbsURL.equals( aResultURL2 ); - ::osl::FileBase::RC nError31 = aFileBase.getAbsoluteFileURL( aUserDirectoryURL, aRelURL3, aUStr_AbsURL ); - sal_Bool nError32 = aUStr_AbsURL.equals( aResultURL3 ); - ::osl::FileBase::RC nError41 = aFileBase.getAbsoluteFileURL( aUserDirectoryURL, aRelURL4, aUStr_AbsURL ); - sal_Bool nError42 = aUStr_AbsURL.equals( aResultURL4 ); - ::osl::FileBase::RC nError61 = aFileBase.getAbsoluteFileURL( aUserDirectoryURL, aRelURL6, aUStr_AbsURL ); - sal_Bool nError62 = aUStr_AbsURL.equals( aResultURL6 ); - 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 ) && - ( ::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 ) ); - } - - -#if ( defined UNX ) || ( defined OS2 ) //Link is not defined in Windows - void getAbsoluteFileURL_002( ) - { - ::rtl::OUString aUStr_AbsURL, aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys ); - ( ( aUStr_LnkFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/link.file"); - ( ( aUStr_SrcFileSys += aSlashURL ) += getCurrentPID( ) ) += ::rtl::OUString::createFromAscii("/canonical.name"); - - rtl::OString strLinkFileName, strSrcFileName; - strLinkFileName = OUStringToOString( aUStr_LnkFileSys, RTL_TEXTENCODING_ASCII_US ); - strSrcFileName = OUStringToOString( aUStr_SrcFileSys, RTL_TEXTENCODING_ASCII_US ); - - createTestFile( aCanURL1 ); - sal_Int32 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() ); - CPPUNIT_ASSERT( fd == 0 ); - - nError = aFileBase.getAbsoluteFileURL( aUserDirectoryURL, aLnkURL1, aUStr_AbsURL ); - bOk = aUStr_AbsURL.equals( aResultURL5 ); - - ::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getAbsoluteFileURL(' "); - suError += aUserDirectoryURL; - suError += ::rtl::OUString::createFromAscii("', '"); - suError += aLnkURL1; - suError += ::rtl::OUString::createFromAscii("', '"); - suError += aUStr_AbsURL; - suError += outputError( aUStr_AbsURL, aResultURL5, "' ),"); - //printFileName(suError); - - deleteTestFile( aCanURL1 ); - fd = remove( strLinkFileName.getStr() ); - CPPUNIT_ASSERT( fd == 0 ); - - CPPUNIT_ASSERT_MESSAGE("test for getAbsoluteFileURL function: URL contain link( Solaris version )", - ( ::osl::FileBase::E_None == nError ) && ( sal_True == bOk ) ); - } -#else //Windows version - void getAbsoluteFileURL_002( ) - { - CPPUNIT_ASSERT_MESSAGE("test for getAbsoluteFileURL function: URL contain link( Windows version )", - 1 ); - } -#endif - - void getAbsoluteFileURL_003( ) - { -// LLA: may be a wrong test, aTmpName1 not a real URL -#if 0 - ::rtl::OUString aUStr_AbsURL; - - nError = aFileBase.getAbsoluteFileURL( aTmpName1, aRelURL1, aUStr_AbsURL ); //base dir invalid error - ::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getAbsoluteFileURL('"); - suError += aTmpName1; - suError += ::rtl::OUString::createFromAscii("', '"); - suError += aRelURL1; - suError += ::rtl::OUString::createFromAscii("', '"); - 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 ) ); -#endif - } - - //use ".." in relartive path, the BasePath must exist on the file system - void getAbsoluteFileURL_004( ) - { - //create two level directories under $Temp/PID/ - ::rtl::OUString aUStrUpBase = aUserDirectoryURL + ::rtl::OUString::createFromAscii("/test1"); - createTestDirectory( aUStrUpBase ); - ::rtl::OUString aUStrBase = aUserDirectoryURL + ::rtl::OUString::createFromAscii("/test1/dir1"); - createTestDirectory( aUStrBase ); - - ::rtl::OUString aUStrRelar = ::rtl::OUString::createFromAscii("../../mytestfile"); - ::rtl::OUString aUStr_AbsURL; - ::rtl::OUString aResultURL6 = aUserDirectoryURL + ::rtl::OUString::createFromAscii("/mytestfile"); - - nError = aFileBase.getAbsoluteFileURL( aUStrBase, aUStrRelar, aUStr_AbsURL ); - bOk = aUStr_AbsURL.equals( aResultURL6 ); - ::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getAbsoluteFileURL('"); - suError += aUStrBase; - suError += ::rtl::OUString::createFromAscii("', '"); - suError += aUStrRelar; - suError += ::rtl::OUString::createFromAscii("', '"); - suError += aUStr_AbsURL; - suError += outputError( aUStr_AbsURL, aResultURL6, "' ), did not pass on Win32 "); - - deleteTestDirectory( aUStrBase ); - deleteTestDirectory( aUStrUpBase ); - - CPPUNIT_ASSERT_MESSAGE( suError, ( ::osl::FileBase::E_None == nError ) && ( sal_True == bOk ) ); - } - - CPPUNIT_TEST_SUITE( getAbsoluteFileURL ); - CPPUNIT_TEST( getAbsoluteFileURL_001 ); - CPPUNIT_TEST( getAbsoluteFileURL_002 ); - CPPUNIT_TEST( getAbsoluteFileURL_003 ); - CPPUNIT_TEST( getAbsoluteFileURL_004 ); - CPPUNIT_TEST_SUITE_END( ); - };// class getAbsoluteFileURL*/ - void getAbsoluteFileURL::check_getAbsoluteFileURL( rtl::OUString const& _suBaseURL, rtl::OString const& _sRelativeURL, ::osl::FileBase::RC _nAssumeError, rtl::OUString const& _suAssumeResultStr ) { rtl::OUString suRelativeURL = rtl::OStringToOUString(_sRelativeURL, RTL_TEXTENCODING_UTF8); @@ -1427,26 +1219,6 @@ namespace osl_FileBase checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, ""); } -#if 0 - void SystemPath_FileURL::getSystemPathFromFileURL_003( ) - { -// LLA: ??? -//!! seams to be, that the directories do not pass together - ::rtl::OUString aUStr; - ::rtl::OUString aRelativeURL = ::rtl::OUString::createFromAscii("../../relartive/file3"); - ::rtl::OUString aResultURL ( aSysPath4 ); - ::osl::FileBase::RC nError = osl::FileBase::getSystemPathFromFileURL( aRelativeURL, aUStr ); - - sal_Bool bOk = compareFileName( aUStr, aResultURL ); - - ::rtl::OUString suError = ::rtl::OUString::createFromAscii("test for getSystemPathFromFileURL("); - 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 ) ); - } -#endif - //normal legal case void SystemPath_FileURL::getSystemPathFromFileURL_004( ) { @@ -1772,9 +1544,6 @@ namespace osl_FileBase };// class createTempFile // ----------------------------------------------------------------------------- -#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" ); @@ -1785,135 +1554,6 @@ namespace osl_FileBase //------------------------------------------------------------------------ -// Beginning of the test cases for VolumeDevice class -//------------------------------------------------------------------------ - -#if 0 //~ this Class has been deprecated -namespace osl_VolumeDevice -{ - - //--------------------------------------------------------------------- - // testing the method - // VolumeDevice() : _aHandle( NULL ) - //--------------------------------------------------------------------- - class ctors : public CppUnit::TestFixture - { - ::osl::VolumeDevice aVolumeDevice; - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1, nError2; - - public: - // initialization - void setUp( ) - { - } - - void tearDown( ) - { - } - - // test code. - void 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( ) ) ) ); - } - - 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 ); - } - - 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 ); - } - - CPPUNIT_TEST_SUITE( ctors ); - CPPUNIT_TEST( ctors_001 ); - CPPUNIT_TEST( ctors_002 ); - CPPUNIT_TEST( ctors_003 ); - CPPUNIT_TEST_SUITE_END( ); - };// class ctors - - - //--------------------------------------------------------------------- - // testing the method - // inline RC automount() - //--------------------------------------------------------------------- - class automount : public CppUnit::TestFixture - { - ::osl::VolumeDevice aVolumeDevice; - ::rtl::OUString aUStr; - ::osl::FileBase::RC nError1, nError2; - - public: - // initialization - void setUp( ) - { - } - - void tearDown( ) - { - - } - - // test code. - void automount_001( ) - { - ::osl::VolumeDevice aVolumeDevice1; - nError1 = aVolumeDevice1.automount( ); - - CPPUNIT_ASSERT_MESSAGE( "test for automount function: invalid parameter.", - ( osl::FileBase::E_INVAL == nError1 ) ); - } - - 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 ) ); - } - - CPPUNIT_TEST_SUITE( automount ); - CPPUNIT_TEST( automount_001 ); - CPPUNIT_TEST( automount_002 ); - CPPUNIT_TEST_SUITE_END( ); - };// class automount - - - // ----------------------------------------------------------------------------- - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeDevice::ctors, "osl_VolumeDevice" ); - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeDevice::automount, "osl_VolumeDevice" ); -}// namespace osl_VolumeDevice -#endif - - -//------------------------------------------------------------------------ // Beginning of the test cases for VolumeInfo class //------------------------------------------------------------------------ namespace osl_VolumeInfo @@ -3189,56 +2829,6 @@ namespace osl_FileStatus void getFileType_003( ) { -#if 0 -// LLA: this have to be discussed. - ::osl::FileStatus rFileStatus( FileStatusMask_Type ); - nError1 = m_aVolumeItem.getFileStatus( rFileStatus ); - CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 ); - - if (rFileStatus.isValid(FileStatusMask_Type)) - { - osl::FileStatus::Type eType = rFileStatus.getFileType( ); - - CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: Volume, it seems the volume part of the field is not implemented, it did not pass in (W32)(UNX).", - ( eType == ::osl::FileStatus::Volume ) ); - } -#endif - } - - - void getFileType_004( ) - { -#if ( defined UNX ) || ( defined OS2 ) //Fifo creation is differ in Windows - - //create a fifo in $ROOT/tmp/tmpdir, get its DirectoryItem. - rtl::OString strFifoSys; - strFifoSys = OUStringToOString( aFifoSys, RTL_TEXTENCODING_ASCII_US ); - ::rtl::OUString aFifoURL; - - int fd = mkfifo( strFifoSys.getStr(), O_RDWR | O_CREAT ); - CPPUNIT_ASSERT_MESSAGE("mkfifo failed!", fd == 0 ); - ::osl::FileBase::getFileURLFromSystemPath( aFifoSys, aFifoURL ); - - nError1 = ::osl::DirectoryItem::get( aFifoURL, m_aFifoItem ); - CPPUNIT_ASSERT_MESSAGE("get item failed!", ::osl::FileBase::E_None == nError1 ); - - //check for File type - ::osl::FileStatus rFileStatus( FileStatusMask_Type ); - nError1 = m_aFifoItem.getFileStatus( rFileStatus ); - CPPUNIT_ASSERT_MESSAGE("get Status failed!", ::osl::FileBase::E_None == nError1 ); - - //delete fifo - nError1 = ::osl::File::remove( aFifoURL ); - CPPUNIT_ASSERT_MESSAGE("remove file failed!", ::osl::FileBase::E_None == nError1 ); - - if (rFileStatus.isValid(FileStatusMask_Type)) - { - osl::FileStatus::Type eType = rFileStatus.getFileType( ); - - CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: Fifo, Solaris version ", - ( eType == ::osl::FileStatus::Fifo ) ); - } -#endif } /* |