|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file TestExecuteLog.h |
|
22 */ |
|
23 |
|
24 #if !(defined __TESTEXECUTE_LOG_H__) |
|
25 #define __TESTEXECUTE_LOG_H__ |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <test/tefexportconst.h> |
|
29 |
|
30 _LIT8(KTEFOverflowMessage8, "\t..Message Truncated"); |
|
31 _LIT16(KTEFOverflowMessage16, "\t..Message Truncated"); |
|
32 const TInt overflowMessageLen = 21; // Size of the truncation message. To be changed if the text above is changed |
|
33 |
|
34 /** |
|
35 @internalComponent |
|
36 @test |
|
37 * Derived class implementation of TDes16Overflow class |
|
38 * Implements the base class pure virtual Overflow() to handle descriptor overflow |
|
39 * during AppendFormatList() operations on TDes16 objects |
|
40 */ |
|
41 class TTEFDes16Overflow : public TDes16Overflow |
|
42 { |
|
43 inline virtual void Overflow(TDes16& aDes) |
|
44 { |
|
45 TInt actualMessageLen = aDes.Length(); |
|
46 TInt maxLengthOfDes = aDes.MaxLength(); |
|
47 |
|
48 TInt midPosForEdit = maxLengthOfDes - overflowMessageLen; |
|
49 if (actualMessageLen <= midPosForEdit) |
|
50 { |
|
51 aDes.Append(KTEFOverflowMessage16()); |
|
52 } |
|
53 else |
|
54 { |
|
55 aDes.SetLength(midPosForEdit + overflowMessageLen); |
|
56 aDes.Replace(midPosForEdit, overflowMessageLen, KTEFOverflowMessage16()); |
|
57 } |
|
58 } |
|
59 }; |
|
60 |
|
61 /** |
|
62 @internalComponent |
|
63 @test |
|
64 * Derived class implementation of TDes8Overflow class |
|
65 * Implements the base class pure virtual Overflow() to handle descriptor overflow |
|
66 * during AppendFormatList() operations on TDes8 objects |
|
67 */ |
|
68 class TTEFDes8Overflow : public TDes8Overflow |
|
69 { |
|
70 inline virtual void Overflow(TDes8& aDes) |
|
71 { |
|
72 TInt actualMessageLen = aDes.Length(); |
|
73 TInt maxLengthOfDes = aDes.MaxLength(); |
|
74 |
|
75 TInt midPosForEdit = maxLengthOfDes - overflowMessageLen; |
|
76 if (actualMessageLen <= midPosForEdit) |
|
77 { |
|
78 aDes.Append(KTEFOverflowMessage8()); |
|
79 } |
|
80 else |
|
81 { |
|
82 aDes.SetLength(midPosForEdit + overflowMessageLen); |
|
83 aDes.Replace(midPosForEdit, overflowMessageLen, KTEFOverflowMessage8()); |
|
84 } |
|
85 } |
|
86 }; |
|
87 |
|
88 class RTestExecuteLogServ : public RSessionBase |
|
89 /** |
|
90 @internalComponent |
|
91 @test |
|
92 */ |
|
93 { |
|
94 public: |
|
95 enum TLogMode{ELogModeAppend,ELogModeOverWrite}; |
|
96 // Logging level |
|
97 enum TLogCommand{ECreateLog,EWriteLog}; |
|
98 |
|
99 IMPORT_C TInt Connect(); |
|
100 IMPORT_C TInt CreateLog(const TDesC& aLogFilePath,TLogMode aMode); |
|
101 IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt,...); |
|
102 IMPORT_C void Write(const TDesC& aLogBuffer); |
|
103 IMPORT_C void WriteFormat(TRefByValue<const TDesC> aFmt,...); |
|
104 IMPORT_C void Write(const TDesC8& aLogBuffer); |
|
105 IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt,...); |
|
106 IMPORT_C void LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt, VA_LIST aList); |
|
107 IMPORT_C void WriteFormat(TRefByValue<const TDesC> aFmt, VA_LIST aList); |
|
108 IMPORT_C void WriteFormat(TRefByValue<const TDesC8> aFmt, VA_LIST aList); |
|
109 IMPORT_C void SetLogLevel(TLogSeverity aSeverity); |
|
110 private: |
|
111 void WriteL(const TDesC& aLogBuffer); |
|
112 void WriteL(TDes8& aLogBuffer); |
|
113 void GetCPPModuleName(TDes& aModuleName, const TText8* aCPPFileName); |
|
114 void AddTime(TDes8& aTime); |
|
115 TLogSeverity iLogLevel; |
|
116 }; |
|
117 #endif |