|
1 // Copyright (c) 2001-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 // Declare CTOCSPScript. This opens a file, starts a scheduler and runs a CIdle object. |
|
15 // Each tick takes a line from the file, parses it into tokens and gives these to |
|
16 // the command processor. |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 #ifndef __TOCSP_SCRIPT_H__ |
|
26 #define __TOCSP_SCRIPT_H__ |
|
27 |
|
28 #include <e32base.h> |
|
29 #include <f32file.h> |
|
30 |
|
31 #include "logger.h" |
|
32 #include "TEFparser.h" |
|
33 #include "main.h" |
|
34 |
|
35 class CTOCSPCommand; |
|
36 class CTOCSPResult; |
|
37 |
|
38 // At most this many chars per line in input file, thanks. |
|
39 const TInt KMaxInputFileLineLength = 256; |
|
40 |
|
41 /** |
|
42 * This class provides a convenient interface to the test script. |
|
43 */ |
|
44 class CTOCSPScript : public CActive |
|
45 { |
|
46 public: |
|
47 /** |
|
48 * This function creates a new CTOCSPScript instance and pushes it on the |
|
49 * cleanup stack. |
|
50 * @param aLog the logger which writes the log into the log file and the cosole. |
|
51 * @param aResult pass/fail result data on the tests |
|
52 * @param aInputFileName The name of the test script file we want to access. |
|
53 * @return A new instance of CTOCSPScript. |
|
54 */ |
|
55 static CTOCSPScript* NewLC(CTOCSPLogger& aLog, |
|
56 CTOCSPResult& aResult, |
|
57 const TDesC& aInputFileName, |
|
58 TInt aTransaction = 0); |
|
59 |
|
60 static CTOCSPScript* NewL(CTOCSPLogger& aLog, |
|
61 CTOCSPResult& aResult, |
|
62 const TDesC& aInputFileName, |
|
63 TInt aTransaction = 0); |
|
64 // script file parser |
|
65 //*********************************************************** |
|
66 static CTOCSPScript* NewL(CTOCSPLogger& aLog, |
|
67 CTOCSPResult& aResult, |
|
68 TInt aTransaction = 0); |
|
69 |
|
70 static CTOCSPScript* NewLC(CTOCSPLogger& aLog, |
|
71 CTOCSPResult& aResult, |
|
72 TInt aTransaction = 0); |
|
73 //*********************************************************** |
|
74 |
|
75 |
|
76 ~CTOCSPScript(); |
|
77 |
|
78 void RunTestL(TRequestStatus& aStatus); |
|
79 |
|
80 // Get the number of transactions performed |
|
81 TInt TransactionCount(); |
|
82 |
|
83 /** Set whether to print informational messages. */ |
|
84 void SetVerbose(TBool aVerbose); |
|
85 |
|
86 /** Get the number of lines we have processed. */ |
|
87 TInt LinesProcessed() const; |
|
88 |
|
89 /** Get the last line processed. */ |
|
90 const TDesC& LastLine() const; |
|
91 |
|
92 void RunL(); |
|
93 void DoCancel(); |
|
94 TInt RunError(TInt aError); |
|
95 |
|
96 private: |
|
97 CTOCSPScript(CTOCSPLogger& aLog); |
|
98 void ConstructL(const TDesC& aInputFileName, CTOCSPResult& aResult, TInt aTransaction); |
|
99 |
|
100 void ConstructL(CTOCSPResult& aResult, TInt aTransaction); |
|
101 |
|
102 void ReadLineL(); |
|
103 |
|
104 private: |
|
105 CTOCSPLogger& iLog; |
|
106 |
|
107 CTOCSPCommand* iCommand; |
|
108 |
|
109 TInt iError; // error code to return to client |
|
110 |
|
111 // File server stuff |
|
112 RFs iFs; |
|
113 RFile iFile; |
|
114 TFileText iLineReader; |
|
115 TInt iLinesProcessed; |
|
116 TBuf<KMaxInputFileLineLength> iLine; |
|
117 TRequestStatus* iClientRequestStatus; |
|
118 TInt iStartPos; |
|
119 }; |
|
120 |
|
121 #endif |