1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/test/testexecutelog.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,116 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +/**
1.23 + @file TestExecuteLog.h
1.24 +*/
1.25 +
1.26 +#if !(defined __TESTEXECUTE_LOG_H__)
1.27 +#define __TESTEXECUTE_LOG_H__
1.28 +
1.29 +#include <e32base.h>
1.30 +#include <test/tefexportconst.h>
1.31 +
1.32 +_LIT8(KTEFOverflowMessage8, "\t..Message Truncated");
1.33 +_LIT16(KTEFOverflowMessage16, "\t..Message Truncated");
1.34 +const TInt overflowMessageLen = 21; // Size of the truncation message. To be changed if the text above is changed
1.35 +
1.36 +/**
1.37 + @internalComponent
1.38 + @test
1.39 + * Derived class implementation of TDes16Overflow class
1.40 + * Implements the base class pure virtual Overflow() to handle descriptor overflow
1.41 + * during AppendFormatList() operations on TDes16 objects
1.42 + */
1.43 +class TTEFDes16Overflow : public TDes16Overflow
1.44 + {
1.45 + inline virtual void Overflow(TDes16& aDes)
1.46 + {
1.47 + TInt actualMessageLen = aDes.Length();
1.48 + TInt maxLengthOfDes = aDes.MaxLength();
1.49 +
1.50 + TInt midPosForEdit = maxLengthOfDes - overflowMessageLen;
1.51 + if (actualMessageLen <= midPosForEdit)
1.52 + {
1.53 + aDes.Append(KTEFOverflowMessage16());
1.54 + }
1.55 + else
1.56 + {
1.57 + aDes.SetLength(midPosForEdit + overflowMessageLen);
1.58 + aDes.Replace(midPosForEdit, overflowMessageLen, KTEFOverflowMessage16());
1.59 + }
1.60 + }
1.61 + };
1.62 +
1.63 +/**
1.64 + @internalComponent
1.65 + @test
1.66 + * Derived class implementation of TDes8Overflow class
1.67 + * Implements the base class pure virtual Overflow() to handle descriptor overflow
1.68 + * during AppendFormatList() operations on TDes8 objects
1.69 + */
1.70 +class TTEFDes8Overflow : public TDes8Overflow
1.71 + {
1.72 + inline virtual void Overflow(TDes8& aDes)
1.73 + {
1.74 + TInt actualMessageLen = aDes.Length();
1.75 + TInt maxLengthOfDes = aDes.MaxLength();
1.76 +
1.77 + TInt midPosForEdit = maxLengthOfDes - overflowMessageLen;
1.78 + if (actualMessageLen <= midPosForEdit)
1.79 + {
1.80 + aDes.Append(KTEFOverflowMessage8());
1.81 + }
1.82 + else
1.83 + {
1.84 + aDes.SetLength(midPosForEdit + overflowMessageLen);
1.85 + aDes.Replace(midPosForEdit, overflowMessageLen, KTEFOverflowMessage8());
1.86 + }
1.87 + }
1.88 + };
1.89 +
1.90 +class RTestExecuteLogServ : public RSessionBase
1.91 +/**
1.92 +@internalComponent
1.93 +@test
1.94 +*/
1.95 + {
1.96 +public:
1.97 + enum TLogMode{ELogModeAppend,ELogModeOverWrite};
1.98 + // Logging level
1.99 + enum TLogCommand{ECreateLog,EWriteLog};
1.100 +
1.101 + IMPORT_C TInt Connect();
1.102 + IMPORT_C TInt CreateLog(const TDesC& aLogFilePath,TLogMode aMode);
1.103 + IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt,...);
1.104 + IMPORT_C void Write(const TDesC& aLogBuffer);
1.105 + IMPORT_C void WriteFormat(TRefByValue<const TDesC> aFmt,...);
1.106 + IMPORT_C void Write(const TDesC8& aLogBuffer);
1.107 + IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt,...);
1.108 + IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt, VA_LIST aList);
1.109 + IMPORT_C void WriteFormat(TRefByValue<const TDesC> aFmt, VA_LIST aList);
1.110 + IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST aList);
1.111 + IMPORT_C void SetLogLevel(TLogSeverity aSeverity);
1.112 +private:
1.113 + void WriteL(const TDesC& aLogBuffer);
1.114 + void WriteL(TDes8& aLogBuffer);
1.115 + void GetCPPModuleName(TDes& aModuleName, const TText8* aCPPFileName);
1.116 + void AddTime(TDes8& aTime);
1.117 + TLogSeverity iLogLevel;
1.118 + };
1.119 +#endif