kerneltest/f32test/server/t_file64bit.cpp
changeset 0 a41df078684a
child 109 b3a1d9898418
child 175 5af6c74cd793
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // //File Name:	f32test/server/t_file64bit.cpp
       
    15 // //Description:This file contains implementation for checking the 64bit file
       
    16 // //			server functionality. All the affected APIs are tested.
       
    17 // //While generating a file for reading, the contents are generated such that 
       
    18 // //every four bytes of the file contains its location. So the file would be
       
    19 // //generated as:
       
    20 // // 0000: 00 00 00 00 
       
    21 // // 0004: 04 00 00 00
       
    22 // // 0008: 08 00 00 00
       
    23 // // .. etc
       
    24 // 
       
    25 //
       
    26 
       
    27 
       
    28 #include <f32file.h>
       
    29 #include <e32test.h>
       
    30 #include <e32svr.h>
       
    31 #include "t_server.h"
       
    32 #include "t_file64bit.h"
       
    33 #include "..\\fileshare\\handshare64bit.h"
       
    34 #include <f32pluginutils.h>
       
    35 #include <massstorage.h>
       
    36 #include <e32math.h>
       
    37 #include "f32_test_utils.h"
       
    38 
       
    39 using namespace F32_Test_Utils;
       
    40 
       
    41 RTest test(_L("T_FILE64BIT Tests"));
       
    42 
       
    43 _LIT(KTestPath,  ":\\F32-TST\\TFILE64BIT\\");
       
    44 
       
    45 // to test any file system that supports file sizes of greater than 4GB -1, 
       
    46 // this value shall be set.
       
    47 TBool KFileSizeMaxLargerThan4GBMinusOne = EFalse;
       
    48 
       
    49 
       
    50 
       
    51 TInt GenerateBigFileContents()
       
    52 	{
       
    53 	test.Printf(_L("GenerateBigFileContents()\n"));
       
    54 
       
    55 	TInt r;
       
    56     const TUint KBufSize = 256*K1KiloByte;
       
    57     RBuf8 buf;
       
    58     
       
    59     r = buf.CreateMax(KBufSize);
       
    60     test(r == KErrNone);
       
    61 
       
    62     RFile64 file;
       
    63 	TFileName fileName;
       
    64 	fileName.Append(gDriveToTest);
       
    65 	fileName.Append(KTestPath);
       
    66 	fileName.Append(_L("File4GBMinusOne.txt"));
       
    67 	r = file.Replace(TheFs,fileName, EFileWrite);
       
    68 	test(r == KErrNone);
       
    69 	
       
    70     r = file.SetSize(K4GBMinusOne);
       
    71 	test(r == KErrNone);
       
    72 	
       
    73 	TInt64 nNumberOfBytesToWrite = 0;
       
    74 	TInt64 nNumberOfBytesWritten = 0;
       
    75 	for (TInt64 pos = 0; pos < K4GBMinusOne; pos += nNumberOfBytesWritten)
       
    76 		{
       
    77 		// Prepare the write buffer
       
    78 		for (TUint n = 0; n<KBufSize; n += 4)
       
    79 			{
       
    80             *((TUint*) &buf[n]) = I64LOW(pos + n);
       
    81 			}
       
    82 		
       
    83 		nNumberOfBytesToWrite = Min(MAKE_TINT64(0,KBufSize), K4GBMinusOne - pos);
       
    84         TPtrC8 pText(buf.Ptr(), KBufSize);
       
    85 
       
    86 		file.Write(pText, (TInt)nNumberOfBytesToWrite);
       
    87 		
       
    88         nNumberOfBytesWritten = nNumberOfBytesToWrite; 
       
    89 		}
       
    90 	
       
    91 	r = file.Flush();
       
    92 	test(r == KErrNone);
       
    93 	test.Printf(_L("\nFile writing is completed!!"));
       
    94 	
       
    95 	
       
    96 	file.Close();
       
    97 	
       
    98     buf.Close();
       
    99 
       
   100     return KErrNone;
       
   101 	}
       
   102 
       
   103 TInt RFileHandleSharer64Bit::Connect()
       
   104 	{
       
   105 	return CreateSession(KServerName, TVersion(1,0,0));
       
   106 	}
       
   107 
       
   108 
       
   109 TInt RFileHandleSharer64Bit::Exit()
       
   110 	{
       
   111 	return SendReceive(EMsgExit, TIpcArgs(NULL));
       
   112 	}
       
   113 			
       
   114 TInt RFileHandleSharer64Bit::SetTestDrive(TInt aDrive)
       
   115 	{
       
   116 	return SendReceive(EMsgDrive, TIpcArgs(aDrive));
       
   117 	}
       
   118 
       
   119 TInt RFileHandleSharer64Bit::PassFileHandleProcessLargeFileClient(TIpcArgs& aIpcArgs)
       
   120 	{
       
   121 	return SendReceive(EMsgPassFileHandleProcessLargeFileClient, aIpcArgs);
       
   122 	}
       
   123 
       
   124 TInt RFileHandleSharer64Bit::PassFileHandleProcessLargeFileCreator()
       
   125 	{
       
   126 	return SendReceive(EMsgPassFileHandleProcessLargeFileCreator);
       
   127 	}
       
   128 
       
   129 TInt RFileHandleSharer64Bit::GetFileHandleLargeFile2(TInt &aHandle, TFileMode aFileMode)
       
   130 	{
       
   131 	TPckgBuf<TInt> fh;
       
   132 	TInt fsh = SendReceive(EMsgGetFileHandleLargeFile, TIpcArgs(&fh, aFileMode));
       
   133 	aHandle = fh();
       
   134 	return fsh;
       
   135 	}
       
   136 	
       
   137 void RFileHandleSharer64Bit::Sync()
       
   138 	{
       
   139 	SendReceive(EMsgSync, TIpcArgs());
       
   140 	}	
       
   141 
       
   142 
       
   143 CFileManObserver::CFileManObserver(CFileMan* aFileMan)
       
   144 	{
       
   145 	__DECLARE_NAME(_S("CFileManObserver"));
       
   146 	iFileMan = aFileMan;
       
   147 	}
       
   148 
       
   149 MFileManObserver::TControl CFileManObserver::NotifyFileManStarted()
       
   150 	{
       
   151 	return(MFileManObserver::EContinue);
       
   152 	}
       
   153 
       
   154 MFileManObserver::TControl CFileManObserver::NotifyFileManOperation()
       
   155 	{
       
   156 	return(MFileManObserver::EContinue);
       
   157 	}
       
   158 
       
   159 MFileManObserver::TControl CFileManObserver::NotifyFileManEnded()
       
   160 	{
       
   161 	TInt lastError = iFileMan->GetLastError();
       
   162 	TFileName fileName = iFileMan->CurrentEntry().iName;
       
   163 	test.Printf(_L("NotifyFileManEnded(): Error %d File %S\n"),lastError, &fileName);
       
   164 	if (lastError == KErrNone)
       
   165 		iNotifyEndedSuccesses++;
       
   166 	else
       
   167 		iNotifyEndedFailures++;
       
   168 	return(MFileManObserver::EContinue);
       
   169 	}
       
   170 
       
   171 
       
   172 
       
   173 RFsTest& RFsTest::Replace(const TDesC &anOldName, const TDesC &aNewName)
       
   174 //
       
   175 // Replaces a single file with another
       
   176 //
       
   177 	{
       
   178 	test.Printf(_L("%S File Replaced with %S\n"),&anOldName,&aNewName);\
       
   179 	TInt r = TheFs.Replace(anOldName,aNewName);
       
   180 	test(r == KErrNone);
       
   181 	return(*this);
       
   182 	}
       
   183 	
       
   184 RFsTest& RFsTest::ReadFileSection(const TDesC& aName, TInt64 aPos,TDes8& aBuffer,TInt aLen)
       
   185 //
       
   186 // Reads data from the file without opening it. Expected not to fail.
       
   187 //
       
   188 	{
       
   189 	test.Printf(_L("Read File Section %S\n"),&aName);
       
   190 	TInt r = TheFs.ReadFileSection(aName,aPos,aBuffer,aLen);
       
   191 	TInt len = aBuffer.Length();
       
   192 	
       
   193 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   194 		{
       
   195 		if(aPos < K4GB) 
       
   196 			test(r == KErrNone);
       
   197 		else
       
   198 			{
       
   199 			test(r == KErrNone);
       
   200 			test(len == 0);				
       
   201 			}
       
   202 		}
       
   203 	else
       
   204 		{
       
   205 		test (r == KErrNone);	
       
   206 		}
       
   207 	return(*this);
       
   208 	}
       
   209 	
       
   210 	
       
   211 RFsTest& RFsTest::GetDir(const TDesC &aName, TUint anEntryAttMask, TUint anEntrySortKey, CDir *&anEntryList)
       
   212 //
       
   213 // Gets a filtered list of a directory's contents.
       
   214 //
       
   215 	{
       
   216 	test.Printf(_L("Name of the directory for which listing is required %S\n"),&aName);	
       
   217 	TInt r = TheFs.GetDir(aName,anEntryAttMask,anEntrySortKey,anEntryList);
       
   218 	test(r == KErrNone);
       
   219 	return(*this);
       
   220 	}
       
   221 
       
   222 RFsTest& RFsTest::GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey,CDir*& anEntryList,CDir*& aDirList)
       
   223 //
       
   224 // Gets a filtered list of the directory and the file entries contained in a directory and a
       
   225 // list of the directory entries only.
       
   226 	{
       
   227 	test.Printf(_L("Name of the directory for which directory and file listing is required %S\n"),&aName);	
       
   228 	TInt r = TheFs.GetDir(aName,anEntryAttMask,anEntrySortKey,anEntryList,aDirList);
       
   229 	test(r == KErrNone);
       
   230 	return(*this);
       
   231 	}
       
   232 
       
   233 RFsTest& RFsTest::GetDir(const TDesC& aName,const TUidType& anEntryUid,TUint anEntrySortKey,CDir*& aFileList)
       
   234 //
       
   235 // Gets a filtered list of directory contents by UID type.
       
   236 //
       
   237 	{
       
   238 	test.Printf(_L("Name of the directory for which listing is required %S\n"),&aName);	
       
   239 	TInt r = TheFs.GetDir(aName,anEntryUid,anEntrySortKey,aFileList);
       
   240 	test(r == KErrNone);
       
   241 	return(*this);	
       
   242 	}
       
   243 		
       
   244 	
       
   245 RFileTest::RFileTest(const TDesC& aName)
       
   246 //
       
   247 // Constructor
       
   248 //
       
   249 	: iName(aName)
       
   250 	{}
       
   251 
       
   252 RFileTest& RFileTest::Create(const TDesC& aName, TUint aFileMode)
       
   253 //
       
   254 // Creates and opens a new file for writing, if the file already exists an error is returned
       
   255 //
       
   256 	{
       
   257 	test.Printf(_L("%S create %S in %d Mode\n"),&iName,&aName,aFileMode);
       
   258 	TInt r = RFile64::Create(TheFs,aName,aFileMode);
       
   259 	test(r == KErrNone || r == KErrAlreadyExists);
       
   260 	return(*this);		
       
   261 	}
       
   262 	
       
   263 RFileTest& RFileTest::Replace(const TDesC& aName)
       
   264 //
       
   265 // Opens a file for writing, replacing the content of any existing file of the same name
       
   266 // if it exists or cretaing a new file if it does not exist.
       
   267 //
       
   268 	{
       
   269 	test.Printf(_L("%S replace %S\n"),&iName,&aName);
       
   270 	TInt r = RFile64::Replace(TheFs,aName,EFileStream|EFileWrite);
       
   271 	test(r == KErrNone);
       
   272 	return(*this);
       
   273 	}
       
   274 
       
   275 RFileTest& RFileTest::Replace(const TDesC& aName, TUint aFileMode)
       
   276 //
       
   277 // Opens a file in aFileMode, replacing the content of any existing file of the same name
       
   278 // if it exists or cretaing a new file if it does not exist.
       
   279 //
       
   280 	{
       
   281 	test.Printf(_L("%S replace %S in %d Mode\n"),&iName,&aName, aFileMode);
       
   282 	TInt r = RFile64::Replace(TheFs,aName,aFileMode);
       
   283 	if (r == KErrNone)
       
   284 		test(r == KErrNone);
       
   285 	else
       
   286 		test(r == KErrBadName);
       
   287 	return(*this);		
       
   288 	}
       
   289 	
       
   290 RFileTest& RFileTest::Open(const TDesC& aName)
       
   291 //
       
   292 // Open a existing file for reading and writing in shared access mode.
       
   293 //
       
   294 	{
       
   295 	test.Printf(_L("%S open %S\n"),&iName,&aName);
       
   296 	TInt r = RFile64::Open(TheFs,aName,EFileWrite|EFileShareAny);
       
   297 	test(r == KErrNone);
       
   298 	return(*this);
       
   299 	}
       
   300 
       
   301 RFileTest& RFileTest::Open(const TDesC& aName, TUint aFileMode)
       
   302 //
       
   303 // Opens an existing file using aFileMode.
       
   304 //
       
   305 	{
       
   306 	test.Printf(_L("%S open %S in %d Mode\n"),&iName,&aName, aFileMode);
       
   307 	TInt r = RFile64::Open(TheFs,aName,aFileMode);
       
   308 	test(r == KErrNone);
       
   309 	return(*this);
       
   310 	}
       
   311 
       
   312 RFileTest& RFileTest::Temp(const TDesC& aPath,TFileName& aName,TUint aFileMode)
       
   313 //
       
   314 // Creates and opens a temporary file with a unique name for writing and reading.
       
   315 //
       
   316 	{
       
   317 	test.Printf(_L("%S Temp file %S in %d Mode\n"),&iName,&aName, aFileMode);
       
   318 	TInt r = RFile64::Temp(TheFs,aPath,aName,aFileMode);	
       
   319 	test(r == KErrNone);
       
   320 	return(*this);
       
   321 	}
       
   322 	
       
   323 void RFileTest::Close()
       
   324 //
       
   325 // Closes the file.
       
   326 //
       
   327 	{
       
   328 	RFile::Close();
       
   329 	}
       
   330 	
       
   331 RFileTest& RFileTest::Lock(TInt64 aPos, TInt64 aLen)
       
   332 //
       
   333 // Set a lock on the file. Expected not to fail.
       
   334 //
       
   335 	{
       
   336 	test.Printf(_L("%S lock   0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   337 	TInt r = RFile64::Lock(aPos,aLen);
       
   338 	test(r == KErrNone);
       
   339 	return(*this);
       
   340 	}
       
   341 
       
   342 RFileTest& RFileTest::LockE(TInt64 aPos, TInt64 aLen)
       
   343 //
       
   344 // Set a lock on the file. Expected to fail.
       
   345 //
       
   346 	{
       
   347 	test.Printf(_L("%S lockE  0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   348 	TInt r = RFile64::Lock(aPos,aLen);
       
   349 	test(r == KErrLocked);
       
   350 	return(*this);
       
   351 	}
       
   352 
       
   353 RFileTest& RFileTest::UnLock(TInt64 aPos, TInt64 aLen)
       
   354 //
       
   355 // Unlock the file. Expected not to fail.
       
   356 //
       
   357 	{
       
   358 	test.Printf(_L("%S ulock  0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   359 	TInt r = RFile64::UnLock(aPos,aLen);
       
   360 	test(r == KErrNone);
       
   361 	return(*this);
       
   362 	}
       
   363 
       
   364 RFileTest& RFileTest::UnLockE(TInt64 aPos, TInt64 aLen)
       
   365 //
       
   366 // Unlock the file. Expected to fail.
       
   367 //
       
   368 	{
       
   369 	test.Printf(_L("%S ulockE 0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   370 	TInt r = RFile64::UnLock(aPos,aLen);
       
   371 	test(r == KErrNotFound);
       
   372 	return(*this);
       
   373 	}
       
   374 
       
   375 RFileTest& RFileTest::Write(const TDesC8& aDes)
       
   376 //
       
   377 // Write to the file.
       
   378 //
       
   379 	{
       
   380 	test.Printf(_L("%S write\n"),&iName);
       
   381 	
       
   382 	TInt64 seekPos = 0;
       
   383 	TInt rr = RFile64::Seek(ESeekCurrent,seekPos);
       
   384 	test(rr == KErrNone);
       
   385 		
       
   386 	TInt r = RFile64::Write(aDes);
       
   387 	if( KErrNone == r)	// this is to ensure that the written data is committed and not cached.
       
   388 		r = RFile64::Flush(); 		
       
   389 		
       
   390 	
       
   391 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   392 		{
       
   393 		if((seekPos + aDes.Length()) < K4GB)
       
   394 			test(r == KErrNone);
       
   395 		else
       
   396 			test(r == KErrNotSupported);
       
   397 		}
       
   398 	else
       
   399 		{
       
   400 		test (r == KErrNone);	
       
   401 		}
       
   402 	return(*this);
       
   403 	}
       
   404 
       
   405 RFileTest& RFileTest::Write(const TDesC8 &aDes, TRequestStatus &aStatus)
       
   406 //
       
   407 // Write to the file.
       
   408 //
       
   409 	{
       
   410 	test.Printf(_L("%S write\n"),&iName);
       
   411 	
       
   412 	TInt64 seekPos = 0;
       
   413 	TInt rr = RFile64::Seek(ESeekCurrent,seekPos);
       
   414 	test(rr == KErrNone);
       
   415 		
       
   416 	RFile64::Write(aDes, aStatus);
       
   417 	User::WaitForRequest(aStatus);
       
   418 	if( KErrNone == aStatus.Int())	// this is to ensure that the written data is committed and not cached.
       
   419 		{
       
   420 		RFile64::Flush(aStatus); 
       
   421 		User::WaitForRequest(aStatus);
       
   422 		}
       
   423 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   424 		{
       
   425 		if((seekPos + aDes.Length()) < K4GB)
       
   426 			test(aStatus.Int() == KErrNone);
       
   427 		else
       
   428 			test(aStatus.Int() == KErrNotSupported);
       
   429 		
       
   430 		}
       
   431 	else
       
   432 		{
       
   433 		test(aStatus.Int() == KErrNone);
       
   434 		}
       
   435 	return(*this);
       
   436 	}
       
   437 	
       
   438 RFileTest& RFileTest::Write(const TDesC8& aDes, TInt aLength)
       
   439 //
       
   440 // Write aLength specified number of bytes to the file.
       
   441 //
       
   442 	{
       
   443 	test.Printf(_L("%S write\n"),&iName);
       
   444 	
       
   445 	TInt64 seekPos = 0;
       
   446 	TInt rr = RFile64::Seek(ESeekCurrent,seekPos);
       
   447 	test(rr == KErrNone);
       
   448 	
       
   449 	TInt r = RFile64::Write(aDes, aLength);
       
   450 	if( KErrNone == r)	// this is to ensure that the written data is committed and not cached.
       
   451 		r = RFile64::Flush(); 		
       
   452 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   453 		{
       
   454 		if((seekPos + aLength) < K4GB)
       
   455 			test(r == KErrNone);
       
   456 		else
       
   457 			test(r == KErrNotSupported);
       
   458 		}
       
   459 	else
       
   460 		{
       
   461 		test(r == KErrNone);
       
   462 		}
       
   463 	return(*this);	
       
   464 	}	
       
   465 
       
   466 RFileTest& RFileTest::Write(const TDesC8& aDes, TInt aLength, TRequestStatus &aStatus)	
       
   467 //
       
   468 // Write aLength specified number of bytes to the file. Expected not to fail (Asynchronous).
       
   469 //
       
   470 	{
       
   471 	test.Printf(_L("%S write\n"),&iName);
       
   472 	
       
   473 	TInt64 seekPos = 0;
       
   474 	TInt rr = RFile64::Seek(ESeekCurrent,seekPos);
       
   475 	test(rr == KErrNone);
       
   476 	
       
   477 	RFile64::Write(aDes,aLength,aStatus);
       
   478 	User::WaitForRequest(aStatus);
       
   479 	if( KErrNone == aStatus.Int())	// this is to ensure that the written data is committed and not cached.
       
   480 		{
       
   481 		RFile64::Flush(aStatus);
       
   482 		User::WaitForRequest(aStatus);	
       
   483 		}
       
   484 		
       
   485 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   486 		{
       
   487 		if((seekPos + aLength) < K4GB)
       
   488 			test(aStatus.Int() == KErrNone);
       
   489 		else	
       
   490 			test(aStatus.Int() == KErrNotSupported);
       
   491 		}
       
   492 	else
       
   493 		{
       
   494 		test(aStatus.Int() == KErrNone);
       
   495 		}
       
   496 	return(*this);
       
   497 	}
       
   498 	
       
   499 RFileTest& RFileTest::WriteP(TInt64 aPos, const TDesC8& aDes)
       
   500 //
       
   501 // Write to the file. Expected not to fail.
       
   502 //
       
   503 	{
       
   504 	test.Printf(_L("%S write  0x%lx\n"),&iName,aPos);
       
   505 	TInt r = RFile64::Write(aPos,aDes);
       
   506 	if( KErrNone == r)	// this is to ensure that the written data is committed and not cached.
       
   507 		r = RFile64::Flush();
       
   508 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   509 		{
       
   510 		if ((aPos + aDes.Length()) < K4GB)
       
   511 			test(r == KErrNone);
       
   512 		else
       
   513 			test(r == KErrNotSupported);
       
   514 		}
       
   515 	else
       
   516 		{
       
   517 		test(r == KErrNone);
       
   518 		}
       
   519 	return(*this);
       
   520 	}
       
   521 
       
   522 RFileTest& RFileTest::WriteU(TUint aPos, const TDesC8& aDes)
       
   523 //
       
   524 // Write to the file. Expected not to fail.
       
   525 // Position is a TUint value
       
   526 //
       
   527 	{
       
   528 	test.Printf(_L("%S write  %08x\n"),&iName,aPos);
       
   529 	TInt r = RFile64::Write(aPos,aDes);
       
   530 	if( KErrNone == r)	// this is to ensure that the written data is committed and not cached.
       
   531 		r = RFile64::Flush();
       
   532 	test(r == KErrNone);
       
   533 	return(*this);
       
   534 	}
       
   535 
       
   536 
       
   537 RFileTest& RFileTest::Write(TInt64 aPos, const TDesC8& aDes, TInt aLen)
       
   538 //
       
   539 // Write to the file. Synchronous Expected not to fail.
       
   540 //
       
   541 	{
       
   542 	test.Printf(_L("%S write  0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   543 	TInt r = RFile64::Write(aPos,aDes,aLen);
       
   544 	if( KErrNone == r)	// this is to ensure that the written data is committed and not cached.
       
   545 		r = RFile64::Flush();
       
   546 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   547 		{
       
   548 		if ((aPos + aLen) < K4GB)
       
   549 			{
       
   550 			if (aLen < 0)
       
   551 				test(r == KErrArgument);
       
   552 			else
       
   553 				test(r == KErrNone);
       
   554 			}
       
   555 		else
       
   556 			test(r == KErrNotSupported);
       
   557 		}
       
   558 	else
       
   559 		{
       
   560 		if (aLen < 0)
       
   561 			test(r == KErrArgument);
       
   562 		else
       
   563 			test(r == KErrNone);
       
   564 		}
       
   565 	return(*this);
       
   566 	}
       
   567 
       
   568 RFileTest& RFileTest::WriteU(TUint aPos, const TDesC8& aDes, TInt aLen)
       
   569 //
       
   570 // Write to the file. Synchronous Expected not to fail.
       
   571 // Position is a TUint value
       
   572 //
       
   573 	{
       
   574 	test.Printf(_L("%S write  %08x-%08x\n"),&iName,aPos,aPos+aLen-1);
       
   575 	TInt r = RFile64::Write(aPos,aDes,aLen);
       
   576 	if( KErrNone == r)	// this is to ensure that the written data is committed and not cached.
       
   577 		r = RFile64::Flush();
       
   578 	test(r == KErrNone);
       
   579 	return(*this);
       
   580 	}
       
   581 
       
   582 
       
   583 RFileTest& RFileTest::WriteE(TInt64 aPos, const TDesC8& aDes, TInt aLen)
       
   584 //
       
   585 // Write to the file. Expected to fail.
       
   586 //
       
   587 	{
       
   588 	test.Printf(_L("%S writeE 0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   589 	TInt r = RFile64::Write(aPos,aDes,aLen);
       
   590 	if (aLen < 0)
       
   591 		test(r == KErrArgument);
       
   592 	else
       
   593 		test(r == KErrLocked);
       
   594 	return(*this);
       
   595 	}
       
   596 
       
   597 RFileTest& RFileTest::Write(TInt64 aPos, const TDesC8& aDes, TInt aLen, TRequestStatus &aStatus)
       
   598 // 
       
   599 // Write to the file. Asynchronous
       
   600 	{
       
   601 	test.Printf(_L("%S write  0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   602 	RFile64::Write(aPos,aDes,aLen,aStatus);
       
   603 	User::WaitForRequest(aStatus);
       
   604 	if( KErrNone == aStatus.Int())	// this is to ensure that the written data is committed and not cached.
       
   605 		{
       
   606 		RFile64::Flush(aStatus);
       
   607 		User::WaitForRequest(aStatus);	
       
   608 		}
       
   609 
       
   610 	if(aLen < 0)
       
   611 		test(aStatus.Int() == KErrArgument);
       
   612 	else
       
   613 		{
       
   614 		if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   615 			{
       
   616 			if((aPos + aLen) < K4GB)
       
   617 				test(aStatus.Int() == KErrNone);
       
   618 			else
       
   619 				test(aStatus.Int() == KErrNotSupported);
       
   620 			}
       
   621 		else
       
   622 			test(aStatus.Int() == KErrNone);
       
   623 		}
       
   624 	return(*this);	
       
   625 	}
       
   626 	
       
   627 RFileTest& RFileTest::Write(TInt64 aPos, const TDesC8& aDes, TRequestStatus &aStatus)
       
   628 //
       
   629 // Write to the file (Asynchronous).
       
   630 	{
       
   631 	test.Printf(_L("%S write  0x%lx\n"),&iName,aPos);
       
   632 	RFile64::Write(aPos,aDes,aStatus);
       
   633 	User::WaitForRequest(aStatus);
       
   634 	if( KErrNone == aStatus.Int())	// this is to ensure that the written data is committed and not cached.
       
   635 		{
       
   636 		RFile64::Flush(aStatus);
       
   637 		User::WaitForRequest(aStatus);	
       
   638 		}
       
   639 	
       
   640 	
       
   641 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   642 		{
       
   643 		if((aPos + aDes.Length()) < K4GB)
       
   644 			test(aStatus.Int() == KErrNone);
       
   645 		else
       
   646 			test(aStatus.Int() == KErrNotSupported);
       
   647 		}
       
   648 	else
       
   649 		{
       
   650 		test(aStatus.Int() == KErrNone);
       
   651 		}
       
   652 	return(*this);	
       
   653 	}
       
   654 
       
   655 RFileTest& RFileTest::WriteU(TUint aPos, const TDesC8& aDes, TRequestStatus &aStatus)
       
   656 //
       
   657 // Write to the file (Asynchronous).
       
   658 // Position is a TUint value
       
   659 //
       
   660 	{
       
   661 	test.Printf(_L("%S write  %08x\n"),&iName,aPos);
       
   662 	RFile64::Write(aPos,aDes,aStatus);
       
   663 	User::WaitForRequest(aStatus);
       
   664 	if( KErrNone == aStatus.Int())	// this is to ensure that the written data is committed and not cached.
       
   665 		{
       
   666 		RFile64::Flush(aStatus);
       
   667 		User::WaitForRequest(aStatus);	
       
   668 		}
       
   669 	test(aStatus.Int() == KErrNone);
       
   670 	return(*this);	
       
   671 	}
       
   672 
       
   673 RFileTest& RFileTest::WriteU(TUint aPos, const TDesC8& aDes, TInt aLen, TRequestStatus &aStatus)
       
   674 // 
       
   675 // Write to the file. Asynchronous
       
   676 // Position is a TUint value
       
   677 //
       
   678 	{
       
   679 	test.Printf(_L("%S write  %08x-%08x\n"),&iName,aPos,aPos+aLen-1);
       
   680 	RFile64::Write(aPos,aDes,aLen,aStatus);
       
   681 	User::WaitForRequest(aStatus);
       
   682 	if( KErrNone == aStatus.Int())	// this is to ensure that the written data is committed and not cached.
       
   683 		{
       
   684 		RFile64::Flush(aStatus);
       
   685 		User::WaitForRequest(aStatus);	
       
   686 		}
       
   687 
       
   688 	if(aLen < 0)
       
   689 		test(aStatus.Int() == KErrArgument);
       
   690 	else
       
   691 		test(aStatus.Int() == KErrNone);
       
   692 	return(*this);	
       
   693 	}
       
   694 
       
   695 
       
   696 	
       
   697 RFileTest& RFileTest::Read(TDes8& aDes) 
       
   698 //
       
   699 // Read from the file. Expected not to fail (Synchronous).
       
   700 //
       
   701 	{
       
   702 	test.Printf(_L("%S read \n"),&iName);
       
   703 	TInt r = RFile64::Read(aDes);
       
   704 	test(r == KErrNone);
       
   705 	return(*this);
       
   706 	}
       
   707 
       
   708 RFileTest& RFileTest::Read(TDes8& aDes, TRequestStatus& aStatus) 
       
   709 //
       
   710 // Read from the file. Expected not to fail (Asynchronous).
       
   711 //
       
   712 	{
       
   713 	TInt64 size = 0;
       
   714 	test.Printf(_L("%S read \n"),&iName);
       
   715 	RFile64::Read(aDes, aStatus);
       
   716 	User::WaitForRequest(aStatus);
       
   717 	TInt len = aDes.Length();
       
   718 	TInt rr = RFile64::Size(size);
       
   719 	test(rr == KErrNone);
       
   720 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   721 		{
       
   722 		if(size < K4GB)
       
   723 			test(aStatus.Int() == KErrNone);
       
   724 		else
       
   725 			{
       
   726 			test(aStatus.Int() == KErrNone);
       
   727 			test(len == 0);	
       
   728 			}
       
   729 		}
       
   730 	else
       
   731 		{
       
   732 		test(aStatus.Int() == KErrNone);
       
   733 		}
       
   734 	return(*this);
       
   735 	}
       
   736 
       
   737 RFileTest& RFileTest::Read(TDes8& aDes,TInt aLen,TRequestStatus& aStatus) 
       
   738 //
       
   739 // Read from the file. Expected not to fail (Asynchronous).
       
   740 //
       
   741 	{
       
   742 	TInt64 size = 0;
       
   743 	test.Printf(_L("%S read \n"),&iName);
       
   744 	RFile64::Read(aDes,aLen,aStatus);
       
   745 	User::WaitForRequest(aStatus);
       
   746 	TInt len = aDes.Length();
       
   747 	TInt rr = RFile64::Size(size);
       
   748 	test(rr == KErrNone);
       
   749 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   750 		{
       
   751 		if(size < K4GB)
       
   752 			test(aStatus.Int() == KErrNone);
       
   753 		else
       
   754 			{
       
   755 			test(aStatus.Int() == KErrNone);
       
   756 			test(len == 0);	
       
   757 			}
       
   758 		}
       
   759 	else
       
   760 		{
       
   761 		test(aStatus.Int() == KErrNone);
       
   762 		}	
       
   763 	return(*this);
       
   764 	}
       
   765 	
       
   766 RFileTest& RFileTest::Read(TDes8 &aDes, TInt aLen)
       
   767 //
       
   768 // Read from the file. Expected not to fail (Synchronous).
       
   769 //
       
   770 	{
       
   771 	test.Printf(_L("%S read 0x%08x bytes\n"),&iName,aLen);
       
   772 	TInt r = RFile64::Read(aDes,aLen);
       
   773 	if(aLen < 0)
       
   774 		test(r == KErrArgument);
       
   775 	else
       
   776 		test(r == KErrNone);
       
   777 	return(*this);
       
   778 	}
       
   779 	
       
   780 RFileTest& RFileTest::Read(TInt64 aPos, TDes8& aDes, TInt aLen) 
       
   781 //
       
   782 // Read from the file. Expected not to fail (Synchronous).
       
   783 //
       
   784 	{
       
   785 	test.Printf(_L("%S read   0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   786 	TInt r = RFile64::Read(aPos,aDes,aLen);
       
   787 	TInt len = aDes.Length();
       
   788 	if(aLen < 0)
       
   789 		test(r == KErrArgument);
       
   790 	else 
       
   791 		test(r == KErrNone);
       
   792 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   793 		{	
       
   794 		if(aPos >= K4GB) 
       
   795 			test(len == 0);
       
   796 		}
       
   797 	return(*this);
       
   798 	}
       
   799 
       
   800 RFileTest& RFileTest::ReadE(TInt64 aPos, TDes8& aDes, TInt aLen) 
       
   801 //
       
   802 // Reads the specified number of bytes from the file at a specified offset. Expected to fail.
       
   803 //
       
   804 	{
       
   805 	test.Printf(_L("%S readE  0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   806 	TInt r = RFile64::Read(aPos,aDes,aLen);
       
   807 	test(r == KErrLocked);
       
   808 	return(*this);
       
   809 	}
       
   810 
       
   811 RFileTest& RFileTest::Read(TInt64 aPos, TDes8& aDes, TInt aLen, TRequestStatus& aStatus) 
       
   812 //
       
   813 // Reads the specified number of bytes from the file at a specified offset, Expected not to fail (Asynchronous).
       
   814 //
       
   815 	{
       
   816 	test.Printf(_L("%S read   0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   817 	RFile64::Read(aPos,aDes,aLen,aStatus);
       
   818 	User::WaitForRequest(aStatus);
       
   819 	TInt len = aDes.Length();
       
   820 	if(aLen < 0)
       
   821 		test(aStatus.Int() == KErrArgument);
       
   822 	else
       
   823 		test(aStatus.Int() == KErrNone);
       
   824 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   825 		{
       
   826 		if(aPos >= K4GB) 
       
   827 			test(len == 0);		
       
   828 		}
       
   829 	return(*this);
       
   830 	}
       
   831 
       
   832 RFileTest& RFileTest::ReadP(TInt64 aPos, TDes8& aDes)
       
   833 //
       
   834 // Reads from the file at the specfied offset with in the file (Synchronous).
       
   835 //
       
   836 	{
       
   837 	test.Printf(_L("%S read   0x%lx\n"),&iName,aPos);
       
   838 	TInt r = RFile64::Read(aPos,aDes);
       
   839 	test(r == KErrNone);
       
   840 	return(*this);	
       
   841 	}
       
   842 
       
   843 RFileTest& RFileTest::ReadU(TUint aPos, TDes8& aDes)
       
   844 //
       
   845 // Reads from the file at the specfied offset with in the file (Synchronous).
       
   846 // Offset is specified as a TUint value.
       
   847 //
       
   848 	{
       
   849 	test.Printf(_L("%S read   0x%lx\n"),&iName,aPos);
       
   850 	TInt r = RFile64::Read(aPos,aDes);
       
   851 	test(r == KErrNone);
       
   852 	return(*this);	
       
   853 	}
       
   854 
       
   855 RFileTest& RFileTest::ReadU(TUint aPos, TDes8& aDes,TRequestStatus& aStatus)
       
   856 //
       
   857 // Reads from the file at the specfied offset with in the file (Asynchronous).
       
   858 // Offset is specified as a TUint value.
       
   859 //
       
   860 	{
       
   861 	test.Printf(_L("%S read   0x%lx\n"),&iName,aPos);
       
   862 	RFile64::Read(aPos,aDes,aStatus);
       
   863 	User::WaitForRequest(aStatus);
       
   864 	test(aStatus.Int() == KErrNone);
       
   865 	return(*this);
       
   866 	}
       
   867 
       
   868 RFileTest& RFileTest::ReadU(TUint aPos, TDes8& aDes, TInt aLen) 
       
   869 //
       
   870 // Read from the file. Expected not to fail (Synchronous).
       
   871 // Offset is specified as a TUint value.
       
   872 //
       
   873 	{
       
   874 	test.Printf(_L("%S read   0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   875 	TInt r = RFile64::Read(aPos,aDes,aLen);
       
   876 	if(aLen < 0)
       
   877 		test(r == KErrArgument);
       
   878 	else 
       
   879 		test(r == KErrNone);
       
   880 	return(*this);
       
   881 	}
       
   882 
       
   883 RFileTest& RFileTest::ReadU(TUint aPos, TDes8& aDes, TInt aLen, TRequestStatus& aStatus) 
       
   884 //
       
   885 // Reads the specified number of bytes from the file at a specified offset, Expected not to fail (Asynchronous).
       
   886 // Offset is specified as a TUint value.
       
   887 //
       
   888 	{
       
   889 	test.Printf(_L("%S read   0x%lx-0x%lx\n"),&iName,aPos,aPos+aLen-1);
       
   890 	RFile64::Read(aPos,aDes,aLen,aStatus);
       
   891 	User::WaitForRequest(aStatus);
       
   892 	if(aLen < 0)
       
   893 		test(aStatus.Int() == KErrArgument);
       
   894 	else
       
   895 		test(aStatus.Int() == KErrNone);
       
   896 	return(*this);
       
   897 	}
       
   898 
       
   899 	
       
   900 RFileTest& RFileTest::Read(TInt64 aPos, TDes8& aDes, TRequestStatus& aStatus)
       
   901 //
       
   902 // Reads from the file at the specfied offset with in the file (Asynchronous).
       
   903 //
       
   904 	{
       
   905 	test.Printf(_L("%S read   0x%lx\n"),&iName,aPos);
       
   906 	RFile64::Read(aPos,aDes,aStatus);
       
   907 	User::WaitForRequest(aStatus);
       
   908 	test(aStatus.Int() == KErrNone);
       
   909 	return(*this);
       
   910 	}
       
   911 	
       
   912 RFileTest& RFileTest::SetSize(TInt64 aSize)
       
   913 //
       
   914 // Set the size of the file. Expected not to fail.
       
   915 //
       
   916 	{
       
   917 	test.Printf(_L("%S size: 0x%lx\n"),&iName,aSize);
       
   918 	TInt r = RFile64::SetSize(aSize);
       
   919 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   920 		{
       
   921 		if(aSize < K4GB)
       
   922 			test(r == KErrNone);
       
   923 		else
       
   924 			test(r == KErrNotSupported);
       
   925 		}
       
   926 	else
       
   927 		{
       
   928 		test(r == KErrNone);
       
   929 		}
       
   930 	return(*this);
       
   931 	}
       
   932 
       
   933 RFileTest& RFileTest::SetSizeE(TInt64 aSize)
       
   934 //
       
   935 // Set the size of the file. Expected to fail.
       
   936 //
       
   937 	{
       
   938 	test.Printf(_L("%S sizeE: 0x%lx\n"),&iName,aSize);
       
   939 	TInt r = RFile64::SetSize(aSize);
       
   940 	test(r == KErrLocked);
       
   941 	return(*this);
       
   942 	}
       
   943 
       
   944 RFileTest& RFileTest::Size(TInt64& aSize)
       
   945 //
       
   946 // Gets the current file size. Expected not to fail.
       
   947 //
       
   948 	{
       
   949 	TInt r = RFile64::Size(aSize);
       
   950 	test.Printf(_L("%S size: 0x%lx\n"),&iName,aSize);
       
   951 
       
   952     if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
   953 		{
       
   954 		if(aSize < K4GB)
       
   955 			test(r == KErrNone);
       
   956 		else
       
   957 			test(r == KErrTooBig);
       
   958 		}
       
   959 	else
       
   960 		{
       
   961 		test(r == KErrNone);
       
   962 		}
       
   963 	return(*this);	
       
   964 
       
   965 	}
       
   966 RFileTest& RFileTest::Seek(TSeek aMode, TInt64& aPos)
       
   967 //
       
   968 // Sets the current file position. Expected not to fail.
       
   969 //
       
   970 	{
       
   971 	test.Printf(_L("Seek to pos %LD in %d Mode\n"),aPos, aMode);
       
   972 	TInt r = RFile64::Seek(aMode, aPos);
       
   973 	if(aPos < 0)
       
   974 		test(r == KErrArgument);
       
   975 	else
       
   976 		test(r == KErrNone);
       
   977 	return(*this);	
       
   978 	}
       
   979 
       
   980 /**
       
   981 @SYMTestCaseID      PBASE-T_FILE64BIT-0756
       
   982 @SYMTestPriority    High
       
   983 @SYMTestRequirement REQ9531 
       
   984 @SYMTestType        CIT
       
   985 @SYMTestCaseDesc    Test opening a large file = 2GB in size
       
   986 @SYMTestActions     
       
   987 1) Gets the entry details for a file using RFs::Entry(). The original file size=2GB
       
   988 2) Open a large file whose size = 2GB, with File Mode = EFileRead
       
   989 3) Close the file
       
   990 @SYMTestExpectedResults
       
   991 1) File size = 2GB
       
   992 2) KErrNone, File open successful
       
   993 3) File closed successfully
       
   994 @SYMTestStatus      Implemented
       
   995 */
       
   996 void TestOpen2GB()
       
   997 	{
       
   998 	TEntry entry;
       
   999 	TInt64 testSize, size = 0;
       
  1000 	TFileName fileName;
       
  1001 	fileName.Append(gDriveToTest);
       
  1002 	fileName.Append(KTestPath);
       
  1003 	fileName.Append(_L("File2GB.txt"));
       
  1004 	
       
  1005 	testSize = K2GB;
       
  1006 	
       
  1007 	test.Next(_L("Create the file using RFile64::Replace and set the size and close"));
       
  1008 	TestRFile1.Replace(fileName);
       
  1009 	TestRFile1.SetSize(testSize);
       
  1010 	TestRFile1.Close();
       
  1011 	
       
  1012 	
       
  1013 	test.Next(_L("2GB File: Open"));
       
  1014 	TInt r = TheFs.Entry(fileName, entry);
       
  1015 	test(r == KErrNone);
       
  1016 	test((TUint) entry.iSize == testSize);
       
  1017 
       
  1018     TestRFile1.Open(fileName, EFileRead);
       
  1019 	
       
  1020 	
       
  1021 	TestRFile1.Size(size);
       
  1022 	test(size == testSize);
       
  1023 	
       
  1024 	TestRFile1.Close();
       
  1025 	r = TheFs.Delete(fileName);
       
  1026 	test(r == KErrNone);
       
  1027 	}
       
  1028 
       
  1029 /**
       
  1030 @SYMTestCaseID      PBASE-T_FILE64BIT-0757
       
  1031 @SYMTestPriority    High
       
  1032 @SYMTestRequirement REQ9531 
       
  1033 @SYMTestType        CIT
       
  1034 @SYMTestCaseDesc    Test opening a large file = 3GB in size
       
  1035 @SYMTestActions     
       
  1036 1) Gets the entry details for a file using RFs::GetEntry(). The original file size=3GB
       
  1037 2) Open a large file whose size = 3GB, with File Mode = EFileRead
       
  1038 3) Close the file
       
  1039 @SYMTestExpectedResults
       
  1040 1) File size = 3GB
       
  1041 2) KErrNone, File open successful
       
  1042 3) File closed successfully
       
  1043 @SYMTestStatus      Implemented
       
  1044 */
       
  1045 void TestOpen3GB()
       
  1046 	{
       
  1047 	TInt r;
       
  1048 	TEntry entry;
       
  1049 	TInt64 testSize, size = 0;
       
  1050 	TFileName fileName;
       
  1051 	fileName.Append(gDriveToTest);
       
  1052 	fileName.Append(KTestPath);
       
  1053 	fileName.Append(_L("File3GB.txt"));
       
  1054 	testSize = K3GB;
       
  1055 	
       
  1056 	test.Next(_L("Create the file using RFile64::Replace and set the size and close"));
       
  1057 	TestRFile1.Replace(fileName);
       
  1058 	TestRFile1.SetSize(testSize);
       
  1059 	TestRFile1.Close();
       
  1060 		
       
  1061 	test.Next(_L("3GB File: Open"));
       
  1062 	r = TheFs.Entry(fileName, entry);
       
  1063 	test(r == KErrNone);
       
  1064 	test((TUint) entry.iSize == testSize);
       
  1065 	
       
  1066 	TestRFile1.Open(fileName,EFileRead);
       
  1067 	
       
  1068 	TestRFile1.Size(size);
       
  1069 	test(size == testSize);
       
  1070 	TestRFile1.Close();
       
  1071 	
       
  1072 	r = TheFs.Delete(fileName);
       
  1073 	test(r == KErrNone);
       
  1074 	}
       
  1075 
       
  1076 /**
       
  1077 @SYMTestCaseID      PBASE-T_FILE64BIT-0758
       
  1078 @SYMTestPriority    High
       
  1079 @SYMTestRequirement REQ9531 
       
  1080 @SYMTestType        CIT
       
  1081 @SYMTestCaseDesc    Test opening a large file < 4GB in size
       
  1082 @SYMTestActions     
       
  1083 1) Gets the entry details for a file using RFs::GetEntry(). The original file size=4GB-1
       
  1084 2) Open a large file whose size = 4GB-1, with File Mode = EFileRead
       
  1085 3) Close the file
       
  1086 @SYMTestExpectedResults
       
  1087 1) File size = 4GB-1
       
  1088 2) KErrNone, File open successful
       
  1089 3) File closed successfully
       
  1090 @SYMTestStatus      Implemented
       
  1091 */
       
  1092 void TestOpen4GBMinusOne()
       
  1093 	{
       
  1094 	TInt r;
       
  1095 	TEntry entry;
       
  1096 	TInt64 testSize, size = 0;
       
  1097 	TFileName fileName;
       
  1098 	fileName.Append(gDriveToTest);
       
  1099 	fileName.Append(KTestPath);
       
  1100 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  1101 	testSize = K4GB-1;
       
  1102 	
       
  1103 	test.Next(_L("Create the file using RFile64::Replace and set the size and close"));
       
  1104 	TestRFile1.Replace(fileName);
       
  1105 	TestRFile1.SetSize(testSize);
       
  1106 	TestRFile1.Close();
       
  1107 	
       
  1108 	test.Next(_L("4GB-1 File: Open"));
       
  1109 	r = TheFs.Entry(fileName, entry);
       
  1110 	test(r == KErrNone);
       
  1111 	
       
  1112 	test((TUint) entry.iSize == testSize);
       
  1113 	
       
  1114 	TestRFile1.Open(fileName, EFileRead);
       
  1115 		
       
  1116 	TestRFile1.Size(size);
       
  1117 		
       
  1118 	test(size == testSize);
       
  1119 	TestRFile1.Close();
       
  1120 	
       
  1121 	r = TheFs.Delete(fileName);
       
  1122 	test(r == KErrNone);
       
  1123 	}
       
  1124 	
       
  1125 /**
       
  1126 @SYMTestCaseID      PBASE-T_FILE64BIT-0759
       
  1127 @SYMTestPriority    High
       
  1128 @SYMTestRequirement REQ9531 
       
  1129 @SYMTestType        CIT
       
  1130 @SYMTestCaseDesc    Test opening a large file 4GB in size
       
  1131 @SYMTestActions     
       
  1132 1) Gets the entry details for a file using RFs::GetEntry(). The original file size=4GB
       
  1133 2) Open a large file whose size = 4GB, with File Mode = EFileRead
       
  1134 3) Close the file
       
  1135 @SYMTestExpectedResults
       
  1136 1) File size = 4GB
       
  1137 2) KErrNone, File open successful
       
  1138 3) File closed successfully
       
  1139 @SYMTestStatus      Implemented
       
  1140 */
       
  1141 void TestOpen4GB()
       
  1142 	{
       
  1143 	TInt r;
       
  1144 	TEntry entry;
       
  1145 	TInt64 testSize, size = 0;
       
  1146 	TFileName fileName;
       
  1147 	fileName.Append(gDriveToTest);
       
  1148 	fileName.Append(KTestPath);
       
  1149 	fileName.Append(_L("File4GB.txt"));
       
  1150 	testSize = K4GB;
       
  1151 
       
  1152 	test.Next(_L("Create the file using RFile64::Replace and set the size and close"));
       
  1153 	TestRFile1.Replace(fileName);
       
  1154 	TestRFile1.SetSize(testSize);
       
  1155 	TestRFile1.Close();
       
  1156 	
       
  1157 	test.Next(_L("4GB File: Open"));
       
  1158 	r = TheFs.Entry(fileName, entry);
       
  1159 	test(r == KErrNone);
       
  1160 	
       
  1161 	if ((TUint) entry.iSize == testSize)
       
  1162 		{
       
  1163 		TestRFile1.Open(fileName, EFileRead);
       
  1164 		TestRFile1.Size(size);
       
  1165 		test(size == testSize);
       
  1166 		TestRFile1.Close();
       
  1167 		}
       
  1168 	
       
  1169 	r = TheFs.Delete(fileName);
       
  1170 	test(r == KErrNone);
       
  1171 		
       
  1172 	}	
       
  1173 	
       
  1174 /**
       
  1175 @SYMTestCaseID      PBASE-T_FILE64BIT-0760
       
  1176 @SYMTestPriority    High
       
  1177 @SYMTestRequirement REQ9531 
       
  1178 @SYMTestType        CIT
       
  1179 @SYMTestCaseDesc    Tests opening a large file > 2GB in size
       
  1180 @SYMTestActions     
       
  1181 1) Create a new file named "File4GBMinusOne.txt"
       
  1182 2) Open the file with file mode = EFileWrite
       
  1183 3) Set the file size to 4GB-1
       
  1184 4) Write few bytes to the file and close
       
  1185 5) Close the file
       
  1186 6) Open the file "File4GBMinusOne.txt"
       
  1187 7) If FAT32 file system, set the file size to 4GB
       
  1188 8) Close the file
       
  1189 9) Open the file with file mode = EDeleteOnClose
       
  1190 @SYMTestExpectedResults
       
  1191 1) File creation successful with KErrNone
       
  1192 2) File open successful with KErrNone
       
  1193 3) KErrNone, Sets the file size to 4GB-1
       
  1194 4) KErrNone, write is successful and file closed successfully
       
  1195 5) File closed successfully
       
  1196 6) KErrNone, file open successful
       
  1197 7) KErrNotSupported. For next generation file system KErrNone is expected
       
  1198 8) File closed successfully
       
  1199 9) File open failed with KErrArgument
       
  1200 @SYMTestStatus      Implemented
       
  1201 */
       
  1202 void TestOpenMoreThan2GB()
       
  1203 	{
       
  1204 	// constants and literals
       
  1205 	test.Next(_L("\nTest Files of size more than 2GB\n"));
       
  1206 	
       
  1207 	TInt64 			size;
       
  1208 	TBuf8<KBUFSIZE> readBuf;
       
  1209 	TFileName fileName;
       
  1210 	fileName.Append(gDriveToTest);
       
  1211 	fileName.Append(KTestPath);
       
  1212 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  1213 	
       
  1214 	test.Start(_L("Test to create a large file > 2GB\n"));
       
  1215 	
       
  1216 	TestRFile1.Replace(fileName);
       
  1217 	test.Next(_L("Set the file size to 4GB-1\n"));
       
  1218 	
       
  1219 	size = K4GBMinusOne;
       
  1220 	TestRFile1.SetSize(size);
       
  1221 	
       
  1222 	TBuf8<10> writeBuf;
       
  1223 	writeBuf.Zero();
       
  1224 	for(TInt count = 0; count < 10; count++)
       
  1225 		{
       
  1226 		writeBuf.Append(count);
       
  1227 		}
       
  1228 		
       
  1229    	test.Next(_L("Write 10 bytes to the file\n"));
       
  1230 	TestRFile1.Write(0, writeBuf, 10);	
       
  1231 	test.Next(_L("Read 10 bytes from position 0\n"));
       
  1232 	TestRFile1.Read(0, readBuf, 10); 
       
  1233 	test(writeBuf == readBuf);
       
  1234 	
       
  1235 	TInt64 s;
       
  1236 	TestRFile1.Size(s);
       
  1237 	if(s < K4GB)
       
  1238 		{
       
  1239 		test.Printf(_L("\nFile size is less than 4 GB !!!!\n"));	
       
  1240 		}
       
  1241 
       
  1242 	TestRFile1.Close();
       
  1243 		
       
  1244 	test.Next(_L("Open the file File4GBMinusOne.txt\n"));
       
  1245 	TestRFile1.Open(fileName);
       
  1246 	
       
  1247 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)	
       
  1248 		{
       
  1249 		test.Next (_L("Set the file size to 4GB\n"));
       
  1250 		size = K4GB;
       
  1251 		TestRFile1.SetSize(size);
       
  1252 		}
       
  1253 	TestRFile1.Close();
       
  1254 	
       
  1255 	RFile64 file64;
       
  1256 	TInt r = file64.Open(TheFs,fileName,EDeleteOnClose);
       
  1257 	test (r == KErrArgument);
       
  1258 	
       
  1259 	r = TheFs.Delete(fileName);
       
  1260 	test(r == KErrNone);
       
  1261 	
       
  1262 	}
       
  1263 
       
  1264 /**
       
  1265 @SYMTestCaseID      PBASE-T_FILE64BIT-0761
       
  1266 @SYMTestPriority    High
       
  1267 @SYMTestRequirement REQ9531 
       
  1268 @SYMTestType        CIT
       
  1269 @SYMTestCaseDesc    Tests opening a file using RFile and RFile64 in file sharing mode
       
  1270 @SYMTestActions     
       
  1271 1) Create a file using RFile::Replace()
       
  1272 2) Open the file using RFile::Open()  and file mode = EFileShareAny
       
  1273 3) Write 100 bytes to the file and close the file
       
  1274 4) Open the same file using RFile64::Open() and file mode = EFileShareAny
       
  1275 5) Set the file size to 4GB-1 using RFile64::SetSize().
       
  1276 6) Get the file size using RFile::Size()
       
  1277 7) Seek to the file position 2GB+5 using RFile::Seek()
       
  1278 8) Get the file size using RFile64::Size()
       
  1279 9) Seek to the file position 4GB-10 using RFile64::Seek()
       
  1280 10) Read from the file position 4GB-10 using RFile::Read() of length 5 bytes
       
  1281 11) Close the file.
       
  1282 12) Open the file using RFile::Open().
       
  1283 13) Open the file using RFile64::Open() and close the file.
       
  1284 @SYMTestExpectedResults
       
  1285 1) File created successful with KErrNone.
       
  1286 2) File opened successfully with KErrNone.
       
  1287 3) Write successful with KErrNone.
       
  1288 4) File opened successfully with KErrNone.
       
  1289 5) File size set successfully with KErrNone.
       
  1290 6) Fail with KErrNotSupported.
       
  1291 7) Seek operation fail with KErrArgument.
       
  1292 8) FileSize == 4GB-1.
       
  1293 9) KErrNone.
       
  1294 10) Read fail with KErrNotSupported.
       
  1295 11) File closed successfully.
       
  1296 12) File Open failed with KErrTooBig.
       
  1297 13) File open successfully with KErrNone and file closed successfully.
       
  1298 @SYMTestStatus      Implemented
       
  1299 */
       
  1300 void TestOpenRFileRFile64()
       
  1301 	{
       
  1302 	RFile file;
       
  1303 	TInt size;
       
  1304 	TInt64 size64;
       
  1305 	TInt count;
       
  1306 	TFileName fileName;
       
  1307 	fileName.Append(gDriveToTest);
       
  1308 	fileName.Append(KTestPath);
       
  1309 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  1310 	
       
  1311 	test.Start(_L("Test opening a file using RFile and RFile64 in file sharing mode\n"));
       
  1312 	TInt r = file.Replace(TheFs,fileName,EFileShareAny|EFileWrite);
       
  1313 	test(r == KErrNone);
       
  1314 	
       
  1315 	TBuf8<100> writeBuf;
       
  1316 	TBuf8<100> readBuf;
       
  1317 	writeBuf.Zero();
       
  1318 	for(count = 0; count < 100; count++)
       
  1319 		{
       
  1320 		writeBuf.Append(count);
       
  1321 		}
       
  1322 		
       
  1323    	test.Next(_L("Write 100 bytes to the file\n"));
       
  1324 	r = file.Write(0, writeBuf, 100);	
       
  1325 	test(r == KErrNone);
       
  1326 	
       
  1327 	test.Next(_L("Read 100 bytes from position 0"));
       
  1328 	r = file.Read(0, readBuf, 100); 
       
  1329 	test(r == KErrNone);
       
  1330 	
       
  1331 	test.Next(_L("Compare the read data to the written data"));
       
  1332 	test(readBuf == writeBuf);
       
  1333 
       
  1334 	
       
  1335 	test.Next(_L("Open the same file using RFile64::Open"));
       
  1336 	TestRFile1.Open(fileName,EFileShareAny|EFileWrite);
       
  1337 	
       
  1338 	test.Next(_L("Set the file size to 4GB-1\n"));
       
  1339 	TestRFile1.SetSize(K4GBMinusOne);
       
  1340 	
       
  1341 	test.Next(_L("Query the file size using Rfile::Size()\n"));
       
  1342 	r = file.Size(size);
       
  1343 	test (r == KErrTooBig);
       
  1344 	
       
  1345 	test.Next(_L("Seek to the file position using 2GB+5 using RFile::Seek()\n"));
       
  1346 	TUint seekPos1 = K2GB + 5;
       
  1347 	TInt seekPos  = (TInt)seekPos1;
       
  1348 	r = file.Seek(ESeekStart,seekPos);
       
  1349 	test(r == KErrArgument);
       
  1350 	
       
  1351 	test.Next(_L("Get the file size using RFile64::Size()\n"));
       
  1352 	TestRFile1.Size(size64);
       
  1353 	
       
  1354 	test.Next(_L("Seek to the file position 4GB-10 using RFile64::Seek()\n"));
       
  1355 	TInt64 seekPos64 = K4GB - 10;
       
  1356 	TestRFile1.Seek(ESeekStart,seekPos64);
       
  1357 	
       
  1358 	TBuf8<5> writeBuf64;
       
  1359 	TBuf8<5> readBuf64;
       
  1360 	writeBuf64.Zero();
       
  1361 	for(count = 0; count < 5; count++)
       
  1362 		{
       
  1363 		writeBuf64.Append(count);
       
  1364 		}
       
  1365 	
       
  1366 	test.Next(_L("Read from the file position 4GB-10 using RFile::Read() of length 5 bytes\n"));
       
  1367 	TestRFile1.Write(seekPos64,writeBuf64,5);
       
  1368 	TestRFile1.Seek(ESeekStart,seekPos64);
       
  1369 	TestRFile1.Read(seekPos64,readBuf64,5);
       
  1370 	test(readBuf64 == writeBuf64);
       
  1371 	
       
  1372 	TestRFile1.Close();
       
  1373 	file.Close();
       
  1374 	
       
  1375 	test.Next(_L("Open the file using Rfile::Open()\n"));
       
  1376 	r = file.Open(TheFs,fileName,EFileShareAny|EFileWrite);
       
  1377 	test(r == KErrTooBig);
       
  1378 	
       
  1379 	test.Next(_L("Open the file using Rfile64::Open() and close\n"));
       
  1380 	TestRFile1.Open(fileName,EFileShareAny|EFileWrite);
       
  1381 	TestRFile1.Close();
       
  1382 	
       
  1383 	r = TheFs.Delete(fileName);
       
  1384 	test(r == KErrNone);
       
  1385 	}
       
  1386 
       
  1387 /**
       
  1388 @SYMTestCaseID      PBASE-T_FILE64BIT-0762
       
  1389 @SYMTestPriority    High
       
  1390 @SYMTestRequirement REQ9531
       
  1391 @SYMTestType        CIT
       
  1392 @SYMTestCaseDesc    Tests the temporary file creation using RFile64::Temp()
       
  1393 @SYMTestActions     
       
  1394 1) Create a Temporary file using RFile64::Temp() in write mode and DeleteOnClose
       
  1395 2) Set the file size to 4GB-1
       
  1396 3) Write 100 bytes to the file at position 2GB+1
       
  1397 4) Write 1 byte to file position 4GB-2
       
  1398 5) Write 10 bytes to file position 0.
       
  1399 6) Write 1 byte to file position 4GB+1
       
  1400 7) Read and compare the data at position 2GB+1,4GB-2,0 and close the file
       
  1401 8) Delete the temporary file.
       
  1402 9) Create a temporary file using RFile64::Temp() in write mode and without DeleteOnClose flag
       
  1403 10) Close the File
       
  1404 11) Delete the temporary file
       
  1405 @SYMTestExpectedResults
       
  1406 1) Temporary file created successfully 
       
  1407 2) File size = 4GB-1
       
  1408 3) Write successful with KErrNone
       
  1409 4) Write successful with KErrNone
       
  1410 5) Write successful with KErrNone
       
  1411 6) Write fail with KErrNotSupported
       
  1412 7) Read data == written data
       
  1413 8) KErrNotFound, since the file is already deleted on close
       
  1414 9) File created successfully
       
  1415 10) File closed
       
  1416 11) File deleted successfully
       
  1417 
       
  1418 @SYMTestStatus      Implemented
       
  1419 */
       
  1420 void TestCreateTempFile()
       
  1421 	{
       
  1422 	TInt count;
       
  1423 	TFileName testDir;
       
  1424 	testDir.Append(gDriveToTest);
       
  1425 	testDir.Append(KTestPath);
       
  1426 	
       
  1427 	TInt r = TheFs.MkDir(testDir);
       
  1428 	test(r == KErrNone || r == KErrAlreadyExists);
       
  1429 	
       
  1430 	TFileName fileName;
       
  1431 	TestRFile1.Temp(testDir, fileName, EFileWrite|EDeleteOnClose);
       
  1432 	
       
  1433 	test.Next(_L("Set the file size to 4GB-1\n"));
       
  1434 	TestRFile1.SetSize(K4GBMinusOne);
       
  1435 	
       
  1436 	TInt64 size = 0;
       
  1437 	TestRFile1.Size(size);
       
  1438 	test (size == K4GBMinusOne);
       
  1439 	
       
  1440 	TBuf8<0x64> writeBuf;
       
  1441 	TBuf8<0x64> readBuf;
       
  1442 	writeBuf.Zero();
       
  1443 	for(count = 0; count < 100; count++)
       
  1444 		{
       
  1445 		writeBuf.Append(count);
       
  1446 		}
       
  1447 	TInt64 seekPos = K2GB + 1;
       
  1448 	test.Next(_L("Write 100 bytes to the file at position 2GB+1\n"));
       
  1449 	TestRFile1.Write(seekPos, writeBuf, 100);	
       
  1450 	test.Next(_L("Read 100 bytes from position 2GB+1"));
       
  1451 	TestRFile1.Read(seekPos, readBuf, 100); 
       
  1452 	test(writeBuf == readBuf);
       
  1453 	
       
  1454 	test.Next(_L("Write 1 byte to the file at position 4GB-2\n"));
       
  1455 	TBuf8<01> writeBuf1Byte;
       
  1456 	TBuf8<01> readBuf1Byte;
       
  1457 	writeBuf1Byte.Zero();
       
  1458 	writeBuf1Byte.Append(0);
       
  1459 	seekPos = K4GBMinusTwo;
       
  1460 	TestRFile1.Write(seekPos, writeBuf1Byte, 1);	
       
  1461 	
       
  1462 	test.Next(_L("Read 1 byte from position 4GB-2"));
       
  1463 	seekPos = K4GBMinusTwo;
       
  1464 	TestRFile1.Read(seekPos, readBuf1Byte, 1); 
       
  1465 	test(writeBuf1Byte == readBuf1Byte);
       
  1466 	
       
  1467 	test.Next(_L("Write 10 bytes to the file at position 0\n"));
       
  1468 	TBuf8<10> writeBuf10Byte;
       
  1469 	TBuf8<10> readBuf10Byte;
       
  1470 	writeBuf10Byte.Zero();
       
  1471 	for(count = 0; count < 10; count++)
       
  1472 		{
       
  1473 		writeBuf10Byte.Append(count);
       
  1474 		}
       
  1475 	TestRFile1.Write(0, writeBuf10Byte, 10);	
       
  1476 	
       
  1477 	test.Next(_L("Read 10 byte from position 0"));
       
  1478 	TestRFile1.Read(0, readBuf10Byte, 10); 
       
  1479 	test(writeBuf10Byte == readBuf10Byte);
       
  1480 	
       
  1481 	test.Next(_L("Write 1 byte to the file at position 4GB+1\n"));
       
  1482 	seekPos = K4GB + 1;
       
  1483 	TestRFile1.Write(seekPos, writeBuf1Byte, 1);
       
  1484 	
       
  1485 	TestRFile1.Close();
       
  1486 	
       
  1487 	test.Next(_L("Delete the temporary file\n"));
       
  1488 	r = TheFs.Delete(fileName);
       
  1489 	test(r == KErrNotFound);
       
  1490 	
       
  1491 	test.Next(_L("Create a temporary file using RFile64::Temp without EDeleteOnClose flag\n"));
       
  1492 	TestRFile1.Temp(testDir, fileName, EFileWrite);
       
  1493 	
       
  1494 	test.Next(_L("Close the file\n"));	
       
  1495 	TestRFile1.Close();
       
  1496 	
       
  1497 	test.Next(_L("Delete the temporary the file\n"));	
       
  1498 	r = TheFs.Delete(fileName);
       
  1499 	test(r == KErrNone);
       
  1500 	
       
  1501 	}
       
  1502 
       
  1503 /**
       
  1504 @SYMTestCaseID      PBASE-T_FILE64BIT-0763
       
  1505 @SYMTestPriority    High
       
  1506 @SYMTestRequirement REQ9531 
       
  1507 @SYMTestType        CIT
       
  1508 @SYMTestCaseDesc    Tests the file creation using RFile64::Create()
       
  1509 @SYMTestActions     
       
  1510 1) Create a file FileLargeOne.txt in write mode.
       
  1511 2) Set the file size to 3GB-4KB
       
  1512 3) Seek the file: Mode = ESeekEnd
       
  1513 4) Write to a file with current position and length =4KB
       
  1514 5) Get the file size.
       
  1515 6) Write to a file at position 0 and length = 100 bytes.
       
  1516 7) Write to a file at position 4GB -2 and length = 1 byte
       
  1517 8) Write to a file at position 4GB -2 and length = 3 byte
       
  1518 9) Read and compare the data written at position 0, 4GB-1
       
  1519 10) Close the File.
       
  1520 11) Create the file FileLargeOne.txt in write mode.
       
  1521 12) Create a file with invalid path and file name.
       
  1522 @SYMTestExpectedResults
       
  1523 1) File created successfully with KErrNone 
       
  1524 2) File size = 3GB-4KB
       
  1525 3) KErrNone
       
  1526 4) Write successful with KErrNone
       
  1527 5) File size == 3GB
       
  1528 6) Write successful with KErrNone
       
  1529 7) Write successful with KErrNone
       
  1530 8) Write fails with KErrNotSupported.
       
  1531 9) Read data == written data.
       
  1532 10) File closed successfully.
       
  1533 11) File creation failed with KErrAlreadyExists
       
  1534 12) File Creation failed with KErrPathNotFound.
       
  1535 @SYMTestStatus      Implemented
       
  1536 */
       
  1537 void TestCreateRFile64()
       
  1538 	{
       
  1539 	TInt count;
       
  1540 	TFileName fileName;
       
  1541 	fileName.Append(gDriveToTest);
       
  1542 	fileName.Append(KTestPath);
       
  1543 	fileName.Append(_L("FileLargeOne.txt"));
       
  1544 	
       
  1545 	test.Next(_L("create a file named FileLargeOne.txt\n"));
       
  1546 	TestRFile1.Create(fileName, EFileWrite);
       
  1547 	
       
  1548 	test.Next(_L("set the file size to 3GB - 4KB\n"));
       
  1549 	TestRFile1.SetSize(K3GB-K4KB);
       
  1550 	
       
  1551 	TInt64 size = 0;
       
  1552 	TestRFile1.Size(size);
       
  1553 	test (size == K3GB-K4KB);
       
  1554 	
       
  1555 	test.Next(_L("seek to the end of the file\n"));
       
  1556 	TInt64 seekPos = 0;
       
  1557 	TestRFile1.Seek(ESeekEnd,seekPos);
       
  1558 	test(seekPos == K3GB-K4KB);	
       
  1559 	
       
  1560 	test.Next(_L("write to the file current position and length = 4KB\n"));
       
  1561 	TBuf8<4096> writeBufK4KB;
       
  1562 	TBuf8<4096> readBufK4KB;
       
  1563 	for (count = 0; count < 4096; count++)
       
  1564 		{
       
  1565 		writeBufK4KB.Append(count+1);
       
  1566 		}
       
  1567 	
       
  1568 	TestRFile1.Write(writeBufK4KB,K4KB);
       
  1569 	
       
  1570 	test.Next(_L("read from the file from position K3GB-K4KB and length = 4KB\n"));
       
  1571 	seekPos = K3GB - K4KB;
       
  1572 	TestRFile1.Read(seekPos,readBufK4KB,K4KB);
       
  1573 	test(writeBufK4KB == readBufK4KB);
       
  1574 	
       
  1575 	test.Next(_L("get the size of the file\n"));
       
  1576 	size = 0;
       
  1577 	TestRFile1.Size(size);
       
  1578 	test(size == K3GB);
       
  1579 	
       
  1580 	test.Next(_L("write to the file at position 0 and length = 100bytes\n"));
       
  1581 	TBuf8<0x64> writeBuf100B;
       
  1582 	TBuf8<0x64> readBuf100B;
       
  1583 	writeBuf100B.Zero();
       
  1584 	for(count = 0; count < 100; count++)
       
  1585 		{
       
  1586 		writeBuf100B.Append(count);
       
  1587 		}
       
  1588 	seekPos = 0;
       
  1589 	TestRFile1.Write(seekPos, writeBuf100B, 100);	
       
  1590 	
       
  1591 	test.Next(_L("Read 100 bytes from position 0"));
       
  1592 	TestRFile1.Read(seekPos, readBuf100B, 100); 
       
  1593 	test(writeBuf100B == readBuf100B);
       
  1594 	
       
  1595 	test.Next(_L("Write 1 byte to the file at position 4GB-2\n"));
       
  1596 	TBuf8<01> writeBuf1Byte;
       
  1597 	TBuf8<01> readBuf1Byte;
       
  1598 	writeBuf1Byte.Zero();
       
  1599 	writeBuf1Byte.Append(0);
       
  1600 	seekPos = K4GBMinusTwo;
       
  1601 	TestRFile1.SetSize(K4GB-1);
       
  1602 	TestRFile1.Write(seekPos, writeBuf1Byte, 1);	
       
  1603 	
       
  1604 	test.Next(_L("Read 1 byte from position 4GB-2"));
       
  1605 	seekPos = K4GBMinusTwo;
       
  1606 	TestRFile1.Read(seekPos, readBuf1Byte, 1); 
       
  1607 	test(writeBuf1Byte == readBuf1Byte);
       
  1608 	
       
  1609 	test.Next(_L("Write 3 bytes to the file at position 4GB-1\n"));
       
  1610 	TBuf8<3> writeBuf3Byte;
       
  1611 	
       
  1612 	writeBuf3Byte.Zero();
       
  1613 	for(count = 0; count < 3; count++)
       
  1614 		{
       
  1615 		writeBuf3Byte.Append(count);
       
  1616 		}
       
  1617 	seekPos = K4GBMinusTwo;
       
  1618 	TestRFile1.Write(seekPos, writeBuf1Byte, 3);	
       
  1619 	
       
  1620 	TestRFile1.Close();
       
  1621 	
       
  1622 	test.Next(_L("create a file named FileLargeOne.txt(KErrAlreadyExists)\n"));
       
  1623 	TestRFile1.Create(fileName,EFileWrite);
       
  1624 	
       
  1625 	test.Next(_L("create a file with InvalidPath and fileName\n"));	
       
  1626 	RFile64 file64;
       
  1627 	TInt r = file64.Create(TheFs, _L("C:\\InvalidPathName\\FileName"),EFileWrite);
       
  1628 	test(r == KErrPathNotFound);
       
  1629 	
       
  1630 	r = TheFs.Delete(fileName);
       
  1631 	test(r == KErrNone);
       
  1632 	}	
       
  1633 	
       
  1634 /**
       
  1635 @SYMTestCaseID      PBASE-T_FILE64BIT-0764
       
  1636 @SYMTestPriority    High
       
  1637 @SYMTestRequirement REQ9531 
       
  1638 @SYMTestType        CIT
       
  1639 @SYMTestCaseDesc    Tests the file creation using RFile64::Replace()
       
  1640 @SYMTestActions     
       
  1641 1) Replace a file FileLargeOne.txt in write mode using RFile64::Replace.
       
  1642 2) Set the file size to 4GB-1
       
  1643 3) Write to a file with position = 4GB-4KB-2 and length = 4KB
       
  1644 4) Get the file size
       
  1645 5) Seek the file: Mode = ESeekEnd,pos = 0.
       
  1646 6) Write to a file with current position, length = 1 byte
       
  1647 7) Seek the file: Mode = ESeekStart
       
  1648 8) Write to a file with current position and length = 4KB
       
  1649 9) Seek the file: Mode = ESeekEnd
       
  1650 10)Read from the current position and length = 1 byte and compare with written data
       
  1651 11)Seek the file: Mode = ESeekStart
       
  1652 12)Read the data from the current position and length = 4KB and compare with written data
       
  1653 13)Close the file
       
  1654 14)Replace a file FileLargeOne.txt in write mode
       
  1655 15)Get the file size
       
  1656 16)Close the file.
       
  1657 17)Replace a file FileLargeOne.txt with invalid path
       
  1658 @SYMTestExpectedResults
       
  1659 1) File created successfully with KErrNone 
       
  1660 2) File size = 4GB-1
       
  1661 3) Write successful with KErrNone
       
  1662 4) File size = 4GB-1
       
  1663 5) KErrNone
       
  1664 6) Write successful with KErrNone
       
  1665 7) KErrNone
       
  1666 8) Write successful with KErrNone
       
  1667 9) KErrNone
       
  1668 10)Written data == Read data
       
  1669 11)KErrNone
       
  1670 12)Written data == Read data
       
  1671 13)File Closed
       
  1672 14)File creatd successfully with KErrNone
       
  1673 15)File size = 0
       
  1674 16)File Closed
       
  1675 17)File creation failed with KErrPathNotFound.
       
  1676 @SYMTestStatus      Implemented
       
  1677 */
       
  1678 void TestReplaceRFile64()
       
  1679 	{
       
  1680 	TFileName fileName;
       
  1681 	fileName.Append(gDriveToTest);
       
  1682 	fileName.Append(KTestPath);
       
  1683 	fileName.Append(_L("FileLargeOne.txt"));
       
  1684 	
       
  1685 	test.Next(_L("Replace a file named FileLargeOne.txt\n"));
       
  1686 	TestRFile1.Replace(fileName, EFileWrite);
       
  1687 	
       
  1688 	test.Next(_L("Set the size of the file to 4GB-1\n"));
       
  1689 	TestRFile1.SetSize(K4GB-1);
       
  1690 
       
  1691 	TBuf8<4096> writeBufK4KB;
       
  1692 	TBuf8<4096> readBufK4KB;	
       
  1693 	for (TInt count = 0; count < 4096; count++)
       
  1694 		{
       
  1695 		writeBufK4KB.Append(count+1);
       
  1696 		}
       
  1697 	
       
  1698 	test.Next(_L("Write to a file with position = 4GB-4KB-2 and length = 4KB\n"));
       
  1699 	TInt64 pos = K4GB-K4KB-2;
       
  1700 	TestRFile1.Write(pos,writeBufK4KB,K4KB);
       
  1701 	
       
  1702 	test.Next(_L("Read from 4GB-4KB-1 and compare data\n"));	
       
  1703 	TestRFile1.Read(pos,readBufK4KB,K4KB);
       
  1704 	test(writeBufK4KB == readBufK4KB);
       
  1705 	
       
  1706 	test.Next(_L("Get the file size\n"));
       
  1707 	TInt64 size = 0;
       
  1708 	TestRFile1.Size(size);
       
  1709 	test (size == K4GB-1);
       
  1710 	
       
  1711 	test.Next(_L("Seek the file: Mode = ESeekEnd,pos = 0.\n"));
       
  1712 	TInt64 seekPos = 0;
       
  1713 	TestRFile1.Seek(ESeekEnd,seekPos);
       
  1714 	test(seekPos == K4GB-1);
       
  1715 		
       
  1716 	test.Next(_L("Write to a file with current position, length = 1 byte\n"));
       
  1717 	TBuf8<1> writeBuf1B(_L8("0"));
       
  1718 	TBuf8<1> readBuf1B;
       
  1719 	
       
  1720     if(!KFileSizeMaxLargerThan4GBMinusOne)
       
  1721         seekPos--;
       
  1722 
       
  1723     TestRFile1.Write(seekPos,writeBuf1B,1); //-- now seek pos is K4GB
       
  1724 	
       
  1725 	
       
  1726 	test.Next(_L("Seek the file: Mode = ESeekStart\n"));	
       
  1727 	seekPos = 0;
       
  1728 	TestRFile1.Seek(ESeekStart,seekPos);
       
  1729 	
       
  1730 	test.Next(_L("Write to a file with current position and length = 4KB\n"));	
       
  1731 	TestRFile1.Write(seekPos,writeBufK4KB,K4KB);
       
  1732 	
       
  1733 	test.Next(_L("Seek the file: Mode = ESeekEnd\n"));	
       
  1734 	seekPos = 0;
       
  1735 	TestRFile1.Seek(ESeekEnd,seekPos);
       
  1736     
       
  1737     if(KFileSizeMaxLargerThan4GBMinusOne)
       
  1738     {//-- file is larger than 4G-1
       
  1739         test(seekPos == K4GB);
       
  1740     }
       
  1741 	else
       
  1742     {
       
  1743         test(seekPos == K4GB-1);
       
  1744  	}
       
  1745 	
       
  1746     seekPos--;
       
  1747     
       
  1748 
       
  1749 	test.Next(_L("Read from pos = 4GB-1 and compare data\n"));	
       
  1750 	TestRFile1.Read(seekPos,readBuf1B,1);
       
  1751 	test(writeBuf1B == readBuf1B);	
       
  1752 	
       
  1753 	test.Next(_L("Seek the file: Mode = ESeekStart\n"));	
       
  1754 	seekPos = 0;
       
  1755 	TestRFile1.Seek(ESeekStart,seekPos);
       
  1756 	
       
  1757 	test.Next(_L("Read from the file and compare written data\n"));	
       
  1758 	TestRFile1.Read(seekPos,readBufK4KB,K4KB);
       
  1759 	test (writeBufK4KB == readBufK4KB);
       
  1760 	
       
  1761 	test.Next(_L("Close the file\n"));	
       
  1762 	TestRFile1.Close();
       
  1763 
       
  1764 	test.Next(_L("Replace a file FileLargeOne.txt in write mode\n"));
       
  1765 	TestRFile1.Replace(fileName, EFileWrite);
       
  1766 	
       
  1767 	test.Next(_L("Get the file size\n"));
       
  1768 	size = 0;
       
  1769 	TestRFile1.Size(size);
       
  1770 	test (size == 0);
       
  1771 	
       
  1772 	test.Next(_L("Close the file\n"));	
       
  1773 	TestRFile1.Close();
       
  1774 	
       
  1775 	test.Next(_L("Replace a file FileLargeOne.txt with invalid path\n"));	
       
  1776 	RFile64 file64;
       
  1777 	TInt r = file64.Replace(TheFs,_L("C:\\InvalidPath\\FileLargeOne.Txt"),EFileWrite);
       
  1778 	test (r == KErrPathNotFound);
       
  1779 	
       
  1780 	r = TheFs.Delete(fileName);
       
  1781 	test(r == KErrNone);
       
  1782 	}
       
  1783 
       
  1784 /**
       
  1785 @SYMTestCaseID      PBASE-T_FILE64BIT-0765
       
  1786 @SYMTestPriority    High
       
  1787 @SYMTestRequirement REQXXXX 
       
  1788 @SYMTestType        CIT
       
  1789 @SYMTestCaseDesc    Tests the file replace using RFs::Replace()
       
  1790 @SYMTestActions     
       
  1791 1) Create a file named FileLargeOne.txt using RFile64::Replace()
       
  1792 2) Set the file size to 3GB and get the file size
       
  1793 3) Write 10 bytes to location 2GB+10 and close the file
       
  1794 4) Replace the file named ReNameFileLargeOne.txt using RFs::Replace()
       
  1795 5) Open the file ReNameFileLargeOne.txt
       
  1796 6) Set the file size to 4GB-1
       
  1797 7) Write 10 bytes to the location 3GB+10
       
  1798 8) Read the above file from the location 3GB+10
       
  1799 9) Compare the read and the written data
       
  1800 10)Close the file
       
  1801 @SYMTestExpectedResults
       
  1802 1) File created successfully with KErrNone 
       
  1803 2) File size = 3GB
       
  1804 3) Write successful with KErrNone and file closed
       
  1805 4) FileLargeOne.txt is replaced with ReNameFileLargeOne.txt successfully
       
  1806 5) File ReNameFileLargeOne.txt is opened successfully
       
  1807 6) KErrNone
       
  1808 7) Write successful with KErrNone
       
  1809 8) Read is successful with KErrNone
       
  1810 9) Written data == Read data
       
  1811 10)File Closed
       
  1812 @SYMTestStatus      Implemented
       
  1813 */
       
  1814 void TestReplaceRFile64RFs()
       
  1815 	{
       
  1816 	
       
  1817 	TFileName fileName;
       
  1818 	fileName.Append(gDriveToTest);
       
  1819 	fileName.Append(KTestPath);
       
  1820 	fileName.Append(_L("FileLargeOne.txt"));
       
  1821 	
       
  1822 	test.Next(_L("Replace a file named FileLargeOne.txt\n"));
       
  1823 	TestRFile1.Replace(fileName, EFileWrite);
       
  1824 	
       
  1825 	test.Next(_L("Set the file size to 3GB and get the file size\n"));
       
  1826 	TestRFile1.SetSize(K3GB);
       
  1827 	TInt64 size = 0;
       
  1828 	TestRFile1.Size(size);
       
  1829 	test (size == K3GB);
       
  1830 	
       
  1831 	
       
  1832 	test.Next(_L("Write 10 bytes to location 2GB+10 and close the file\n"));
       
  1833 	TBuf8<10> writeBuf;
       
  1834 	TBuf8<10> readBuf;	
       
  1835 	for (TInt count = 0; count < 10; count++)
       
  1836 		{
       
  1837 		writeBuf.Append(count+1);
       
  1838 		}
       
  1839 	TInt64 pos = K2GB+10;
       
  1840 	TestRFile1.Write(pos,writeBuf,10);
       
  1841 	TestRFile1.Read(pos,readBuf,10);
       
  1842 	test(readBuf == writeBuf);
       
  1843 	TestRFile1.Close();
       
  1844 	
       
  1845 	test.Next(_L("Replace the file named ReNameFileLargeOne.txt using RFs::Replace()\n"));
       
  1846 	TFileName fileNameReplace;
       
  1847 	fileNameReplace.Append(gDriveToTest);
       
  1848 	fileNameReplace.Append(KTestPath);
       
  1849 	fileNameReplace.Append(_L("ReNameFileLargeOne.txt\n"));
       
  1850 	TestRFs.Replace(fileName,fileNameReplace);
       
  1851 	
       
  1852 	test.Next(_L("Open the file ReNameFileLargeOne.txt\n"));
       
  1853 	TestRFile1.Open(fileNameReplace,EFileWrite);
       
  1854 	
       
  1855 	test.Next(_L("Set the file size to 4GB-1\n"));
       
  1856 	TestRFile1.SetSize(K4GB-1);
       
  1857 	size = 0;
       
  1858 	TestRFile1.Size(size);
       
  1859 	test (size == K4GB-1);
       
  1860 	
       
  1861 	test.Next(_L("Write 10 bytes to the location 3GB+10\n"));
       
  1862 	pos = K3GB+10;
       
  1863 	TestRFile1.Write(pos,_L8("ABCDEFGHIJ"),10);
       
  1864 	
       
  1865 	test.Next(_L("Read the above file from the location 3GB+10 and compare\n"));
       
  1866 	TBuf8<10> readBuffer;	
       
  1867 	TestRFile1.Read(pos,readBuffer,10);
       
  1868 	test(readBuffer == _L8("ABCDEFGHIJ"));
       
  1869 	
       
  1870 	test.Next(_L("Close the file and delete\n"));
       
  1871 	TestRFile1.Close();
       
  1872 	TInt r = TheFs.Delete(fileNameReplace);
       
  1873 	test(r == KErrNone);
       
  1874 	}
       
  1875 
       
  1876 /**
       
  1877 @SYMTestCaseID      PBASE-T_FILE64BIT-0766
       
  1878 @SYMTestPriority    High
       
  1879 @SYMTestRequirement REQXXXX
       
  1880 @SYMTestType        CIT
       
  1881 @SYMTestCaseDesc    Test the file creation using RFile64::AdoptFromClient()
       
  1882 @SYMTestActions 
       
  1883 1) Connect to the File server 
       
  1884 2) Create a file and set the file size to 4GB-1
       
  1885 3) Write few bytes to the location 4GB-10, length = 9bytes
       
  1886 4) Transfer the file handle using TransferToServer() close the file
       
  1887 5) Adopt the already open file from a client using RFile64::Adopt::AdoptFromClient()
       
  1888 6) Read the file from position 4GB-10 and compare the data
       
  1889 @SYMTestExpectedResults
       
  1890 1) Connection successful
       
  1891 2) File created successfully
       
  1892 3) Write successful with KErrNone
       
  1893 4) KErrNone, Transfer to server is successful
       
  1894 5) successfully Allows the server to adopt an already open file from a client process
       
  1895 6) File read should be successful and Read Data = Test Data
       
  1896 @SYMTestStatus      Implemented
       
  1897 */
       
  1898 void TestRFile64AdoptFromClient()
       
  1899 	{
       
  1900 	test.Next(_L("Tests for checking RFile64::AdoptFromClient()"));
       
  1901 
       
  1902 	RProcess p;
       
  1903 	TInt r = p.Create(_L("FHServer64Bit.exe"), KNullDesC);
       
  1904 	test(r == KErrNone);
       
  1905 	
       
  1906 	
       
  1907 	test.Next(_L("Connect to the File server \n"));
       
  1908 	RFs fs;
       
  1909 	r = fs.Connect();
       
  1910 	test(r == KErrNone);
       
  1911 
       
  1912 	// Check the number of open file handles
       
  1913 	TInt resCount = fs.ResourceCount();
       
  1914 	test(resCount == 0);
       
  1915 
       
  1916 	r = fs.ShareProtected();
       
  1917 	test(r == KErrNone);
       
  1918 
       
  1919 	r = fs.CreatePrivatePath(gDrive);
       
  1920 	test(r == KErrNone);
       
  1921 	r = fs.SetSessionToPrivate(gDrive);
       
  1922 	
       
  1923 	test.Next(_L("Create a file and set the file size to 4GB-1\n"));
       
  1924 	RFile64 file1;
       
  1925 	r = file1.Replace(fs,KClientFileName,EFileWrite);
       
  1926 	test(r == KErrNone);
       
  1927 	r = file1.SetSize(K4GB-1);
       
  1928 	test(r == KErrNone);
       
  1929 	
       
  1930 	test.Next(_L("Write few bytes to the location 4GB-10, length = 9bytes\n"));
       
  1931 	r = file1.Write(K4GB-10,KTestData3(),9);
       
  1932 	test(r == KErrNone);
       
  1933 	file1.Close();
       
  1934 
       
  1935 	r = p.SetParameter(3, gDrive);
       
  1936 	test(r == KErrNone);
       
  1937 	
       
  1938 	p.Resume();
       
  1939 	
       
  1940 	
       
  1941 	test.Next(_L("Transfer the file handle using TransferToServer() close the file\n"));
       
  1942 	RFileHandleSharer64Bit handsvr;
       
  1943 	do
       
  1944 		{
       
  1945 		r = handsvr.Connect();
       
  1946 		}
       
  1947 	while(r == KErrNotFound);
       
  1948 	test(r == KErrNone);
       
  1949 
       
  1950 	r = handsvr.SetTestDrive(gDrive);
       
  1951 	test(r == KErrNone);
       
  1952 
       
  1953 	r = fs.SetSessionToPrivate(gDrive);
       
  1954 	test(r == KErrNone);
       
  1955 
       
  1956 	r = file1.Open(fs,KClientFileName,EFileRead);
       
  1957 	test(r == KErrNone);
       
  1958 	
       
  1959 	// pass the file handle to FHServer
       
  1960 	test.Next(_L("RFile::TransferToServer()"));
       
  1961 
       
  1962 	TIpcArgs ipcArgs;
       
  1963 	r = file1.TransferToServer(ipcArgs, 0, 1);
       
  1964 	test(r == KErrNone);
       
  1965 	
       
  1966 	test.Next(_L("Adopt the already open file from a client using RFile64::AdoptFromClient()\n"));
       
  1967 	r = handsvr.PassFileHandleProcessLargeFileClient(ipcArgs);
       
  1968 	test(r == KErrNone);
       
  1969 
       
  1970 	// verify that the original file handle's position is unchanged
       
  1971 	TInt64 pos = 0;
       
  1972 	r = file1.Seek(ESeekCurrent, pos);
       
  1973 	test(r == KErrNone);
       
  1974 	test(pos == 0);
       
  1975 	// make sure we can still use it
       
  1976 
       
  1977 	test.Next(_L("Read the file from position 4GB-10 and compare the data\n"));
       
  1978 	TBuf8<9> rbuf;
       
  1979 	r = file1.Read(K4GB-10,rbuf);
       
  1980 	test(r == KErrNone);
       
  1981 	test (rbuf == KTestData3);
       
  1982 
       
  1983 	// Close the file
       
  1984 	file1.Close();	
       
  1985 	handsvr.Exit();
       
  1986 	handsvr.Close();
       
  1987 	r = fs.MkDir(_L("C:\\mdir"));
       
  1988 	test(r == KErrNone || r == KErrAlreadyExists);
       
  1989 		
       
  1990 	// Check the number of open file handles
       
  1991 	resCount = fs.ResourceCount();
       
  1992 	test(resCount == 0);
       
  1993 
       
  1994 	r = fs.Delete(KClientFileName);
       
  1995 	test(r == KErrNone);
       
  1996 	fs.Close();
       
  1997 	}
       
  1998 
       
  1999 /**
       
  2000 @SYMTestCaseID      PBASE-T_FILE64BIT-0767
       
  2001 @SYMTestPriority    High
       
  2002 @SYMTestRequirement REQXXXX
       
  2003 @SYMTestType        CIT
       
  2004 @SYMTestCaseDesc    Test the file creation using RFile64::AdoptFromCreator()
       
  2005 @SYMTestActions 
       
  2006 1) Create a process named "FHServer64Bit.exe"
       
  2007 2) Connect to the File server 
       
  2008 3) Create a file and set the file size to 4GB-1
       
  2009 4) Write few bytes to the location 4GB-10, length = 3 bytes
       
  2010 5) Transfer the file handle using TransferToProcess() close the file
       
  2011 6) Resume the process "FHServer64bit.exe" 
       
  2012 7) Adopts the already open file from a client using RFile64::AdoptFromCreator()
       
  2013 8) Read the file from position 4GB-10 and compare the data
       
  2014 @SYMTestExpectedResults
       
  2015 1) Process is created successfully with KErrnone
       
  2016 2) Connection successful
       
  2017 3) File created successfully
       
  2018 4) Write successful with KErrNone
       
  2019 5) KErrNone, Transfer to other process is successful
       
  2020 6) Server process should be resumed
       
  2021 7) successfully Allows the server to adopt an already open file from a client process
       
  2022 8) File read should be successful and Read Data = Test Data
       
  2023 @SYMTestStatus      Implemented
       
  2024 */
       
  2025 
       
  2026 void TestRFile64AdoptFromCreator()
       
  2027 	{
       
  2028 	TInt r;
       
  2029 	test.Next(_L("Tests for checking RFile64::AdoptFromCreator()"));
       
  2030 	//create test server
       
  2031 	test.Next(_L("Create a process named FHServer64Bit.exe\n"));
       
  2032 	RProcess p;
       
  2033 	r = p.Create(_L("FHServer64Bit.exe"), KNullDesC);
       
  2034 	test(r == KErrNone);
       
  2035 		
       
  2036 	test.Next(_L("Connect to the file server\n"));
       
  2037 	RFs fs;
       
  2038 	r = fs.Connect();
       
  2039 	test(r == KErrNone);
       
  2040 
       
  2041 	// Check the number of open file handles
       
  2042 	TInt resCount = fs.ResourceCount();
       
  2043 	test(resCount == 0);
       
  2044 
       
  2045 	r = fs.ShareProtected();
       
  2046 	test(r == KErrNone);
       
  2047 
       
  2048 	r = fs.CreatePrivatePath(gDrive);
       
  2049 	test(r == KErrNone);
       
  2050 	r = fs.SetSessionToPrivate(gDrive);
       
  2051 	
       
  2052 	test.Next(_L("Create a file and set the file size to 4GB-1\n"));
       
  2053 	RFile64 file1;
       
  2054 	r = file1.Replace(fs,KClientFileName,EFileWrite);
       
  2055 	test(r == KErrNone);
       
  2056 	r = file1.SetSize(K4GB-1);
       
  2057 	test(r == KErrNone);
       
  2058 	
       
  2059 	test.Next(_L("Write few bytes to the location 4GB-10, length = 3bytes\n"));
       
  2060 	r = file1.Write(K4GB-10,KTestData2(),3);
       
  2061 	test(r == KErrNone);
       
  2062 	file1.Close();
       
  2063 
       
  2064 	r = file1.Open(fs, KClientFileName, EFileWrite);
       
  2065 
       
  2066 	test(r == KErrNone);
       
  2067 	
       
  2068 	// NB slot 0 is reserved for the command line
       
  2069 
       
  2070 	test.Next(_L("Transfer the file handle using TransferToProcess() close the file"));
       
  2071 
       
  2072 	r = file1.TransferToProcess(p, 1, 2);
       
  2073 
       
  2074 	r = p.SetParameter(3, gDrive);
       
  2075 	test(r == KErrNone);
       
  2076 
       
  2077 	r = fs.SetSessionToPrivate(gDrive);
       
  2078 	test(r == KErrNone);
       
  2079 
       
  2080 	// make sure we can still read from the file
       
  2081 	TBuf8<3> rbuf;
       
  2082 	r = file1.Read(K4GB-10,rbuf,3);
       
  2083 	test(r == KErrNone);
       
  2084 	r = rbuf.CompareF(KTestData2());
       
  2085 	test(r == KErrNone);
       
  2086 	file1.Close();
       
  2087 
       
  2088 	r = fs.MkDir(_L("C:\\mdir"));
       
  2089 	test(r == KErrNone || r == KErrAlreadyExists);
       
  2090 	
       
  2091 	// Check the number of open file handles - 
       
  2092 	// should be 1 (the one duplicated for the other process)
       
  2093 	resCount = fs.ResourceCount();
       
  2094 	test(resCount == 1);
       
  2095 
       
  2096 	fs.Close();
       
  2097 
       
  2098 	test.Next(_L("Resume the process FHServer64bit.exe "));
       
  2099 // Start the server thread
       
  2100 	p.Resume();
       
  2101 
       
  2102 // connect to the server
       
  2103 	RFileHandleSharer64Bit handsvr;
       
  2104 	do
       
  2105 		{
       
  2106 		r = handsvr.Connect();
       
  2107 		}
       
  2108 	while(r == KErrNotFound);
       
  2109 	test(r == KErrNone);
       
  2110 	r = handsvr.SetTestDrive(gDrive);
       
  2111 	test(r == KErrNone);
       
  2112 
       
  2113 	// wait for server to read the file
       
  2114 	r = handsvr.PassFileHandleProcessLargeFileCreator();
       
  2115 	test (r == KErrNone);
       
  2116 	
       
  2117 	
       
  2118 	// cleanup	
       
  2119 	handsvr.Exit();
       
  2120 	handsvr.Close();
       
  2121 	p.Close();
       
  2122 	}
       
  2123 
       
  2124 /**
       
  2125 @SYMTestCaseID      PBASE-T_FILE64BIT-0768
       
  2126 @SYMTestPriority    High
       
  2127 @SYMTestRequirement REQXXXX
       
  2128 @SYMTestType        CIT
       
  2129 @SYMTestCaseDesc    Test the file creation using RFile64::AdoptFromServer()
       
  2130 @SYMTestActions 
       
  2131 1) Connect to the File server 
       
  2132 2) Create a file and set the file size to 4GB-1
       
  2133 3) Write few bytes to the location 4GB-10, length = 9bytes
       
  2134 4) Adopt an already open file from a server using RFile64::AdoptFromServer()
       
  2135 5) Read the file from position 4GB-10 and compare the data
       
  2136 @SYMTestExpectedResults
       
  2137 1) Connection successful
       
  2138 2) File created successfully
       
  2139 3) Write successful with KErrNone
       
  2140 4) successfully Allows the client to adopt an already open file from a server process
       
  2141 5) File read should be successful and Read Data = Test Data
       
  2142 @SYMTestStatus      Implemented
       
  2143 */
       
  2144 
       
  2145 void TestRFile64AdoptFromServer()
       
  2146 	{
       
  2147 	
       
  2148 	test.Next(_L("Tests for checking RFile64::AdoptFromServer()"));
       
  2149 	TInt r;
       
  2150 	
       
  2151 	test.Next(_L("Connect to the file server\n"));
       
  2152 	RFs fs;
       
  2153 	r = fs.Connect();
       
  2154 	test(r == KErrNone);
       
  2155 
       
  2156 	// Check the number of open file handles
       
  2157 	TInt resCount = fs.ResourceCount();
       
  2158 	test(resCount == 0);
       
  2159 
       
  2160 	r = fs.ShareProtected();
       
  2161 	test(r == KErrNone);
       
  2162 
       
  2163 	r = fs.CreatePrivatePath(gDrive);
       
  2164 	test(r == KErrNone);
       
  2165 	r = fs.SetSessionToPrivate(gDrive);
       
  2166 	
       
  2167 	test.Next(_L("Create a file and set the file size to 4GB-1\n"));
       
  2168 	RFile64 file1;
       
  2169 	r = file1.Replace(fs,KClientFileName,EFileWrite);
       
  2170 	test(r == KErrNone);
       
  2171 	r = file1.SetSize(K4GB-1);
       
  2172 	test(r == KErrNone);
       
  2173 	
       
  2174 	
       
  2175 	r = file1.Write(K4GB-10,KTestData3(),9);
       
  2176 	test(r == KErrNone);
       
  2177 		
       
  2178 	file1.Close();
       
  2179 	r = fs.Delete(KClientFileName);
       
  2180 	test(r == KErrNone);
       
  2181 	
       
  2182 	RProcess p;
       
  2183 	r = p.Create(_L("FHServer64Bit.exe"), KNullDesC);
       
  2184 	test(r == KErrNone);
       
  2185 	// Request an open file (write mode) from the server
       
  2186 	// using RFile64::AdoptFromServer()
       
  2187 	
       
  2188 	test.Next(_L("Adopt an already open file from a server using RFile64::AdoptFromServer()\n"));
       
  2189 	p.Resume();
       
  2190 	RFileHandleSharer64Bit handsvr;
       
  2191 	do
       
  2192 		{
       
  2193 		r = handsvr.Connect();
       
  2194 		}
       
  2195 	while(r == KErrNotFound);
       
  2196 	test(r == KErrNone);
       
  2197 
       
  2198 	r = handsvr.SetTestDrive(gDrive);
       
  2199 	test(r == KErrNone);
       
  2200 
       
  2201 	TInt ssh;
       
  2202 	TInt fsh = handsvr.GetFileHandleLargeFile2(ssh, EFileWrite);
       
  2203 	test (fsh >= 0);
       
  2204 
       
  2205 	// Closing the handle to the server ensures the server has closed it's
       
  2206 	// RFs and RFile handles - this provides a means of testing whether we 
       
  2207 	// can still adopt the RFile even if the server has closed it's one.
       
  2208 
       
  2209 	handsvr.Sync(); // make sure server has finished doing what it's doing
       
  2210 	handsvr.Exit();
       
  2211 	handsvr.Close();
       
  2212 
       
  2213 	// adopt the file handle from FHServer
       
  2214 	test.Next(_L("RFile64::AdoptFromServer()"));
       
  2215 
       
  2216 	RFile64 file;
       
  2217 	r = file.AdoptFromServer(fsh, ssh);
       
  2218 	test(r == KErrNone);
       
  2219 
       
  2220 	test.Next(_L("Read the file from position 4GB-10 and compare the data\n"));
       
  2221 	TBuf8<9> rbuf;
       
  2222 	r = file.Read(K4GB-10,rbuf);
       
  2223 	test(r == KErrNone);
       
  2224 	// server should write KTestData1 ("Server!!!") to file
       
  2225 	test (rbuf == KTestData4);
       
  2226 
       
  2227 	TFileName fileName;
       
  2228 	r = file.FullName(fileName);
       
  2229 	test(r == KErrNone);
       
  2230 	
       
  2231 	file.Close();
       
  2232 	//cleanup
       
  2233 	r = fs.Delete(fileName);
       
  2234 	test(r == KErrNone);
       
  2235 		
       
  2236 	TFileName sessionPath;
       
  2237 	r = fs.SessionPath(sessionPath);
       
  2238 	test(r == KErrNone);
       
  2239 	
       
  2240 	r = fs.RmDir(sessionPath);
       
  2241 	test(r == KErrNone);
       
  2242 	
       
  2243 	fs.Close();
       
  2244 	
       
  2245 	}
       
  2246 
       
  2247 	
       
  2248 /**
       
  2249 @SYMTestCaseID      PBASE-T_FILE64BIT-0769
       
  2250 @SYMTestPriority    High
       
  2251 @SYMTestRequirement REQ9526 
       
  2252 @SYMTestType        CIT
       
  2253 @SYMTestCaseDesc    Tests for reading a big file synchronously with specified position
       
  2254 @SYMTestActions     
       
  2255 1) Big file is read synchronously in a thread, with aPos = 0;
       
  2256 2) Big file is read synchronously in a thread, with aPos = 2GB-1;
       
  2257 3) Big file is read synchronously in a thread. With aPos = 4GB -2. File size= 4GB-1.
       
  2258 4) Check for FAT32 file system, Read from a big file synchronously in a thread with aPos = 4GB.
       
  2259 @SYMTestExpectedResults 
       
  2260 1) KErrNone, file is read successfully
       
  2261 2) KErrNone, file is read successfully
       
  2262 3) KErrNone, file is read successfully
       
  2263 4) KErrNone and zero length descriptor, if NGFS is supported we should get the valid data
       
  2264 @SYMTestStatus      Implemented
       
  2265 */
       
  2266 void TestOpenAndReadSyncLargeFile()
       
  2267 	{
       
  2268 	const TUint KBufSize = KKB;
       
  2269 	TUint 			pos;
       
  2270 	TBuf8<KBufSize> readBuf1;
       
  2271 	TBuf8<KBufSize> readBuf2;
       
  2272 	TUint i;
       
  2273 	TInt r = GenerateBigFileContents();
       
  2274 	test(r == KErrNone);
       
  2275 	
       
  2276 	test.Next(_L("Open & Read Synchronously Large File From Diff Offset:"));
       
  2277 
       
  2278 	TFileName fileName;
       
  2279 	fileName.Append(gDriveToTest);
       
  2280 	fileName.Append(KTestPath);
       
  2281 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  2282 	TestRFile1.Open(fileName,EFileRead);
       
  2283 
       
  2284 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 0\n"));
       
  2285 	// Sync read from pos = 0
       
  2286 	pos = 0; 
       
  2287 	readBuf1.Zero();
       
  2288 	TestRFile1.ReadP(pos, readBuf1);
       
  2289 	
       
  2290 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2291 	for(i = pos; i< pos + (KBufSize / 4); i+=4)
       
  2292 		{
       
  2293 		TUint j =  * ((TUint*) &readBuf1[i - pos]);
       
  2294 		test(i == j);
       
  2295 		}
       
  2296 		
       
  2297 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 2GB-1\n"));
       
  2298 	// Sync read from pos = 2GB-1
       
  2299 	pos = K2GB;
       
  2300 	readBuf2.Zero();
       
  2301 	TestRFile1.ReadP(pos, readBuf2);
       
  2302 
       
  2303 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2304 	for(i = pos; i< pos + (KBufSize / 4); i+=4)
       
  2305 		{
       
  2306 		TUint j =  * ((TUint*) &readBuf2[i - pos]);
       
  2307 		test(i == j);
       
  2308 		}
       
  2309 	
       
  2310 	
       
  2311 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 4GB-2\n"));	
       
  2312 	TBuf8<1> readBuffer;
       
  2313 	pos = K4GBMinusTwo;
       
  2314 	TestRFile1.ReadP(pos, readBuffer);
       
  2315 	test(readBuffer.Length() == 1);
       
  2316 
       
  2317 	// tests need to be repeated for calling the TUint variant of RFile64::Read()
       
  2318 	pos = 0;
       
  2319 	TestRFile1.ReadU(pos, readBuf1);
       
  2320 	
       
  2321 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2322 	for(i = pos; i< pos + (KBufSize / 4); i+=4)
       
  2323 		{
       
  2324 		TUint j =  * ((TUint*) &readBuf1[i - pos]);
       
  2325 		test(i == j);
       
  2326 		}
       
  2327 		
       
  2328 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 2GB\n"));
       
  2329 	// Sync read from pos = 2GB
       
  2330 	pos = K2GB;
       
  2331 	readBuf2.Zero();
       
  2332 	TestRFile1.ReadU(pos, readBuf2);
       
  2333 
       
  2334 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2335 	for(i = pos; i< pos + (KBufSize / 4); i+=4)
       
  2336 		{
       
  2337 		TUint j =  * ((TUint*) &readBuf2[i - pos]);
       
  2338 		test(i == j);
       
  2339 		}
       
  2340 	
       
  2341 	
       
  2342 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 4GB-2\n"));	
       
  2343 	pos = K4GBMinusTwo;
       
  2344 	TestRFile1.ReadU(pos, readBuffer);
       
  2345 	test(readBuffer.Length() == 1);
       
  2346 
       
  2347 	// tests need to be repeated for calling the current position variant of RFile64::Read()
       
  2348 	TInt64 seekPos = 0;
       
  2349 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2350 	TestRFile1.Read(readBuf1);
       
  2351 	
       
  2352 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2353 	for(i = (TUint)seekPos; i< seekPos + (KBufSize / 4); i+=4)
       
  2354 		{
       
  2355 		TUint j =  * ((TUint*) &readBuf1[i - (TUint)seekPos]);
       
  2356 		test(i == j);
       
  2357 		}
       
  2358 		
       
  2359 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 2GB\n"));
       
  2360 	// Sync read from pos = 2GB
       
  2361 	seekPos = K2GB;
       
  2362 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2363 	readBuf2.Zero();
       
  2364 	TestRFile1.Read(readBuf2);
       
  2365 
       
  2366 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2367 	for(i = (TUint)seekPos; i< seekPos + (KBufSize / 4); i+=4)
       
  2368 		{
       
  2369 		TUint j =  * ((TUint*) &readBuf2[i - (TUint)seekPos]);
       
  2370 		test(i == j);
       
  2371 		}
       
  2372 	
       
  2373 	
       
  2374 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 4GB-2\n"));	
       
  2375 	seekPos = K4GBMinusTwo;
       
  2376 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2377 	TestRFile1.Read(readBuffer);
       
  2378 	test(readBuffer.Length() == 1);
       
  2379 
       
  2380 	
       
  2381 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)	
       
  2382 		{
       
  2383 		TInt64 pos64 = K4GB;
       
  2384 		TestRFile1.ReadP(pos64, readBuf1);
       
  2385 		test(readBuf1.Length() == 0);
       
  2386 		}
       
  2387 	TestRFile1.Close();
       
  2388 	}
       
  2389 
       
  2390 /**
       
  2391 @SYMTestCaseID      PBASE-T_FILE64BIT-0770
       
  2392 @SYMTestPriority    High
       
  2393 @SYMTestRequirement REQ9526 
       
  2394 @SYMTestType        CIT
       
  2395 @SYMTestCaseDesc    Tests for reading a big file asynchronously with specified position
       
  2396 @SYMTestActions     
       
  2397 1) Big file is read asynchronously in a thread, with aPos = 0;
       
  2398 2) Big file is read asynchronously in a thread, with aPos = 2GB-1;
       
  2399 3) Big file is read asynchronously in a thread. With aPos = 4GB -1.
       
  2400 4) Check for FAT32 file system, Read from a big file asynchronously in a thread with aPos = 4GB.
       
  2401 @SYMTestExpectedResults 
       
  2402 1) KErrNone, file is read successfully
       
  2403 2) KErrNone, file is read successfully
       
  2404 3) KErrNone, file is read successfully
       
  2405 4) KErrNone and zero length descriptor. If NGFS is supported we should get the valid data.
       
  2406 @SYMTestStatus      Implemented
       
  2407 */
       
  2408 void TestOpenAndReadAsyncLargeFile()
       
  2409 	{
       
  2410 	const TUint KBufSize = KKB;
       
  2411 	TInt64  fileSize, size = 0;
       
  2412 	TUint pos;
       
  2413 	TUint i;
       
  2414 	TBuf8<KBufSize> readBuf;
       
  2415 	readBuf.SetLength(KBufSize);
       
  2416 
       
  2417 
       
  2418 	test.Next(_L("Open & Read Asynchronously Large File From Diff Offset:"));
       
  2419 	
       
  2420 	TFileName fileName;
       
  2421 	fileName.Append(gDriveToTest);
       
  2422 	fileName.Append(KTestPath);
       
  2423 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  2424 	TestRFile1.Open(fileName,EFileRead);
       
  2425 	
       
  2426 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 0\n"));
       
  2427 	// Async read from pos = 0
       
  2428 	TRequestStatus status1 = KRequestPending;
       
  2429 	pos = 0;
       
  2430 	TestRFile1.Read(pos, readBuf, status1);
       
  2431 
       
  2432 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2433 	for(i = pos; i< pos + (KBufSize / 4); i+=4)
       
  2434 		{
       
  2435 		TUint j =  * ((TUint*) &readBuf[i - pos]);
       
  2436 		test(i == j);
       
  2437 		}	
       
  2438 	
       
  2439 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 2GB-1\n"));
       
  2440 	// Async read from pos = 2GB-1
       
  2441 	TRequestStatus status2 = KRequestPending;
       
  2442 	pos = K2GB;
       
  2443 	TestRFile1.Read(pos, readBuf, status2);
       
  2444 	
       
  2445 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2446 	for(i = pos; i< pos + (KBufSize / 4); i+=4)
       
  2447 		{
       
  2448 		TUint j =  * ((TUint*) &readBuf[i - pos]);
       
  2449 		test(i == j);
       
  2450 		}
       
  2451 	
       
  2452 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 4GB-1\n"));
       
  2453 	TBuf8<0x1> readBuf1;
       
  2454 	// Async read from pos = 4GB-1
       
  2455 	TRequestStatus status3 = KRequestPending;
       
  2456 	pos = K4GBMinusTwo;
       
  2457 	TestRFile1.Read(pos, readBuf1, status3);
       
  2458 	test(readBuf1.Length() == 1);
       
  2459 			
       
  2460 	fileSize = K4GBMinusOne;
       
  2461 	TestRFile1.Size(size);
       
  2462 	test(size == fileSize);
       
  2463 	
       
  2464 	//tests need to be repeated for calling the TUint variant of RFile64::Read()
       
  2465 	pos = 0;
       
  2466 	TestRFile1.ReadU(pos, readBuf, status1);
       
  2467 
       
  2468 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2469 	for(i = pos; i< pos + (KBufSize / 4); i+=4)
       
  2470 		{
       
  2471 		TUint j =  * ((TUint*) &readBuf[i - pos]);
       
  2472 		test(i == j);
       
  2473 		}	
       
  2474 	
       
  2475 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 2GB-1\n"));
       
  2476 	// Async read from pos = 2GB-1
       
  2477 	status2 = KRequestPending;
       
  2478 	pos = K2GB;
       
  2479 	TestRFile1.ReadU(pos, readBuf, status2);
       
  2480 	
       
  2481 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2482 	for(i = pos; i< pos + (KBufSize / 4); i+=4)
       
  2483 		{
       
  2484 		TUint j =  * ((TUint*) &readBuf[i - pos]);
       
  2485 		test(i == j);
       
  2486 		}
       
  2487 	
       
  2488 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 4GB-1\n"));
       
  2489 	// Async read from pos = 4GB-1
       
  2490 	status3 = KRequestPending;
       
  2491 	pos = K4GBMinusTwo;
       
  2492 	TestRFile1.ReadU(pos, readBuf1, status3);
       
  2493 	test(readBuf1.Length() == 1);
       
  2494 	
       
  2495 	// tests need to be repeated for calling the current position variant of RFile64::Read()
       
  2496 	TInt64 seekPos = 0;
       
  2497 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2498 	TestRFile1.Read(readBuf, status1);
       
  2499 
       
  2500 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2501 	for(i = (TUint)seekPos; i< seekPos + (KBufSize / 4); i+=4)
       
  2502 		{
       
  2503 		TUint j =  * ((TUint*) &readBuf[i - (TUint)seekPos]);
       
  2504 		test(i == j);
       
  2505 		}	
       
  2506 	
       
  2507 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 2GB-1\n"));
       
  2508 	// Async read from pos = 2GB-1
       
  2509 	status2 = KRequestPending;
       
  2510 	seekPos = K2GB;
       
  2511 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2512 	TestRFile1.Read(readBuf, status2);
       
  2513 	
       
  2514 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2515 	for(i = (TUint)seekPos; i< seekPos + (KBufSize / 4); i+=4)
       
  2516 		{
       
  2517 		TUint j =  * ((TUint*) &readBuf[i - (TUint)seekPos]);
       
  2518 		test(i == j);
       
  2519 		}
       
  2520 	
       
  2521 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 4GB-1\n"));
       
  2522 	// Async read from pos = 4GB-1
       
  2523 	status3 = KRequestPending;
       
  2524 	seekPos = K4GBMinusTwo;
       
  2525 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2526 	TestRFile1.Read(readBuf1, status3);
       
  2527 	test(readBuf1.Length() == 1);
       
  2528 	
       
  2529 
       
  2530 	// Async read from pos = 4GB
       
  2531 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
  2532 		{
       
  2533 		TRequestStatus status5 = KRequestPending;
       
  2534 		TInt64 pos64;
       
  2535 		pos64 = K4GB;
       
  2536 		TestRFile1.Read(pos64, readBuf, status5);
       
  2537 		test(readBuf.Length() == 0);
       
  2538 		}
       
  2539 	// Close the file	
       
  2540 	TestRFile1.Close();
       
  2541 	}		
       
  2542 	
       
  2543 /**
       
  2544 @SYMTestCaseID      PBASE-T_FILE64BIT-0771
       
  2545 @SYMTestPriority    High
       
  2546 @SYMTestRequirement REQ9526 
       
  2547 @SYMTestType        CIT
       
  2548 @SYMTestCaseDesc    Tests for reading a big file synchronously with specified position and length
       
  2549 @SYMTestActions     
       
  2550 1) Big file is read synchronously in a thread, with aPos = 0 and length = 256bytes
       
  2551 2) Big file is read synchronously in a thread, with aPos = 2GB-1 and length = 2KB
       
  2552 3) Big file is read synchronously in a thread, with aPos = 4GB -1 and length = 10 bytes
       
  2553 4) Check for FAT32 file system. Read from a big file, synchronously in a thread with aPos = 4GB and length = 1KB
       
  2554 5) Big file is read synchronously in a thread, with aPos = 0 and length = -1
       
  2555 6) Big file is read synchronously in a thread, with aPos = 0 and length = 0 bytes
       
  2556 @SYMTestExpectedResults 
       
  2557 1) KErrNone, file is read successfully
       
  2558 2) KErrNone, file is read successfully
       
  2559 3) KErrNone, file is read successfully
       
  2560 4) KErrNone, with zero length descriptor. If NGFS is supported we should get the valid data
       
  2561 5) KErrArgument
       
  2562 6) KErrNone
       
  2563 @SYMTestStatus      Implemented
       
  2564 */
       
  2565 
       
  2566 void TestOpenAndReadSyncLargeFileWithLen()
       
  2567 	{
       
  2568 	TInt64 pos;
       
  2569 	TUint i;
       
  2570 	TBuf8<KMAXBUFSIZE> readBuf;
       
  2571 	readBuf.SetLength(KMAXBUFSIZE);
       
  2572 
       
  2573 	test.Next(_L("Open & Read Synchronously Large File From Different Offset and Length:"));
       
  2574 
       
  2575 	TFileName fileName;
       
  2576 	fileName.Append(gDriveToTest);
       
  2577 	fileName.Append(KTestPath);
       
  2578 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  2579 	TestRFile1.Open(fileName,EFileRead);
       
  2580 	
       
  2581 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 0 and length = 256bytes:"));
       
  2582 	// Sync read from pos = 0 and length = 256
       
  2583 	pos = 0;
       
  2584 	TestRFile1.Read(pos, readBuf, 256);
       
  2585 	test(readBuf.Length() == 256);
       
  2586 	
       
  2587 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2588 	for(i = (TUint)pos; i< pos + (256 / 4); i+=4)
       
  2589 		{
       
  2590 		TUint j =  * ((TUint*) &readBuf[i - (TUint)pos]);
       
  2591 		test(i == j);
       
  2592 		}
       
  2593 	
       
  2594 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 2GB and length = K2KB:"));
       
  2595 	// Sync read from pos = 2GB and length = K2KB
       
  2596 	pos = K2GB;
       
  2597 	TestRFile1.Read(pos, readBuf, K2KB);
       
  2598 	test(readBuf.Length() == K2KB);
       
  2599 	
       
  2600 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2601 	for(i = (TUint)pos; i< pos + (K2KB / 4); i+=4)
       
  2602 		{
       
  2603 		TUint j =  * ((TUint*) &readBuf[i - (TUint)pos]);
       
  2604 		test(i == j);
       
  2605 		}
       
  2606 	
       
  2607 	
       
  2608 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 4GB -1 and length = 10:"));
       
  2609 	// Sync read from pos = 4GB-1 and length = 10
       
  2610 	pos = K4GBMinusTwo;
       
  2611 	TestRFile1.Read(pos, readBuf, 10);
       
  2612 	test(readBuf.Length() == 1); 
       
  2613 		
       
  2614 
       
  2615 	// Sync read from pos = 4GB and length = KKB
       
  2616 
       
  2617 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)	
       
  2618 		{
       
  2619 		pos = K4GB;
       
  2620 		TestRFile1.Read(pos, readBuf, KKB);
       
  2621 		test(readBuf.Length() == 0);
       
  2622 		}
       
  2623 		
       
  2624 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 0 and length = -1"));
       
  2625 	// Sync read from pos = 0 and length = -1	
       
  2626 	pos = 0;
       
  2627 	TestRFile1.Read(pos, readBuf, -1);
       
  2628 
       
  2629 	//tests need to repeated for TUint variant of RFile64::Read()
       
  2630 
       
  2631 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 0 and length = 256bytes:"));
       
  2632 	// Sync read from pos = 0 and length = 256
       
  2633 	pos = 0;
       
  2634 	TestRFile1.ReadU((TUint)pos, readBuf, 256);
       
  2635 	test(readBuf.Length() == 256);
       
  2636 	
       
  2637 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2638 	for(i = (TUint)pos; i< pos + (256 / 4); i+=4)
       
  2639 		{
       
  2640 		TUint j =  * ((TUint*) &readBuf[i - (TUint)pos]);
       
  2641 		test(i == j);
       
  2642 		}
       
  2643 	
       
  2644 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 2GB and length = K2KB:"));
       
  2645 	// Sync read from pos = 2GB and length = K2KB
       
  2646 	pos = K2GB;
       
  2647 	TestRFile1.ReadU((TUint)pos, readBuf, K2KB);
       
  2648 	test(readBuf.Length() == K2KB);
       
  2649 	
       
  2650 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2651 	for(i = (TUint)pos; i< pos + (K2KB / 4); i+=4)
       
  2652 		{
       
  2653 		TUint j =  * ((TUint*) &readBuf[i - (TUint)pos]);
       
  2654 		test(i == j);
       
  2655 		}
       
  2656 	
       
  2657 	
       
  2658 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 4GB -1 and length = 10:"));
       
  2659 	// Sync read from pos = 4GB-1 and length = 10
       
  2660 	pos = K4GBMinusTwo;
       
  2661 	TestRFile1.ReadU((TUint)pos, readBuf, 10);
       
  2662 	test(readBuf.Length() == 1); 
       
  2663 		
       
  2664 	//tests need to repeated for current position variant of RFile64::Read()
       
  2665 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 0 and length = 256bytes:"));
       
  2666 	// Sync read from pos = 0 and length = 256
       
  2667 	TInt64 seekPos = 0;
       
  2668 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2669 	TestRFile1.Read(readBuf, 256);
       
  2670 	test(readBuf.Length() == 256);
       
  2671 	
       
  2672 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2673 	for(i = (TUint)seekPos; i< seekPos + (256 / 4); i+=4)
       
  2674 		{
       
  2675 		TUint j =  * ((TUint*) &readBuf[i - (TUint)seekPos]);
       
  2676 		test(i == j);
       
  2677 		}
       
  2678 	
       
  2679 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 2GB and length = K2KB:"));
       
  2680 	// Sync read from pos = 2GB and length = K2KB
       
  2681 	seekPos = K2GB;
       
  2682 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2683 	TestRFile1.Read(readBuf, K2KB);
       
  2684 	test(readBuf.Length() == K2KB);
       
  2685 	
       
  2686 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2687 	for(i = (TUint)seekPos; i< seekPos + (K2KB / 4); i+=4)
       
  2688 		{
       
  2689 		TUint j =  * ((TUint*) &readBuf[i - (TUint)seekPos]);
       
  2690 		test(i == j);
       
  2691 		}
       
  2692 	
       
  2693 	
       
  2694 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 4GB -1 and length = 10:"));
       
  2695 	// Sync read from pos = 4GB-1 and length = 10
       
  2696 	seekPos = K4GBMinusTwo;
       
  2697 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2698 	TestRFile1.Read(readBuf, 10);
       
  2699 	test(readBuf.Length() == 1); 
       
  2700 	
       
  2701 
       
  2702 	// Sync read from pos = 4GB and length = KKB
       
  2703 
       
  2704 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)	
       
  2705 		{
       
  2706 		pos = K4GB;
       
  2707 		TestRFile1.Read(pos, readBuf, KKB);
       
  2708 		test(readBuf.Length() == 0);
       
  2709 		}
       
  2710 		
       
  2711 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 0 and length = -1"));
       
  2712 	// Sync read from pos = 0 and length = -1	
       
  2713 	pos = 0;
       
  2714 	TestRFile1.Read(pos, readBuf, -1);
       
  2715 
       
  2716 	
       
  2717 
       
  2718 	test.Next(_L("Big file is read synchronously in a thread, with aPos = 0 and length = 0 bytes"));
       
  2719 	// Sync read from pos = 0 and length = 0
       
  2720 	pos = 0;
       
  2721 	TestRFile1.Read(pos, readBuf, 0);
       
  2722 	test(readBuf.Length() == 0);
       
  2723 
       
  2724 	TestRFile1.Close();
       
  2725 	}
       
  2726 /**
       
  2727 @SYMTestCaseID      PBASE-T_FILE64BIT-0772
       
  2728 @SYMTestPriority    High
       
  2729 @SYMTestRequirement REQ9526 
       
  2730 @SYMTestType        CIT
       
  2731 @SYMTestCaseDesc    Tests for reading a big file asynchronously with specified position and length
       
  2732 @SYMTestActions     
       
  2733 1) Big file is read asynchronously in a thread, with aPos = 0 and length = 256 bytes
       
  2734 2) Big file is read asynchronously in a thread, with aPos = 2GB-1 and length = 1KB
       
  2735 3) Big file is read asynchronously in a thread, with aPos = 4GB-1 and length = 1KB
       
  2736 4) Big file is read asynchronously in a thread, with aPos = 4GB and length = 256 bytes
       
  2737 5) Big file is read asynchronously in a thread, with aPos = 0 and length = -1
       
  2738 6) Big file is read asynchronously in a thread, with aPos = 0 and length = 0 bytes
       
  2739 @SYMTestExpectedResults 
       
  2740 1) KErrNone, file is read successfully
       
  2741 2) KErrNone, file is read successfully
       
  2742 3) KErrNone, file is read successfully
       
  2743 4) KErrNone, with zero length descriptor. If NGFS is supported KErrNone with valid data
       
  2744 5) KErrArgument
       
  2745 6) KErrNone
       
  2746 @SYMTestStatus      Implemented
       
  2747 */
       
  2748 void TestOpenAndReadAsyncLargeFileWithLen()
       
  2749 	{
       
  2750 	TInt64 pos;
       
  2751 	TUint i ;
       
  2752 	TBuf8<KMAXBUFSIZE> readBuf;
       
  2753 	readBuf.SetLength(KMAXBUFSIZE);
       
  2754 
       
  2755 	test.Next(_L("Open & Read Asynchronously Large File From Different Offset & Length:"));
       
  2756 
       
  2757 	TFileName fileName;
       
  2758 	fileName.Append(gDriveToTest);
       
  2759 	fileName.Append(KTestPath);
       
  2760 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  2761 	TestRFile1.Open(fileName,EFileRead);
       
  2762 
       
  2763 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 0 and length = 256 bytes\n"));
       
  2764 	// Async read from pos = 0 and length = 256
       
  2765 	TRequestStatus status1 = KRequestPending;
       
  2766 	pos = 0;
       
  2767 	TestRFile1.Read(pos, readBuf, 256, status1);
       
  2768 	test(readBuf.Length() == 256);
       
  2769 	
       
  2770 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2771 	for(i = (TUint)pos; i< pos + (256 / 4); i+=4)
       
  2772 		{
       
  2773 		TUint j =  * ((TUint*) &readBuf[i - (TUint)pos]);
       
  2774 		test(i == j);
       
  2775 		}
       
  2776 		
       
  2777 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 2GB and length = KKB bytes\n"));	
       
  2778 	// Async read from pos = 2GB and length = KKb
       
  2779 	TRequestStatus status2 = KRequestPending;
       
  2780 	pos = K2GB;
       
  2781 	TestRFile1.Read(pos, readBuf, KKB, status2);
       
  2782 	test(readBuf.Length() == KKB);
       
  2783 	
       
  2784 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2785 	for(i = (TUint)pos; i< pos + (KKB / 4); i+=4)
       
  2786 		{
       
  2787 		TUint j =  * ((TUint*) &readBuf[i - (TUint)pos]);
       
  2788 		test(i == j);
       
  2789 		}
       
  2790 	
       
  2791 	
       
  2792 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 4GB-1 and length = KKb bytes\n"));	
       
  2793 	// Async read from pos = 4GB-1 and length = KKb
       
  2794 	TRequestStatus status3 = KRequestPending;
       
  2795 	pos = K4GBMinusTwo;
       
  2796 	TestRFile1.Read(pos, readBuf, KKB, status3);
       
  2797 	test(readBuf.Length() == 1); 
       
  2798 		
       
  2799 	// tests need to be repeated for TUint variant of RFile64::Read()
       
  2800 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 0 and length = 256 bytes\n"));
       
  2801 	// Async read from pos = 0 and length = 256
       
  2802 	status1 = KRequestPending;
       
  2803 	pos = 0;
       
  2804 	TestRFile1.ReadU((TUint)pos, readBuf, 256, status1);
       
  2805 	test(readBuf.Length() == 256);
       
  2806 	
       
  2807 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2808 	for(i = (TUint)pos; i< pos + (256 / 4); i+=4)
       
  2809 		{
       
  2810 		TUint j =  * ((TUint*) &readBuf[i - (TUint)pos]);
       
  2811 		test(i == j);
       
  2812 		}
       
  2813 		
       
  2814 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 2GB and length = KKB bytes\n"));	
       
  2815 	// Async read from pos = 2GB and length = KKb
       
  2816 	status2 = KRequestPending;
       
  2817 	pos = K2GB;
       
  2818 	TestRFile1.ReadU((TUint)pos, readBuf, KKB, status2);
       
  2819 	test(readBuf.Length() == KKB);
       
  2820 	
       
  2821 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2822 	for(i = (TUint)pos; i< pos + (KKB / 4); i+=4)
       
  2823 		{
       
  2824 		TUint j =  * ((TUint*) &readBuf[i - (TUint)pos]);
       
  2825 		test(i == j);
       
  2826 		}
       
  2827 	
       
  2828 	
       
  2829 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 4GB-1 and length = KKb bytes\n"));	
       
  2830 	// Async read from pos = 4GB-1 and length = KKb
       
  2831 	status3 = KRequestPending;
       
  2832 	pos = K4GBMinusTwo;
       
  2833 	TestRFile1.ReadU((TUint)pos, readBuf, KKB, status3);
       
  2834 	test(readBuf.Length() == 1); 
       
  2835 		
       
  2836 	// tests need to be repeated for current position variant of RFile64::Read()
       
  2837 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 0 and length = 256 bytes\n"));
       
  2838 	// Async read from pos = 0 and length = 256
       
  2839 	status1 = KRequestPending;
       
  2840 	TInt64 seekPos = 0;
       
  2841 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2842 	TestRFile1.Read(readBuf, 256, status1);
       
  2843 	test(readBuf.Length() == 256);
       
  2844 	
       
  2845 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2846 	for(i = (TUint)seekPos; i< seekPos + (256 / 4); i+=4)
       
  2847 		{
       
  2848 		TUint j =  * ((TUint*) &readBuf[i - (TUint)seekPos]);
       
  2849 		test(i == j);
       
  2850 		}
       
  2851 		
       
  2852 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 2GB and length = KKB bytes\n"));	
       
  2853 	// Async read from pos = 2GB and length = KKb
       
  2854 	status2 = KRequestPending;
       
  2855 	seekPos = K2GB;
       
  2856 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2857 	TestRFile1.Read(readBuf, KKB, status2);
       
  2858 	test(readBuf.Length() == KKB);
       
  2859 	
       
  2860 	test.Next(_L("Compare the data read to the expected data\n"));
       
  2861 	for(i = (TUint)seekPos; i< seekPos + (KKB / 4); i+=4)
       
  2862 		{
       
  2863 		TUint j =  * ((TUint*) &readBuf[i - (TUint)seekPos]);
       
  2864 		test(i == j);
       
  2865 		}
       
  2866 	
       
  2867 	
       
  2868 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 4GB-1 and length = KKb bytes\n"));	
       
  2869 	// Async read from pos = 4GB-1 and length = KKb
       
  2870 	status3 = KRequestPending;
       
  2871 	seekPos = K4GBMinusTwo;
       
  2872 	TestRFile1.Seek(ESeekStart,seekPos);
       
  2873 	TestRFile1.Read(readBuf, KKB, status3);
       
  2874 	test(readBuf.Length() == 1); 
       
  2875 	
       
  2876 		
       
  2877 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 4GB and length = 256 bytes\n"));	
       
  2878 	// Async read from pos = 4GB and length = 256
       
  2879 	
       
  2880 	
       
  2881 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
  2882 		{
       
  2883 		TRequestStatus status5 = KRequestPending;
       
  2884 		pos = K4GB;
       
  2885 		TestRFile1.Read(pos, readBuf, 256, status5);
       
  2886 		test(readBuf.Length() == 0);
       
  2887 		}
       
  2888 	
       
  2889 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 0 and length = -1 bytes\n"));	
       
  2890 	// Async read from pos = 0 and length = -1	
       
  2891 	TRequestStatus status6 = KRequestPending;
       
  2892 	pos = 0;
       
  2893 	TestRFile1.Read(pos, readBuf, -1, status6);
       
  2894 
       
  2895 	test.Next(_L("Big file is read asynchronously in a thread, with aPos = 0 and length = 0 bytes\n"));	
       
  2896 	// Async read from pos = 0 and length = 0
       
  2897 	TRequestStatus status7 = KRequestPending;
       
  2898 	pos = 0;
       
  2899 	TestRFile1.Read(pos, readBuf, 0, status7);
       
  2900 
       
  2901 	TestRFile1.Close();
       
  2902 	
       
  2903 	TInt r = TheFs.Delete(fileName);
       
  2904 	test(r == KErrNone);
       
  2905 	}	
       
  2906 
       
  2907 /**
       
  2908 @SYMTestCaseID      PBASE-T_FILE64BIT-0773
       
  2909 @SYMTestPriority    High
       
  2910 @SYMTestRequirement REQ9526 
       
  2911 @SYMTestType        CIT
       
  2912 @SYMTestCaseDesc    Tests for writing to a big file synchronously with specified position
       
  2913 @SYMTestActions     
       
  2914 1) Write to a big file synchronously in a thread, with aPos = 0 and data = 256 bytes, File size = 4GB-1
       
  2915 2) Write to a big file synchronously in a thread, with aPos = 2GB-1 and data = 1KB
       
  2916 3) Write to a big file synchronously in a thread, with aPos = 4GB-1 and data = 1 byte
       
  2917 4) Write a big file synchronously in a thread, with aPos = 4GB and data = 256 bytes
       
  2918 @SYMTestExpectedResults 
       
  2919 1) KErrNone, write is successful
       
  2920 2) KErrNone, write is successful
       
  2921 3) KErrNone, write is successful
       
  2922 4) KErrNotSupported, if NGFS is supported KErrNone and write is successful
       
  2923 @SYMTestStatus      Implemented
       
  2924 */
       
  2925 
       
  2926 void TestOpenAndWriteSyncLargeFile()
       
  2927 	{
       
  2928 	test.Next(_L("Open & Write Synchronously Large File From Different Offset:"));
       
  2929 
       
  2930 	TInt count;
       
  2931 	TFileName fileName;
       
  2932 	fileName.Append(gDriveToTest);
       
  2933 	fileName.Append(KTestPath);
       
  2934 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  2935 	TestRFile1.Replace(fileName, EFileWrite);
       
  2936 	TestRFile1.SetSize(K4GBMinusOne);
       
  2937 	
       
  2938 	TInt64 size;
       
  2939 	TestRFile1.Size(size);
       
  2940 	test(size == K4GBMinusOne);
       
  2941 	
       
  2942 	
       
  2943 	test.Next(_L("Write to a big file synchronously in a thread, with aPos = 0 and data = 256 bytes, File size = 4GB-1\n"));
       
  2944 	TBuf8<0x100> writeBuf100;
       
  2945 	TBuf8<0x100> readBuf100;
       
  2946 	writeBuf100.Zero();
       
  2947 	writeBuf100.FillZ();
       
  2948 	for (count = 0; count < 0x100; count++)
       
  2949 		{
       
  2950 		writeBuf100.Append((TChar)count);
       
  2951 		}
       
  2952 	TestRFile1.WriteP(0,writeBuf100);
       
  2953 	TestRFile1.Size(size);
       
  2954 	TestRFile1.ReadP(0,readBuf100);
       
  2955 	test(writeBuf100 == readBuf100);
       
  2956 	
       
  2957 	test.Next(_L("Write to a big file synchronously in a thread, with aPos = 2GB-1 and data = 1KB\n"));
       
  2958 	TBuf8<0x400> writeBuf400;
       
  2959 	TBuf8<0x400> readBuf400;
       
  2960 	writeBuf400.Zero();
       
  2961 	writeBuf400.FillZ();	
       
  2962 	for (count = 0; count < 0x400; count++)
       
  2963 		{
       
  2964 		writeBuf400.Append(count+20);
       
  2965 		}
       
  2966 	TestRFile1.WriteP(K2GBMinusOne,writeBuf400);
       
  2967 	TestRFile1.ReadP(K2GBMinusOne,readBuf400); // just for validation
       
  2968 	test(writeBuf400 == readBuf400);
       
  2969 
       
  2970 	test.Next(_L("Write to a big file synchronously in a thread, with aPos = 4GB-1 and data = 1 byte\n"));
       
  2971 	TBuf8<1> testReadBuf;
       
  2972 	TestRFile1.WriteP(K4GBMinusTwo,_L8("1"));
       
  2973 	TestRFile1.ReadP(K4GBMinusTwo, testReadBuf); 
       
  2974 	test(testReadBuf.Length() == 1);
       
  2975 	
       
  2976 	//tests need to be repeated for TUint variant of RFile64::Write()
       
  2977 	readBuf100.Zero(); //to ensure that the previous data is removed
       
  2978 	test.Next(_L("Write to a big file synchronously in a thread, with aPos = 0 and data = 256 bytes, File size = 4GB-1\n"));
       
  2979 	TUint pos = 0;
       
  2980 	TestRFile1.WriteU(pos,writeBuf100);
       
  2981 	TestRFile1.ReadU(pos,readBuf100);
       
  2982 	test(writeBuf100 == readBuf100);
       
  2983 	
       
  2984 	test.Next(_L("Write to a big file synchronously in a thread, with aPos = 2GB-1 and data = 1KB\n"));
       
  2985 	readBuf400.Zero();//to ensure that the previous data is removed
       
  2986 	pos = K2GBMinusOne;
       
  2987 	TestRFile1.WriteU(pos,writeBuf400);
       
  2988 	TestRFile1.ReadU(pos,readBuf400); // just for validation
       
  2989 	test(writeBuf400 == readBuf400);
       
  2990 
       
  2991 
       
  2992 	test.Next(_L("Write to a big file synchronously in a thread, with aPos = 4GB-1 and data = 1 byte\n"));
       
  2993 	pos = K4GBMinusTwo;
       
  2994 	testReadBuf.Zero();//to ensure that the previous data is removed
       
  2995 	TestRFile1.WriteU(pos,_L8("1"));
       
  2996 	TestRFile1.ReadU(pos, testReadBuf); 
       
  2997 	test(testReadBuf.Length() == 1);
       
  2998 	
       
  2999 	//
       
  3000 	//tests need to be repeated for current position variant of RFile64::Write()
       
  3001 	//testing with only current position as 4GB-2(boundary condition)
       
  3002 	//
       
  3003 	test.Next(_L("Write to a big file synchronously in a thread, with aPos = 4GB-1 and data = 1 byte\n"));
       
  3004 	TInt64 seekPos = K4GBMinusTwo;
       
  3005 	testReadBuf.Zero();//to ensure that the previous data is removed
       
  3006 	TestRFile1.Seek(ESeekStart,seekPos);
       
  3007 	TestRFile1.Write(_L8("1"));
       
  3008 	TestRFile1.Seek(ESeekStart,seekPos);
       
  3009 	TestRFile1.Read(testReadBuf); 
       
  3010 	test(testReadBuf.Length() == 1);
       
  3011 	
       
  3012 	
       
  3013 	
       
  3014 	test.Next(_L("Write a big file synchronously in a thread, with aPos = 4GB and data = 256 bytes\n"));
       
  3015 	
       
  3016 	
       
  3017 	TBuf8<0x100> writeBuffer256;
       
  3018 	TBuf8<0x100> readBuffer256;
       
  3019 	writeBuffer256.Zero();
       
  3020 	writeBuffer256.FillZ();
       
  3021 	readBuffer256.Zero();
       
  3022 	readBuffer256.FillZ();	
       
  3023 	
       
  3024 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)	
       
  3025 		{	
       
  3026 		for (TInt count = 0; count < 256; count++)
       
  3027 			{
       
  3028 			writeBuffer256.Append((TChar)count);
       
  3029 			}
       
  3030 		TestRFile1.WriteP(K4GB,writeBuffer256); 
       
  3031 		User::After(100000);
       
  3032 		// Validation for boundary condition 4GB
       
  3033 		TestRFile1.ReadP(K4GB,readBuffer256);
       
  3034 		TInt rr = readBuffer256.Length();
       
  3035 		test(rr == KErrNone);
       
  3036 		test(readBuffer256.Length() == 0);
       
  3037 		}
       
  3038 	TestRFile1.Close();
       
  3039 	
       
  3040 	TInt r = TheFs.Delete(fileName);
       
  3041 	test(r == KErrNone);
       
  3042 	}
       
  3043 
       
  3044 /**
       
  3045 @SYMTestCaseID      PBASE-T_FILE64BIT-0774
       
  3046 @SYMTestPriority    High
       
  3047 @SYMTestRequirement REQ9526 
       
  3048 @SYMTestType        CIT
       
  3049 @SYMTestCaseDesc    Tests for writing to a big file asynchronously with specified position
       
  3050 @SYMTestActions     
       
  3051 1) Write to a big file asynchronously in a thread, with aPos = 0 and data = 256 bytes, File size = 4GB-1
       
  3052 2) Write to a big file asynchronously in a thread, with aPos = 2GB-1 and data = 1KB
       
  3053 3) Write to a big file asynchronously in a thread, with aPos = 4GB-1 and data = 1 byte
       
  3054 4) Check for FAT32 file system. Write to a big file asynchronously in a thread with aPos =  4GB and data length = 256 bytes
       
  3055 @SYMTestExpectedResults 
       
  3056 1) KErrNone, write is successful
       
  3057 2) KErrNone, write is successful
       
  3058 3) KErrNone, write is successful
       
  3059 4) KErrNotSupported, if NGFS is available KErrNone and write is successful.
       
  3060 @SYMTestStatus      Implemented
       
  3061 */
       
  3062 
       
  3063 void TestOpenAndWriteAsyncLargeFile()
       
  3064 	{
       
  3065 	test.Next(_L("Open & Write Asynchronously Large File From Different Offset:"));
       
  3066 
       
  3067 	TInt count;
       
  3068 	TFileName fileName;
       
  3069 	fileName.Append(gDriveToTest);
       
  3070 	fileName.Append(KTestPath);
       
  3071 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  3072 	TestRFile1.Replace(fileName, EFileWrite);
       
  3073 
       
  3074 	TestRFile1.SetSize(K4GBMinusOne);
       
  3075 	TInt64 size;
       
  3076 	TestRFile1.Size(size);
       
  3077 
       
  3078 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 0 and data = 256 bytes, File size = 4GB-1\n"));
       
  3079 	TBuf8<0x100> writeBuf100;
       
  3080 	TBuf8<0x100> readBuf100;
       
  3081 	writeBuf100.Zero();
       
  3082 	writeBuf100.FillZ();
       
  3083 	for (count = 0; count < 0x100; count++)
       
  3084 		{
       
  3085 		writeBuf100.Append((TChar)count);
       
  3086 		}
       
  3087 	TRequestStatus status1 = KRequestPending;
       
  3088 	TestRFile1.Write(0,writeBuf100,status1);
       
  3089 	TestRFile1.ReadP(0,readBuf100);
       
  3090 	test (writeBuf100 == readBuf100);
       
  3091 
       
  3092 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 2GB-1 and data = 1KB\n"));
       
  3093 	TBuf8<0x400> writeBuf400;
       
  3094 	TBuf8<0x400> readBuf400;
       
  3095 	writeBuf400.Zero();
       
  3096 	writeBuf400.FillZ();	
       
  3097 	for (count = 0; count < 0x400; count++)
       
  3098 		{
       
  3099 		writeBuf400.Append(count+20);
       
  3100 		}
       
  3101 	TRequestStatus status2 = KRequestPending;
       
  3102 	TestRFile1.Write(K2GBMinusOne,writeBuf400,status2);
       
  3103 	TestRFile1.ReadP(K2GBMinusOne,readBuf400); // just for validation
       
  3104 	test(writeBuf400 == readBuf400);
       
  3105 
       
  3106 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 4GB-1 and data = 1 byte\n"));
       
  3107 	TBuf8<0x1> writeBuf;
       
  3108 	TBuf8<0x1> readBuf;
       
  3109 	writeBuf.Zero();
       
  3110 	writeBuf.FillZ();
       
  3111 	for (count = 0; count < 0x1; count++)
       
  3112 		{
       
  3113 		writeBuf.Append((TChar)(count+17));
       
  3114 		}
       
  3115 	TRequestStatus status3 = KRequestPending;	
       
  3116 	TestRFile1.Write(K4GBMinusTwo,writeBuf,status3); 
       
  3117 	TestRFile1.ReadP(K4GBMinusTwo,readBuf);
       
  3118 	test(readBuf.Length() == 1);
       
  3119 	
       
  3120 	//tests need to be repeated for TUint variant of RFile64::Write()
       
  3121 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 0 and data = 256 bytes, File size = 4GB-1\n"));
       
  3122 	readBuf100.Zero();//to ensure that the previous data is removed
       
  3123 	status1 = KRequestPending;
       
  3124 	TUint pos = 0;
       
  3125 	TestRFile1.WriteU(pos,writeBuf100,status1);
       
  3126 	TestRFile1.ReadU(pos,readBuf100);
       
  3127 	test (writeBuf100 == readBuf100);
       
  3128 
       
  3129 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 2GB-1 and data = 1KB\n"));
       
  3130 	readBuf400.Zero();//to ensure that the previous data is removed
       
  3131 	status2 = KRequestPending;
       
  3132 	pos = K2GBMinusOne;
       
  3133 	TestRFile1.WriteU(pos,writeBuf400,status2);
       
  3134 	TestRFile1.ReadU(pos,readBuf400); // just for validation
       
  3135 	test(writeBuf400 == readBuf400);
       
  3136 
       
  3137 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 4GB-1 and data = 1 byte\n"));
       
  3138 	readBuf.Zero();//to ensure that the previous data is removed
       
  3139 	status3 = KRequestPending;	
       
  3140 	pos = K4GBMinusTwo;
       
  3141 	TestRFile1.WriteU(pos,writeBuf,status3); 
       
  3142 	TestRFile1.ReadU(pos,readBuf);
       
  3143 	test(readBuf.Length() == 1);
       
  3144 	
       
  3145 	//
       
  3146 	//tests need to be repeated for current position variant of RFile64::Write()
       
  3147 	//testing with only current position as 4GB-2(boundary condition)
       
  3148 	//
       
  3149 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 4GB-1 and data = 1 byte\n"));
       
  3150 	readBuf.Zero();//to ensure that the previous data is removed
       
  3151 	status3 = KRequestPending;	
       
  3152 	TInt64 seekPos = K4GBMinusTwo;
       
  3153 	TestRFile1.Seek(ESeekStart,seekPos);
       
  3154 	TestRFile1.Write(writeBuf,status3); 
       
  3155 	TestRFile1.Seek(ESeekStart,seekPos);
       
  3156 	TestRFile1.Read(readBuf);
       
  3157 	test(readBuf.Length() == 1);
       
  3158 	
       
  3159 	
       
  3160 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
  3161 		{	
       
  3162 		TBuf8<0x100> writeBuf256;
       
  3163 		TBuf8<0x100> readBuf256;
       
  3164 		writeBuf256.Zero();
       
  3165 		writeBuf256.FillZ();
       
  3166 		for (TInt count = 0; count < 0x100; count++)
       
  3167 			{
       
  3168 			writeBuf256.Append((TChar)(count+7));
       
  3169 			}
       
  3170 		TRequestStatus status4 = KRequestPending;
       
  3171 		TestRFile1.Write(K4GB,writeBuf256,status4); 
       
  3172 		User::After(100000);
       
  3173 		// Validation for boundary condition 4GB
       
  3174 		TestRFile1.ReadP(K4GB,readBuf256);
       
  3175 		test(readBuf256.Length() == 0);
       
  3176 		}
       
  3177 	TestRFile1.Close();
       
  3178 	
       
  3179 	TInt r = TheFs.Delete(fileName);
       
  3180 	test(r == KErrNone);
       
  3181 	}
       
  3182 
       
  3183 /**
       
  3184 @SYMTestCaseID      PBASE-T_FILE64BIT-0775
       
  3185 @SYMTestPriority    High
       
  3186 @SYMTestRequirement REQ9526 
       
  3187 @SYMTestType        CIT
       
  3188 @SYMTestCaseDesc    Tests for writing to a big file synchronously with specified position and length
       
  3189 @SYMTestActions     
       
  3190 1) Write to a big file synchronously in a thread with aPos = 0, data = 256 bytes and length = 255 bytes
       
  3191 2) Write to a big file synchronously in a thread with aPos = 2GB -1, data = 1KB and length = 200 bytes
       
  3192 3) Write to a big file synchronously in a thread with aPos = 4GB-10 and data = 1KB and length = 10 bytes
       
  3193 4) Check for FAT32 file system. Write to a big file synchronously in a thread with aPos = 4GB, data length = 256 bytes and length = 10 bytes
       
  3194 5) Write to a big file synchronously in a thread with aPos = 0 ,  data = 256 bytes and length =0 bytes
       
  3195 6) Write to a big file synchronously in a thread with aPos = 0 ,  data = 256 bytes and length = -1
       
  3196 @SYMTestExpectedResults 
       
  3197 1) KErrNone, write is successful
       
  3198 2) KErrNone, write is successful
       
  3199 3) KErrNone, write is successful
       
  3200 4) KErrNotSupported. If NGFS is supported and write is successful 
       
  3201 5) KErrNone
       
  3202 6) KErrArgument
       
  3203 @SYMTestStatus      Implemented
       
  3204 */
       
  3205 
       
  3206 void TestOpenAndWriteSyncLargeFileWithLen()
       
  3207 	{
       
  3208 	test.Next(_L("Open & Write Synchronously Large File From Different Offset and length:"));
       
  3209 
       
  3210 	TInt count;
       
  3211 	TFileName fileName;
       
  3212 	fileName.Append(gDriveToTest);
       
  3213 	fileName.Append(KTestPath);
       
  3214 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  3215 	TestRFile1.Replace(fileName, EFileWrite);
       
  3216 	
       
  3217 	TestRFile1.SetSize(K4GBMinusOne);
       
  3218 	
       
  3219 	test.Next(_L("Write to a big file synchronously in a thread with aPos = 0, data = 256 bytes and length = 255 bytes\n"));	
       
  3220 	TBuf8<0x100> writeBuf100;
       
  3221 	TBuf8<0x100> readBuf100;
       
  3222 	TBuf8<0x100> validateBuf100;
       
  3223 	writeBuf100.Zero();
       
  3224 	writeBuf100.FillZ();
       
  3225 	validateBuf100.Zero();
       
  3226 	for (count = 0; count < 0x100; count++)
       
  3227 		{
       
  3228 		writeBuf100.Append((TChar)count);
       
  3229 		if(count < 0xFF)
       
  3230 			validateBuf100.Append((TChar)count);
       
  3231 		}
       
  3232 	TestRFile1.Write(0,writeBuf100,255);
       
  3233 	TestRFile1.Read(0,readBuf100,255);
       
  3234 	test(validateBuf100 == readBuf100);
       
  3235 	
       
  3236 	test.Next(_L("Write to a big file synchronously in a thread with aPos = 2GB -1, data = 1KB and length = 200 bytes\n"));	
       
  3237 	TBuf8<0x400> writeBuf400;
       
  3238 	TBuf8<0x400> readBuf400;
       
  3239 	TBuf8<0x400> validateBuf400;
       
  3240 	writeBuf400.Zero();
       
  3241 	writeBuf400.FillZ();	
       
  3242 	for (count = 0; count < 0x400; count++)
       
  3243 		{
       
  3244 		writeBuf400.Append(count+20);
       
  3245 		if(count<200)
       
  3246 			validateBuf400.Append(count+20);
       
  3247 		}
       
  3248 	TestRFile1.Write(K2GBMinusOne,writeBuf400,200);
       
  3249 	TestRFile1.Read(K2GBMinusOne,readBuf400,200); 
       
  3250 	test(validateBuf400 == readBuf400);
       
  3251 	
       
  3252 	test.Next(_L("Write to a big file synchronously in a thread with aPos = 4GB-10 and data = 1KB and length = 10 bytes\n"));	
       
  3253 	TBuf8<0x400> writeBuf1024;
       
  3254 	TBuf8<0x400> readBuf1024;
       
  3255 	TBuf8<0x400> validateBuf1024;
       
  3256 	writeBuf1024.Zero();
       
  3257 	writeBuf1024.FillZ();	
       
  3258 	for (count = 0; count < 0x400; count++)
       
  3259 		{
       
  3260 		writeBuf1024.Append(count+3);
       
  3261 		if(count < 9)
       
  3262 			validateBuf1024.Append(count+3);
       
  3263 		}
       
  3264 	TestRFile1.Write(K4GBMinusTen,writeBuf1024,9);
       
  3265 	TestRFile1.Read(K4GBMinusTen,readBuf1024,9); 
       
  3266 	test(validateBuf1024 == readBuf1024);
       
  3267 	
       
  3268 	//tests need to be repeated for TUint variant of RFile64::Write()
       
  3269 	test.Next(_L("Write to a big file synchronously in a thread with aPos = 0, data = 256 bytes and length = 255 bytes\n"));	
       
  3270 	readBuf100.Zero();//to ensure that the previous data is removed
       
  3271 	TUint pos = 0;
       
  3272 	TestRFile1.WriteU(pos,writeBuf100,255);
       
  3273 	TestRFile1.ReadU(pos,readBuf100,255);
       
  3274 	test(validateBuf100 == readBuf100);
       
  3275 	
       
  3276 	test.Next(_L("Write to a big file synchronously in a thread with aPos = 2GB -1, data = 1KB and length = 200 bytes\n"));	
       
  3277 	readBuf400.Zero();//to ensure that the previous data is removed
       
  3278 	pos = K2GBMinusOne;
       
  3279 	TestRFile1.WriteU(pos,writeBuf400,200);
       
  3280 	TestRFile1.ReadU(pos,readBuf400,200); 
       
  3281 	test(validateBuf400 == readBuf400);
       
  3282 	
       
  3283 	test.Next(_L("Write to a big file synchronously in a thread with aPos = 4GB-10 and data = 1KB and length = 10 bytes\n"));	
       
  3284 	readBuf1024.Zero();//to ensure that the previous data is removed
       
  3285 	pos = K4GBMinusTen;
       
  3286 	TestRFile1.WriteU(pos,writeBuf1024,9);
       
  3287 	TestRFile1.ReadU(pos,readBuf1024,9); 
       
  3288 	test(validateBuf1024 == readBuf1024);
       
  3289 	
       
  3290 	//
       
  3291 	//tests need to be repeated for current position variant of RFile64::Write()
       
  3292 	//testing with only current position as 4GB-2(boundary condition)
       
  3293 	//
       
  3294 	test.Next(_L("Write to a big file synchronously in a thread with aPos = 4GB-10 and data = 1KB and length = 10 bytes\n"));	
       
  3295 	readBuf1024.Zero();//to ensure that the previous data is removed
       
  3296 	TInt64 seekPos = K4GBMinusTen;
       
  3297 	TestRFile1.Seek(ESeekStart,seekPos);
       
  3298 	TestRFile1.Write(writeBuf1024,9);
       
  3299 	TestRFile1.Seek(ESeekStart,seekPos);
       
  3300 	TestRFile1.Read(readBuf1024,9); 
       
  3301 	test(validateBuf1024 == readBuf1024);
       
  3302 	
       
  3303 	
       
  3304 		
       
  3305 	test.Next(_L("Check for FAT32 file system. Write to a big file synchronously in a thread with aPos = 4GB, data length = 256 bytes and length = 10 bytes\n"));	
       
  3306 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
  3307 		{	
       
  3308 		TBuf8<0x100> writeBuf256;
       
  3309 		TBuf8<0x100> readBuf256;
       
  3310 		writeBuf256.Zero();
       
  3311 		writeBuf256.FillZ();	
       
  3312 		for (TInt count = 0; count < 0x100; count++)
       
  3313 			{
       
  3314 			writeBuf256.Append(count+6);
       
  3315 			}
       
  3316 		TestRFile1.Write(K4GB,writeBuf256,10);
       
  3317 		TestRFile1.Read(K4GB,readBuf256,10); 
       
  3318 		test(readBuf256.Length() == 0);
       
  3319 		}
       
  3320 	test.Next(_L(" Write to a big file synchronously in a thread with aPos = 0 ,  data = 256 bytes and length =0 bytes\n"));	
       
  3321 	TBuf8<0x100> wrBuf256;
       
  3322 	TBuf8<0x100> reBuf256;
       
  3323 	wrBuf256.Zero();
       
  3324 	wrBuf256.FillZ();	
       
  3325 	for (count = 0; count < 0x100; count++)
       
  3326 		{
       
  3327 		wrBuf256.Append(count+6);
       
  3328 		}
       
  3329 	TestRFile1.Write(0,wrBuf256,0);
       
  3330 	TestRFile1.Read(0,reBuf256,0);
       
  3331 	test(reBuf256.Length() == 0);
       
  3332 
       
  3333 	test.Next(_L("Write to a big file synchronously in a thread with aPos = 0 ,  data = 256 bytes and length = -1\n"));	
       
  3334 	TBuf8<0x100> wBuf256;
       
  3335 	wBuf256.Zero();
       
  3336 	wBuf256.FillZ();	
       
  3337 	for (count = 0; count < 0x100; count++)
       
  3338 		{
       
  3339 		wBuf256.Append(count+3);
       
  3340 		}
       
  3341 	TestRFile1.Write(0,wrBuf256,-1);
       
  3342 	TestRFile1.Close();
       
  3343 	
       
  3344 	TInt r = TheFs.Delete(fileName);
       
  3345 	test(r == KErrNone);
       
  3346 	}
       
  3347 		
       
  3348 /**
       
  3349 @SYMTestCaseID      PBASE-T_FILE64BIT-0776
       
  3350 @SYMTestPriority    High
       
  3351 @SYMTestRequirement REQ9526
       
  3352 @SYMTestType        CIT
       
  3353 @SYMTestCaseDesc    Tests for writing to a big file asynchronously with specified position and length
       
  3354 @SYMTestActions     
       
  3355 1) Write to a big file asynchronously in a thread, with aPos = 0, data = 256 bytes and length = 255 bytes 
       
  3356 2) Write to a big file asynchronously in a thread, with aPos = 2GB-1, data = 1KB and length = 200 bytes
       
  3357 3) Write to a big file asynchronously in a thread, with aPos = 4GB-10, data = 10 bytes and length = 10 bytes
       
  3358 4) Check for FAT32 file system. Write to a big file asynchronously in a thread, with aPos = 4GB+1, data = 256 bytes and length = 10 bytes
       
  3359 5) Write to a big file asynchronously in a thread, with aPos = 0, data = 256 bytes and length = 0 bytes
       
  3360 6) Write to a big file asynchronously in a thread, with aPos = 0, data = 256 bytes and length = -1bytes 
       
  3361 @SYMTestExpectedResults 
       
  3362 1) KErrNone, write is successful
       
  3363 2) KErrNone, write is successful
       
  3364 3) KErrNone, write is successful
       
  3365 4) KErrNotSupported. If NGFS is supported KErrNone and write is successful
       
  3366 5) KErrNone
       
  3367 6) KErrArgument
       
  3368 @SYMTestStatus      Implemented
       
  3369 */
       
  3370 	
       
  3371 void TestOpenAndWriteAsyncLargeFileWithLen()
       
  3372 	{
       
  3373 	test.Next(_L("Open & Write Asynchronously Large File From Different Offset and length:"));
       
  3374 
       
  3375 	TInt count;
       
  3376 	TFileName fileName;
       
  3377 	fileName.Append(gDriveToTest);
       
  3378 	fileName.Append(KTestPath);
       
  3379 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  3380 	TestRFile1.Replace(fileName, EFileWrite);
       
  3381 	
       
  3382 	TestRFile1.SetSize(K4GBMinusOne);
       
  3383 	
       
  3384 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 0, data = 256 bytes and length = 255 bytes \n"));
       
  3385 	TBuf8<0x100> writeBuf100;
       
  3386 	TBuf8<0x100> readBuf100;
       
  3387 	TBuf8<0x100> validateBuf100;
       
  3388 	writeBuf100.Zero();
       
  3389 	writeBuf100.FillZ();
       
  3390 	validateBuf100.Zero();
       
  3391 	for (count = 0; count < 0x100; count++)
       
  3392 		{
       
  3393 		writeBuf100.Append((TChar)count);
       
  3394 		if(count < 0xFF)
       
  3395 			validateBuf100.Append((TChar)count);
       
  3396 		}
       
  3397 	TRequestStatus status1 = KRequestPending;
       
  3398 	TestRFile1.Write(0,writeBuf100,255,status1);
       
  3399 	TestRFile1.Read(0,readBuf100,255);
       
  3400 	test(validateBuf100 == readBuf100);
       
  3401 
       
  3402 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 2GB-1, data = 1KB and length = 200 bytes\n"));
       
  3403 	TBuf8<0x400> writeBuf400;
       
  3404 	TBuf8<0x400> readBuf400;
       
  3405 	TBuf8<0x400> validateBuf400;
       
  3406 	writeBuf400.Zero();
       
  3407 	writeBuf400.FillZ();
       
  3408 	validateBuf400.Zero();
       
  3409 	for (count = 0; count < 0x400; count++)
       
  3410 		{
       
  3411 		writeBuf400.Append(count+20);
       
  3412 		if(count < 200)
       
  3413 			validateBuf400.Append(count+20);
       
  3414 		}
       
  3415 	TRequestStatus status2 = KRequestPending;
       
  3416 	TestRFile1.Write(K2GBMinusOne,writeBuf400,200,status2);
       
  3417 	TestRFile1.Read(K2GBMinusOne,readBuf400,200); 
       
  3418 	test(validateBuf400 == readBuf400);
       
  3419 
       
  3420 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 4GB-10, data = 10 bytes and length = 10 bytes\n"));
       
  3421 	TBuf8<0x0A> writeBuf0A;
       
  3422 	TBuf8<0x0A> readBuf0A;
       
  3423 	TBuf8<0x0A> validateBuf0A;
       
  3424 	writeBuf0A.Zero();
       
  3425 	readBuf0A.FillZ();
       
  3426 	validateBuf0A.Zero();	
       
  3427 	for (count = 0; count < 0x0A; count++)
       
  3428 		{
       
  3429 		writeBuf0A.Append(count+3);
       
  3430 		if(count<9)
       
  3431 			validateBuf0A.Append(count+3);
       
  3432 		}
       
  3433 	TRequestStatus status3 = KRequestPending;
       
  3434 	TestRFile1.Write(K4GBMinusTen,writeBuf0A,9,status3);
       
  3435 	TestRFile1.Read(K4GBMinusTen,readBuf0A,9);
       
  3436 	test(validateBuf0A == readBuf0A); 
       
  3437 	
       
  3438 	//tests need to be repeated for TUint variant of RFile64::Write()
       
  3439 	
       
  3440 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 0, data = 256 bytes and length = 255 bytes \n"));
       
  3441 	readBuf100.Zero();//to ensure that the previous data is removed
       
  3442 	status1 = KRequestPending;
       
  3443 	TUint pos = 0;
       
  3444 	TestRFile1.WriteU(pos,writeBuf100,255,status1);
       
  3445 	TestRFile1.ReadU(pos,readBuf100,255);
       
  3446 	test(validateBuf100 == readBuf100);
       
  3447 
       
  3448 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 2GB-1, data = 1KB and length = 200 bytes\n"));
       
  3449 	readBuf400.Zero();//to ensure that the previous data is removed
       
  3450 	status2 = KRequestPending;
       
  3451 	pos = K2GBMinusOne;
       
  3452 	TestRFile1.Write(pos,writeBuf400,200,status2);
       
  3453 	TestRFile1.Read(pos,readBuf400,200); 
       
  3454 	test(validateBuf400 == readBuf400);
       
  3455 
       
  3456 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 4GB-10, data = 10 bytes and length = 10 bytes\n"));
       
  3457 	readBuf0A.Zero();//to ensure that the previous data is removed
       
  3458 	status3 = KRequestPending;
       
  3459 	pos = K4GBMinusTen;
       
  3460 	TestRFile1.Write(pos,writeBuf0A,9,status3);
       
  3461 	TestRFile1.Read(pos,readBuf0A,9);
       
  3462 	test(validateBuf0A == readBuf0A); 
       
  3463 	
       
  3464 	//
       
  3465 	//tests need to be repeated for current position variant of RFile64::Write()
       
  3466 	//testing with only current position as 4GB-2(boundary condition)
       
  3467 	//
       
  3468 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 4GB-10, data = 10 bytes and length = 10 bytes\n"));
       
  3469 	readBuf0A.Zero();//to ensure that the previous data is removed
       
  3470 	status3 = KRequestPending;
       
  3471 	TInt64 seekPos = K4GBMinusTen;
       
  3472 	TestRFile1.Seek(ESeekStart,seekPos);
       
  3473 	TestRFile1.Write(writeBuf0A,9,status3);
       
  3474 	TestRFile1.Seek(ESeekStart,seekPos);
       
  3475 	TestRFile1.Read(readBuf0A,9);
       
  3476 	test(validateBuf0A == readBuf0A); 
       
  3477 	
       
  3478 	
       
  3479 	
       
  3480 	test.Next(_L("Check for FAT32 file system. Write to a big file asynchronously in a thread, with aPos = 4GB+1, data = 256 bytes and length = 10 bytes\n"));
       
  3481 	
       
  3482 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
  3483 		{	
       
  3484 		TBuf8<0x100> writeBuf256;
       
  3485 		TBuf8<0x100> readBuf256;
       
  3486 		writeBuf256.Zero();
       
  3487 		writeBuf256.FillZ();	
       
  3488 		for (TInt count = 0; count < 0x100; count++)
       
  3489 			{
       
  3490 			writeBuf256.Append(count+6);
       
  3491 			}
       
  3492 		TRequestStatus status5 = KRequestPending;
       
  3493 		TestRFile1.Write(K4GBPlusOne,writeBuf256,10,status5);
       
  3494 		TestRFile1.Read(K4GBPlusOne,readBuf256,10); 
       
  3495 		test(readBuf256.Length() == 0);
       
  3496 		}
       
  3497 	
       
  3498 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 0, data = 256 bytes and length = 0 bytes\n"));	
       
  3499 	TBuf8<0x100> wrBuf256;
       
  3500 	TBuf8<0x100> reBuf256;
       
  3501 	wrBuf256.Zero();
       
  3502 	wrBuf256.FillZ();	
       
  3503 	for (count = 0; count < 0x100; count++)
       
  3504 		{
       
  3505 		wrBuf256.Append(count+6);
       
  3506 		}
       
  3507 	TRequestStatus status6 = KRequestPending;
       
  3508 	TestRFile1.Write(0,wrBuf256,0,status6);
       
  3509 	TestRFile1.Read(0,reBuf256,0); 
       
  3510 	test(reBuf256.Length() == 0);
       
  3511 
       
  3512 	test.Next(_L("Write to a big file asynchronously in a thread, with aPos = 0, data = 256 bytes and length = -1bytes \n"));	
       
  3513 	TBuf8<0x100> wBuf256;
       
  3514 	wBuf256.Zero();
       
  3515 	wBuf256.FillZ();	
       
  3516 	for (count = 0; count < 0x100; count++)
       
  3517 		{
       
  3518 		wBuf256.Append(count+3);
       
  3519 		}
       
  3520 	TRequestStatus status7 = KRequestPending;
       
  3521 	TestRFile1.Write(0,wrBuf256,-1,status7);
       
  3522 	TestRFile1.Close();
       
  3523 	
       
  3524 	TInt r = TheFs.Delete(fileName);
       
  3525 	test(r == KErrNone);
       
  3526 	}
       
  3527 			
       
  3528 /**
       
  3529 @SYMTestCaseID      PBASE-T_FILE64BIT-0777
       
  3530 @SYMTestPriority    High
       
  3531 @SYMTestRequirement REQ9526
       
  3532 @SYMTestType        CIT
       
  3533 @SYMTestCaseDesc    Tests for locking a large file using RFile64::Lock()
       
  3534 @SYMTestActions     
       
  3535 1) Lock a big file with aPos = 0, aLength = 2GB-1
       
  3536 2) Lock a big file with aPos = 0, aLength = 2GB-1 ( i.e. again Lock with same parameters). This is to test multiple locks to same region.
       
  3537 3) Extend the Lock with aPos = 0, aLength  = 2GB+10.This tests overlapped locks.
       
  3538 4) Extend the Lock with aPos = 2GB-100, aLength = 200. This also tests overlapped locks.
       
  3539 5) Lock with aPos = 100, aLength = 2GB-100.This tries to lock sub region of a Lock
       
  3540 6) Lock same file with aPos = 2GB-1 and aLength = 200. Lock same file with aPos = 2GB + 300 and aLength =200.
       
  3541 7) Lock a big file with aPos = 0, aLength = 4GB-1.Tests boundary condition.
       
  3542 8) Lock a file with aPos =4GB and aLength=10
       
  3543 @SYMTestExpectedResults
       
  3544 1) KErrNone, lock is successful
       
  3545 2) KErrLocked, lock is unsuccessful
       
  3546 3) KErrLocked, lock is unsuccessful
       
  3547 4) KErrLocked, lock is unsuccessful
       
  3548 5) KErrLocked, lock is unsuccessful
       
  3549 6) KErrNone, lock is successful 
       
  3550 7) KErrLocked, lock is successful
       
  3551 8) KErrNone
       
  3552 @SYMTestStatus      Implemented
       
  3553 */
       
  3554 	
       
  3555 void TestFileLock()
       
  3556 	{
       
  3557 	test.Next(_L("Tests for locking a big file:"));
       
  3558 
       
  3559 	TFileName fileName;
       
  3560 	fileName.Append(gDriveToTest);
       
  3561 	fileName.Append(KTestPath);
       
  3562 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  3563 	TestRFile1.Replace(fileName, EFileRead);
       
  3564 	
       
  3565 	test.Next(_L("Lock a big file with aPos = 0, aLength = 2GB-1\n"));
       
  3566 	TestRFile1.Lock(0, K2GBMinusOne);
       
  3567 		
       
  3568 	
       
  3569 	test.Next(_L(" Attempt to lock the same region again\n"));
       
  3570 	TestRFile1.LockE(0, K2GBMinusOne);
       
  3571 	
       
  3572 	test.Next(_L("Extend the Lock with aPos = 0, aLength  = 2GB+10\n"));	
       
  3573 	TestRFile1.LockE(0, K2GBPlusTen);
       
  3574 	
       
  3575 	test.Next(_L("Extend the Lock with aPos = 2GB-100, aLength = 200\n"));	
       
  3576 	TestRFile1.LockE(K2GBMinus100, 200);
       
  3577 	
       
  3578 	test.Next(_L("Lock with aPos = 100, aLength = 2GB-100.\n"));	
       
  3579 	TestRFile1.LockE(100, K2GBMinus100);
       
  3580 	
       
  3581 	test.Next(_L("Lock same file with aPos = 2GB-1 and aLength = 200\n"));		
       
  3582 	TestRFile1.Lock(K2GBMinusOne, 200);
       
  3583 	
       
  3584 	test.Next(_L("Lock a big file with aPos = 0, aLength = 4GB-1\n"));			
       
  3585 	TestRFile1.LockE(0, K4GBMinusOne);
       
  3586 	
       
  3587 	
       
  3588     if(KFileSizeMaxLargerThan4GBMinusOne)
       
  3589     {	    
       
  3590 	    test.Next(_L("Lock a file with aPos =4GB and aLength=10\n"));			
       
  3591 	    TestRFile1.Lock(K4GB + 2, 10);
       
  3592 	}
       
  3593 
       
  3594 	TestRFile1.Close();
       
  3595 	
       
  3596 	TInt r = TheFs.Delete(fileName);
       
  3597 	test(r == KErrNone);
       
  3598 	}
       
  3599 
       
  3600 
       
  3601 /**
       
  3602 @SYMTestCaseID      PBASE-T_FILE64BIT-0778
       
  3603 @SYMTestPriority    High
       
  3604 @SYMTestRequirement REQ9526
       
  3605 @SYMTestType        CIT
       
  3606 @SYMTestCaseDesc    Tests the File unlock functionality using RFile64::UnLock()
       
  3607 @SYMTestActions     
       
  3608 1) UnLock a big file, same region which is locked with aPos = 0, aLength = 2GB-1.
       
  3609 2) UnLock a big file, which is not locked with aPos = 0, aLength = 2GB-1.
       
  3610 3) UnLock a big file twice, same region which is locked with aPos = 0, aLength = 2GB-1.
       
  3611 4) UnLock a big file in a region which is sub region of Lock.  aPos = 10, aLength = 2GB-100. File should have been locked with aPos = 0, aLength = 2GB-1.
       
  3612 5) UnLock a big file in a region which is extended region of Lock, with aPos = 0, aLength = 2GB +100. File should have been locked with aPos = 0, aLength = 2GB-1.
       
  3613 6) UnLock a big file to test boundary condition, with aPos = 0, aLength = 4GB-1.The file should have been locked with same arguments.
       
  3614 7) UnLock different regions of a file which were locked in same order with aPos = 0, aLength = 2GB+200. 
       
  3615 						Second Unlock   aPos = 2GB+300 and aLength =200. 
       
  3616 						Third UnLock aPos = 2GB+600 and aLength = 200.
       
  3617 8) UnLock different regions of a file which were locked in different order with aPos = 0, aLength = 2GB+100. 
       
  3618 						Second Unlock   aPos = 2GB+300 and aLength =200. 
       
  3619 						Third UnLock aPos = 2GB+600 and aLength = 200.
       
  3620 9) UnLock multiple locked regions with aPos = 0, aLength = 2GB-1.The file should have been locked in same region but with different locks  
       
  3621 10)Unlock a locked file with aPos = 4GB and aLength = 10bytes
       
  3622 
       
  3623 @SYMTestExpectedResults 
       
  3624 1) KErrNone
       
  3625 2) KErrNotFound
       
  3626 3) KErrNotFound
       
  3627 4) KErrNotFound
       
  3628 5) KErrNotFound
       
  3629 6) KErrNone 
       
  3630 7) KErrNone
       
  3631 8) KErrNone
       
  3632 9) KErrNotFound
       
  3633 10)KErrNone
       
  3634 @SYMTestStatus      Implemented
       
  3635 */
       
  3636 	
       
  3637 void TestFileUnlock()
       
  3638 	{
       
  3639 	test.Next(_L("Tests for Unlocking a big file:\n"));
       
  3640 
       
  3641 	TFileName fileName;
       
  3642 	fileName.Append(gDriveToTest);
       
  3643 	fileName.Append(KTestPath);
       
  3644 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  3645 	TestRFile2.Replace(fileName, EFileRead);
       
  3646 	
       
  3647 	test.Next(_L("UnLock a big file, same region which is locked with aPos = 0, aLength = 2GB-1.\n"));
       
  3648 	TestRFile2.Lock(0, K2GBMinusOne);
       
  3649 	TestRFile2.UnLock(0, K2GBMinusOne);
       
  3650 	TestRFile2.UnLockE(0, K2GBMinusOne);
       
  3651 	
       
  3652 	test.Next(_L("UnLock a big file, which is not locked with aPos = 0, aLength = 2GB-1\n"));	
       
  3653 	TestRFile2.UnLockE(0, K2GBMinusOne);
       
  3654 	
       
  3655 	test.Next(_L("UnLock a big file twice, same region which is locked with aPos = 0, aLength = 2GB-1\n"));		
       
  3656 	TestRFile2.Lock(0, K2GBMinusOne);
       
  3657 	TestRFile2.UnLockE(10, K2GBMinus100);
       
  3658 	TestRFile2.UnLock(0, K2GBMinusOne);
       
  3659 	
       
  3660 	test.Next(_L("UnLock a big file in a region which is sub region of Lock.  aPos = 10, aLength = 2GB-100. File should have been locked with aPos = 0, aLength = 2GB-1\n"));			
       
  3661 	TestRFile2.Lock(0, K2GBMinusOne);
       
  3662 	TestRFile2.UnLockE(10, K2GBMinus100); 
       
  3663 	TestRFile2.UnLock(0, K2GBMinusOne);
       
  3664 	
       
  3665 	test.Next(_L("UnLock a big file in a region which is extended region of Lock, with aPos = 0, aLength = 2GB +100. File should have been locked with aPos = 0, aLength = 2GB-1.\n"));
       
  3666 	TestRFile2.Lock(0, K2GBMinusOne);
       
  3667 	TestRFile2.UnLockE(10, K2GBPlus100);
       
  3668 	TestRFile2.UnLock(0, K2GBMinusOne);
       
  3669 
       
  3670 	test.Next(_L("UnLock a big file to test boundary condition, with aPos = 0, aLength = 4GB-1.The file should have been locked with same arguments\n"));	
       
  3671 	TestRFile2.Lock(0, K4GBMinusOne);
       
  3672 	TestRFile2.UnLock(0, K4GBMinusOne);
       
  3673 	
       
  3674 	test.Next(_L("UnLock different regions of a file which were locked in same order with aPos = 0, aLength = 2GB+200\n"));	
       
  3675 	TestRFile2.Lock(0, K2GBPlus200);
       
  3676 	TestRFile2.Lock(K2GBPlus300, 200);
       
  3677 	TestRFile2.Lock(K2GBPlus600, 200);
       
  3678 	TestRFile2.UnLock(0, K2GBPlus200);
       
  3679 	TestRFile2.UnLock(K2GBPlus300, 200);
       
  3680 	TestRFile2.UnLock(K2GBPlus600, 200);
       
  3681 		
       
  3682 	test.Next(_L("UnLock different regions of a file which were locked in different order with aPos = 0, aLength = 2GB+100\n"));	
       
  3683 	TestRFile2.Lock(0, K2GBPlus100);
       
  3684 	TestRFile2.Lock(K2GBPlus600, 200);
       
  3685 	TestRFile2.Lock(K2GBPlus300, 200);                                        
       
  3686 	TestRFile2.UnLock(K2GBPlus600, 200);
       
  3687 	TestRFile2.UnLock(K2GBPlus300, 200);
       
  3688 	TestRFile2.UnLock(0, K2GBPlus100); 
       
  3689 	
       
  3690 	test.Next(_L("UnLock multiple locked regions with aPos = 0, aLength = 2GB-1.The file should have been locked in same region but with different locks\n"));	
       
  3691 	TestRFile2.Lock(0, 100);
       
  3692 	TestRFile2.Lock(100, K2GBMinusOne);
       
  3693 	TestRFile2.UnLockE(0, K2GBMinusOne);
       
  3694 
       
  3695 		
       
  3696     if(KFileSizeMaxLargerThan4GBMinusOne)
       
  3697         {	    
       
  3698 		
       
  3699 	test.Next(_L("Unlock a locked file with aPos = 4GB and aLength = 10bytes\n"));		
       
  3700 	TestRFile2.Lock(K4GB, 10);	
       
  3701 	TestRFile2.UnLock(K4GB, 10);	
       
  3702 	    }
       
  3703 
       
  3704     TestRFile2.Close();
       
  3705 	TInt r = TheFs.Delete(fileName);
       
  3706 	test(r == KErrNone);
       
  3707 	}
       
  3708 
       
  3709 /**
       
  3710 @SYMTestCaseID      PBASE-T_FILE64BIT-0779
       
  3711 @SYMTestPriority    High
       
  3712 @SYMTestRequirement REQ9526
       
  3713 @SYMTestType        CIT
       
  3714 @SYMTestCaseDesc    Tests for file seek operation using RFile64::Seek()
       
  3715 @SYMTestActions     
       
  3716 1) Set the file size as 20
       
  3717 2) Seek mode = ESeekEnd, seek position = 80, call RFile64::Seek() 
       
  3718 3) Check Seek position
       
  3719 4) Set file size = 512
       
  3720 5) Seek mode =ESeekStart, assign seek position =513, get the seek position using RFile64::Seek()
       
  3721 6) Check the seek position
       
  3722 7) Seek mode = ESeekEnd, get the seek position using RFile64::Seek()
       
  3723 8) Check the seek position
       
  3724 9) Seek position =-530, seek mode = ESeekEnd, Get the seek position using RFile64::Seek()
       
  3725 10)Check the seek position
       
  3726 11)Seek position =-10, seek mode = ESeekEnd, get the seek position using RFile64::Seek()
       
  3727 12)Seek position =-10, seek mode = ESeekStart, get the seek position using RFile64::Seek()
       
  3728 13)Seek position =0, seek mode = ESeekEnd, get the seek position using RFile64::Seek()
       
  3729 @SYMTestExpectedResults 
       
  3730 1) KErrNone
       
  3731 2) KErrNone
       
  3732 3) Seek position = 20
       
  3733 4) KErrNone
       
  3734 5) KErrNone
       
  3735 6) Seek position = 513
       
  3736 7) KErrNone 
       
  3737 8) Seek position = 512
       
  3738 9) KErrNone
       
  3739 10)Seekposition = 0
       
  3740 11)Seek position =502
       
  3741 12)KErrArgument, seek position unchanged
       
  3742 13)Seek position =512
       
  3743 @SYMTestStatus      Implemented
       
  3744 */
       
  3745 	
       
  3746 void TestFileSeek()
       
  3747 	{
       
  3748 	TInt64 seekPos;
       
  3749 	
       
  3750 	TFileName fileName;
       
  3751 	fileName.Append(gDriveToTest);
       
  3752 	fileName.Append(KTestPath);
       
  3753 	fileName.Append(_L("seektest.txt"));
       
  3754 	TestRFile1.Replace(fileName);
       
  3755 
       
  3756 
       
  3757 	test.Next(_L("Set the file size as 20\n"));			
       
  3758 	TestRFile1.SetSize(20);
       
  3759 	
       
  3760 	test.Next(_L("Seek mode = ESeekEnd, seek position = 80, call RFile64::Seek() "));
       
  3761 	seekPos = 80;								
       
  3762     TestRFile1.Seek(ESeekEnd, seekPos);	
       
  3763     test(seekPos == 20);				
       
  3764 
       
  3765 	test.Next(_L("Set the file size as 512\n"));			
       
  3766 	TestRFile1.SetSize(512);
       
  3767 	
       
  3768 	test.Next(_L("Seek mode =ESeekStart, assign seek position =513, get the seek position using RFile64::Seek()\n"));			
       
  3769 	seekPos = 513;
       
  3770 	TestRFile1.Seek(ESeekStart, seekPos);
       
  3771 	test(seekPos == 513);
       
  3772 
       
  3773 	test.Next(_L("Seek mode = ESeekEnd, get the seek position using RFile64::Seek()\n"));			
       
  3774 	TestRFile1.Seek(ESeekEnd, seekPos);
       
  3775 	test(seekPos == 512);
       
  3776 
       
  3777 	test.Next(_L("Seek position =-530, seek mode = ESeekEnd, Get the seek position using RFile64::Seek()\n"));			
       
  3778 	seekPos = -530;
       
  3779 	TestRFile1.Seek(ESeekEnd, seekPos);
       
  3780 	test(seekPos == 0);
       
  3781 
       
  3782 	test.Next(_L("Seek position =-10, seek mode = ESeekEnd, get the seek position using RFile64::Seek()\n"));	
       
  3783 	seekPos = -10;
       
  3784 	TestRFile1.Seek(ESeekEnd, seekPos);
       
  3785 	test(seekPos == 502);
       
  3786 
       
  3787 	test.Next(_L("Seek position =-10, seek mode = ESeekStart, get the seek position using RFile64::Seek()\n"));	
       
  3788 	seekPos = -10;
       
  3789 	TestRFile1.Seek(ESeekStart,seekPos);
       
  3790 	test(seekPos == -10);
       
  3791 
       
  3792 	test.Next(_L("Seek position =0, seek mode = ESeekEnd, get the seek position using RFile64::Seek()\n"));	
       
  3793 	seekPos = 0;
       
  3794 	TestRFile1.Seek(ESeekEnd,seekPos);
       
  3795 	test(seekPos == 512);
       
  3796 
       
  3797 	TestRFile1.Close();
       
  3798 	
       
  3799 	TInt r = TheFs.Delete(fileName);
       
  3800 	test(r == KErrNone);
       
  3801 	}
       
  3802 
       
  3803 /**
       
  3804 @SYMTestCaseID      PBASE-T_FILE64BIT-0780
       
  3805 @SYMTestPriority    High
       
  3806 @SYMTestRequirement REQ9526
       
  3807 @SYMTestType        CIT
       
  3808 @SYMTestCaseDesc    Test file seek operation for large file
       
  3809 @SYMTestActions     
       
  3810 1) Set the file size as 2GB-1
       
  3811 2) Seek mode = ESeekEnd, seek position = 2GB+80, call RFile64::Seek()  
       
  3812 3) Check Seek position
       
  3813 4) Set file size = 4GB -1
       
  3814 5) Seek mode = ESeekStart, assign seek position = 4GB-1, get the seek position using RFile64::Seek()
       
  3815 6) Check the seek position
       
  3816 7) Seek mode = ESeekEnd, get the seek position using RFile64::Seek()
       
  3817 8) Check the seek position
       
  3818 9) Seek position = (4GB), seek mode = ESeekEnd, Get the seek position using RFile64::Seek()
       
  3819 10)Check the seek position
       
  3820 11)Seek position =-10, seek mode = ESeekEnd, get the seek position using RFile64::Seek()
       
  3821 12)Seek position =-10, seek mode = ESeekStart, get the seek position using RFile64::Seek()
       
  3822 13)Seek position =0, seek mode = ESeekEnd, get the seek position using RFile64::Seek()
       
  3823 @SYMTestExpectedResults 
       
  3824 1) KErrNone
       
  3825 2) KErrNone
       
  3826 3) Seek position = 2GB-1
       
  3827 4) KErrNone
       
  3828 5) KErrNone
       
  3829 6) Seek position = 4GB-1
       
  3830 7) KErrNone 
       
  3831 8) Seek position = 4GB-1
       
  3832 9) KErrNone
       
  3833 10)Seekposition = 0
       
  3834 11)Seek position =4GB-10
       
  3835 12)KErrArgument, seek position unchanged
       
  3836 13)Seek position =4GB - 1
       
  3837 @SYMTestStatus      Implemented
       
  3838 */
       
  3839 	
       
  3840 void TestFileSeekBigFile()
       
  3841 	
       
  3842 	{
       
  3843 	TInt64 seekPos;
       
  3844 	
       
  3845 	
       
  3846 	TFileName fileName;
       
  3847 	fileName.Append(gDriveToTest);
       
  3848 	fileName.Append(KTestPath);
       
  3849 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  3850 	TestRFile1.Replace(fileName, EFileRead|EFileWrite);
       
  3851 	
       
  3852 	test.Next(_L("Set the file size as 2GB-1\n"));	
       
  3853 	TestRFile1.SetSize(K2GBMinusOne);
       
  3854 	
       
  3855 	test.Next(_L("Seek mode = ESeekEnd, seek position = 2GB+80, call RFile64::Seek()\n"));		
       
  3856 	seekPos = K2GBPlus80;
       
  3857     TestRFile1.Seek(ESeekEnd, seekPos);
       
  3858     test(seekPos == K2GBMinusOne);
       
  3859 	
       
  3860 	test.Next(_L("Set the file size to 4GB-1\n"));	
       
  3861 	TestRFile1.SetSize(K4GBMinusOne);
       
  3862 	
       
  3863 	test.Next(_L("Seek mode = ESeekStart, assign seek position = 4GB-1, get the seek position using RFile64::Seek()\n"));	
       
  3864 	seekPos = K4GBMinusOne;
       
  3865 	TestRFile1.Seek(ESeekStart, seekPos);
       
  3866 	test(seekPos == K4GBMinusOne);
       
  3867 
       
  3868 	test.Next(_L("Seek mode = ESeekEnd, get the seek position using RFile64::Seek()\n"));	
       
  3869 	TestRFile1.Seek(ESeekEnd, seekPos);
       
  3870 	test(seekPos == K4GBMinusOne);
       
  3871 	
       
  3872 	if(KFileSizeMaxLargerThan4GBMinusOne)
       
  3873 		{
       
  3874 		TestRFile1.SetSize(K4GB);
       
  3875 		TestRFile1.Seek(ESeekEnd, seekPos);
       
  3876 		test(seekPos == K4GB);
       
  3877 		seekPos = -10;
       
  3878 		TestRFile1.Seek(ESeekEnd, seekPos);
       
  3879 		test(seekPos == K4GB-10);
       
  3880 		seekPos = -10;
       
  3881 		TestRFile1.Seek(ESeekStart,seekPos);
       
  3882 		test(seekPos == -10);
       
  3883 		seekPos = 0;
       
  3884 		TestRFile1.Seek(ESeekEnd,seekPos);
       
  3885 		test(seekPos == K4GB);
       
  3886 		}
       
  3887 	else
       
  3888 		{
       
  3889 		TestRFile1.SetSize(K4GB);
       
  3890 		TestRFile1.Seek(ESeekEnd, seekPos);
       
  3891 		test(seekPos == K4GBMinusOne);
       
  3892 		seekPos = -10;
       
  3893 		TestRFile1.Seek(ESeekEnd, seekPos);
       
  3894 		test(seekPos == K4GBMinusOne-10);
       
  3895 		seekPos = -10;
       
  3896 		TestRFile1.Seek(ESeekStart,seekPos);
       
  3897 		test(seekPos == -10);
       
  3898 		seekPos = 0;
       
  3899 		TestRFile1.Seek(ESeekEnd,seekPos);
       
  3900 		test(seekPos == K4GBMinusOne);
       
  3901 		}
       
  3902 		
       
  3903 
       
  3904 	TestRFile1.Close();
       
  3905 	
       
  3906 	TInt r = TheFs.Delete(fileName);
       
  3907 	test(r == KErrNone);
       
  3908 }
       
  3909 
       
  3910 /**
       
  3911 @SYMTestCaseID      PBASE-T_FILE64BIT-0781
       
  3912 @SYMTestPriority    High
       
  3913 @SYMTestRequirement REQ9527
       
  3914 @SYMTestType        CIT
       
  3915 @SYMTestCaseDesc    Test RFile64::SetSize() and RFile64::Size() functionality
       
  3916 @SYMTestActions     
       
  3917 1) Set the file size =128KB
       
  3918 2) Write a test data = "ABCDEFGH", at position = 0
       
  3919 3) Get the file size
       
  3920 4) Read the data from position = 0
       
  3921 5) Compare the read data with written data
       
  3922 6) Set the file size to = 2GB-1
       
  3923 7) Write test data = "IJKLMnOPxY IJKLMnOPx",  length=20 bytes, at position 2GB-10
       
  3924 8) Get the file size
       
  3925 9) Read the data from the position 2GB-10
       
  3926 10)Compare the read data
       
  3927 11)Set the file size = 4GB-1
       
  3928 12)Write test data = "IJKLMnOPxY IJKLMnOPx",  length=10 bytes, at position 4GB-10
       
  3929 13)Get the file size
       
  3930 14)Read the data from the position 4GB-10
       
  3931 15)Compare the read data
       
  3932 @SYMTestExpectedResults 
       
  3933 1) KErrNone
       
  3934 2) KErrNone, write is successful
       
  3935 3) KErrNone, File Size = 128KB 
       
  3936 4) KErrNone, read is successful
       
  3937 5) Read data == Written data
       
  3938 6) KErrNone
       
  3939 7) KErrNone, write is successful
       
  3940 8) KErrNone File Size = 2GB+10
       
  3941 9) KErrNone, read is successful
       
  3942 10)Read data == Written data
       
  3943 11)KErrNone
       
  3944 12)KErrNone, write is successful for 10 bytes
       
  3945 13)KErrNone File Size == 4GB-1
       
  3946 14)KErrNone, read is successful
       
  3947 15)Read data == Written data
       
  3948 @SYMTestStatus      Implemented
       
  3949 */
       
  3950 	
       
  3951 void TestSetsize()
       
  3952 	{
       
  3953 	test.Next(_L("Create a large file"));
       
  3954 	
       
  3955 	TFileName fileName;
       
  3956 	fileName.Append(gDriveToTest);
       
  3957 	fileName.Append(KTestPath);
       
  3958 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  3959 	TestRFile1.Replace(fileName, EFileRead|EFileWrite);
       
  3960 	
       
  3961 	CheckDisk();
       
  3962 	
       
  3963 	test.Next(_L("Set the file size =128KB\n"));
       
  3964 	TestRFile1.SetSize(131072); // 128KB
       
  3965 	
       
  3966 	test.Next(_L("Write a test data = ABCDEFGH, at position = 0\n"));
       
  3967 	TBuf8<16> testData = _L8("ABCDEFGH");
       
  3968 	TestRFile1.WriteP(0,testData);
       
  3969 	TInt64 size = 0;
       
  3970 	
       
  3971 	test.Next(_L("Get the file size\n"));
       
  3972 	TestRFile1.Size(size);
       
  3973 	test(size == 131072) ;
       
  3974 	
       
  3975 	test.Next(_L("Read and compare the data from position = 0\n"));
       
  3976 	TBuf8<16> testData2;
       
  3977 	TestRFile1.Read(0,testData2,8);
       
  3978 	test(testData == testData2);
       
  3979 	
       
  3980 	test.Next(_L("Set the file size =2GB - 1 \n"));
       
  3981 	TestRFile1.SetSize(K2GBMinusOne); // 2GB-1
       
  3982 	
       
  3983 	test.Next(_L("Write test data = IJKLMnOPxY IJKLMnOPx ,length=20 bytes, at position 2GB-10\n"));
       
  3984 	TBuf8<20> testData3 = _L8("IJKLMnOPxY IJKLMnOPx");
       
  3985 	TestRFile1.Write(K2GBMinusTen,testData3, 20);
       
  3986 	
       
  3987 	test.Next(_L("Get the file size\n"));
       
  3988 	TestRFile1.Size(size);
       
  3989 	test(size == K2GBPlusTen);
       
  3990 	
       
  3991 	test.Next(_L("Read and compare the data from position = 2GB-10\n"));
       
  3992 	TBuf8<10> testData4;
       
  3993 	TestRFile1.Read(K2GBMinusTen,testData4,10);
       
  3994 	test(testData4 == _L8("IJKLMnOPxY"));
       
  3995 
       
  3996 	test.Next(_L("Set the file size =2GB - 1 \n"));
       
  3997 	TestRFile1.SetSize(K4GBMinusOne); // 4GB-1
       
  3998 	
       
  3999 	test.Next(_L("Write test data = IJKLMnOPxY IJKLMnOPx,  length=10 bytes, at position 4GB-10\n"));
       
  4000 	TBuf8<20> testData5 = _L8("IJKLMnOPxY IJKLMnOPx");
       
  4001 	TestRFile1.Write(K4GBMinusTen,testData5,9);
       
  4002 	
       
  4003 	test.Next(_L("Get the file size\n"));
       
  4004 	TestRFile1.Size(size);
       
  4005 	test(size == K4GBMinusOne);
       
  4006 	
       
  4007 	test.Next(_L("Read the data from the position 4GB-10\n"));
       
  4008 	TBuf8<10> testData6;
       
  4009 	TestRFile1.Read(K4GBMinusTen,testData6,9);
       
  4010 	test(testData6 == _L8("IJKLMnOPx"));
       
  4011 	TestRFile1.Close();
       
  4012 	
       
  4013 	TInt r = TheFs.Delete(fileName);
       
  4014 	test(r == KErrNone);
       
  4015 	}
       
  4016 
       
  4017 /**
       
  4018 @SYMTestCaseID      PBASE-T_FILE64BIT-0782
       
  4019 @SYMTestPriority    High
       
  4020 @SYMTestRequirement REQ9528
       
  4021 @SYMTestType        CIT
       
  4022 @SYMTestCaseDesc    Tests for reading a data from a big file without opening it
       
  4023 @SYMTestActions     
       
  4024 1) Read from a big file using RFs::ReadFileSection() from position 3GB-1,52byte lengths of data
       
  4025 2) Open a big file in EFileShareAny | EFileRead mode and read from it using RFs::ReadFileSection() from position 3GB-1, 52byte lengths of data
       
  4026 3) Open a big file in EFileShareExclusive | EFileRead mode and read from it using RFs::ReadFileSection( ) from position 3GB-1, 52byte lengths of data
       
  4027 4) Open a big file in EFileShareExclusive | EFileWrite mode and read from it using RFs::ReadFileSection( ) from position 3GB-1, 52byte lengths of data
       
  4028 5) Check for FAT32 file system. Read from a big file using RFs::ReadFileSection( ) from position equal to 4GB, 52byte lengths of data
       
  4029 @SYMTestExpectedResults 
       
  4030 1) KErrNone, read is successful
       
  4031 2) KErrNone, open and read both are successful
       
  4032 3) KErrNone, open and read both are successful
       
  4033 4) KErrNone, open and read both are successful
       
  4034 5) KErrNone with zero length descriptor,if NGFS is supported we should get the valid data
       
  4035 @SYMTestStatus      Implemented
       
  4036 */
       
  4037 void TestReadFilesection()
       
  4038 	{
       
  4039 	test.Next(_L("Read data from a large file using RFs::ReadFileSection\n"));
       
  4040 	TBuf8<52> testDes;
       
  4041 	TBuf8<52>  readBuf;
       
  4042 	
       
  4043 	RFile64 file;
       
  4044 		
       
  4045 	TFileName fileName;
       
  4046 	fileName.Append(gDriveToTest);
       
  4047 	fileName.Append(KTestPath);
       
  4048 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  4049 	
       
  4050 	TInt r = file.Replace(TheFs,fileName,EFileWrite);
       
  4051 	test(r == KErrNone);
       
  4052 	r = file.SetSize(K4GBMinusOne);
       
  4053 	test(r == KErrNone);
       
  4054 	file.Close();
       
  4055 	
       
  4056 	test.Next(_L("Read from a big file using RFs::ReadFileSection() from position 3GB-1,52byte lengths of data\n"));
       
  4057 	TestRFs.ReadFileSection(fileName,K3GBMinusOne,testDes,52);
       
  4058 
       
  4059 	test.Next(_L("Open a big file in EFileShareAny | EFileRead mode and read from it using RFs::ReadFileSection() from position 3GB-1, 52byte lengths of data\n"));
       
  4060 	TestRFile1.Open(fileName,EFileShareAny|EFileRead);
       
  4061 	TestRFs.ReadFileSection(fileName,0,testDes,52);
       
  4062 	test(testDes.Length() == 52);
       
  4063 	TestRFile1.Close();
       
  4064 	
       
  4065 	test.Next(_L("Open a big file in EFileShareExclusive | EFileRead mode and read from it using RFs::ReadFileSection( ) from position 3GB-1, 52byte lengths of data\n"));
       
  4066 	TestRFile1.Open(fileName,EFileShareExclusive|EFileRead);
       
  4067 	TestRFs.ReadFileSection(fileName,K3GBMinusOne,testDes,52);
       
  4068 	TestRFile1.Close();
       
  4069 	
       
  4070 	test.Next(_L("Open a big file in EFileShareExclusive | EFileWrite mode and read from it using RFs::ReadFileSection( ) from position 3GB-1, 52byte lengths of data\n"));
       
  4071 	TestRFile1.Open(fileName,EFileShareExclusive|EFileWrite);
       
  4072 	TestRFs.ReadFileSection(fileName,K3GBMinusOne,testDes,52);
       
  4073 	TestRFile1.Close();
       
  4074 	
       
  4075 	
       
  4076 	test.Next(_L("Check for FAT32 file system. Read from a big file using RFs::ReadFileSection( ) from position equal to 4GB, 52byte lengths of data\n"));
       
  4077 		
       
  4078 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
  4079 		{
       
  4080 		TestRFs.ReadFileSection(fileName,K4GB,readBuf,52);
       
  4081 		}
       
  4082 		
       
  4083 	r = TheFs.Delete(fileName);
       
  4084 	test(r == KErrNone);
       
  4085 	}
       
  4086 	
       
  4087 /**
       
  4088 @SYMTestCaseID      PBASE-T_FILE64BIT-0783
       
  4089 @SYMTestPriority    High
       
  4090 @SYMTestRequirement REQ9530
       
  4091 @SYMTestType        CIT
       
  4092 @SYMTestCaseDesc    Check that we can get a valid directory listing of a directory containing large files using RDir and then CDir
       
  4093 					TInt RFs::GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey,CDir*& anEntryList) const;
       
  4094 @SYMTestActions     
       
  4095 1) Get the directory listing, sort by size
       
  4096 2) Check the files count in the directory. Number of files in a directory is 4
       
  4097 3) Get the entry list & Check the files are listed in order of file sizes
       
  4098 @SYMTestExpectedResults 
       
  4099 1) KErrNone
       
  4100 2) 4 Files in the directory
       
  4101 3) File size should match and arranged in ascending order
       
  4102 @SYMTestStatus      Implemented
       
  4103 */
       
  4104 void TestGetDirectory()
       
  4105 	{
       
  4106 	test.Next(_L("Read a directory containing large files using RDir"));
       
  4107 
       
  4108 	TFileName dirName;
       
  4109 	dirName.Append(gDriveToTest);
       
  4110 	dirName.Append(KTestPath);
       
  4111 		
       
  4112 	TFileName file4GBMinusOne;
       
  4113 	file4GBMinusOne.Append(gDriveToTest);
       
  4114 	file4GBMinusOne.Append(KTestPath);
       
  4115 	file4GBMinusOne.Append(_L("File4GBMinusOne.txt"));
       
  4116 	TFileName file2GBMinusOne;
       
  4117 	file2GBMinusOne.Append(gDriveToTest);
       
  4118 	file2GBMinusOne.Append(KTestPath);
       
  4119 	file2GBMinusOne.Append(_L("File2GBMinusOne.txt"));
       
  4120 	TFileName file2GB;
       
  4121 	file2GB.Append(gDriveToTest);
       
  4122 	file2GB.Append(KTestPath);
       
  4123 	file2GB.Append(_L("File2GB.txt"));
       
  4124 	TFileName file3GB;
       
  4125 	file3GB.Append(gDriveToTest);
       
  4126 	file3GB.Append(KTestPath);
       
  4127 	file3GB.Append(_L("File3GB.txt"));
       
  4128 
       
  4129 	TestRFile1.Replace(file4GBMinusOne);
       
  4130 	TestRFile1.SetSize(K4GBMinusOne);
       
  4131 	TestRFile1.Close();
       
  4132 	
       
  4133 	TestRFile1.Replace(file2GBMinusOne);
       
  4134 	TestRFile1.SetSize(K2GBMinusOne);
       
  4135 	TestRFile1.Close();
       
  4136 	
       
  4137 	TestRFile1.Replace(file2GB);
       
  4138 	TestRFile1.SetSize(K2GB);
       
  4139 	TestRFile1.Close();
       
  4140 	
       
  4141 	TestRFile1.Replace(file3GB);
       
  4142 	TestRFile1.SetSize(K3GB);
       
  4143 	TestRFile1.Close();
       
  4144 		
       
  4145 	test.Next(_L("Get the directory listing, sort by size\n"));
       
  4146 	RDir dir;
       
  4147 	TInt r = dir.Open(TheFs, dirName, KEntryAttNormal);
       
  4148 	test (r == KErrNone);
       
  4149 	
       
  4150 	TEntryArray entryArray;
       
  4151 	r = dir.Read(entryArray);
       
  4152 	test (r == KErrEof);
       
  4153 
       
  4154 	test.Next(_L("Check the files count in the directory. Number of files in a directory is 4\n"));
       
  4155 	test(entryArray.Count() == gFilesInDirectory);
       
  4156 	
       
  4157 	test.Next(_L("Get the entry list & Check the files are listed in order of file sizes\n"));
       
  4158 	TInt n;
       
  4159 	for (n = 0; n<entryArray.Count(); n++)
       
  4160 		{
       
  4161 		const TEntry& entry = entryArray[n];
       
  4162 		if (entry.iName.MatchF(KFile2GBMinusOne()) == 0)
       
  4163 			test(entry.FileSize() == K2GBMinusOne);
       
  4164 		else if (entry.iName.MatchF(KFile2GB()) == 0)
       
  4165 			test(entry.FileSize() == K2GB);
       
  4166 		else if (entry.iName.MatchF(KFile3GB()) == 0)
       
  4167 			test(entry.FileSize() == K3GB);
       
  4168 		else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0)
       
  4169 			test(entry.FileSize() == K4GBMinusOne);
       
  4170 		else
       
  4171 			test(EFalse);
       
  4172 		}
       
  4173 
       
  4174 	dir.Close();
       
  4175 
       
  4176 	test.Next(_L("Read a directory containing large files using CDir & sort by size"));
       
  4177 	CDir* dirList = NULL;
       
  4178 	TestRFs.GetDir(dirName, KEntryAttMaskSupported, ESortBySize, dirList);
       
  4179 	test(dirList->Count() == gFilesInDirectory);
       
  4180 	for (n = 0; n<dirList->Count(); n++)
       
  4181 		{
       
  4182 		TEntry entry;
       
  4183 		entry = (*dirList)[n];
       
  4184 		if (entry.iName.MatchF(KFile2GBMinusOne()) == 0)
       
  4185 			test(entry.FileSize() == K2GBMinusOne);
       
  4186 		else if (entry.iName.MatchF(KFile2GB()) == 0)
       
  4187 			test(entry.FileSize() == K2GB);
       
  4188 		else if (entry.iName.MatchF(KFile3GB()) == 0)
       
  4189 			test(entry.FileSize() == K3GB);
       
  4190 		else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0)
       
  4191 			test(entry.FileSize() == K4GBMinusOne);
       
  4192 		else
       
  4193 			test(EFalse);
       
  4194 		}
       
  4195 	delete dirList;
       
  4196 	dirList = NULL;
       
  4197 	}
       
  4198 	
       
  4199 
       
  4200 /**
       
  4201 @SYMTestCaseID      PBASE-T_FILE64BIT-0784
       
  4202 @SYMTestPriority    High
       
  4203 @SYMTestRequirement REQ9533
       
  4204 @SYMTestType        CIT
       
  4205 @SYMTestCaseDesc    Tests functionality of TEntry
       
  4206 @SYMTestActions     
       
  4207 1) Set the File Size to 4GB-1 using RFile64::SetSize()
       
  4208 2) Get the entry
       
  4209 3) Get the file size, using TEntry::FileSize()
       
  4210 4) Get the file size using iSize (i.e. without type cast to TUint)
       
  4211 5) Check for FAT32 file system. Set the file size to 4GB
       
  4212 6) Get the file size, using TEntry::FileSize()
       
  4213 7) Compare the File size with expected size
       
  4214 @SYMTestExpectedResults 
       
  4215 1) KErrNone
       
  4216 2) KErrNone
       
  4217 3) File size = 4GB-1
       
  4218 4) File size = -1
       
  4219 5) KErrNotSupported for FAT32 and KErrNone for NGFS
       
  4220 6) FAT32 file size = 4GB-1 and NGFS file size = 4GB
       
  4221 7) File size = 4GB-1
       
  4222 @SYMTestStatus      Implemented
       
  4223 */
       
  4224 void TestTEntry()	
       
  4225 	{
       
  4226 	test.Next(_L("Tests functionality for TEntry"));
       
  4227 	
       
  4228 	TFileName fileName;
       
  4229 	fileName.Append(gDriveToTest);
       
  4230 	fileName.Append(KTestPath);
       
  4231 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  4232 	TestRFile1.Replace(fileName, EFileRead|EFileWrite);
       
  4233 	
       
  4234 	CDir* anEntryList;
       
  4235 	TEntry entry;
       
  4236 	TInt64 size = 0;
       
  4237 	
       
  4238 	test.Next(_L("Set the File Size to 4GB-1 using RFile64::SetSize()\n"));
       
  4239 	TestRFile1.SetSize(K4GBMinusOne);
       
  4240 	
       
  4241 	test.Next(_L("Get the entry\n"));
       
  4242 	TestRFs.GetDir(fileName, KEntryAttMaskSupported, ESortBySize, anEntryList);
       
  4243 	for (TInt n = 0; n<anEntryList->Count(); n++)
       
  4244 		{
       
  4245 		entry = (*anEntryList)[n];
       
  4246 		if (entry.iName.MatchF(KFile4GBMinusOne()) == 0)
       
  4247 			{
       
  4248 			test(entry.FileSize() == K4GBMinusOne);
       
  4249 			}
       
  4250 		}
       
  4251 		
       
  4252 	test.Next(_L("Get the file size, using TEntry::FileSize()\n"));
       
  4253 	size = entry.FileSize();
       
  4254 	test(size == K4GBMinusOne);
       
  4255 	test(entry.iSize == -1);
       
  4256 	
       
  4257 	
       
  4258 	
       
  4259 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)
       
  4260 		{
       
  4261 		TestRFile1.SetSize(K4GB);
       
  4262 		size = entry.FileSize();
       
  4263 		test(size == K4GBMinusOne);	
       
  4264 		}
       
  4265 	TestRFile1.Close();
       
  4266 	delete anEntryList;
       
  4267 	anEntryList = NULL;
       
  4268 	}
       
  4269 	
       
  4270 /**
       
  4271 @SYMTestCaseID      PBASE-T_FILE64BIT-0785
       
  4272 @SYMTestPriority    High
       
  4273 @SYMTestRequirement REQ9530
       
  4274 @SYMTestType        CIT
       
  4275 @SYMTestCaseDesc    Test the RDir read functionality with large file
       
  4276 @SYMTestActions     
       
  4277 1) Open the directory containing large file, using RDir open()
       
  4278 2) Read the directory entry using TEntryArray as parameter 
       
  4279 3) Check the count
       
  4280 4) Close using RDir 
       
  4281 @SYMTestExpectedResults 
       
  4282 1) KErrNone, open is successful
       
  4283 2) KErrEof
       
  4284 3) count = 4 files
       
  4285 4) Closes the directory
       
  4286 @SYMTestStatus      Implemented
       
  4287 */
       
  4288 	
       
  4289 void TestReadDirectory()
       
  4290 	{
       
  4291 	test.Next(_L("RDir::Read()"));
       
  4292 	
       
  4293 	TFileName dirName;
       
  4294 	dirName.Append(gDriveToTest);
       
  4295 	dirName.Append(KTestPath);
       
  4296 	
       
  4297 	test.Next(_L("Open the directory containing large file, using RDir open()\n"));
       
  4298 	RDir dir;
       
  4299 	TInt r = dir.Open(TheFs, dirName, KEntryAttNormal);
       
  4300 	test (r == KErrNone);
       
  4301 	
       
  4302 	test.Next(_L("Read the directory entry using TEntryArray as parameter\n"));
       
  4303 	TEntryArray entryArray;
       
  4304 	r = dir.Read(entryArray);
       
  4305 	test (r == KErrEof);
       
  4306 	
       
  4307 	test.Next(_L("Check the count\n"));
       
  4308 	test(entryArray.Count() == gFilesInDirectory);
       
  4309 	
       
  4310 	test.Next(_L("Close using RDir\n"));
       
  4311 	dir.Close();
       
  4312 	}
       
  4313 
       
  4314 /**
       
  4315 @SYMTestCaseID      PBASE-T_FILE64BIT-0786
       
  4316 @SYMTestPriority    High
       
  4317 @SYMTestRequirement REQ9530
       
  4318 @SYMTestType        CIT
       
  4319 @SYMTestCaseDesc    Test the sorting of directory entries using CDir::Sort()
       
  4320 @SYMTestActions     
       
  4321 1) Sort with number of entries =0
       
  4322 2) Sort the directory entries with large files, sort key = ESortBySize
       
  4323 3) Get the entries count
       
  4324 4) Check the files are arranged in increasing file size
       
  4325 @SYMTestExpectedResults 
       
  4326 1) KErrNone
       
  4327 2) KErrNone, sort is successful
       
  4328 3) count = 4
       
  4329 4) sequence should be in increasing order
       
  4330 @SYMTestStatus      Implemented
       
  4331 */
       
  4332 	
       
  4333 void TestSortDirectory()
       
  4334 	{
       
  4335 	CDir* anEntryList;
       
  4336 	TEntry entry;
       
  4337 	
       
  4338 	
       
  4339 	TFileName testDir0;
       
  4340 	testDir0.Append(gDriveToTest);
       
  4341 	testDir0.Append(_L("F32-TEST"));
       
  4342 	
       
  4343 	TInt r = TheFs.MkDir(testDir0);
       
  4344 	test(r == KErrNone || r == KErrAlreadyExists);
       
  4345 	
       
  4346 	test.Next(_L("Sort with number of entries =0\n"));
       
  4347 	TestRFs.GetDir(testDir0, KEntryAttMaskSupported, ESortBySize, anEntryList);
       
  4348 	test(anEntryList->Count() == 0);
       
  4349 	delete anEntryList;
       
  4350 	anEntryList = NULL;
       
  4351 	
       
  4352 	test.Next(_L("	Sort the directory entries with large files, sort key = ESortBySize\n"));
       
  4353 	TFileName testDir;
       
  4354 	testDir.Append(gDriveToTest);
       
  4355 	testDir.Append(KTestPath);
       
  4356 	CDir* aDirList;
       
  4357 	TestRFs.GetDir(testDir, KEntryAttMaskSupported, ESortBySize, aDirList);
       
  4358 	
       
  4359 	test.Next(_L("Get the entries count\n"));
       
  4360 	test(aDirList->Count() == gFilesInDirectory);
       
  4361 	
       
  4362 	
       
  4363 	test.Next(_L("Check the files are arranged in increasing file size\n"));
       
  4364 	for (TInt n = 0; n<aDirList->Count(); n++)
       
  4365 		{
       
  4366 		entry = (*aDirList)[n];
       
  4367 		if (entry.iName.MatchF(KFile2GBMinusOne()) == 0)
       
  4368 			{
       
  4369 			test(entry.FileSize() == K2GBMinusOne);
       
  4370 			test(n == 0);
       
  4371 			}
       
  4372 		else if (entry.iName.MatchF(KFile2GB()) == 0)
       
  4373 			{
       
  4374 			test(entry.FileSize() == K2GB);
       
  4375 			test(n == 1);
       
  4376 			}
       
  4377 		else if (entry.iName.MatchF(KFile3GB()) == 0)
       
  4378 			{
       
  4379 			test(entry.FileSize() == K3GB);
       
  4380 			test(n == 2);
       
  4381 			}
       
  4382 		else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0)
       
  4383 			{
       
  4384 			test(entry.FileSize() == K4GBMinusOne);
       
  4385 			test(n == 3);
       
  4386 			}
       
  4387 		else
       
  4388 			test(EFalse);
       
  4389 		}
       
  4390 	delete aDirList;
       
  4391 	aDirList = NULL;
       
  4392 	}	
       
  4393 
       
  4394 /**
       
  4395 @SYMTestCaseID      PBASE-T_FILE64BIT-0787
       
  4396 @SYMTestPriority    High
       
  4397 @SYMTestRequirement REQ9530
       
  4398 @SYMTestType        CIT
       
  4399 @SYMTestCaseDesc    Test cases for validating CDir::AddL()
       
  4400 @SYMTestActions     
       
  4401 1) Fill the directory entry with details of large files contained in them
       
  4402 2) Get the directory entry,using RFs::GetDir()
       
  4403 3) Compare with entry added
       
  4404 @SYMTestExpectedResults 
       
  4405 1) KErrNone
       
  4406 2) KErrNone
       
  4407 3) Added entry == retrieved entry
       
  4408 @SYMTestStatus      Implemented
       
  4409 */
       
  4410 void TestAddLDirectory()
       
  4411 	{
       
  4412 	CDir* aDirList;
       
  4413 	TEntry entry;
       
  4414 	
       
  4415 	TFileName testDir;
       
  4416 	testDir.Append(gDriveToTest);
       
  4417 	testDir.Append(KTestPath);	
       
  4418 	
       
  4419 	test.Next(_L("Get the directory entry,using RFs::GetDir()\n"));
       
  4420 	TestRFs.GetDir(testDir, KEntryAttMaskSupported, ESortBySize, aDirList);
       
  4421 	test(aDirList->Count() == gFilesInDirectory);
       
  4422 
       
  4423 	test.Next(_L("Compare with entry added\n"));
       
  4424 	for (TInt n = 0; n<aDirList->Count(); n++)
       
  4425 		{
       
  4426 		entry = (*aDirList)[n];
       
  4427 		if (entry.iName.MatchF(KFile2GBMinusOne()) ==0 )
       
  4428 			{
       
  4429 			test(entry.FileSize() == K2GBMinusOne);
       
  4430 			test(n == 0);
       
  4431 			}
       
  4432 		else if (entry.iName.MatchF(KFile2GB) == 0)
       
  4433 			{
       
  4434 			test(entry.FileSize() == K2GB);
       
  4435 			test(n == 1);
       
  4436 			}
       
  4437 		else if (entry.iName.MatchF(KFile3GB()) == 0)
       
  4438 			{
       
  4439 			test(entry.FileSize() == K3GB);
       
  4440 			test(n == 2);
       
  4441 			}
       
  4442 		else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0)
       
  4443 			{
       
  4444 			test(entry.FileSize() == K4GBMinusOne);
       
  4445 			test(n == 3);
       
  4446 			}
       
  4447 		else
       
  4448 			test(EFalse);
       
  4449 		}
       
  4450 		delete aDirList;
       
  4451 		aDirList = NULL;
       
  4452 		
       
  4453 	TFileName file4GBMinusOne;
       
  4454 	file4GBMinusOne.Append(gDriveToTest);
       
  4455 	file4GBMinusOne.Append(KTestPath);
       
  4456 	file4GBMinusOne.Append(_L("File4GBMinusOne.txt"));
       
  4457 	TFileName file2GBMinusOne;
       
  4458 	file2GBMinusOne.Append(gDriveToTest);
       
  4459 	file2GBMinusOne.Append(KTestPath);
       
  4460 	file2GBMinusOne.Append(_L("File2GBMinusOne.txt"));
       
  4461 	TFileName file2GB;
       
  4462 	file2GB.Append(gDriveToTest);
       
  4463 	file2GB.Append(KTestPath);
       
  4464 	file2GB.Append(_L("File2GB.txt"));
       
  4465 	TFileName file3GB;
       
  4466 	file3GB.Append(gDriveToTest);
       
  4467 	file3GB.Append(KTestPath);
       
  4468 	file3GB.Append(_L("File3GB.txt"));
       
  4469 	
       
  4470 	TInt r = TheFs.Delete(file4GBMinusOne);
       
  4471 	test(r == KErrNone);
       
  4472 	r = TheFs.Delete(file2GBMinusOne);
       
  4473 	test(r == KErrNone);
       
  4474 	r = TheFs.Delete(file2GB);
       
  4475 	test(r == KErrNone);
       
  4476 	r = TheFs.Delete(file3GB);
       
  4477 	test(r == KErrNone);
       
  4478 	}
       
  4479 	
       
  4480 /**
       
  4481 @SYMTestCaseID      PBASE-T_FILE64BIT-0788
       
  4482 @SYMTestPriority    High
       
  4483 @SYMTestRequirement REQXXXX
       
  4484 @SYMTestType        CIT
       
  4485 @SYMTestCaseDesc    Test cases for validating TFileText changes.
       
  4486 @SYMTestActions     
       
  4487 1) Open test file and get the file size using RFile64::Size() and set the file handle to TFileText object
       
  4488 2) Seek to the file end using TFileText::Seek()
       
  4489 3) Get current file position using RFile64::Seek() and verify it is at file end.
       
  4490 4) Seek to location greater than 2GB-1 using RFile64::Seek
       
  4491 5) Write data to the file using RFile64::Write
       
  4492 6) Read data using TFileText::Read
       
  4493 7) Compare the data read in steps 6 to the data written in step 5.
       
  4494 8) Seek to the file end using TFileText::Seek(ESeekEnd).
       
  4495 9) Write known data using TFileText::Write
       
  4496 10) Read the data using RFile64::Read
       
  4497 11) Compare the source data with read data.
       
  4498 @SYMTestExpectedResults 
       
  4499 1) KErrNone
       
  4500 2) KErrNone
       
  4501 3) Current file position is file end.
       
  4502 4) KErrNone
       
  4503 5) KErrNone
       
  4504 6) KErrNone
       
  4505 7) Read data == Written data
       
  4506 8) KErrNone
       
  4507 9) KErrNone
       
  4508 10) KErrNone
       
  4509 11) Read data == Source data
       
  4510 @SYMTestStatus      Implemented
       
  4511 */	
       
  4512 void TestTFileText()
       
  4513 	{
       
  4514 	TFileName fileName;
       
  4515 	fileName.Append(gDriveToTest);
       
  4516 	fileName.Append(KTestPath);
       
  4517 	fileName.Append(_L("test.txt"));
       
  4518 	TInt r;
       
  4519 	RFile64 file64;
       
  4520 	TInt64 sizeK3GB = K3GB;
       
  4521 	
       
  4522 	test.Next(_L("Open test file and get the file size using RFile64::Size() and set the file handle to TFileText object\n"));
       
  4523 	r = file64.Replace(TheFs,fileName,EFileRead|EFileWrite);
       
  4524 	test(r == KErrNone);
       
  4525 	r = file64.SetSize(sizeK3GB);
       
  4526 	test(r == KErrNone);
       
  4527 	TFileText fileText;
       
  4528 	fileText.Set(file64);
       
  4529 	
       
  4530 	test.Next(_L("Seek to the file end using TFileText::Seek()\n"));
       
  4531 	r = fileText.Seek(ESeekEnd);
       
  4532 	test(r == KErrNone);
       
  4533 	
       
  4534 	test.Next(_L("Get current file position using RFile64::Seek() and verify it is at file end.\n"));
       
  4535 	TInt64 pos = 0;
       
  4536 	r = file64.Seek(ESeekCurrent, pos);
       
  4537 	test(r == KErrNone);
       
  4538 	test(pos == sizeK3GB);
       
  4539 	
       
  4540 	test.Next(_L("Write data to the file using RFile64::Write\n"));
       
  4541 	HBufC* record = HBufC::NewL(10);
       
  4542 	record->Des().SetLength(10);
       
  4543 	record->Des().Fill('A');
       
  4544 	TPtrC8 bufPtr;
       
  4545 	bufPtr.Set((TUint8*)record->Ptr(),record->Size()); // Size() returns length in bytes
       
  4546 	r = file64.Write(pos,bufPtr);
       
  4547 	test(r == KErrNone);
       
  4548 	
       
  4549 	test.Next(_L("Read data using TFileText::Read\n"));
       
  4550 	TBuf<20> fileTextReadBuf;
       
  4551 	file64.Seek(ESeekStart,pos);//seek to the position where the data has been written
       
  4552 	r = fileText.Read(fileTextReadBuf);
       
  4553 	test(fileTextReadBuf == _L("AAAAAAAAAA"));
       
  4554 	
       
  4555 	test.Next(_L("Seek to the file end using TFileText::Seek(ESeekEnd)\n"));
       
  4556 	r = fileText.Seek(ESeekEnd);
       
  4557 	test(r == KErrNone);
       
  4558 	
       
  4559 	test.Next(_L("Write known data using TFileText::Write\n"));
       
  4560 	TBuf<20> fileTextWriteBuf(_L("AAAAAAAAAA"));
       
  4561 	pos = 0;
       
  4562 	r = file64.Seek(ESeekCurrent,pos);
       
  4563 	r = fileText.Write(fileTextWriteBuf);
       
  4564 	test(r == KErrNone);
       
  4565 	
       
  4566 	test.Next(_L("Read the data using RFile64::Read\n"));
       
  4567 	TBuf8<20> file64ReadBuf;
       
  4568 	file64ReadBuf.Zero();
       
  4569 	r = file64.Read(pos,file64ReadBuf);
       
  4570 	r = bufPtr.Compare(file64ReadBuf);
       
  4571 	test (r == KErrNone);
       
  4572 	
       
  4573 	file64.Close();
       
  4574 	
       
  4575 	r = TheFs.Delete(fileName);
       
  4576 	test(r == KErrNone);
       
  4577 	User::Free(record);
       
  4578 	}
       
  4579 
       
  4580 
       
  4581 /**
       
  4582 @SYMTestCaseID      PBASE-T_FILE64BIT-0789
       
  4583 @SYMTestPriority    High
       
  4584 @SYMTestRequirement REQ9526
       
  4585 @SYMTestType        CIT
       
  4586 @SYMTestCaseDesc    Test the file read and write with locking a specified region of the file.
       
  4587 @SYMTestActions     
       
  4588 1) Set the File Size to 2GB-1
       
  4589 2) Lock a section of large file, position =0, aLength = 2GB-1
       
  4590 3) Read from position = 2GB-100 and length = 99
       
  4591 4) Write to the File, position = 2GB-100 and length = 99
       
  4592 5) Use  RFs::ReadFileSection () and with position = 2GB -100 and length = 99
       
  4593 6) Set the file size to 4GB-1
       
  4594 7) Lock a section of large file, position =2GB, aLength = 4GB-1
       
  4595 8) Write to the File, position = 4GB-100 and length = 99
       
  4596 @SYMTestExpectedResults 
       
  4597 1) KErrNone
       
  4598 2) KErrNone, file lock successful
       
  4599 3) KErrNone, read is successful
       
  4600 4) KErrLocked, write is unsuccessful
       
  4601 5) KErrNone, read is successful
       
  4602 6) KErrNone
       
  4603 7) KErrNone, lock is successful
       
  4604 8) KErrLocked, write is unsuccessful
       
  4605 @SYMTestStatus      Implemented
       
  4606 */
       
  4607 void TestReadWriteLock()
       
  4608 	{
       
  4609 	TBuf8<0x63> readBuf;
       
  4610 	TBuf8<0x63> buf;
       
  4611 	TFileName fileName;
       
  4612 	fileName.Append(gDriveToTest);
       
  4613 	fileName.Append(KTestPath);
       
  4614 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  4615 	
       
  4616 	test.Start(_L("Test Lock Functionality\n"));
       
  4617 	TestRFile1.Replace(fileName, EFileWrite|EFileShareAny);
       
  4618 	TestRFile2.Open(fileName);
       
  4619 
       
  4620 	test.Next(_L("Creating test pattern"));
       
  4621 	pattern.SetLength(pattern.MaxLength());
       
  4622 	for (TInt i = 0;i<pattern.MaxLength();i++)
       
  4623 		pattern[i] = (TText8)(i + 10);
       
  4624 		
       
  4625 	TInt64 size = 0;
       
  4626 	test.Next(_L("Multi file tests"));
       
  4627 	
       
  4628 	test.Next(_L("Set the File Size to 2GB-1\n"));
       
  4629 	TestRFile1.SetSize(K2GBMinusOne);
       
  4630 	TestRFile1.Size(size);
       
  4631 	test(size == K2GBMinusOne);
       
  4632 	
       
  4633 	test.Next(_L("Lock a section of large file, position =0, aLength = 2GB-1\n"));
       
  4634 	TestRFile1.Lock(0,K2GBMinusOne);
       
  4635 	TestRFile1.LockE(0,K2GBMinusOne);
       
  4636 	
       
  4637 	test.Next(_L("Read from position = 2GB-100 and length = 99\n"));
       
  4638 	TestRFile1.Read(K2GBMinus100,buf,99);
       
  4639 	
       
  4640 	test.Next(_L("Write to the File, position = 2GB-100 and length = 99\n"));
       
  4641 	TestRFile2.WriteE(K2GBMinus100,pattern,99);
       
  4642 	TestRFile1.UnLock(0,K2GBMinusOne);
       
  4643 	TestRFile2.Write(K2GBMinus100,pattern,99);
       
  4644 
       
  4645 	test.Next(_L("Use  RFs::ReadFileSection () and with position = 2GB -100 and length = 99\n"));
       
  4646 	TestRFs.ReadFileSection(fileName,K2GBMinus100,readBuf,99);
       
  4647 	
       
  4648 	test.Next(_L("Set the file size to 4GB-1\n"));
       
  4649 	TestRFile1.SetSize(K4GBMinusOne);
       
  4650 	TestRFile1.Size(size);
       
  4651 	test(size == K4GBMinusOne);
       
  4652 
       
  4653     if(KFileSizeMaxLargerThan4GBMinusOne)
       
  4654         {	    
       
  4655 
       
  4656 	    test.Next(_L("Lock a section of large file, position =2GB, aLength = 4GB-1\n"));
       
  4657 	    TestRFile1.Lock(K2GB,K4GBMinusOne);
       
  4658 	    TestRFile1.LockE(K2GB,K4GBMinusOne);
       
  4659 	    
       
  4660 	    test.Next(_L("Write to the File, position = 4GB-100 and length = 99\n"));
       
  4661 	    TestRFile2.WriteE(K4GBMinus100,pattern,99);
       
  4662 	    TestRFile1.UnLock(K2GB,K4GBMinusOne);
       
  4663 	    }
       
  4664     
       
  4665     TestRFile2.Close();
       
  4666 	TestRFile1.Close();
       
  4667 	
       
  4668 	TInt r = TheFs.Delete(fileName);
       
  4669 	test(r == KErrNone);
       
  4670 	test.End();
       
  4671 	}
       
  4672 
       
  4673 /**
       
  4674 @SYMTestCaseID      PBASE-T_FILE64BIT-0790
       
  4675 @SYMTestPriority    High
       
  4676 @SYMTestRequirement REQ9526
       
  4677 @SYMTestType        CIT
       
  4678 @SYMTestCaseDesc    Test the files unlock functionality and performs file read and write.
       
  4679 @SYMTestActions     
       
  4680 1) Set the File Size to 2GB-1
       
  4681 2) Lock a section of file, position =0, aLength = 2GB-1
       
  4682 3) UnLock a section of large file, position = 0, aLength = 2GB-1
       
  4683 4) Read a file with position = 2GB-100 and length = 99
       
  4684 5) Write to a file with position = 2GB-100 and length = 99
       
  4685 6) Use RFs::ReadFileSection() to read from a file, position = 0 and length = 100(Open mode = EFileShareAny)
       
  4686 7) Set the File Size to 4GB-1
       
  4687 8) Lock a section of large file, position =2GB, aLength = 4GB-1
       
  4688 9) UnLock a section of large file, position =2GB, aLength = 4GB-1
       
  4689 10)Write to the File, position = 4GB-100 and length = 99
       
  4690 @SYMTestExpectedResults returns 
       
  4691 1) KErrNone
       
  4692 2) KErrNone, file locked successfully
       
  4693 3) KErrNone, File unlocked successfully
       
  4694 4) KErrNone, read is successful
       
  4695 5) KErrNone, write is successful
       
  4696 6) KErrNone, read is successful
       
  4697 7) KErrNone
       
  4698 8) KErrNone, lock is successful
       
  4699 9) KErrNone, unlock is successful
       
  4700 10)KErrNone, write is successful
       
  4701 @SYMTestStatus      Implemented
       
  4702 */
       
  4703 void TestUnLock()
       
  4704 	{
       
  4705 	TBuf8<0x63> buf;
       
  4706 	TBuf8<0x64> readBuf;
       
  4707 	TInt64 size = 0;
       
  4708 	TFileName fileName;
       
  4709 	fileName.Append(gDriveToTest);
       
  4710 	fileName.Append(KTestPath);
       
  4711 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  4712 	
       
  4713 	test.Start(_L("Test Unlock Functionality\n"));
       
  4714 	TestRFile1.Replace(fileName,EFileWrite|EFileShareAny);
       
  4715 	TestRFile2.Open(fileName);
       
  4716 
       
  4717 	test.Next(_L("Creating test pattern"));
       
  4718 	pattern.SetLength(pattern.MaxLength());
       
  4719 	for (TInt i = 0;i < pattern.MaxLength();i++)
       
  4720 		pattern[i] = (TText8)(i+10);
       
  4721 
       
  4722 	test.Next(_L("Set the File Size to 2GB-1\n"));
       
  4723 	TestRFile1.SetSize(K2GBMinusOne);
       
  4724 	TestRFile1.Size(size);
       
  4725 	test(size == K2GBMinusOne);
       
  4726 	
       
  4727 	test.Next(_L("Lock a section of file, position =0, aLength = 2GB-1\n"));
       
  4728 	TestRFile1.Lock(0,K2GBMinusOne);
       
  4729 	TestRFile1.LockE(0,K2GBMinusOne);
       
  4730 	
       
  4731 	test.Next(_L("UnLock a section of large file, position = 0, aLength = 2GB-1\n"));
       
  4732 	TestRFile1.UnLock(0,K2GBMinusOne);
       
  4733 	
       
  4734 	test.Next(_L("Read a file with position = 2GB-100 and length = 99\n"));
       
  4735 	TestRFile1.Read(K2GBMinus100,buf,99);
       
  4736 	
       
  4737 	test.Next(_L("Write to a file with position = 2GB-100 and length = 99\n"));
       
  4738 	TestRFile2.Write(K2GBMinus100,pattern,99);
       
  4739 	TestRFile1.Read(K2GBMinus100,buf,99);
       
  4740 	test(pattern == buf); // Written data == Read data
       
  4741 
       
  4742 	test.Next(_L("Use RFs::ReadFileSection() to read from a file, position = 0 and length = 100(Open mode = EFileShareAny)\n"));
       
  4743 	TFileName fileName1;
       
  4744 	fileName1.Append(gDriveToTest);
       
  4745 	fileName1.Append(KTestPath);
       
  4746 	fileName1.Append(_L("File2GB.txt"));
       
  4747 	RFile64 file;
       
  4748 	TInt r = file.Replace(TheFs, fileName1, EFileWrite);
       
  4749 	test (r == KErrNone);
       
  4750 	file.SetSize(K2GB);
       
  4751 	test (r == KErrNone);
       
  4752 	file.Close();
       
  4753 	TestRFs.ReadFileSection(fileName1,0,readBuf,100);
       
  4754 	r = TheFs.Delete(fileName1);
       
  4755 	test (r == KErrNone);
       
  4756 	test.Next(_L("Creating test pattern"));
       
  4757 	
       
  4758 	TBuf8<0x63> writeBuf63;
       
  4759 	TBuf8<0x63> readBuf63;
       
  4760 	for (TInt count = 0; count < 0x63; count++)
       
  4761 		{
       
  4762 		writeBuf63.Append((TChar)count);
       
  4763 		}
       
  4764 	
       
  4765 	test.Next(_L("Set the File Size to 4GB-1\n"));
       
  4766 	TestRFile1.SetSize(K4GBMinusOne);
       
  4767 	TestRFile1.Size(size);
       
  4768 	test(size == K4GBMinusOne);
       
  4769 	 
       
  4770     if(KFileSizeMaxLargerThan4GBMinusOne)
       
  4771         {	    
       
  4772 	    test.Next(_L("Lock a section of large file, position =2GB, aLength = 4GB-1\n"));
       
  4773 	    TestRFile1.Lock(K2GB,K4GBMinusOne);
       
  4774 
       
  4775 	
       
  4776 	test.Next(_L("UnLock a section of large file, position =2GB, aLength = 4GB-1\n"));
       
  4777 	TestRFile1.UnLock(K2GB,K4GBMinusOne);
       
  4778 	
       
  4779 	test.Next(_L("Write to the File, position = 4GB-100 and length = 99\n"));
       
  4780 	TestRFile2.Write(K4GBMinus100,writeBuf63,99);
       
  4781   	TestRFile2.Read(K4GBMinus100,readBuf63,99);
       
  4782    	test(writeBuf63 == readBuf63); // Written data == Read data
       
  4783         }
       
  4784 	
       
  4785 	TestRFile2.Close();
       
  4786 	TestRFile1.Close();
       
  4787 	
       
  4788 	r = TheFs.Delete(fileName);
       
  4789 	test(r == KErrNone);
       
  4790 	test.End();
       
  4791 	}
       
  4792 
       
  4793 /**
       
  4794 @SYMTestCaseID      PBASE-T_FILE64BIT-2349
       
  4795 @SYMTestPriority    High
       
  4796 @SYMTestRequirement REQ9529
       
  4797 @SYMTestType        CIT
       
  4798 @SYMTestCaseDesc    Test RFile64::Seek(), Read() & Write() functionality for synchronous calls
       
  4799 
       
  4800 					IMPORT_C TInt Read(TDes8 &aDes) const;
       
  4801 					IMPORT_C TInt Write(const TDesC8 &aDes);
       
  4802 @SYMTestActions     
       
  4803 1) Open the large file, Set the File Size to 2GB-1
       
  4804 2) File Seek with: Mode= ESeekCurrent, position = 2GB-100
       
  4805 3) Write to a file with current position and length = 99
       
  4806 4) Seek the file: Mode= ESeekStart, position = 2GB-100
       
  4807 5) Read a file with current position and length =99
       
  4808 6) Compare the read data with written data
       
  4809 7) Seek the file: Mode = ESeekEnd
       
  4810 8) Write to a file with current position and length =99
       
  4811 9) Set the file size to 4GB-1
       
  4812 10)Check for FAT32 File system. Seek the file: Mode = ESeekEnd
       
  4813 11)Write to a file with current position and length =99
       
  4814 12)If NGFS is supported,  Set the file size to 4GB+10
       
  4815 13)Seek the file: Mode = ESeekEnd
       
  4816 14)Write to a file with current position and length =99
       
  4817 @SYMTestExpectedResults 
       
  4818 1) KErrNone, open is successful
       
  4819 2) KErrNone, Seek Position = 2GB-100
       
  4820 3) KErrNone, write is successful
       
  4821 4) KErrNone, Seek Position = 2GB-100
       
  4822 5) KErrNone, read is successful
       
  4823 6) Read data == written data
       
  4824 7) KErrNone
       
  4825 8) KErrNone, write is successful
       
  4826 9) KErrNone
       
  4827 10)KErrNone
       
  4828 11)
       
  4829 12)KErrNone
       
  4830 13)KErrNone
       
  4831 14)KErrNone
       
  4832 @SYMTestStatus      Implemented
       
  4833 */
       
  4834 void TestSeekReadWrite()
       
  4835 	{
       
  4836 	TBuf8<0x63> readBuf;
       
  4837 	TBuf8<0x63> writeBuf;
       
  4838 	TInt count;
       
  4839 	TInt64 seekPos = 0;
       
  4840 	TFileName fileName;
       
  4841 	fileName.Append(gDriveToTest);
       
  4842 	fileName.Append(KTestPath);
       
  4843 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  4844 	
       
  4845 	test.Start(_L("Test RFile64::Seek(), RFile64::Read() & RFile64::Write() for synchronous calls\n"));
       
  4846 	
       
  4847 	test.Next(_L("Open the large file, Set the File Size to 2GB-1\n"));
       
  4848 	TestRFile1.Replace(fileName,EFileWrite|EFileShareAny);
       
  4849 	
       
  4850 	for (count = 0; count < 0x63; count++)
       
  4851 		{
       
  4852 		writeBuf.Append(count);
       
  4853 		}
       
  4854 
       
  4855 	test.Next(_L("Single file tests"));
       
  4856 	TInt64 size2GBMinusOne = 1;
       
  4857 	size2GBMinusOne <<= 31;
       
  4858 	size2GBMinusOne -= 1;
       
  4859 	TestRFile1.SetSize(size2GBMinusOne);
       
  4860 
       
  4861 	test.Next(_L("File Seek with: Mode= ESeekCurrent, position = 2GB-100\n"));
       
  4862 	seekPos = K2GBMinus100;
       
  4863 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  4864 	seekPos = 0;
       
  4865 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  4866 	test(seekPos == K2GBMinus100);
       
  4867 	
       
  4868 	test.Next(_L("Write to a file with current position and length = 99\n"));
       
  4869 	TestRFile1.Write(writeBuf); // Write 99 bytes of data to a file
       
  4870 	
       
  4871 	test.Next(_L("Seek the file: Mode= ESeekStart, position = 2GB-100\n"));
       
  4872 	seekPos = 0;
       
  4873 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  4874 	test(seekPos == K2GBMinusOne);
       
  4875 	
       
  4876 	test.Next(_L("Read a file with current position and length =99\n"));
       
  4877 	seekPos = K2GBMinus100;
       
  4878 	TestRFile1.Seek(ESeekStart,seekPos);
       
  4879 	TestRFile1.Read(readBuf);
       
  4880 	
       
  4881 	test.Next(_L("Compare the read data with written data\n"));
       
  4882 	test(writeBuf == readBuf); // Written data == Read data
       
  4883 	
       
  4884 	TBuf8<0x63> writeBuf99;
       
  4885 	TBuf8<0x63> readBuf99;
       
  4886 	TInt64 size = 0;
       
  4887 	
       
  4888 	test.Next(_L("Seek the file: Mode = ESeekEnd\n"));
       
  4889 	TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  4890 	test(seekPos == K2GBMinusOne);
       
  4891 	
       
  4892 	test.Next(_L("Write to a file with current position and length =99\n"));
       
  4893 	for (count = 0; count < 0x63; count++)
       
  4894 		{
       
  4895 		writeBuf99.Append(count+1);
       
  4896 		}
       
  4897 	TestRFile1.Write(writeBuf99);
       
  4898 	seekPos = K2GBMinusOne;
       
  4899 	TestRFile1.Seek(ESeekStart,seekPos);
       
  4900 	TestRFile1.Read(readBuf99);
       
  4901 	test(writeBuf99 == readBuf99); // Written data == Read data
       
  4902 	// Query Size
       
  4903 	TestRFile1.Size(size);
       
  4904 	test(size == K2GBPlus98); // Validate the file size
       
  4905 
       
  4906 	TBuf8<0x63> readBufx63;
       
  4907 	TBuf8<0x63> writeBufx63;
       
  4908 	size = 0;
       
  4909 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse) //File Systems supporting size of upto 4GB-1
       
  4910 		{
       
  4911 		TestRFile1.SetSize(K4GBMinusOne);
       
  4912 		TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  4913 		test(seekPos == K4GBMinusOne);
       
  4914 		for (TInt count = 0; count < 0x63; count++)
       
  4915 			{
       
  4916 			writeBufx63.Append(count+2);
       
  4917 			}
       
  4918 		TestRFile1.Write(writeBufx63);
       
  4919 		TestRFile1.Size(size);
       
  4920 		test(size == K4GBMinusOne);
       
  4921 		}
       
  4922 	else
       
  4923 		{ //-- the currenc file system supports files larger than 4G-1
       
  4924 		TestRFile1.SetSize(K4GB+10);
       
  4925 		TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  4926 		test(seekPos == K4GB+10);
       
  4927 		for (TInt count = 0; count < 0x63; count++)
       
  4928 			{
       
  4929 			writeBufx63.Append(count+2);
       
  4930 			}
       
  4931 		TestRFile1.Write(writeBufx63);
       
  4932 		TestRFile1.Size(size);
       
  4933 		test(size == K4GB+109);	
       
  4934 		TestRFile1.Read(readBufx63); // validating the content
       
  4935 		}
       
  4936 
       
  4937 	TestRFile1.Close();
       
  4938 	
       
  4939 	TInt r = TheFs.Delete(fileName);
       
  4940 	test(r == KErrNone);
       
  4941 	test.End();	
       
  4942 	}	
       
  4943 
       
  4944 /**
       
  4945 @SYMTestCaseID      PBASE-T_FILE64BIT-2350
       
  4946 @SYMTestPriority    High
       
  4947 @SYMTestRequirement REQ9529
       
  4948 @SYMTestType        CIT
       
  4949 @SYMTestCaseDesc    Test RFile64::Seek(), Read() & Write() functionality for asynchronous calls
       
  4950 
       
  4951 					IMPORT_C void Read(TDes8 &aDes, TRequestStatus &aStatus) const;
       
  4952 					IMPORT_C void Write(const TDesC8 &aDes, TRequestStatus &aStatus);
       
  4953 @SYMTestActions     
       
  4954 1) Open the large file, Set the File Size to 2GB-1
       
  4955 2) File Seek with: Mode= ESeekCurrent, position = 2GB-100
       
  4956 3) Write to a file with current position and length = 99
       
  4957 4) Seek the file: Mode= ESeekStart, position = 2GB-100
       
  4958 5) Read a file with current position and length =99
       
  4959 6) Compare the read data with written data
       
  4960 7) Seek the file: Mode = ESeekEnd
       
  4961 8) Write to a file with current position and length =99
       
  4962 9) Set the file size to 4GB-1
       
  4963 10)Check for FAT32 File system. Seek the file: Mode = ESeekEnd
       
  4964 11)Write to a file with current position and length =99
       
  4965 12)If NGFS is supported,  Set the file size to 4GB+10
       
  4966 13)Seek the file: Mode = ESeekEnd
       
  4967 14)Write to a file with current position and length =99
       
  4968 @SYMTestExpectedResults 
       
  4969 1) KErrNone, open is successful
       
  4970 2) KErrNone, Seek Position = 2GB-100
       
  4971 3) KErrNone, write is successful
       
  4972 4) KErrNone, Seek Position = 2GB-100
       
  4973 5) KErrNone, read is successful
       
  4974 6) Read data == written data
       
  4975 7) KErrNone
       
  4976 8) KErrNone, write is successful
       
  4977 9) KErrNone
       
  4978 10)KErrNone
       
  4979 11)
       
  4980 12)KErrNone
       
  4981 13)KErrNone
       
  4982 14)KErrNone
       
  4983 @SYMTestStatus      Implemented
       
  4984 */
       
  4985 void TestSeekAsyncReadWrite()
       
  4986 	{
       
  4987 	TBuf8<0x63> readBuf;
       
  4988 	TBuf8<0x63> writeBuf;
       
  4989 	TInt count;
       
  4990 	TFileName fileName;
       
  4991 	fileName.Append(gDriveToTest);
       
  4992 	fileName.Append(KTestPath);
       
  4993 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  4994 	
       
  4995 	test.Start(_L("Test RFile64::Seek(), RFile64::Read() & RFile64::Write() for Asynchronous calls\n"));
       
  4996 	
       
  4997 	TestRFile1.Replace(fileName,EFileWrite|EFileShareAny);
       
  4998 	
       
  4999 	for (count = 0; count < 0x63; count++)
       
  5000 		{
       
  5001 		writeBuf.Append(count);
       
  5002 		}
       
  5003 
       
  5004 	test.Next(_L("Single file tests"));
       
  5005 	TestRFile1.SetSize(K2GBMinusOne);
       
  5006 	TInt64 seekPos = K2GBMinus100;
       
  5007 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  5008 	seekPos = 0;
       
  5009 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  5010 	test(seekPos == K2GBMinus100);
       
  5011 	
       
  5012 	TRequestStatus status1 = KRequestPending;
       
  5013 	TestRFile1.Write(writeBuf,status1); // Write 99 bytes of data to a file
       
  5014 	seekPos = 0;
       
  5015 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  5016 	test(seekPos == K2GBMinusOne);
       
  5017 	seekPos = K2GBMinus100;
       
  5018 	TestRFile1.Seek(ESeekStart,seekPos);
       
  5019 	TRequestStatus status2 = KRequestPending;
       
  5020 	TestRFile1.Read(readBuf, status2);
       
  5021 	test(writeBuf == readBuf); // Written data == Read data
       
  5022 	
       
  5023 	TBuf8<0x63> writeBuf99;
       
  5024 	TBuf8<0x63> readBuf99;
       
  5025 	TInt64 size = 0;
       
  5026 	TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  5027 	test(seekPos == K2GBMinusOne);
       
  5028 	for (count = 0; count < 0x63; count++)
       
  5029 		{
       
  5030 		writeBuf99.Append(count+1);
       
  5031 		}
       
  5032 	TRequestStatus status3 = KRequestPending;
       
  5033 	TestRFile1.Write(writeBuf99, status3);
       
  5034 	seekPos = K2GBMinusOne;
       
  5035 	TestRFile1.Seek(ESeekStart,seekPos);
       
  5036 	TRequestStatus status4 = KRequestPending;
       
  5037 	TestRFile1.Read(readBuf99, status4);
       
  5038 	test(writeBuf99 == readBuf99); // Written data == Read data
       
  5039 	// Query Size
       
  5040 	TestRFile1.Size(size);
       
  5041 	test(size == K2GBPlus98); // Validate the file size
       
  5042 
       
  5043 	TBuf8<0x63> readBufx63;
       
  5044 	TBuf8<0x63> writeBufx63;
       
  5045 	size = 0;
       
  5046 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)//File Systems supporting size of upto 4GB-1
       
  5047 		{
       
  5048 		TestRFile1.SetSize(K4GBMinusOne);
       
  5049 		TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  5050 		test(seekPos == K4GBMinusOne);
       
  5051 		for (TInt count = 0; count < 0x63; count++)
       
  5052 			{
       
  5053 			writeBufx63.Append(count+2);
       
  5054 			}
       
  5055 		TRequestStatus status5 = KRequestPending;
       
  5056 		TestRFile1.Write(writeBufx63, status5);
       
  5057 		TestRFile1.Size(size);
       
  5058 		test(size == K4GBMinusOne);
       
  5059 		}
       
  5060     else
       
  5061 		{
       
  5062 		TestRFile1.SetSize(K4GB+10);
       
  5063 		TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  5064 		test(seekPos == K4GB+10);
       
  5065 		for (TInt count = 0; count < 0x63; count++)
       
  5066 			{
       
  5067 			writeBufx63.Append(count+2);
       
  5068 			}
       
  5069 		TRequestStatus status7 = KRequestPending;			
       
  5070 		TestRFile1.Write(writeBufx63, status7);
       
  5071 		TestRFile1.Size(size);
       
  5072 		test(size == K4GB+109);
       
  5073 		TRequestStatus status8 = KRequestPending;;	
       
  5074 		TestRFile1.Read(readBufx63, status8); // validating the content
       
  5075 		}
       
  5076 	TestRFile1.Close();
       
  5077 	
       
  5078 	TInt r = TheFs.Delete(fileName);
       
  5079 	test(r == KErrNone);
       
  5080 	test.End();	
       
  5081 	}	
       
  5082 
       
  5083 /**
       
  5084 @SYMTestCaseID      PBASE-T_FILE64BIT-2351
       
  5085 @SYMTestPriority    High
       
  5086 @SYMTestRequirement REQ9529
       
  5087 @SYMTestType        CIT
       
  5088 @SYMTestCaseDesc    Test RFile64::Seek(), Read() & Write() functionality for synchronous calls with length
       
  5089 
       
  5090 					IMPORT_C TInt Read(TDes8 &aDes, TInt aLength) const;
       
  5091 					IMPORT_C TInt Write(const TDesC8 &aDes, TInt aLength);
       
  5092 @SYMTestActions     
       
  5093 1) Open the large file, Set the File Size to 2GB-1
       
  5094 2) File Seek with: Mode= ESeekCurrent, position = 2GB-100
       
  5095 3) Write to a file with current position and length = 99
       
  5096 4) Seek the file: Mode= ESeekStart, position = 2GB-100
       
  5097 5) Read a file with current position and length =99
       
  5098 6) Compare the read data with written data
       
  5099 7) Seek the file: Mode = ESeekEnd
       
  5100 8) Write to a file with current position and length =99
       
  5101 9) Set the file size to 4GB-1
       
  5102 10)Check for FAT32 File system. Seek the file: Mode = ESeekEnd
       
  5103 11)Write to a file with current position and length =99
       
  5104 12)If NGFS is supported,  Set the file size to 4GB+10
       
  5105 13)Seek the file: Mode = ESeekEnd
       
  5106 14)Write to a file with current position and length =99
       
  5107 @SYMTestExpectedResults 
       
  5108 1) KErrNone, open is successful
       
  5109 2) KErrNone, Seek Position = 2GB-100
       
  5110 3) KErrNone, write is successful
       
  5111 4) KErrNone, Seek Position = 2GB-100
       
  5112 5) KErrNone, read is successful
       
  5113 6) Read data == written data
       
  5114 7) KErrNone
       
  5115 8) KErrNone, write is successful
       
  5116 9) KErrNone
       
  5117 10)KErrNone
       
  5118 11)
       
  5119 12)KErrNone
       
  5120 13)KErrNone
       
  5121 14)KErrNone
       
  5122 @SYMTestStatus      Implemented
       
  5123 */
       
  5124 void TestSeekReadWriteLen()
       
  5125 	{
       
  5126 	TBuf8<0x63> readBuf;
       
  5127 	TBuf8<0x63> writeBuf;
       
  5128 	TInt count;
       
  5129 	TFileName fileName;
       
  5130 	fileName.Append(gDriveToTest);
       
  5131 	fileName.Append(KTestPath);
       
  5132 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  5133 	
       
  5134 	test.Start(_L("Test RFile64::Seek(), RFile64::Read() & RFile64::Write() with Length\n"));
       
  5135 	
       
  5136 	TestRFile1.Replace(fileName,EFileWrite|EFileShareAny);
       
  5137 	
       
  5138 	for (count = 0; count < 0x63; count++)
       
  5139 		{
       
  5140 		writeBuf.Append(count);
       
  5141 		}
       
  5142 
       
  5143 	test.Next(_L("Single file tests"));
       
  5144 	
       
  5145 	test.Next(_L("Open the large file, Set the File Size to 2GB-1\n"));
       
  5146 	TestRFile1.SetSize(K2GBMinusOne);
       
  5147 	
       
  5148 	test.Next(_L("File Seek with: Mode= ESeekCurrent, position = 2GB-100\n"));
       
  5149 	TInt64 seekPos = K2GBMinus100;
       
  5150 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  5151 	seekPos = 0;
       
  5152 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  5153 	test(seekPos == K2GBMinus100);
       
  5154 	
       
  5155 	test.Next(_L("Write to a file with current position and length = 99\n"));
       
  5156 	TestRFile1.Write(writeBuf, 99); // Write 99 bytes of data to a file
       
  5157 	seekPos = 0;
       
  5158 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  5159 	test(seekPos == K2GBMinusOne);
       
  5160 	
       
  5161 	test.Next(_L("Seek the file: Mode= ESeekStart, position = 2GB-100\n"));
       
  5162 	seekPos = K2GBMinus100;
       
  5163 	TestRFile1.Seek(ESeekStart,seekPos);
       
  5164 	
       
  5165 	test.Next(_L("Read a file with current position and length =99\n"));
       
  5166 	TestRFile1.Read(readBuf, 99);
       
  5167 	
       
  5168 	test.Next(_L("Compare the read data with written data\n"));
       
  5169 	test(writeBuf == readBuf); // Written data == Read data
       
  5170 	
       
  5171 	test.Next(_L("Seek the file: Mode = ESeekEnd\n"));
       
  5172 	TBuf8<0x63> writeBuf99;
       
  5173 	TBuf8<0x63> readBuf99;
       
  5174 	TInt64 size = 0;
       
  5175 	TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  5176 	test(seekPos == K2GBMinusOne);
       
  5177 	
       
  5178 	test.Next(_L("Write to a file with current position and length =99\n"));
       
  5179 	for (count = 0; count < 0x63; count++)
       
  5180 		{
       
  5181 		writeBuf99.Append(count+1);
       
  5182 		}
       
  5183 	TestRFile1.Write(writeBuf99, 99);
       
  5184 	seekPos = K2GBMinusOne;
       
  5185 	TestRFile1.Seek(ESeekStart,seekPos);
       
  5186 	TestRFile1.Read(readBuf99, 99);
       
  5187 	test(writeBuf99 == readBuf99); // Written data == Read data
       
  5188 	// Query Size
       
  5189 	TestRFile1.Size(size);
       
  5190 	test(size == K2GBPlus98); // Validate the file size
       
  5191 
       
  5192 	TBuf8<0x63> readBufx63;
       
  5193 	TBuf8<0x63> writeBufx63;
       
  5194 	size = 0;
       
  5195 	if(KFileSizeMaxLargerThan4GBMinusOne == EFalse)//File Systems supporting size of upto 4GB-1
       
  5196 		{
       
  5197 		TestRFile1.SetSize(K4GBMinusOne);
       
  5198 		TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  5199 		test(seekPos == K4GBMinusOne);
       
  5200 		for (TInt count = 0; count < 0x63; count++)
       
  5201 			{
       
  5202 			writeBufx63.Append(count+2);
       
  5203 			}
       
  5204 		TestRFile1.Write(writeBufx63, 99);
       
  5205 		TestRFile1.Size(size);
       
  5206 		test(size == K4GBMinusOne);
       
  5207 		}
       
  5208     else
       
  5209 		{
       
  5210 		TestRFile1.SetSize(K4GB+10);
       
  5211 		TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  5212 		test(seekPos == K4GB+10);
       
  5213 		for (TInt count = 0; count < 0x63; count++)
       
  5214 			{
       
  5215 			writeBufx63.Append(count+2);
       
  5216 			}
       
  5217 		TestRFile1.Write(writeBufx63, 99);
       
  5218 		TestRFile1.Size(size);
       
  5219 		test(size == K4GB+109);	
       
  5220 		TestRFile1.Read(readBufx63, 99); // validating the content
       
  5221 		}
       
  5222 
       
  5223 	TestRFile1.Close();
       
  5224 	
       
  5225 	TInt r = TheFs.Delete(fileName);
       
  5226 	test(r == KErrNone);
       
  5227 	test.End();	
       
  5228 	}	
       
  5229 /**
       
  5230 @SYMTestCaseID      PBASE-T_FILE64BIT-2352
       
  5231 @SYMTestPriority    High
       
  5232 @SYMTestRequirement REQ9529
       
  5233 @SYMTestType        CIT
       
  5234 @SYMTestCaseDesc    Test RFile64::Seek(), Read() & Write() functionality for asynchronous calls with length
       
  5235 					IMPORT_C void Read(TDes8 &aDes, TRequestStatus &aStatus) const;
       
  5236 					IMPORT_C void Write(const TDesC8 &aDes, TRequestStatus &aStatus);
       
  5237 @SYMTestActions     
       
  5238 1) Open the large file, Set the File Size to 2GB-1
       
  5239 2) File Seek with: Mode= ESeekCurrent, position = 2GB-100
       
  5240 3) Write to a file with current position and length = 99
       
  5241 4) Seek the file: Mode= ESeekStart, position = 2GB-100
       
  5242 5) Read a file with current position and length =99
       
  5243 6) Compare the read data with written data
       
  5244 7) Seek the file: Mode = ESeekEnd
       
  5245 8) Write to a file with current position and length =99
       
  5246 9) Set the file size to 4GB-1
       
  5247 10)Check for FAT32 File system. Seek the file: Mode = ESeekEnd
       
  5248 11)Write to a file with current position and length =99
       
  5249 12)If NGFS is supported,  Set the file size to 4GB+10
       
  5250 13)Seek the file: Mode = ESeekEnd
       
  5251 14)Write to a file with current position and length =99
       
  5252 @SYMTestExpectedResults 
       
  5253 1) KErrNone, open is successful
       
  5254 2) KErrNone, Seek Position = 2GB-100
       
  5255 3) KErrNone, write is successful
       
  5256 4) KErrNone, Seek Position = 2GB-100
       
  5257 5) KErrNone, read is successful
       
  5258 6) Read data == written data
       
  5259 7) KErrNone
       
  5260 8) KErrNone, write is successful
       
  5261 9) KErrNone
       
  5262 10)KErrNone
       
  5263 11)
       
  5264 12)KErrNone
       
  5265 13)KErrNone
       
  5266 14)KErrNone
       
  5267 @SYMTestStatus      Implemented
       
  5268 */	
       
  5269 
       
  5270 void TestSeekAsyncReadWriteLen()
       
  5271 	{
       
  5272 	TBuf8<0x63> readBuf;
       
  5273 	TBuf8<0x63> writeBuf;
       
  5274 	TInt count;
       
  5275 	TFileName fileName;
       
  5276 	fileName.Append(gDriveToTest);
       
  5277 	fileName.Append(KTestPath);
       
  5278 	fileName.Append(_L("File4GBMinusOne.txt"));
       
  5279 	
       
  5280 	
       
  5281 	test.Start(_L("Test RFile64::Seek, RFile64::Read & RFile64::Write\n"));
       
  5282 	
       
  5283 	test.Next(_L("Open the large file, Set the File Size to 2GB-1\n"));
       
  5284 	TestRFile1.Replace(fileName,EFileWrite|EFileShareAny);
       
  5285 	
       
  5286 	for (count = 0; count < 0x63; count++)
       
  5287 		{
       
  5288 		writeBuf.Append(count);
       
  5289 		}
       
  5290 
       
  5291 	test.Next(_L("Single file tests"));
       
  5292 	TestRFile1.SetSize(K2GBMinusOne);
       
  5293 	
       
  5294 	test.Next(_L("File Seek with: Mode= ESeekCurrent, position = 2GB-100\n"));
       
  5295 	TInt64 seekPos = K2GBMinus100;
       
  5296 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  5297 	seekPos = 0;
       
  5298 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  5299 	test(seekPos == K2GBMinus100);
       
  5300 
       
  5301 	test.Next(_L("Write to a file with current position and length = 99"));
       
  5302 	TRequestStatus status1 = KRequestPending;
       
  5303 	TestRFile1.Write(writeBuf,99,status1); // Write 99 bytes of data to a file
       
  5304 	
       
  5305 	test.Next(_L("Seek the file: Mode= ESeekStart, position = 2GB-100\n"));
       
  5306 	seekPos = 0;
       
  5307 	TestRFile1.Seek(ESeekCurrent,seekPos);
       
  5308 	test(seekPos == K2GBMinusOne);
       
  5309 	seekPos = K2GBMinus100;
       
  5310 	TestRFile1.Seek(ESeekStart,seekPos);
       
  5311 	
       
  5312 	test.Next(_L("Read a file with current position and length =99\n"));
       
  5313 	TRequestStatus status2 = KRequestPending;
       
  5314 	TestRFile1.Read(readBuf,99,status2);
       
  5315 	
       
  5316 	test.Next(_L("Compare the read data with written data\n"));
       
  5317 	test(writeBuf == readBuf); // Written data == Read data
       
  5318 	
       
  5319 	test.Next(_L("Seek the file: Mode = ESeekEnd\n"));
       
  5320 	TBuf8<0x63> writeBuf99;
       
  5321 	TBuf8<0x63> readBuf99;
       
  5322 	TInt64 size = 0;
       
  5323 	TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  5324 	test(seekPos == K2GBMinusOne);
       
  5325 	for (count = 0; count < 0x63; count++)
       
  5326 		{
       
  5327 		writeBuf99.Append(count+1);
       
  5328 		}
       
  5329 		
       
  5330 	test.Next(_L("Write to a file with current position and length =99\n"));
       
  5331 	TRequestStatus status3 = KRequestPending;
       
  5332 	TestRFile1.Write(writeBuf99,99,status3);
       
  5333 	seekPos = K2GBMinusOne;
       
  5334 	TestRFile1.Seek(ESeekStart,seekPos);
       
  5335 	TRequestStatus status4 = KRequestPending;
       
  5336 	TestRFile1.Read(readBuf99,99,status4);
       
  5337 	test(writeBuf99 == readBuf99); // Written data == Read data
       
  5338 	// Query Size
       
  5339 	TestRFile1.Size(size);
       
  5340 	test(size == K2GBPlus98); // Validate the file size
       
  5341 	
       
  5342 	TBuf8<0x63> readBufx63;
       
  5343 	TBuf8<0x63> writeBufx63;
       
  5344 	size = 0;
       
  5345     if(KFileSizeMaxLargerThan4GBMinusOne == EFalse) //File Systems supporting size of upto 4GB-1
       
  5346 		{
       
  5347 		test.Next(_L("Set the file size to 4GB-1\n"));
       
  5348 		TestRFile1.SetSize(K4GBMinusOne);
       
  5349 		TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  5350 		test(seekPos == K4GBMinusOne);
       
  5351 		for (TInt count = 0; count < 0x63; count++)
       
  5352 			{
       
  5353 			writeBufx63.Append(count+2);
       
  5354 			}
       
  5355 		TRequestStatus status5 = KRequestPending;
       
  5356 		TestRFile1.Write(writeBufx63,99,status5);
       
  5357 		TestRFile1.Size(size);
       
  5358 		test(size == K4GBMinusOne);
       
  5359 		}
       
  5360     else
       
  5361 		{
       
  5362 		TestRFile1.SetSize(K4GB+10);
       
  5363 		TestRFile1.Seek(ESeekEnd,seekPos); // Seek to end
       
  5364 		test(seekPos == K4GB+10);
       
  5365 		for (TInt count = 0; count < 0x63; count++)
       
  5366 			{
       
  5367 			writeBufx63.Append(count+2);
       
  5368 			}
       
  5369 		TRequestStatus status7 = KRequestPending;			
       
  5370 		TestRFile1.Write(writeBufx63,99,status7);
       
  5371 		TestRFile1.Size(size);
       
  5372 		test(size == K4GB+109);
       
  5373 		TRequestStatus status8 = KRequestPending;;	
       
  5374 		TestRFile1.Read(readBufx63,99,status8); 
       
  5375 		}
       
  5376 	TestRFile1.Close();
       
  5377 	TInt r = TheFs.Delete(fileName);
       
  5378 	test(r == KErrNone);
       
  5379 	test.End();	
       
  5380 	}	
       
  5381 /**
       
  5382 @SYMTestCaseID      PBASE-T_FILE64BIT-2353
       
  5383 @SYMTestPriority    High
       
  5384 @SYMTestRequirement REQ9529
       
  5385 @SYMTestType        CIT
       
  5386 @SYMTestCaseDesc    Tests File resizing functionality
       
  5387 @SYMTestActions	
       
  5388 1) Create a file name "test" in write mode
       
  5389 2) Generate a random file size
       
  5390 3) Set the file size using RFile64::SetSize()
       
  5391 4) Get the file size.
       
  5392 5) Seek to the file position RFile64::Size() -100 & File position >0
       
  5393 6) Write 99 bytes to the current file position
       
  5394 7) Read from the current file position.
       
  5395 8) Compare the file read with written data.
       
  5396 9) Repeat step 2 to 8 for <10> times in a loop.
       
  5397 10) Close the file
       
  5398 @SYMTestExpectedResults
       
  5399 1) File create successfully.
       
  5400 2) Ramdom file size generated.
       
  5401 3) File size set successfully.
       
  5402 4) File size = Random file size set.
       
  5403 5) File seek successful.
       
  5404 6) File write successful with KErrNone.
       
  5405 7) File read successful with KErrNone.
       
  5406 8) Read data == Written data.
       
  5407 9) Expect result same as step 2 to 8.
       
  5408 10) File closed successfully.
       
  5409 @SYMTestStatus      Implemented
       
  5410 */
       
  5411 void TestFileReSize()
       
  5412 	{
       
  5413 	TInt64 seed = K4GBMinusOne;
       
  5414 	TBuf8<0x63> readBuf;
       
  5415 	TBuf8<0x63> writeBuf;
       
  5416 	TFileName fileName;
       
  5417 	fileName.Append(gDriveToTest);
       
  5418 	fileName.Append(KTestPath);
       
  5419 	fileName.Append(_L("test.txt"));
       
  5420 	for (TInt count = 0; count < 0x63; count++)
       
  5421 		{
       
  5422 		writeBuf.Append(count);
       
  5423 		}
       
  5424 	test.Next(_L("Create a file name test in write mode\n"));
       
  5425 	TestRFile1.Replace(fileName, EFileWrite);
       
  5426 	TInt randSize;
       
  5427 	TInt64 size;
       
  5428 	for (TInt i = 0; i<10; i++)
       
  5429 		{
       
  5430 		test.Next(_L("Generate a random file size\n"));
       
  5431 		randSize = Math::Rand(seed);
       
  5432 		
       
  5433 		test.Next(_L("Set the file size using RFile64::SetSize()\n"));
       
  5434 		TestRFile1.SetSize(randSize);
       
  5435 		
       
  5436 		test.Next(_L("Get the file size.\n"));
       
  5437 		TestRFile1.Size(size);
       
  5438 		test(randSize == size);
       
  5439 		
       
  5440 		test.Next(_L("Seek to the file position RFile64::Size() -100 & File position >0\n"));
       
  5441 		TInt64 seekPos = size - 100;
       
  5442 		if(size>100) //carry out tests for file sizes greater than 100 bytes
       
  5443 			{	
       
  5444 			TestRFile1.Seek(ESeekStart,seekPos);
       
  5445 			TRequestStatus status1 = KRequestPending;
       
  5446 			
       
  5447 			test.Next(_L("Write 99 bytes to the current file position\n"));
       
  5448 			TestRFile1.Write(writeBuf,99,status1); // Write 99 bytes of data to a file
       
  5449 			TestRFile1.Seek(ESeekStart,seekPos);
       
  5450 			
       
  5451 			
       
  5452 			test.Next(_L("Read from the current file position.\n"));
       
  5453 			TRequestStatus status2 = KRequestPending;
       
  5454 			
       
  5455 			test.Next(_L("Compare the file read with written data.\n"));
       
  5456 			TestRFile1.Read(readBuf,99,status2);
       
  5457 			test(writeBuf == readBuf); // Written data == Read data
       
  5458 			}
       
  5459 		}
       
  5460 	TestRFile1.Close();
       
  5461 	TInt r = TheFs.Delete(fileName);
       
  5462 	test(r == KErrNone);
       
  5463 	}
       
  5464 /**
       
  5465 @SYMTestCaseID      PBASE-T_FILE64BIT-2354
       
  5466 @SYMTestPriority    High
       
  5467 @SYMTestRequirement REQ9532
       
  5468 @SYMTestType        CIT
       
  5469 @SYMTestCaseDesc    Tests for copying a directory containing large files using CFileMan::Copy()
       
  5470 @SYMTestActions     
       
  5471 1) Create one large file in the specified test path
       
  5472 2) Set the file size to 3GB-4KB
       
  5473 3) Seek to the end of the file
       
  5474 4) Check the seek position
       
  5475 5) Write to a file with position = 3GB-4KB and length = 4KB
       
  5476 6) Get the file size
       
  5477 7) Create 3 small files in the specified test path
       
  5478 8) Write 10 bytes to the created files
       
  5479 9) Copy the files from one folder to another using CFileMan::Copy()
       
  5480 10)Get the directory entry and find how many files are copied
       
  5481 11)Set file man observer
       
  5482 12)Copy the files from one folder to another, source folder has 3 small files and a large file
       
  5483 13)Check observer for number of successful copy and failed copy
       
  5484 14)Get the directory entry and find how many files copied
       
  5485 @SYMTestExpectedResults 
       
  5486 1) KErrNone, file created successfully
       
  5487 2) KErrNone
       
  5488 3) KErrNone
       
  5489 4) Seek position = 3GB-4KB
       
  5490 5) KErrNone, write is successful
       
  5491 6) File size = 3GB
       
  5492 7) KErrNone, 3 small files created successfully
       
  5493 8) KErrNone, write is successful
       
  5494 9) KErrNone, copy is successful
       
  5495 10)4 files copied successfully
       
  5496 11)KErrNone
       
  5497 12)KErrNone, copy is successful
       
  5498 13)Number of success file copy = 4, Failed = 0
       
  5499 14)4 files copied successfully
       
  5500 @SYMTestStatus      Implemented
       
  5501 */	
       
  5502 
       
  5503 void TestCopyDirectory()
       
  5504 	{
       
  5505 	test.Next(_L("Copy a directory containing large files"));
       
  5506 	CFileMan* fileMan = CFileMan::NewL(TheFs);
       
  5507 	test(fileMan != NULL);
       
  5508 	
       
  5509 	CFileManObserver* observer = new CFileManObserver(fileMan);
       
  5510 	test(observer != NULL);
       
  5511 
       
  5512 	TPath filePathOld;
       
  5513 	filePathOld.Append(gDriveToTest);
       
  5514 	filePathOld.Append(KTestPath);
       
  5515 	
       
  5516 		
       
  5517 	TPath filePathNew;
       
  5518 	filePathNew.Append(gDriveToTest);
       
  5519 	filePathNew.Append(_L(":\\TEST\\"));
       
  5520 	
       
  5521 	
       
  5522 	// create some small files in the source directory 
       
  5523 	// so that there is a combination of small files and one large files
       
  5524 	RDir dir;
       
  5525 	TEntryArray entryArray;
       
  5526 	
       
  5527 	TFileName fileLarge1;
       
  5528 	fileLarge1.Append(gDriveToTest);
       
  5529 	fileLarge1.Append(KTestPath);
       
  5530 	fileLarge1.Append(_L("FileLargeOne.txt"));
       
  5531 	
       
  5532 	test.Next(_L("	Create one large file in the specified test path\n"));
       
  5533 	TestRFile1.Replace(fileLarge1, EFileWrite | EFileShareAny);
       
  5534 	
       
  5535 	
       
  5536 	test.Next(_L("Set the file size to 3GB-4KB\n"));
       
  5537 	TestRFile1.SetSize(K3GB-K4KB);
       
  5538 	TInt64 size1 = 0;
       
  5539 	TestRFile1.Size(size1);
       
  5540 	
       
  5541 	test.Next(_L("Seek to the end of the file\n"));
       
  5542 	TInt64 seekPos = 0;
       
  5543 	TestRFile1.Seek(ESeekEnd,seekPos); 
       
  5544 	test(seekPos == K3GB-K4KB);
       
  5545 	
       
  5546 	test.Next(_L("Write to a file with position = 3GB-4KB and length = 4KB\n"));
       
  5547 	TBuf8<4096> writeBufK4KB;
       
  5548 	for (TInt count = 0; count < 4096; count++)
       
  5549 		{
       
  5550 		writeBufK4KB.Append(count+1);
       
  5551 		}
       
  5552 	TestRFile1.Write(seekPos, writeBufK4KB, writeBufK4KB.Length());
       
  5553 	TestRFile1.Size(size1);
       
  5554 	test.Next(_L("Get the file size\n"));
       
  5555 	TInt64 size = 0;
       
  5556 	TestRFile1.Size(size);
       
  5557 	test(size == K3GB);
       
  5558 	TestRFile1.Close();
       
  5559 	
       
  5560 	test.Next(_L("Create 3 small files in the specified test path and Write 10 bytes to the created files\n"));
       
  5561 	TFileName fileSmall1;
       
  5562 	fileSmall1.Append(gDriveToTest);
       
  5563 	fileSmall1.Append(KTestPath);
       
  5564 	fileSmall1.Append(_L("FileSmallOne.txt"));
       
  5565 	
       
  5566 	TFileName fileSmall2;
       
  5567 	fileSmall2.Append(gDriveToTest);
       
  5568 	fileSmall2.Append(KTestPath);
       
  5569 	fileSmall2.Append(_L("FileSmallTwo.txt"));
       
  5570 	
       
  5571 	TFileName fileSmall3;
       
  5572 	fileSmall3.Append(gDriveToTest);
       
  5573 	fileSmall3.Append(KTestPath);
       
  5574 	fileSmall3.Append(_L("FileSmallThree.txt"));
       
  5575 	
       
  5576 	TestRFile1.Create(fileSmall1, EFileWrite | EFileShareAny);
       
  5577 	TestRFile1.Write(_L8("1234567891"));
       
  5578 	TestRFile1.Close();
       
  5579 
       
  5580 	TestRFile1.Create(fileSmall2, EFileWrite | EFileShareAny);
       
  5581 	TestRFile1.Write(_L8("1234567891"));
       
  5582 	TestRFile1.Close();
       
  5583 
       
  5584 	TestRFile1.Create(fileSmall3, EFileWrite | EFileShareAny);
       
  5585 	TestRFile1.Write(_L8("1234567891"));
       
  5586 	TestRFile1.Close();
       
  5587 
       
  5588 	test.Next(_L("Copy the files from one folder to another using CFileMan::Copy()\n"));
       
  5589 	TInt r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite);
       
  5590 	test(r == KErrNone || r == KErrTooBig);
       
  5591 
       
  5592 	test.Next(_L("Get the directory entry and find how many files are copied\n"));
       
  5593 	// check SMALL and LARGE files have been copied
       
  5594 	r = dir.Open(TheFs, filePathNew, KEntryAttNormal);
       
  5595 	test (r == KErrNone);
       
  5596 	r = dir.Read(entryArray);
       
  5597 	test (r == KErrEof);
       
  5598 	test(entryArray.Count() == gFilesInDirectory);
       
  5599 	dir.Close();
       
  5600 	
       
  5601 	// then delete the new directory
       
  5602 	r = fileMan->Delete(filePathNew);
       
  5603 	test(r == KErrNone);
       
  5604 
       
  5605 	test.Next(_L("Set file man observer\n"));
       
  5606 	// attempt to copy to new directory again - this time with an observer
       
  5607 	fileMan->SetObserver(observer);
       
  5608 	
       
  5609 	test.Next(_L("Copy the files from one folder to another, source folder has 3 small files and a large file\n"));
       
  5610 	r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite);
       
  5611 	test(r == KErrNone || r == KErrTooBig);
       
  5612 	
       
  5613 	test.Next(_L("Check observer for number of successful copy and failed copy\n"));
       
  5614 	// test that 3 small files and 1 large file were copied
       
  5615 	// (For 8 GB disk, the 4GB file is missing)
       
  5616 	test(observer->iNotifyEndedSuccesses == gFilesInDirectory);
       
  5617 	test(observer->iNotifyEndedFailures == 0); 
       
  5618 
       
  5619 	test.Next(_L("Get the directory entry and find how many files copied\n"));
       
  5620 	// check SMALL files have been copied
       
  5621 	r = dir.Open(TheFs, filePathNew, KEntryAttNormal);
       
  5622 	test (r == KErrNone);
       
  5623 	r = dir.Read(entryArray);
       
  5624 	test (r == KErrEof);
       
  5625 
       
  5626 	test(entryArray.Count() == gFilesInDirectory); 
       
  5627 	dir.Close();
       
  5628 	
       
  5629 	// then delete the new directory
       
  5630 	r = fileMan->Delete(filePathNew);
       
  5631 	test(r == KErrNone);
       
  5632 
       
  5633 	delete observer;
       
  5634 	delete fileMan;
       
  5635 	
       
  5636 	r = TheFs.Delete(fileSmall1);
       
  5637 	test(r == KErrNone);
       
  5638 	r = TheFs.Delete(fileSmall2);
       
  5639 	test(r == KErrNone);
       
  5640 	r = TheFs.Delete(fileSmall3);
       
  5641 	test(r == KErrNone);
       
  5642 	r = TheFs.Delete(fileLarge1);
       
  5643 	test(r == KErrNone);
       
  5644 	}
       
  5645 /**
       
  5646 @SYMTestCaseID      PBASE-T_FILE64BIT-2355
       
  5647 @SYMTestPriority    High
       
  5648 @SYMTestRequirement REQ9532
       
  5649 @SYMTestType        CIT
       
  5650 @SYMTestCaseDesc    Tests for moving a directory containing large files using CFileMan::Move()
       
  5651 @SYMTestActions     	
       
  5652 1) Create 3 small files and 1 large file
       
  5653 2) Write 10 bytes to the created files
       
  5654 3) Move the files from one folder to another using CFileMan Move
       
  5655 4) Get the directory entry and find how many files moved in a directory
       
  5656 5) Move the files back to the original folder 
       
  5657 @SYMTestExpectedResults 
       
  5658 1) KErrNone, files created successfully
       
  5659 2) KErrNone, write is successful
       
  5660 3) KErrNone
       
  5661 4) 4 files moved successfully
       
  5662 5) KErrNone
       
  5663 @SYMTestStatus      Implemented
       
  5664 */
       
  5665 void TestMoveDirectory()
       
  5666 	{
       
  5667 	test.Next(_L("Move a directory containing large files"));
       
  5668 	CFileMan* fileMan = CFileMan::NewL(TheFs);
       
  5669 	test(fileMan != NULL);
       
  5670 	
       
  5671 	TPath filePathOld;
       
  5672 	filePathOld.Append(gDriveToTest);
       
  5673 	filePathOld.Append(KTestPath);
       
  5674 	
       
  5675 		
       
  5676 	TPath filePathNew;
       
  5677 	filePathNew.Append(gDriveToTest);
       
  5678 	filePathNew.Append(_L(":\\TEST\\"));
       
  5679 	
       
  5680 	test.Next(_L("Create 3 small files and 1 large file\n"));
       
  5681 	
       
  5682 	TFileName fileLarge1;
       
  5683 	fileLarge1.Append(gDriveToTest);
       
  5684 	fileLarge1.Append(KTestPath);
       
  5685 	fileLarge1.Append(_L("FileLargeOne.txt"));
       
  5686 	TestRFile1.Replace(fileLarge1, EFileWrite | EFileShareAny);
       
  5687 	TestRFile1.SetSize(K4GB-1);
       
  5688 	TestRFile1.Close();
       
  5689 	
       
  5690 	
       
  5691 	TFileName fileSmall1;
       
  5692 	fileSmall1.Append(gDriveToTest);
       
  5693 	fileSmall1.Append(KTestPath);
       
  5694 	fileSmall1.Append(_L("FileSmallOne.txt"));
       
  5695 	
       
  5696 	TFileName fileSmall2;
       
  5697 	fileSmall2.Append(gDriveToTest);
       
  5698 	fileSmall2.Append(KTestPath);
       
  5699 	fileSmall2.Append(_L("FileSmallTwo.txt"));
       
  5700 	
       
  5701 	TFileName fileSmall3;
       
  5702 	fileSmall3.Append(gDriveToTest);
       
  5703 	fileSmall3.Append(KTestPath);
       
  5704 	fileSmall3.Append(_L("FileSmallThree.txt"));
       
  5705 	
       
  5706 	TestRFile1.Create(fileSmall1, EFileWrite | EFileShareAny);
       
  5707 	TestRFile1.Write(_L8("1234567891"));
       
  5708 	TestRFile1.Close();
       
  5709 
       
  5710 	TestRFile1.Create(fileSmall2, EFileWrite | EFileShareAny);
       
  5711 	TestRFile1.Write(_L8("1234567891"));
       
  5712 	TestRFile1.Close();
       
  5713 
       
  5714 	TestRFile1.Create(fileSmall3, EFileWrite | EFileShareAny);
       
  5715 	TestRFile1.Write(_L8("1234567891"));
       
  5716 	TestRFile1.Close();
       
  5717 	
       
  5718 
       
  5719 	// move to new directory
       
  5720 	TInt r = fileMan->Move(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite);
       
  5721 	test(r == KErrNone || r == KErrTooBig);
       
  5722 
       
  5723 	// check SMALL and LARGE files have been moved
       
  5724 	RDir dir;
       
  5725 	r = dir.Open(TheFs, filePathNew, KEntryAttNormal);
       
  5726 	test (r == KErrNone);
       
  5727 	TEntryArray entryArray;
       
  5728 	r = dir.Read(entryArray);
       
  5729 	test (r == KErrEof);
       
  5730 	test(entryArray.Count() == 4);
       
  5731 	dir.Close();
       
  5732 	
       
  5733 	// then delete the new directory
       
  5734 	r = fileMan->Delete(filePathNew);
       
  5735 	test(r == KErrNone);
       
  5736 	delete fileMan;
       
  5737 	}
       
  5738 
       
  5739 
       
  5740 static void TestOpenFiles()
       
  5741 	{
       
  5742     TestOpen2GB();
       
  5743 	TestOpen3GB();
       
  5744 	TestOpen4GBMinusOne();
       
  5745 	TestOpen4GB();
       
  5746 	TestOpenMoreThan2GB();
       
  5747 	TestOpenRFileRFile64();
       
  5748 	TestCreateTempFile();
       
  5749 	TestCreateRFile64();
       
  5750     TestReplaceRFile64();
       
  5751 	TestReplaceRFile64RFs();
       
  5752 	}
       
  5753 	
       
  5754 static void TestAdoptFiles()
       
  5755 	{
       
  5756 	TInt r;
       
  5757 	RFs fs;
       
  5758 	r = fs.Connect();
       
  5759 	test(r == KErrNone);
       
  5760 	r = fs.ShareProtected();
       
  5761 	test(r == KErrNone);
       
  5762 	TFileName sessionp;
       
  5763 	fs.SessionPath(sessionp);
       
  5764 	r = fs.MkDirAll(sessionp);
       
  5765 	test(r == KErrNone || r == KErrAlreadyExists);
       
  5766 	fs.Close();
       
  5767 	TestRFile64AdoptFromCreator();
       
  5768 	TestRFile64AdoptFromClient();
       
  5769 	TestRFile64AdoptFromServer();
       
  5770 	}
       
  5771 
       
  5772 
       
  5773 static void TestReadFile()
       
  5774 	{
       
  5775 //
       
  5776 //The order of these tests need to be preserved, since the first test creates
       
  5777 //a 4GB file, while the last one deletes it. 
       
  5778 // 
       
  5779 	TestOpenAndReadSyncLargeFile();
       
  5780 	TestOpenAndReadAsyncLargeFile();
       
  5781 	TestOpenAndReadSyncLargeFileWithLen(); 
       
  5782     TestOpenAndReadAsyncLargeFileWithLen();
       
  5783 	}
       
  5784 	
       
  5785 static void TestWriteFile()
       
  5786 	{
       
  5787 	TestOpenAndWriteSyncLargeFile();
       
  5788 	TestOpenAndWriteAsyncLargeFile();
       
  5789 	TestOpenAndWriteSyncLargeFileWithLen();
       
  5790 	TestOpenAndWriteAsyncLargeFileWithLen();
       
  5791 	}
       
  5792 	
       
  5793 static void TestFileAccess()
       
  5794 	{
       
  5795 	TestFileLock();
       
  5796 	TestFileUnlock();
       
  5797 	TestFileSeek();
       
  5798 	TestFileSeekBigFile();
       
  5799 	}
       
  5800 
       
  5801 static void TestLockUnLock()
       
  5802 	{
       
  5803 	TestReadWriteLock();
       
  5804 	TestUnLock();
       
  5805 	TestSeekReadWrite();
       
  5806 	TestSeekAsyncReadWrite(); 
       
  5807   	TestSeekReadWriteLen();
       
  5808     TestSeekAsyncReadWriteLen();
       
  5809 	}
       
  5810 
       
  5811 static void TestCopyMoveDirectory()
       
  5812 	{
       
  5813 	TestCopyDirectory();
       
  5814 	TestMoveDirectory();
       
  5815 	}
       
  5816 
       
  5817 TInt testLockPanic(TAny* aPtr)
       
  5818 	{
       
  5819 	TInt aPos=128;
       
  5820 	TInt aLen=-1;
       
  5821 	RFile64 * ptr = (RFile64 *)aPtr;
       
  5822 	TInt r=ptr->Lock(aPos, aLen);
       
  5823 	test (KErrNone == r);	
       
  5824 	return KErrNone;
       
  5825 	}
       
  5826 
       
  5827 TInt testUnLockPanic(TAny* aPtr)
       
  5828 	{
       
  5829 	TInt aPos=128;
       
  5830 	TInt aLen=-1;
       
  5831 	RFile64 * ptr = (RFile64 *)aPtr;
       
  5832 	TInt r=ptr->UnLock(aPos, aLen);
       
  5833 	test (KErrNone == r);	
       
  5834 	return KErrNone;
       
  5835 	}
       
  5836 
       
  5837 TInt testSetSizePanic(TAny* aPtr)
       
  5838 	{
       
  5839 	TInt aSize=-1;
       
  5840 	RFile64 * ptr = (RFile64 *)aPtr;
       
  5841 	TInt r=ptr->SetSize(aSize);
       
  5842 	test (KErrNone == r);	
       
  5843 	return KErrNone;
       
  5844 	}
       
  5845 
       
  5846 static void TestRFile64NegLen()
       
  5847 	{
       
  5848 	test.Start(_L("Test RFile64::Lock, RFile64::Unlock, RFile64::SetSize and RFile::Write with Negative Length parameter"));
       
  5849 	
       
  5850 	test(TheFs.ShareProtected() == KErrNone);
       
  5851 	
       
  5852 	RFile64 aFile;
       
  5853 	TInt r = aFile.Create(TheFs, _L("\\testRFile64NegLen.txt"), EFileWrite);
       
  5854 	test((KErrNone == r) || (KErrAlreadyExists == r));
       
  5855 	
       
  5856 	TRequestStatus status = KRequestPending;
       
  5857 
       
  5858 	// launch call on separate thread as expected to panic
       
  5859 	// Test Lock with a negative length
       
  5860 	User::SetJustInTime(EFalse);
       
  5861 	RThread t;
       
  5862 	test(t.Create(_L("testLockPanic"), testLockPanic, KDefaultStackSize, 0x2000, 0x2000, &aFile) == KErrNone);
       
  5863 	t.Logon(status);
       
  5864 	t.Resume();
       
  5865 	User::WaitForRequest(status);
       
  5866 	User::SetJustInTime(ETrue);
       
  5867 	test(t.ExitType() == EExitPanic);
       
  5868 	test(t.ExitReason() == 17);
       
  5869 	t.Close();
       
  5870 	
       
  5871 	// Test Unlock with a negative length
       
  5872 	User::SetJustInTime(EFalse);
       
  5873 	status = KRequestPending;
       
  5874 	test(t.Create(_L("testUnLockPanic"), testUnLockPanic, KDefaultStackSize, 0x2000, 0x2000, &aFile) == KErrNone);
       
  5875 	t.Logon(status);
       
  5876 	t.Resume();
       
  5877 	User::WaitForRequest(status);
       
  5878 	test(t.ExitType() == EExitPanic);
       
  5879 	test(t.ExitReason() == 18);
       
  5880 	t.Close();
       
  5881 	User::SetJustInTime(ETrue);
       
  5882 	
       
  5883 	// Test SetSize with a negative length
       
  5884 	User::SetJustInTime(EFalse);
       
  5885 	status = KRequestPending;
       
  5886 	test(t.Create(_L("testSetSizePanic"), testSetSizePanic, KDefaultStackSize, 0x2000, 0x2000, &aFile) == KErrNone);
       
  5887 	t.Logon(status);
       
  5888 	t.Resume();
       
  5889 	User::WaitForRequest(status);
       
  5890 	test(t.ExitType() == EExitPanic);
       
  5891 	test(t.ExitReason() == 20);
       
  5892 	t.Close();
       
  5893 	User::SetJustInTime(ETrue);
       
  5894 	
       
  5895 	// Test RFile64::Write with a zero or negative length
       
  5896 	TInt aPos=128;
       
  5897 	TInt aLen=-1;
       
  5898 	TBuf8<0x100> gBuf=_L8("1234567891");
       
  5899 	gBuf.Zero();
       
  5900 	TRequestStatus status1=KRequestPending;
       
  5901 	TRequestStatus status2=KRequestPending;
       
  5902 	
       
  5903 	// If a zero length is passed into the Write function, KErrNone should be returned. 
       
  5904 	r=aFile.Write(aPos,gBuf);
       
  5905 	test(r==KErrNone);
       
  5906 	
       
  5907 	// If the length is a negative, KErrArgument should be returned. 
       
  5908 	r=aFile.Write(aPos,gBuf,aLen);
       
  5909 	test(r==KErrArgument);
       
  5910 	
       
  5911 	// Test the asynchronous requests
       
  5912 	aFile.Write(aPos,gBuf,aLen,status1);
       
  5913 	aFile.Write(aPos,gBuf,aLen,status2);
       
  5914 	User::WaitForRequest(status1);
       
  5915 	test(status1.Int()==KErrArgument);
       
  5916 	User::WaitForRequest(status2);
       
  5917 	test(status2.Int()==KErrArgument);
       
  5918 	
       
  5919 	aFile.Close();
       
  5920 	r = TheFs.Delete(_L("\\testRFile64NegLen.txt"));
       
  5921 	test(r == KErrNone);
       
  5922 	test.End();	
       
  5923 	}
       
  5924 //-------------------------------------------------------------------------------------------------------------------
       
  5925 
       
  5926 static TInt PrepareDisk(TInt aDrive)
       
  5927 	{
       
  5928     TInt r;
       
  5929 
       
  5930     r = FormatDrive(TheFs, aDrive, ETrue);
       
  5931 
       
  5932 	r = TheFs.Volume(gDriveVolumeInfo, aDrive);
       
  5933 	if(KErrNone != r)
       
  5934 		{
       
  5935 		test.Printf(_L("\nError in getting drive volume information!! Error code is %d"),r);
       
  5936 		test(EFalse);
       
  5937 		}
       
  5938 	test.Printf(_L("\nDrive volume size is %LU\n"), gDriveVolumeInfo.iSize);
       
  5939 
       
  5940 	// don't test if media size is less than 4 GB
       
  5941 	if (gDriveVolumeInfo.iFree <= K4GB)
       
  5942 		{
       
  5943 		test.Printf(_L("\nSkipping test: test requires disk with capacity more than 4 GB"));
       
  5944 		return KErrNotSupported;
       
  5945 		}
       
  5946 	
       
  5947 	TFileName fileName;
       
  5948 	fileName.Append(gDriveToTest);
       
  5949 	fileName.Append(KTestPath);
       
  5950 	
       
  5951 	MakeDir(fileName);
       
  5952 	
       
  5953 	
       
  5954     //-- decide if we need to test files >= 4G. As soon as there is no appropriate API yet, this way is dodgy..
       
  5955     if(Is_Fat(TheFs, aDrive))
       
  5956         {
       
  5957         KFileSizeMaxLargerThan4GBMinusOne = EFalse; //-- FAT doesn't support >= 4G files
       
  5958         }
       
  5959     else if(Is_Win32(TheFs, aDrive))
       
  5960         {//-- this is the emulator's windows drive. The maximal file size depends on the Windows FS used for this drive.
       
  5961          //-- if it is NTFS, files >= 4G are supported.   
       
  5962         r = CreateEmptyFile(TheFs, _L("\\test_file"), K4GB);
       
  5963         
       
  5964         KFileSizeMaxLargerThan4GBMinusOne = (r == KErrNone);
       
  5965         r = TheFs.Delete(_L("\\test_file"));
       
  5966 
       
  5967         }
       
  5968     else
       
  5969         {//-- something else, exFAT for example
       
  5970         if(Is_ExFat(TheFs, aDrive))    
       
  5971             KFileSizeMaxLargerThan4GBMinusOne = ETrue; 
       
  5972         }
       
  5973 
       
  5974 
       
  5975 	return KErrNone;
       
  5976 	}
       
  5977 
       
  5978 
       
  5979 void CallTestsL()
       
  5980 	{
       
  5981 	TInt r;
       
  5982 	r = RFs::CharToDrive(gDriveToTest, gDrive);
       
  5983 	test(r == KErrNone);
       
  5984 
       
  5985     //-- set up console output 
       
  5986     F32_Test_Utils::SetConsole(test.Console()); 
       
  5987 
       
  5988     PrintDrvInfo(TheFs, gDrive);
       
  5989 
       
  5990 	r = PrepareDisk(gDrive);
       
  5991 	if(r == KErrNotSupported)
       
  5992 		return;
       
  5993 
       
  5994 
       
  5995 	TestRFile64NegLen();
       
  5996 	TestOpenFiles();
       
  5997 	TestAdoptFiles();
       
  5998 	TestReadFile(); 
       
  5999 	TestWriteFile(); 
       
  6000 	TestFileAccess(); 
       
  6001 	TestSetsize();
       
  6002 	TestReadFilesection();
       
  6003 	TestTFileText();
       
  6004 
       
  6005 	TestLockUnLock(); 
       
  6006 	TestFileReSize();
       
  6007 	//
       
  6008 	// these tests require disk capacity of aaround 12GB.
       
  6009 	//order of these tests need to be preserved since the files are
       
  6010 	//created only in TestGetDirectory() and then deleted in TestAddLDirectory
       
  6011 	//but all the intermediate tests uses those files.
       
  6012 	//
       
  6013 	if (gDriveVolumeInfo.iFree >= K12GB)
       
  6014 		{
       
  6015 		TestGetDirectory();
       
  6016 		TestTEntry(); 
       
  6017 		TestReadDirectory();
       
  6018 		TestSortDirectory();
       
  6019 		TestAddLDirectory();
       
  6020 		}
       
  6021 	// these tests require disk capacity of aaround 9GB.
       
  6022 	if (gDriveVolumeInfo.iFree >= K9GB)
       
  6023 		{
       
  6024 		TestCopyMoveDirectory(); 
       
  6025 		}
       
  6026 	
       
  6027 	// Delete the test directory
       
  6028 	TFileName dirName;
       
  6029 	dirName.Append(gDriveToTest);
       
  6030 	dirName.Append(KTestPath);
       
  6031 	r = TheFs.RmDir(dirName);
       
  6032 	test(r == KErrNone);
       
  6033 	}
       
  6034 
       
  6035 
       
  6036 
       
  6037 
       
  6038 
       
  6039 
       
  6040