kerneltest/f32test/server/t_fnames.cpp
branchRCL_3
changeset 257 3e88ff8f41d5
parent 256 c1f20ce4abcf
equal deleted inserted replaced
256:c1f20ce4abcf 257:3e88ff8f41d5
    13 // Description:
    13 // Description:
    14 // f32test\server\t_fnames.cpp
    14 // f32test\server\t_fnames.cpp
    15 // 
    15 // 
    16 //
    16 //
    17 
    17 
    18 #define __E32TEST_EXTENSION__
       
    19 #include <f32file.h>
    18 #include <f32file.h>
    20 #include <e32test.h>
    19 #include <e32test.h>
    21 #include "t_server.h"
    20 #include "t_server.h"
    22 
    21 
    23 GLDEF_D RTest test(_L("T_FNAMES"));
    22 GLDEF_D RTest test(_L("T_FNAMES"));
    44 
    43 
    45 	TBuf<32> goodName=_L("\\GOODNAME.TXT");
    44 	TBuf<32> goodName=_L("\\GOODNAME.TXT");
    46 	TBuf<32> badName=_L("\\< > : \" / |");
    45 	TBuf<32> badName=_L("\\< > : \" / |");
    47 	TParse parser;
    46 	TParse parser;
    48 	TInt r=parser.Set(aName,NULL,NULL);
    47 	TInt r=parser.Set(aName,NULL,NULL);
    49 	test_Value(r, r == KErrNone || r==anError);
    48 	test(r==KErrNone || r==anError);
    50 	goodName.Insert(0,parser.Drive());
    49 	goodName.Insert(0,parser.Drive());
    51 	badName.Insert(0,parser.Drive());
    50 	badName.Insert(0,parser.Drive());
    52 	
    51 	
    53 	
    52 	
    54 	TBuf<KMaxFileName> name;	//	We need an 8-bit name to test RFs::GetLongName() in 
    53 	TBuf<KMaxFileName> name;	//	We need an 8-bit name to test RFs::GetLongName() in 
   166     TPtrC dirName(_L("c:\\mainTestDir\\test000\\1a34567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890\\"));
   165     TPtrC dirName(_L("c:\\mainTestDir\\test000\\1a34567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890\\"));
   167     
   166     
   168     //-- TParse shall work correctly
   167     //-- TParse shall work correctly
   169     TParse parse;
   168     TParse parse;
   170     TInt err = parse.Set(dirName,NULL,NULL);
   169     TInt err = parse.Set(dirName,NULL,NULL);
   171     test_KErrNone(err);
   170     test( err == KErrNone );
   172     
   171     
   173     //-- try to access a directory with a long name. This just shall not panic.
   172     //-- try to access a directory with a long name. This just shall not panic.
   174     //-- The return code can be any, on the emulator it's very likely to be KErrBadname
   173     //-- The return code can be any, on the emulator it's very likely to be KErrBadname
   175     err = rDir.Open(rfs,dirName,EFileStream|EFileWrite|EFileShareExclusive);
   174     err = rDir.Open(rfs,dirName,EFileStream|EFileWrite|EFileShareExclusive);
   176 
   175 
   190     test(rfs.Connect() == KErrNone);
   189     test(rfs.Connect() == KErrNone);
   191     
   190     
   192     //-- create a dir c:\a
   191     //-- create a dir c:\a
   193     _LIT(dirName, "C:\\a\\");
   192     _LIT(dirName, "C:\\a\\");
   194     TInt err = rfs.MkDir(dirName);
   193     TInt err = rfs.MkDir(dirName);
   195     test_Value(err, err == KErrNone || err == KErrAlreadyExists);
   194     test(err == KErrNone || err == KErrAlreadyExists);
   196     
   195     
   197     if(err == KErrAlreadyExists)
   196     if(err == KErrAlreadyExists)
   198         bDirExisted = ETrue;
   197         bDirExisted = ETrue;
   199     
   198     
   200     //-- dir name longer than KMaxFileName
   199     //-- dir name longer than KMaxFileName
   201     _LIT(longDirName, "C:\\a\\longnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongname\\");
   200     _LIT(longDirName, "C:\\a\\longnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongnamelongname\\");
   202     //TInt nLen = dirName().Length();
   201     //TInt nLen = dirName().Length();
   203     
   202     
   204     //-- try to create a directory with a very long name, checking that it doesn't get truncated to the "c:\a"
   203     //-- try to create a directory with a very long name, checking that it doesn't get truncated to the "c:\a"
   205     err = rfs.MkDir(longDirName);
   204     err = rfs.MkDir(longDirName);
   206     test_Value(err, err == KErrBadName);
   205     test(err == KErrBadName);
   207 
   206 
   208     //-- clean up, remove created directory, otherwise some ill-designed tests can fail
   207     //-- clean up, remove created directory, otherwise some ill-designed tests can fail
   209     if(!bDirExisted)
   208     if(!bDirExisted)
   210         rfs.RmDir(dirName);
   209         rfs.RmDir(dirName);
   211     
   210