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: #include "teststepcomsdbg.h" sl@0: #include "TestMessage.h" sl@0: #include "step_030_xx.h" sl@0: sl@0: sl@0: #include sl@0: sl@0: sl@0: sl@0: /** sl@0: * This is the Constructor sl@0: */ sl@0: sl@0: sl@0: CFloggerTest030_Tag_Setup::CFloggerTest030_Tag_Setup() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_Tag_Setup")); sl@0: } sl@0: sl@0: sl@0: /** sl@0: * This is the Destructor sl@0: */ sl@0: sl@0: sl@0: CFloggerTest030_Tag_Setup::~CFloggerTest030_Tag_Setup() sl@0: { sl@0: } sl@0: sl@0: sl@0: /** sl@0: * This function returns whether the test case has sl@0: * passed or failed sl@0: */ sl@0: sl@0: sl@0: TVerdict CFloggerTest030_Tag_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: //INFO_PRINTF1(_L("leaving Step 030_Tag_Setup ")); sl@0: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_Tag_Setup::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_Tag_Setup::executeStepL() sl@0: { sl@0: return constructFloggerIniL(KTagTestsIniFileSettings); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: * 030_TagSetLogTag01: Test that flogger handles empty tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagSetLogTag01::CFloggerTest030_TagSetLogTag01() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagSetLogTag01")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagSetLogTag01::~CFloggerTest030_TagSetLogTag01() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagSetLogTag01::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag01::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag01::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.SetLogTags(KNullDesC8, KNullDesC8); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagSetLogTag01::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagSetLogTag02: Test that flogger handles empty subsys tag sl@0: */ sl@0: sl@0: CFloggerTest030_TagSetLogTag02::CFloggerTest030_TagSetLogTag02() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagSetLogTag02")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagSetLogTag02::~CFloggerTest030_TagSetLogTag02() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagSetLogTag02::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag02::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag02::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.SetLogTags(KNullDesC8, KStdCompTag8); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagSetLogTag02::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 030_TagSetLogTag03: Test that flogger handles empty component tag sl@0: */ sl@0: sl@0: CFloggerTest030_TagSetLogTag03::CFloggerTest030_TagSetLogTag03() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagSetLogTag03")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagSetLogTag03::~CFloggerTest030_TagSetLogTag03() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagSetLogTag03::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag03::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag03::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KNullDesC8); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagSetLogTag03::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagSetLogTag04: Test that flogger handles spaces in tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagSetLogTag04::CFloggerTest030_TagSetLogTag04() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagSetLogTag04")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagSetLogTag04::~CFloggerTest030_TagSetLogTag04() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagSetLogTag04::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag04::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag04::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KCompTagWithSpaceChars8); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagSetLogTag04::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagSetLogTag05: Test that flogger handles punctuation in tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagSetLogTag05::CFloggerTest030_TagSetLogTag05() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagSetLogTag05")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagSetLogTag05::~CFloggerTest030_TagSetLogTag05() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagSetLogTag05::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag05::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag05::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.SetLogTags(KSubsysTagWithPunctuationChars8, KCompTagWithPunctuationChars8); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagSetLogTag05::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: /** sl@0: * 030_TagSetLogTag06: Test that flogger handles long tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagSetLogTag06::CFloggerTest030_TagSetLogTag06() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagSetLogTag06")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagSetLogTag06::~CFloggerTest030_TagSetLogTag06() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagSetLogTag06::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag06::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag06::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.SetLogTags(KSubsysTag16char8, KCompTag16char8); sl@0: theFlogger.Write(KTestMessage8); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagSetLogTag06::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: else if (returnCode == KErrNotFound) sl@0: { sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagSetLogTag07: Test that flogger handles long tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagSetLogTag07::CFloggerTest030_TagSetLogTag07() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagSetLogTag07")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagSetLogTag07::~CFloggerTest030_TagSetLogTag07() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagSetLogTag07::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag07::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag07::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.SetLogTags(KSubsysTag17char8, KCompTag17char8); sl@0: theFlogger.Write(KTestMessage8); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagSetLogTag07::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: else if (returnCode == KErrNotFound) sl@0: { sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: // We expect to see the string "subsystem0123456" but not "subsystem01234567" sl@0: returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read sl@0: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: returnCode = ptrString.Find(KSubsysTag17char8); //find the test descriptor in the buffer read sl@0: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 3) 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: * 030_TagSetLogTag08: Test that flogger handles very long tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagSetLogTag08::CFloggerTest030_TagSetLogTag08() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagSetLogTag08")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagSetLogTag08::~CFloggerTest030_TagSetLogTag08() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagSetLogTag08::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag08::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagSetLogTag08::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.SetLogTags(KSubsysTag66char8, KCompTag66char8); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagSetLogTag08::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: else if (returnCode == KErrNotFound) sl@0: { sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: // We expect to see the string "subsystem0123456" but not "subsystem01234567" sl@0: returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read sl@0: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 2) 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: /** sl@0: * 030_TagCreateLog01: Test that flogger handles empty tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagCreateLog01::CFloggerTest030_TagCreateLog01() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagCreateLog01")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagCreateLog01::~CFloggerTest030_TagCreateLog01() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagCreateLog01::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagCreateLog01::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagCreateLog01::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.CreateLog(KNullDesC16, KNullDesC16, EFileLoggingModeOverwrite); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagCreateLog01::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagCreateLog02: Test that flogger handles empty subsys tag sl@0: */ sl@0: sl@0: CFloggerTest030_TagCreateLog02::CFloggerTest030_TagCreateLog02() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagCreateLog02")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagCreateLog02::~CFloggerTest030_TagCreateLog02() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagCreateLog02::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagCreateLog02::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagCreateLog02::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.CreateLog(KNullDesC16, KStdCompTag16, EFileLoggingModeOverwrite); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagCreateLog02::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 030_TagCreateLog03: Test that flogger handles empty component tag sl@0: */ sl@0: sl@0: CFloggerTest030_TagCreateLog03::CFloggerTest030_TagCreateLog03() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagCreateLog03")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagCreateLog03::~CFloggerTest030_TagCreateLog03() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagCreateLog03::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagCreateLog03::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagCreateLog03::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.CreateLog(KStdSubsysTag16, KNullDesC16, EFileLoggingModeOverwrite); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagCreateLog03::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagCreateLog04: Test that flogger handles spaces in tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagCreateLog04::CFloggerTest030_TagCreateLog04() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagCreateLog04")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagCreateLog04::~CFloggerTest030_TagCreateLog04() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagCreateLog04::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagCreateLog04::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagCreateLog04::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.CreateLog(KStdSubsysTag16, KCompTagWithSpaceChars16, EFileLoggingModeOverwrite); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagCreateLog04::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagCreateLog05: Test that flogger handles punctuation in tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagCreateLog05::CFloggerTest030_TagCreateLog05() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagCreateLog05")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagCreateLog05::~CFloggerTest030_TagCreateLog05() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagCreateLog05::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagCreateLog05::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagCreateLog05::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.CreateLog(KSubsysTagWithPunctuationChars16, KCompTagWithPunctuationChars16, EFileLoggingModeOverwrite); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagCreateLog05::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 030_TagCreateLog06: Test that flogger handles length 16 tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagCreateLog06::CFloggerTest030_TagCreateLog06() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagCreateLog06")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagCreateLog06::~CFloggerTest030_TagCreateLog06() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagCreateLog06::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagCreateLog06::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagCreateLog06::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.CreateLog(KSubsysTag16char16, KCompTag16char16, EFileLoggingModeOverwrite); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: sl@0: TInt CFloggerTest030_TagCreateLog06::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8<256> testData; //To hold the test descriptor sl@0: sl@0: sl@0: _LIT8(KOOMError, "#Logs may be lost out of memory!!"); sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: if (returnCode == KErrNotFound) sl@0: { sl@0: returnCode = ptrString.Find(KOOMError); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile 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: sl@0: sl@0: /** sl@0: * 030_TagCreateLog07: Test that flogger handles length 17 tags by truncating sl@0: */ sl@0: sl@0: CFloggerTest030_TagCreateLog07::CFloggerTest030_TagCreateLog07() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagCreateLog07")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagCreateLog07::~CFloggerTest030_TagCreateLog07() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagCreateLog07::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagCreateLog07::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagCreateLog07::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.CreateLog(KSubsysTag17char16, KCompTag17char16, EFileLoggingModeOverwrite); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: /** sl@0: * This function checks whether test data was written sl@0: * in to the log file . sl@0: */ sl@0: sl@0: sl@0: TInt CFloggerTest030_TagCreateLog07::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TBuf8<256> testData; //To hold the test descriptor sl@0: TInt numSuccessful = 0; sl@0: sl@0: sl@0: _LIT8(KOOMError, "#Logs may be lost out of memory!!"); sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: // We expect to see the string "subsystem0123456" but not "subsystem01234567" sl@0: testData.Copy(KSubsysTag16char16); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: testData.Copy(KSubsysTag17char16); //Copy the test descriptor sl@0: returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read sl@0: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: returnCode = ptrString.Find(KOOMError); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: if (numSuccessful == 3) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: /** sl@0: * 030_TagCreateLog08: Test that flogger handles very long tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagCreateLog08::CFloggerTest030_TagCreateLog08() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagCreateLog08")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagCreateLog08::~CFloggerTest030_TagCreateLog08() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagCreateLog08::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagCreateLog08::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagCreateLog08::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.CreateLog(KSubsysTag66char16, KCompTag66char16, EFileLoggingModeOverwrite); sl@0: theFlogger.Write(KTestMessage); sl@0: theFlogger.Close(); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagCreateLog08::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: else if (returnCode == KErrNotFound) sl@0: { sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: // We expect to see the string "subsystem0123456" but not "subsystem01234567" sl@0: returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read sl@0: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 2) 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: sl@0: /** sl@0: * 030_TagWrite01: Test that flogger handles empty tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagWrite01::CFloggerTest030_TagWrite01() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagWrite01")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagWrite01::~CFloggerTest030_TagWrite01() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagWrite01::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagWrite01::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagWrite01::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.Close(); sl@0: RFileLogger::Write(KNullDesC8, KNullDesC8,KTestMessage); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagWrite01::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagWrite02: Test that flogger handles empty subsys tag sl@0: */ sl@0: sl@0: CFloggerTest030_TagWrite02::CFloggerTest030_TagWrite02() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagWrite02")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagWrite02::~CFloggerTest030_TagWrite02() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagWrite02::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagWrite02::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagWrite02::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.Close(); sl@0: RFileLogger::Write(KNullDesC8, KStdCompTag8,KTestMessage); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagWrite02::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: * 030_TagWrite03: Test that flogger handles empty component tag sl@0: */ sl@0: sl@0: CFloggerTest030_TagWrite03::CFloggerTest030_TagWrite03() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagWrite03")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagWrite03::~CFloggerTest030_TagWrite03() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagWrite03::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagWrite03::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagWrite03::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.Close(); sl@0: RFileLogger::Write(KStdSubsysTag8, KNullDesC8,KTestMessage); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagWrite03::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagWrite04: Test that flogger handles spaces in tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagWrite04::CFloggerTest030_TagWrite04() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagWrite04")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagWrite04::~CFloggerTest030_TagWrite04() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagWrite04::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagWrite04::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagWrite04::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.Close(); sl@0: RFileLogger::Write(KStdSubsysTag8, KCompTagWithSpaceChars8,KTestMessage); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagWrite04::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagWrite05: Test that flogger handles punctuation in tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagWrite05::CFloggerTest030_TagWrite05() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagWrite05")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagWrite05::~CFloggerTest030_TagWrite05() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagWrite05::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagWrite05::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagWrite05::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.Close(); sl@0: RFileLogger::Write(KSubsysTagWithPunctuationChars8, KCompTagWithPunctuationChars8,KTestMessage); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagWrite05::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: sl@0: /** sl@0: * 030_TagWrite06: Test that flogger handles long tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagWrite06::CFloggerTest030_TagWrite06() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagWrite06")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagWrite06::~CFloggerTest030_TagWrite06() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagWrite06::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagWrite06::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagWrite06::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.Close(); sl@0: RFileLogger::Write(KSubsysTag16char8, KCompTag16char8,KTestMessage8); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagWrite06::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: else if (returnCode == KErrNotFound) sl@0: { sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 1) 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: * 030_TagWrite07: Test that flogger handles long tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagWrite07::CFloggerTest030_TagWrite07() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagWrite07")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagWrite07::~CFloggerTest030_TagWrite07() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagWrite07::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagWrite07::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagWrite07::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: //Create Log by passing the subsystem and component name as parameters sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.Close(); sl@0: RFileLogger::Write(KSubsysTag17char8, KCompTag17char8,KTestMessage8); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagWrite07::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: else if (returnCode == KErrNotFound) sl@0: { sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: // We expect to see the string "subsystem0123456" but not "subsystem01234567" sl@0: returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read sl@0: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: returnCode = ptrString.Find(KSubsysTag17char8); //find the test descriptor in the buffer read sl@0: sl@0: if (returnCode == KErrNotFound) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 3) 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: * 030_TagWrite08: Test that flogger handles very long tags sl@0: */ sl@0: sl@0: CFloggerTest030_TagWrite08::CFloggerTest030_TagWrite08() sl@0: { sl@0: // Store the name of this test case sl@0: SetTestStepName(_L("step_030_TagWrite08")); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CFloggerTest030_TagWrite08::~CFloggerTest030_TagWrite08() sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: TVerdict CFloggerTest030_TagWrite08::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: User::After(KTimeForDisplay); sl@0: sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TInt CFloggerTest030_TagWrite08::executeStepL(TBool) sl@0: { sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt CFloggerTest030_TagWrite08::executeStepL() sl@0: { sl@0: sl@0: TInt ret ; sl@0: RFileLogger theFlogger; sl@0: ret = theFlogger.Connect(); sl@0: sl@0: if ( ret == KErrNone) sl@0: { sl@0: theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8); sl@0: theFlogger.ClearLog(); sl@0: theFlogger.Close(); sl@0: RFileLogger::Write(KSubsysTag66char8, KCompTag66char8,KTestMessage); sl@0: User::After(KTimeToLog); 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: sl@0: TInt CFloggerTest030_TagWrite08::DoTestCheckWriteL() sl@0: { sl@0: RFile theFile; sl@0: HBufC8 * hBuffer; sl@0: TInt listfilesize,returnCode; sl@0: RFs fileSystem; //For file operation create a file system sl@0: TUint numSuccessful = 0; sl@0: sl@0: sl@0: User::LeaveIfError(fileSystem.Connect()); sl@0: CleanupClosePushL(fileSystem); sl@0: sl@0: //Open the file in the read mode sl@0: User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); sl@0: sl@0: CleanupClosePushL(theFile); sl@0: sl@0: User::LeaveIfError(theFile.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 hold the buffer sl@0: sl@0: // Read from position 0: start of file sl@0: User::LeaveIfError(returnCode = theFile.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: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: else if (returnCode == KErrNotFound) sl@0: { sl@0: returnCode = ptrString.Find(KErrOOM); sl@0: if (returnCode > 0) sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: // We expect to see the string "subsystem0123456" but not "subsystem01234567" sl@0: returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read sl@0: sl@0: if (returnCode > 0) sl@0: { sl@0: numSuccessful++; sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(hBuffer); sl@0: CleanupStack::PopAndDestroy(); //theFile sl@0: CleanupStack::PopAndDestroy(); //fileSystem sl@0: sl@0: if (numSuccessful == 2) sl@0: return KErrNone; sl@0: else sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: