sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // See the test specification for details of what these test cases do. sl@0: sl@0: #include "teststepcomsdbg.h" sl@0: #include "TestMessage.h" sl@0: #include "step_028_xx.h" sl@0: sl@0: sl@0: #include sl@0: sl@0: const TInt KWaitForFloggerShutdown = 2000000; sl@0: const TInt KMultipleWriteStressTimes = 100; sl@0: sl@0: /** sl@0: * 028_Sync_Setup - creates flogger.ini to include token "synchronous" sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: sl@0: CFloggerTest028_Sync_Setup::CFloggerTest028_Sync_Setup() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_Setup")); sl@0: } sl@0: sl@0: sl@0: CFloggerTest028_Sync_Setup::~CFloggerTest028_Sync_Setup() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_Setup::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Setup::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_Setup::executeStepL() sl@0: { sl@0: TInt ret; sl@0: RFileLogger flogger; sl@0: flogger.Connect(); sl@0: flogger.__DbgShutDownServer(); sl@0: flogger.Close(); sl@0: User::After(KWaitForFloggerShutdown); sl@0: TRAP(ret,constructFloggerIniL(KSyncTestsIniFileSettings)); sl@0: flogger.Connect(); sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.Close(); sl@0: return ret; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_ConWriteUni - test sync with connected unicode write sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_ConWriteUni::CFloggerTest028_Sync_ConWriteUni() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_ConWriteUni")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_ConWriteUni::~CFloggerTest028_Sync_ConWriteUni() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_ConWriteUni::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteUni::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteUni::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.Write(KTestMessage); sl@0: flogger.Close(); sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteUni::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //To hold the test descriptor sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestMessage); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_ConWriteUniBound - test sync with connected unicode write and long string sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_ConWriteUniBound::CFloggerTest028_Sync_ConWriteUniBound() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_ConWriteUniBound")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_ConWriteUniBound::~CFloggerTest028_Sync_ConWriteUniBound() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_ConWriteUniBound::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteUniBound::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteUniBound::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.Write(KTestTooLongMessage16); sl@0: flogger.Close(); sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteUniBound::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //We expect the maximum chars this time sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestTooLongExpectedMessage); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_ConWriteFormatEUni - test sync with connected unicode write sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_ConWriteFormatEUni::CFloggerTest028_Sync_ConWriteFormatEUni() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_ConWriteFormatEUni")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_ConWriteFormatEUni::~CFloggerTest028_Sync_ConWriteFormatEUni() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_ConWriteFormatEUni::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatEUni::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatEUni::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.WriteFormat(KTestMessageOneParam16,KTestMessageOneParamValue); sl@0: flogger.Close(); sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatEUni::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //To hold the test descriptor sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestMessageOneParamExpected); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_ConWriteFormatEUniBound - test sync with connected unicode write and long string sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_ConWriteFormatEUniBound::CFloggerTest028_Sync_ConWriteFormatEUniBound() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_ConWriteFormatEUniBound")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_ConWriteFormatEUniBound::~CFloggerTest028_Sync_ConWriteFormatEUniBound() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_ConWriteFormatEUniBound::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatEUniBound::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatEUniBound::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.WriteFormat(KTestTooLongMessageOneParam16,KTestTooLongMessageOneParamValue); sl@0: flogger.Close(); sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatEUniBound::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //We expect the maximum chars for this case sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestTooLongMessageOneParamExpected); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_ConWriteFormatV8Bit - test sync with connected unicode write sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_ConWriteFormatV8Bit::CFloggerTest028_Sync_ConWriteFormatV8Bit() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_ConWriteFormatV8Bit")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_ConWriteFormatV8Bit::~CFloggerTest028_Sync_ConWriteFormatV8Bit() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_ConWriteFormatV8Bit::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatV8Bit::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatV8Bit::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: DoTestWriteFormat(KTestMessageOneParam8,KTestMessageOneParamValue); sl@0: flogger.Close(); sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: void CFloggerTest028_Sync_ConWriteFormatV8Bit::DoTestWriteFormat(TRefByValue aFmt,...) sl@0: { sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: flogger.WriteFormat(aFmt,list); sl@0: } sl@0: sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatV8Bit::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //To hold the test descriptor sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestMessageOneParamExpected); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_ConWriteFormatV8BitBound - test sync with connected unicode write and long string sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_ConWriteFormatV8BitBound::CFloggerTest028_Sync_ConWriteFormatV8BitBound() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_ConWriteFormatV8BitBound")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_ConWriteFormatV8BitBound::~CFloggerTest028_Sync_ConWriteFormatV8BitBound() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_ConWriteFormatV8BitBound::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatV8BitBound::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatV8BitBound::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: DoTestWriteFormat(KTestTooLongMessageOneParam8,KTestTooLongMessageOneParamValue); sl@0: flogger.Close(); sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: void CFloggerTest028_Sync_ConWriteFormatV8BitBound::DoTestWriteFormat(TRefByValue aFmt,...) sl@0: { sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: flogger.WriteFormat(aFmt,list); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConWriteFormatV8BitBound::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //We expect the maximum chars for this case sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestTooLongMessageOneParamExpected); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_Static_WriteUni - test sync with connected unicode write sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_Static_WriteUni::CFloggerTest028_Sync_Static_WriteUni() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_Static_WriteUni")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_Static_WriteUni::~CFloggerTest028_Sync_Static_WriteUni() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_Static_WriteUni::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteUni::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteUni::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: // clear the old log messages sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.Close(); sl@0: sl@0: RFileLogger::Write(KStdSubsysTag8, KStdCompTag8, KTestMessage); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteUni::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //To hold the test descriptor sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestMessage); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_Static_WriteUniBound - test sync with connected unicode write and long string sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_Static_WriteUniBound::CFloggerTest028_Sync_Static_WriteUniBound() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_Static_WriteUniBound")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_Static_WriteUniBound::~CFloggerTest028_Sync_Static_WriteUniBound() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_Static_WriteUniBound::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteUniBound::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteUniBound::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: sl@0: // clear the old log messages sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.Close(); sl@0: sl@0: RFileLogger::Write(KStdSubsysTag8, KStdCompTag8, KTestTooLongMessage16); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: return ret; sl@0: sl@0: sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteUniBound::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //We expect the maximum chars for this case sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestTooLongExpectedMessage); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_Static_WriteFormatVUni - test sync with static formatted VA_LIST unicode write sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_Static_WriteFormatVUni::CFloggerTest028_Sync_Static_WriteFormatVUni() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_Static_WriteFormatVUni")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_Static_WriteFormatVUni::~CFloggerTest028_Sync_Static_WriteFormatVUni() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_Static_WriteFormatVUni::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteFormatVUni::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteFormatVUni::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: // clear the old log messages sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.Close(); sl@0: sl@0: DoTestWriteFormat(KTestMessageOneParam16,KTestMessageOneParamValue); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: void CFloggerTest028_Sync_Static_WriteFormatVUni::DoTestWriteFormat(TRefByValue aFmt,...) sl@0: { sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: RFileLogger::WriteFormat(KStdSubsysTag8,KStdCompTag8,aFmt,list); sl@0: } sl@0: sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteFormatVUni::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //To hold the test descriptor sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestMessageOneParamExpected); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_Static_WriteFormatVUniBound - test sync with static formatted VA_LIST unicode write and long string sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_Static_WriteFormatVUniBound::CFloggerTest028_Sync_Static_WriteFormatVUniBound() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_Static_WriteFormatVUniBound")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_Static_WriteFormatVUniBound::~CFloggerTest028_Sync_Static_WriteFormatVUniBound() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_Static_WriteFormatVUniBound::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteFormatVUniBound::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteFormatVUniBound::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: sl@0: // clear the old log messages sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.Close(); sl@0: sl@0: DoTestWriteFormat(KTestTooLongMessageOneParam16,KTestTooLongMessageOneParamValue); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: sl@0: sl@0: void CFloggerTest028_Sync_Static_WriteFormatVUniBound::DoTestWriteFormat(TRefByValue aFmt,...) sl@0: { sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8, aFmt,list); sl@0: } sl@0: sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_WriteFormatVUniBound::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //We expect the maximum chars for this case sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestTooLongMessageOneParamExpected); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_Static_HexDump - test sync with connected unicode write sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_Static_HexDump::CFloggerTest028_Sync_Static_HexDump() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_Static_HexDump")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_Static_HexDump::~CFloggerTest028_Sync_Static_HexDump() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_Static_HexDump::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_HexDump::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_Static_HexDump::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: // clear the old log messages sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.Close(); sl@0: sl@0: RFileLogger::HexDump(KStdSubsysTag8, KStdCompTag8, KTestMessage8); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_HexDump::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: returnCode = ptrString.Find(KTestMessageAsHex8); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode > 0) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_ClearLog - test sync with clearlog sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_ClearLog::CFloggerTest028_Sync_ClearLog() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_ClearLog")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_ClearLog::~CFloggerTest028_Sync_ClearLog() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_ClearLog::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ClearLog::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_ClearLog::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: // clear the old log messages sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.Close(); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ClearLog::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8 testData; //To hold the test descriptor sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: testData.Copy(KTestMessage); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: //from the file sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (returnCode == KErrNotFound) sl@0: return KErrNone; sl@0: else sl@0: return KErrUnknown; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_Binary - test sync with write binary sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_Binary::CFloggerTest028_Sync_Binary() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_Binary")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_Binary::~CFloggerTest028_Sync_Binary() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_Binary::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Binary::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_Binary::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: // clear the old log messages sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: sl@0: flogger.WriteBinary(KTestMessage8); sl@0: sl@0: flogger.Close(); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Binary::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TInt numSuccessful = 0; sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read sl@0: //from the file sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: returnCode = ptrString.Find(KStdSubsysTag8); sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: returnCode = ptrString.Find(KStdCompTag8); sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if (numSuccessful ==3) sl@0: return KErrNone; sl@0: else sl@0: return KErrUnknown; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_ConMultiple - test connect and multiple writes sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_ConMultiple::CFloggerTest028_Sync_ConMultiple() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_ConMultiple")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_ConMultiple::~CFloggerTest028_Sync_ConMultiple() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_ConMultiple::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_ConMultiple::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConMultiple::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: // clear the old log messages sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: sl@0: flogger.Write(KTestMessage); sl@0: flogger.WriteFormat(KTestMessageOneParam16,KTestMessageOneParamValue); sl@0: flogger.Write(KTestTooLongMessage16); sl@0: flogger.WriteFormat(KTestTooLongMessageOneParam16,KTestTooLongMessageOneParamValue); sl@0: DoTestWriteFormat(KTestMessageOneParam8,KTestMessageOneParamValue); sl@0: sl@0: TPtrC8 dataSeg; sl@0: dataSeg.Set(K1KilobyteOfData,K1KilobyteOfDataSize); sl@0: flogger.WriteBinary(dataSeg); sl@0: sl@0: flogger.Close(); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: void CFloggerTest028_Sync_ConMultiple::DoTestWriteFormat(TRefByValue aFmt,...) sl@0: { sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: flogger.WriteFormat(aFmt,list); sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_ConMultiple::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TInt numSuccessful = 0; sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read sl@0: //from the file sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: sl@0: returnCode = ptrString.Find(KTestMessageOneParamExpected); sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: TPtrC8 ptrStringOffsetForSearching = ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length()); sl@0: sl@0: returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: returnCode = ptrString.Find(KTestTooLongExpectedMessage); sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected); sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: // we don't check that all the binary data is there - just that the file is nice and long sl@0: if ( listfilesize > K1KilobyteOfDataSize) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if ( numSuccessful == 6 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrUnknown; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_Static_Multiple - test static multiple writes sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_Static_Multiple::CFloggerTest028_Sync_Static_Multiple() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_Static_Multiple")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_Static_Multiple::~CFloggerTest028_Sync_Static_Multiple() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_Static_Multiple::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_Static_Multiple::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_Multiple::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: // clear the old log messages sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.Close(); sl@0: sl@0: RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestMessage); sl@0: RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8,KTestTooLongMessageOneParam16,KTestTooLongMessageOneParamValue); sl@0: DoTestWriteFormat(KTestMessageOneParam16,KTestMessageOneParamValue); sl@0: DoTestWriteFormat(KTestTooLongMessageOneParam16,KTestTooLongMessageOneParamValue); sl@0: sl@0: RFileLogger::HexDump(KStdSubsysTag8, KStdCompTag8,KTestMessage8); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: void CFloggerTest028_Sync_Static_Multiple::DoTestWriteFormat(TRefByValue aFmt,...) sl@0: { sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8,aFmt,list); sl@0: } sl@0: sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_Multiple::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TInt numSuccessful = 0; sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read sl@0: //from the file sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected); sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: // search for the occurance that the VA_LIST put in sl@0: // when testing serial, the length will be negative, so skip sl@0: TInt len; sl@0: len = (ptrString.Length()-returnCode)-KTestTooLongMessageOneParamExpected().Length(); sl@0: if (len > 0) sl@0: { sl@0: TPtrC8 ptrStringOffsetForSearching = ptrString.Right(len); sl@0: sl@0: returnCode = ptrStringOffsetForSearching.Find(KTestTooLongMessageOneParamExpected); //find the next occurance sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: } sl@0: sl@0: sl@0: returnCode = ptrString.Find(KTestMessageOneParamExpected); sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: returnCode = ptrString.Find(KTestMessageAsHex8); sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if ( numSuccessful == 5 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrUnknown; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_ConMultiple2 - test connect and multiple2 writes sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_ConMultiple2::CFloggerTest028_Sync_ConMultiple2() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_ConMultiple2")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_ConMultiple2::~CFloggerTest028_Sync_ConMultiple2() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_ConMultiple2::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_ConMultiple2::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_ConMultiple2::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: // clear the old log messages sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: sl@0: for (TInt loop = 1; loop <= KMultipleWriteStressTimes; loop++) sl@0: { sl@0: flogger.Write(KTestMessage); sl@0: flogger.WriteFormat(KTestMessageOneParam16,KTestMessageOneParamValue); sl@0: flogger.Write(KTestTooLongMessage16); sl@0: flogger.WriteFormat(KTestTooLongMessageOneParam16,KTestTooLongMessageOneParamValue); sl@0: DoTestWriteFormat(KTestTooLongMessageOneParam8,KTestTooLongMessageOneParamValue); sl@0: sl@0: TPtrC8 dataSeg; sl@0: dataSeg.Set(K1KilobyteOfData,K1KilobyteOfDataSize); sl@0: flogger.WriteBinary(dataSeg); sl@0: } sl@0: flogger.Write(KTestEndMessage8); sl@0: sl@0: flogger.Close(); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: void CFloggerTest028_Sync_ConMultiple2::DoTestWriteFormat(TRefByValue aFmt,...) sl@0: { sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: flogger.WriteFormat(aFmt,list); sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_ConMultiple2::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TInt numSuccessful = 0; sl@0: TInt loop = 0; sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer. This is about 176K in size sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: // the test case writes 6 elements 100 times, but we only check these things: sl@0: // 1. that the test message with one parameter is written 100 times sl@0: // 2. that the long message is written 100 times sl@0: // 3. that the end of test message has been written sl@0: // 4. that the file is suitably big enough to be expected to contain the sl@0: // 1K data segment 100 times in it. sl@0: sl@0: TPtrC8 ptrStringOffsetForSearching; sl@0: returnCode = ptrString.Find(KTestMessageOneParamExpected); sl@0: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: TInt newLength; sl@0: ptrStringOffsetForSearching.Set(ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length())); sl@0: for (loop=0; loop < KMultipleWriteStressTimes; loop++) sl@0: { sl@0: returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestMessageOneParamExpected().Length(); sl@0: if (newLength < 0) sl@0: { sl@0: User::Leave(KErrUnknown); sl@0: } sl@0: ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength)); sl@0: sl@0: } sl@0: sl@0: returnCode = ptrString.Find(KTestTooLongExpectedMessage); sl@0: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: ptrStringOffsetForSearching.Set(ptrString.Right((ptrString.Length()-returnCode)-KTestTooLongExpectedMessage().Length())); sl@0: sl@0: for (loop=0; loop < KMultipleWriteStressTimes; loop++) sl@0: { sl@0: sl@0: returnCode = ptrStringOffsetForSearching.Find(KTestTooLongExpectedMessage); //find the next occurance sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestTooLongExpectedMessage().Length(); sl@0: if (newLength <0) sl@0: { sl@0: User::Leave(KErrUnknown); sl@0: } sl@0: ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength)); sl@0: sl@0: } sl@0: sl@0: sl@0: returnCode = ptrString.Find(KTestEndMessage8); sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: sl@0: // we don't check that all the binary data is there - just that the file is nice and long sl@0: if ( listfilesize > (K1KilobyteOfDataSize * KMultipleWriteStressTimes)) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if ( numSuccessful == 202 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrUnknown; sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: * 028_Sync_Static_Multiple2 - test static multiple2 writes sl@0: * doTestStep returns whether test case passed or failed. sl@0: */ sl@0: sl@0: CFloggerTest028_Sync_Static_Multiple2::CFloggerTest028_Sync_Static_Multiple2() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_028_Sync_Static_Multiple2")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest028_Sync_Static_Multiple2::~CFloggerTest028_Sync_Static_Multiple2() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest028_Sync_Static_Multiple2::doTestStepL( ) sl@0: { sl@0: if ( executeStepL() == KErrNone ) sl@0: SetTestStepResult(EPass); sl@0: sl@0: else sl@0: SetTestStepResult(EFail); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_Multiple2::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest028_Sync_Static_Multiple2::executeStepL() sl@0: { sl@0: TInt ret; sl@0: sl@0: // clear the old log messages sl@0: RFileLogger flogger; sl@0: ret = flogger.Connect(); sl@0: sl@0: if ( ret == KErrNone ) sl@0: { sl@0: flogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: flogger.ClearLog(); sl@0: flogger.Close(); sl@0: sl@0: for (TInt loop = 1; loop <= KMultipleWriteStressTimes; loop++) sl@0: { sl@0: RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestMessage); sl@0: RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestTooLongMessage16); sl@0: DoTestWriteFormat(KTestMessageOneParam16,KTestMessageOneParamValue); sl@0: DoTestWriteFormat(KTestTooLongMessageOneParam16,KTestTooLongMessageOneParamValue); sl@0: sl@0: RFileLogger::HexDump(KStdSubsysTag8, KStdCompTag8,KTestMessage8); sl@0: } sl@0: RFileLogger::Write(KStdSubsysTag8, KStdCompTag8,KTestEndMessage8); sl@0: sl@0: TRAPD(r, ret = DoTestCheckWriteL()); sl@0: if (r != KErrNone) sl@0: ret = r; sl@0: } sl@0: sl@0: sl@0: return ret; sl@0: sl@0: } sl@0: sl@0: void CFloggerTest028_Sync_Static_Multiple2::DoTestWriteFormat(TRefByValue aFmt,...) sl@0: { sl@0: VA_LIST list; sl@0: VA_START(list,aFmt); sl@0: RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8,aFmt,list); sl@0: } sl@0: sl@0: sl@0: sl@0: TInt CFloggerTest028_Sync_Static_Multiple2::DoTestCheckWriteL() sl@0: { sl@0: RFile logFile; sl@0: HBufC8* hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TInt numSuccessful = 0; sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(logFile); sl@0: sl@0: User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file sl@0: sl@0: hBuffer = HBufC8::New(listfilesize); //Allocate the buffer sl@0: CleanupStack::PushL(hBuffer); sl@0: sl@0: TPtr8 ptrString = hBuffer->Des(); //To access the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = logFile.Read(ptrString)); sl@0: sl@0: sl@0: // the test case writes 5 elements 100 times, but we only check these things: sl@0: // 1. that the long test message with one parameter is written 100 times sl@0: // 2. that the test message with one param is written 100 times sl@0: // 3. that the end of test message has been written sl@0: sl@0: TPtrC8 ptrStringOffsetForSearching; sl@0: returnCode = ptrString.Find(KTestMessageOneParamExpected); sl@0: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: TInt newLength; // allow length to be watched during debugging sl@0: TInt loop; sl@0: sl@0: ptrStringOffsetForSearching.Set(ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length())); sl@0: for (loop=0; loop < KMultipleWriteStressTimes; loop++) sl@0: { sl@0: returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestMessageOneParamExpected().Length(); sl@0: if (newLength < 0) sl@0: { sl@0: User::Leave(KErrUnknown); sl@0: } sl@0: sl@0: ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength)); sl@0: sl@0: } sl@0: sl@0: sl@0: returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected); sl@0: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: newLength = ptrString.Length()-returnCode-KTestTooLongMessageOneParamExpected().Length(); sl@0: ptrStringOffsetForSearching.Set(ptrString.Right(newLength)); sl@0: for (loop=0; loop < KMultipleWriteStressTimes; loop++) sl@0: { sl@0: returnCode = ptrStringOffsetForSearching.Find(KTestTooLongMessageOneParamExpected); //find the next occurance sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: if (loop < (KMultipleWriteStressTimes - 1)) sl@0: { sl@0: newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestTooLongMessageOneParamExpected().Length(); sl@0: if (newLength < 0) sl@0: { sl@0: User::Leave(KErrUnknown); sl@0: } sl@0: ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength)); sl@0: } sl@0: sl@0: } sl@0: sl@0: returnCode = ptrString.Find(KTestEndMessage8); sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //logFile sl@0: if ( numSuccessful == 201 ) sl@0: return KErrNone; sl@0: else sl@0: return KErrUnknown; sl@0: }