|
1 // Copyright (c) 2004-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 // Example CTestStep derived implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file addfield_logStep.cpp |
|
20 */ |
|
21 #include "addfield_logStep.h" |
|
22 #include "Te_RFileLoggerSuiteDefs.h" |
|
23 |
|
24 _LIT(K16BitText,"This is a short line of 16 Bit Text"); |
|
25 _LIT(K16BitFormatText,"logger string int = %d, string = %S"); |
|
26 _LIT(K16BitString,"The String16"); |
|
27 |
|
28 Caddfield_logStep::~Caddfield_logStep() |
|
29 /** |
|
30 * Destructor |
|
31 */ |
|
32 { |
|
33 } |
|
34 |
|
35 Caddfield_logStep::Caddfield_logStep() |
|
36 /** |
|
37 * Constructor |
|
38 */ |
|
39 { |
|
40 // **MUST** call SetTestStepName in the constructor as the controlling |
|
41 // framework uses the test step name immediately following construction to set |
|
42 // up the step's unique logging ID. |
|
43 SetTestStepName(Kaddfield_logStep); |
|
44 } |
|
45 |
|
46 TVerdict Caddfield_logStep::doTestStepPreambleL() |
|
47 /** |
|
48 * @return - TVerdict code |
|
49 * Override of base class virtual |
|
50 */ |
|
51 { |
|
52 CTe_RFileLoggerSuiteStepBase::doTestStepPreambleL(); |
|
53 SetTestStepResult(EPass); |
|
54 return TestStepResult(); |
|
55 } |
|
56 |
|
57 |
|
58 TVerdict Caddfield_logStep::doTestStepL() |
|
59 /** |
|
60 * @return - TVerdict code |
|
61 * Override of base class pure virtual |
|
62 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
63 * not leave. That being the case, the current test result value will be EPass. |
|
64 */ |
|
65 { |
|
66 |
|
67 if(TestStepResult()==EFail) return TestStepResult(); |
|
68 INFO_PRINTF1(_L("AddField test and logging test")); |
|
69 |
|
70 // OS needs time to shutdown the server in case being connected previous test |
|
71 // The delay means we get server terminated from the OS |
|
72 // |
|
73 RFileFlogger ilogger; |
|
74 TInt err=ilogger.Connect(); |
|
75 if(err) |
|
76 { |
|
77 INFO_PRINTF2(_L("Connect() failed. err = %d"),err); |
|
78 SetTestStepResult(EFail); |
|
79 return TestStepResult(); |
|
80 } |
|
81 err=ilogger.CreateLog(KLogFile1,RFileFlogger::ELogModeAppend); |
|
82 // err=ilogger.CreateLog(KLogFile1,RFileFlogger::ELogModeOverWrite); |
|
83 //ELogModeAppend |
|
84 if(!err) |
|
85 { |
|
86 INFO_PRINTF1(_L("xml format file open passed and test start")); |
|
87 } |
|
88 else |
|
89 { |
|
90 ERR_PRINTF2(_L("error value = %d"),err); |
|
91 SetTestStepResult(EFail); |
|
92 return TestStepResult(); |
|
93 |
|
94 } |
|
95 |
|
96 TBuf<20> buf16(K16BitString); |
|
97 TInt n=0; |
|
98 ilogger.SetLogLevel(RFileFlogger::ESevrAll); |
|
99 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrAll, K16BitFormatText,n++,&buf16); |
|
100 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrInfo, K16BitFormatText,n++,&buf16); |
|
101 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrWarn, K16BitFormatText,n++,&buf16); |
|
102 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrHigh, K16BitFormatText,n++,&buf16); |
|
103 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrMedium, K16BitFormatText,n++,&buf16); |
|
104 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrLow, K16BitFormatText,n++,&buf16); |
|
105 |
|
106 INFO_PRINTF1(_L("test ESevrErr")); |
|
107 ilogger.SetLogLevel(RFileFlogger::ESevrErr); |
|
108 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrAll, K16BitFormatText,n++,&buf16); |
|
109 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrInfo, K16BitFormatText,n++,&buf16); |
|
110 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrWarn, K16BitFormatText,n++,&buf16); |
|
111 |
|
112 INFO_PRINTF1(_L("test log with add fileds")); |
|
113 TInt aLength = 2; |
|
114 TExtraLogField logField[2]; |
|
115 logField[0].iLogFieldName.Copy(_L("SUITE_NAME")); |
|
116 logField[0].iLogFieldValue.Copy(_L("SUITE_VALUE")); |
|
117 logField[1].iLogFieldName.Copy(_L("TEST_NAME")); |
|
118 logField[1].iLogFieldValue.Copy(_L("TEST_VALUE")); |
|
119 |
|
120 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrErr, aLength, logField, K16BitFormatText,n++,&buf16); |
|
121 |
|
122 |
|
123 INFO_PRINTF1(_L("test ESevrWarn")); |
|
124 n=0; |
|
125 ilogger.SetLogLevel(RFileFlogger::ESevrWarn); |
|
126 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrAll, K16BitFormatText,n++,&buf16); |
|
127 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrInfo, K16BitFormatText,n++,&buf16); |
|
128 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrWarn, K16BitFormatText,n++,&buf16); |
|
129 |
|
130 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrErr, K16BitFormatText,n++,&buf16); |
|
131 |
|
132 INFO_PRINTF1(_L("test ESevrInfo")); |
|
133 n=0; |
|
134 ilogger.SetLogLevel(RFileFlogger::ESevrInfo); |
|
135 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrAll, K16BitFormatText,n++,&buf16); |
|
136 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrInfo, K16BitFormatText,n++,&buf16); |
|
137 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrWarn, K16BitFormatText,n++,&buf16); |
|
138 |
|
139 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrErr, K16BitFormatText,n++,&buf16); |
|
140 |
|
141 INFO_PRINTF1(_L("test ESevrAll")); |
|
142 n=0; |
|
143 ilogger.SetLogLevel(RFileFlogger::ESevrAll); |
|
144 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrAll, K16BitFormatText,n++,&buf16); |
|
145 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrInfo, K16BitFormatText,n++,&buf16); |
|
146 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrWarn, K16BitFormatText,n++,&buf16); |
|
147 |
|
148 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrErr, K16BitFormatText,n++,&buf16); |
|
149 // txt log test |
|
150 ilogger.Close(); |
|
151 err=ilogger.Connect(); |
|
152 if(err) |
|
153 { |
|
154 INFO_PRINTF2(_L("Connect() failed. err = %d"),err); |
|
155 SetTestStepResult(EFail); |
|
156 return TestStepResult(); |
|
157 } |
|
158 INFO_PRINTF1(_L("RFileFlogger::ELogModeAppend test ...")); |
|
159 err=ilogger.CreateLog(KLogFiletxt,RFileFlogger::ELogModeAppend); |
|
160 if(!err) |
|
161 { |
|
162 INFO_PRINTF1(_L("RFileFlogger::ELogModeAppend testing is fine")); |
|
163 INFO_PRINTF1(_L("txt format file open passed and test start")); |
|
164 } |
|
165 else |
|
166 { |
|
167 ERR_PRINTF2(_L("error value = %d"),err); |
|
168 SetTestStepResult(EFail); |
|
169 return TestStepResult(); |
|
170 |
|
171 } |
|
172 |
|
173 n=0; |
|
174 ilogger.SetLogLevel(RFileFlogger::ESevrAll); |
|
175 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrAll, K16BitFormatText,n++,&buf16); |
|
176 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrInfo, K16BitFormatText,n++,&buf16); |
|
177 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrWarn, K16BitFormatText,n++,&buf16); |
|
178 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrHigh, K16BitFormatText,n++,&buf16); |
|
179 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrMedium, K16BitFormatText,n++,&buf16); |
|
180 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrLow, K16BitFormatText,n++,&buf16); |
|
181 |
|
182 INFO_PRINTF1(_L("test ESevrErr")); |
|
183 ilogger.SetLogLevel(RFileFlogger::ESevrErr); |
|
184 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrAll, K16BitFormatText,n++,&buf16); |
|
185 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrInfo, K16BitFormatText,n++,&buf16); |
|
186 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrWarn, K16BitFormatText,n++,&buf16); |
|
187 |
|
188 INFO_PRINTF1(_L("test log with add fileds")); |
|
189 aLength = 2; |
|
190 logField[0].iLogFieldName.Copy(_L("SUITE_NAME")); |
|
191 logField[0].iLogFieldValue.Copy(_L("SUITE_VALUE")); |
|
192 logField[1].iLogFieldName.Copy(_L("TEST_NAME")); |
|
193 logField[1].iLogFieldValue.Copy(_L("TEST_VALUE")); |
|
194 |
|
195 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrErr, aLength, logField, K16BitFormatText,n++,&buf16); |
|
196 |
|
197 |
|
198 INFO_PRINTF1(_L("test ESevrWarn")); |
|
199 n=0; |
|
200 ilogger.SetLogLevel(RFileFlogger::ESevrWarn); |
|
201 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrAll, K16BitFormatText,n++,&buf16); |
|
202 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrInfo, K16BitFormatText,n++,&buf16); |
|
203 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrWarn, K16BitFormatText,n++,&buf16); |
|
204 |
|
205 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrErr, K16BitFormatText,n++,&buf16); |
|
206 |
|
207 INFO_PRINTF1(_L("test ESevrInfo")); |
|
208 n=0; |
|
209 ilogger.SetLogLevel(RFileFlogger::ESevrInfo); |
|
210 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrAll, K16BitFormatText,n++,&buf16); |
|
211 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrInfo, K16BitFormatText,n++,&buf16); |
|
212 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrWarn, K16BitFormatText,n++,&buf16); |
|
213 |
|
214 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrErr, K16BitFormatText,n++,&buf16); |
|
215 |
|
216 INFO_PRINTF1(_L("test ESevrAll")); |
|
217 n=0; |
|
218 ilogger.SetLogLevel(RFileFlogger::ESevrAll); |
|
219 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrAll, K16BitFormatText,n++,&buf16); |
|
220 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrInfo, K16BitFormatText,n++,&buf16); |
|
221 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrWarn, K16BitFormatText,n++,&buf16); |
|
222 |
|
223 ilogger.Log(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrErr, K16BitFormatText,n++,&buf16); |
|
224 |
|
225 |
|
226 ilogger.Close(); |
|
227 |
|
228 INFO_PRINTF1(_L("test finished")); |
|
229 |
|
230 return TestStepResult(); |
|
231 } |
|
232 |
|
233 |
|
234 |
|
235 TVerdict Caddfield_logStep::doTestStepPostambleL() |
|
236 /** |
|
237 * @return - TVerdict code |
|
238 * Override of base class virtual |
|
239 */ |
|
240 { |
|
241 return TestStepResult(); |
|
242 } |