|
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <e32test.h> |
|
17 #include <f32file.h> |
|
18 |
|
19 const TInt IMSCRIPTBUFFERLENGTH = 256; |
|
20 |
|
21 class CEmailTestUtils; |
|
22 |
|
23 class CScriptTestUtils : public CBase |
|
24 { |
|
25 public: |
|
26 IMPORT_C void LogToInputFileL(const TDesC& aSourceFileName, const TDesC& aDestFileName, TBool aStandardiseDateFields); |
|
27 IMPORT_C void LogToOutputFileL(const TDesC& aSourceFileName, const TDesC& aDestFileName, TBool aStandardiseDateFields); |
|
28 |
|
29 IMPORT_C static CScriptTestUtils* NewLC(CEmailTestUtils& aTestUtils); |
|
30 ~CScriptTestUtils(); |
|
31 |
|
32 // Functions for checking the IM output. |
|
33 IMPORT_C TBool CheckLogOutputL(TInt aPortNumber, const TDesC& aTestFileName); |
|
34 IMPORT_C TInt ErrorLineNumber(); |
|
35 IMPORT_C HBufC* ErrorExpectedL(); |
|
36 IMPORT_C HBufC* ErrorActualL(); |
|
37 |
|
38 private: |
|
39 |
|
40 void ConstructL(); |
|
41 |
|
42 enum TImLogLineType |
|
43 { |
|
44 EImLogLineComment, |
|
45 EImLogLineIn, |
|
46 EImLogLineOut, |
|
47 EImEmptyLine, |
|
48 EImReadCancelled |
|
49 }; |
|
50 |
|
51 class TFileReader |
|
52 { |
|
53 public: |
|
54 TFileReader(RFile &rFile); |
|
55 TBool Read(char &rChar); |
|
56 void SeekCurrent(TInt aOffset); |
|
57 void Seek(TInt aOffset); |
|
58 |
|
59 private: |
|
60 RFile& iFile; |
|
61 TBuf8<IMSCRIPTBUFFERLENGTH> iBuffer; |
|
62 TInt iBufferIndex; |
|
63 TInt iBufferStart; |
|
64 }; |
|
65 |
|
66 void StandardiseVariableFieldsL(const TDesC& aSourceFileName); |
|
67 void ReplaceVariableFields(TDes8& aDes); |
|
68 void StripLogFileL(const TFileName& aSourceFileName, const TFileName& aDestFileName, TBool aStandardiseDateFields, TImLogLineType aLogLineType); |
|
69 |
|
70 TImLogLineType LineType(const HBufC8* aLine); |
|
71 HBufC8* GetLineL(TFileReader& aFileReader); |
|
72 |
|
73 CScriptTestUtils(CEmailTestUtils& aTestUtils); |
|
74 |
|
75 private: |
|
76 |
|
77 TInt iErrorLine; |
|
78 HBufC* iExpectedLine; |
|
79 HBufC* iActualLine; |
|
80 |
|
81 class CImTestField |
|
82 { |
|
83 public: |
|
84 HBufC8* iFieldName; |
|
85 HBufC8* iReplacementString; |
|
86 TInt iNumberFound; |
|
87 |
|
88 ~CImTestField(); |
|
89 }; |
|
90 |
|
91 class CImFindReplace |
|
92 { |
|
93 public: |
|
94 HBufC8* iFind; |
|
95 HBufC8* iReplace; |
|
96 |
|
97 ~CImFindReplace(); |
|
98 }; |
|
99 |
|
100 CImFindReplace* FindVariableDataL(TDes8& aLine); |
|
101 |
|
102 CArrayPtrFlat<CImTestField>* iFieldList; |
|
103 CArrayPtrFlat<CImFindReplace>* iFindReplaceList; |
|
104 |
|
105 CEmailTestUtils& iTestUtils; |
|
106 }; |