sl@0
|
1 |
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// This contains Flogger Unit Test Case 009.xx
|
sl@0
|
15 |
|
sl@0
|
16 |
// EPOC includes
|
sl@0
|
17 |
#include <e32base.h>
|
sl@0
|
18 |
|
sl@0
|
19 |
// Test system includes
|
sl@0
|
20 |
#include <comms-infras/commsdebugutility.h>
|
sl@0
|
21 |
#include <f32file.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
//User includes
|
sl@0
|
25 |
#include "teststepcomsdbg.h"
|
sl@0
|
26 |
#include "step_009_xx.h"
|
sl@0
|
27 |
|
sl@0
|
28 |
|
sl@0
|
29 |
/**
|
sl@0
|
30 |
* Function Name : CFloggerTest009_01
|
sl@0
|
31 |
* Input parameters : None
|
sl@0
|
32 |
* Output parameters : None
|
sl@0
|
33 |
* Description : This is the constructor
|
sl@0
|
34 |
*/
|
sl@0
|
35 |
|
sl@0
|
36 |
|
sl@0
|
37 |
CFloggerTest009_01::CFloggerTest009_01()
|
sl@0
|
38 |
{
|
sl@0
|
39 |
SetTestStepName(_L("step_009_01"));
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
|
sl@0
|
43 |
/**
|
sl@0
|
44 |
* Function Name :~ CFloggerTest009_01
|
sl@0
|
45 |
* Input parameters : None
|
sl@0
|
46 |
* Output parameters : None
|
sl@0
|
47 |
* Description : This is the Destructor
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
|
sl@0
|
50 |
|
sl@0
|
51 |
CFloggerTest009_01::~CFloggerTest009_01()
|
sl@0
|
52 |
{
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
|
sl@0
|
56 |
/**
|
sl@0
|
57 |
* Function Name : doTestStepL
|
sl@0
|
58 |
* Input parameters : None
|
sl@0
|
59 |
* Output parameters : TVerdict
|
sl@0
|
60 |
* Description : This function returns weather the test case 009_01 has
|
sl@0
|
61 |
* passed or failed
|
sl@0
|
62 |
|
sl@0
|
63 |
*/
|
sl@0
|
64 |
|
sl@0
|
65 |
|
sl@0
|
66 |
TVerdict CFloggerTest009_01::doTestStepL( )
|
sl@0
|
67 |
{
|
sl@0
|
68 |
RFileLogger logger;
|
sl@0
|
69 |
INFO_PRINTF1(_L("Step 009.01 called "));
|
sl@0
|
70 |
|
sl@0
|
71 |
if ( executeStepL(EFalse) == KErrNone )
|
sl@0
|
72 |
SetTestStepResult(EPass);
|
sl@0
|
73 |
|
sl@0
|
74 |
else
|
sl@0
|
75 |
SetTestStepResult(EFail);
|
sl@0
|
76 |
|
sl@0
|
77 |
|
sl@0
|
78 |
User::After(KTimeForDisplay);
|
sl@0
|
79 |
return TestStepResult();
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
|
sl@0
|
83 |
/**
|
sl@0
|
84 |
* Function Name : executeStepL
|
sl@0
|
85 |
* Input parameters : None
|
sl@0
|
86 |
* Output parameters : TInt
|
sl@0
|
87 |
* Description : This function writes the test data in to the log file
|
sl@0
|
88 |
* This function check the test message is present in the
|
sl@0
|
89 |
* log file or not.
|
sl@0
|
90 |
|
sl@0
|
91 |
*/
|
sl@0
|
92 |
|
sl@0
|
93 |
|
sl@0
|
94 |
TInt CFloggerTest009_01::executeStepL(TBool heapTest)
|
sl@0
|
95 |
{
|
sl@0
|
96 |
TInt ret = KErrNone;
|
sl@0
|
97 |
|
sl@0
|
98 |
ret = DoTestConnect();
|
sl@0
|
99 |
CleanupClosePushL(iFlogger);
|
sl@0
|
100 |
if (ret == KErrNone)
|
sl@0
|
101 |
{
|
sl@0
|
102 |
ret = DoTestWrite();
|
sl@0
|
103 |
if ( ret == KErrNone)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
106 |
if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
|
sl@0
|
107 |
{
|
sl@0
|
108 |
ret = KErrNoMemory;
|
sl@0
|
109 |
}
|
sl@0
|
110 |
else if (r != KErrNone)
|
sl@0
|
111 |
{
|
sl@0
|
112 |
ret = r;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
}
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
// if (ret == KErrNone)
|
sl@0
|
118 |
CleanupStack::PopAndDestroy(); //logger
|
sl@0
|
119 |
return ret;
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
/**
|
sl@0
|
123 |
* Function Name : executeStepL
|
sl@0
|
124 |
* Input parameters : None
|
sl@0
|
125 |
* Output parameters : TInt
|
sl@0
|
126 |
* Description : This function writes the test data in to the log file
|
sl@0
|
127 |
* This function check the test message is present in the
|
sl@0
|
128 |
* log file or not.
|
sl@0
|
129 |
|
sl@0
|
130 |
*/
|
sl@0
|
131 |
|
sl@0
|
132 |
|
sl@0
|
133 |
TInt CFloggerTest009_01::executeStepL()
|
sl@0
|
134 |
{
|
sl@0
|
135 |
return KErrGeneral;
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
/**
|
sl@0
|
139 |
* Function Name : DoTestWrite
|
sl@0
|
140 |
* Input parameters : None
|
sl@0
|
141 |
* Output parameters : TInt
|
sl@0
|
142 |
* Description : This function writes the data to the file logger
|
sl@0
|
143 |
|
sl@0
|
144 |
*/
|
sl@0
|
145 |
|
sl@0
|
146 |
|
sl@0
|
147 |
TInt CFloggerTest009_01::DoTestWrite()
|
sl@0
|
148 |
{
|
sl@0
|
149 |
_LIT8(KTestMessageOne,"TC 9_01: The value of test integer variable :%d");// The value of second test integer variable : %d");
|
sl@0
|
150 |
return DoTestWriteFormat(KTestMessageOne, 100); //Write unicode formatted test descriptor
|
sl@0
|
151 |
}
|
sl@0
|
152 |
|
sl@0
|
153 |
|
sl@0
|
154 |
/**
|
sl@0
|
155 |
* Function Name : DoTestWriteFormat
|
sl@0
|
156 |
* Input parameters : TRefByValue<const TDesC8>
|
sl@0
|
157 |
* Output parameters : TInt
|
sl@0
|
158 |
* Description : This function writes formatted data to the file logger
|
sl@0
|
159 |
|
sl@0
|
160 |
*/
|
sl@0
|
161 |
|
sl@0
|
162 |
|
sl@0
|
163 |
TInt CFloggerTest009_01::DoTestWriteFormat(TRefByValue<const TDesC8> aFmt,...)
|
sl@0
|
164 |
{
|
sl@0
|
165 |
VA_LIST list;
|
sl@0
|
166 |
VA_START(list,aFmt);
|
sl@0
|
167 |
iFlogger.WriteFormat(aFmt,list);
|
sl@0
|
168 |
ForceLogFlush(iFlogger);
|
sl@0
|
169 |
return KErrNone;
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
|
sl@0
|
173 |
/**
|
sl@0
|
174 |
* Function Name : DoTestCheckWriteL
|
sl@0
|
175 |
* Input parameters : None
|
sl@0
|
176 |
* Output parameters : TInt
|
sl@0
|
177 |
* Description : This function checks the weather test data was written
|
sl@0
|
178 |
* in to the log file by DoTestWriteL() or not.
|
sl@0
|
179 |
|
sl@0
|
180 |
*/
|
sl@0
|
181 |
|
sl@0
|
182 |
|
sl@0
|
183 |
TInt CFloggerTest009_01::DoTestCheckWriteL()
|
sl@0
|
184 |
{
|
sl@0
|
185 |
User::After(1000*1000);
|
sl@0
|
186 |
RFile theFile;
|
sl@0
|
187 |
HBufC8 * hBuffer;
|
sl@0
|
188 |
TInt listfilesize;
|
sl@0
|
189 |
TInt returnCode;
|
sl@0
|
190 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
191 |
TBuf8<256> testData; //To hold the test descriptor
|
sl@0
|
192 |
|
sl@0
|
193 |
_LIT8(KTestMessageOne,"TC 9_01: The value of test integer variable :%d");
|
sl@0
|
194 |
testData.Format(KTestMessageOne,100);
|
sl@0
|
195 |
|
sl@0
|
196 |
_LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
|
sl@0
|
197 |
|
sl@0
|
198 |
_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
|
sl@0
|
199 |
|
sl@0
|
200 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
201 |
|
sl@0
|
202 |
//Open the file in the read mode
|
sl@0
|
203 |
User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
|
sl@0
|
204 |
|
sl@0
|
205 |
CleanupClosePushL(theFile);
|
sl@0
|
206 |
|
sl@0
|
207 |
|
sl@0
|
208 |
User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
209 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
210 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
211 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
212 |
|
sl@0
|
213 |
// Read from position 0: start of file
|
sl@0
|
214 |
returnCode = theFile.Read(ptrString);
|
sl@0
|
215 |
|
sl@0
|
216 |
returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
217 |
//from the file
|
sl@0
|
218 |
|
sl@0
|
219 |
if (returnCode == KErrNotFound) //Find the error message
|
sl@0
|
220 |
{
|
sl@0
|
221 |
returnCode = ptrString.Find(KOOMError);
|
sl@0
|
222 |
if (returnCode > 0)
|
sl@0
|
223 |
User::Leave(KErrNoMemory);
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
|
sl@0
|
227 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
228 |
CleanupStack::PopAndDestroy(); // For theFile object
|
sl@0
|
229 |
if (returnCode > 0)
|
sl@0
|
230 |
return KErrNone;
|
sl@0
|
231 |
else
|
sl@0
|
232 |
return KErrNotFound;
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
|
sl@0
|
236 |
/**
|
sl@0
|
237 |
* Function Name : DoTestConnect
|
sl@0
|
238 |
* Input parameters : None
|
sl@0
|
239 |
* Output parameters : TInt
|
sl@0
|
240 |
* Description : This function establishes a connection to file logger
|
sl@0
|
241 |
* and sets the system and component name in file logger.
|
sl@0
|
242 |
|
sl@0
|
243 |
*/
|
sl@0
|
244 |
|
sl@0
|
245 |
|
sl@0
|
246 |
TInt CFloggerTest009_01::DoTestConnect()
|
sl@0
|
247 |
{
|
sl@0
|
248 |
TInt ret = EFail;
|
sl@0
|
249 |
TPtrC8 ptrSubSystem;
|
sl@0
|
250 |
TPtrC8 ptrComponent;
|
sl@0
|
251 |
ptrSubSystem.Set(_L8("SubSystem"));
|
sl@0
|
252 |
ptrComponent.Set(_L8("Component"));
|
sl@0
|
253 |
|
sl@0
|
254 |
ret = iFlogger.Connect(); //Call connect() of Flogger
|
sl@0
|
255 |
if (ret == KErrNone)
|
sl@0
|
256 |
ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
|
sl@0
|
257 |
|
sl@0
|
258 |
if (ret == KErrNone)
|
sl@0
|
259 |
ret = iFlogger.ClearLog(); //clear the contents from the log
|
sl@0
|
260 |
return ret;
|
sl@0
|
261 |
}
|
sl@0
|
262 |
|
sl@0
|
263 |
|
sl@0
|
264 |
|
sl@0
|
265 |
|
sl@0
|
266 |
|
sl@0
|
267 |
/**
|
sl@0
|
268 |
* Function Name : CFloggerTest009_02
|
sl@0
|
269 |
* Input parameters : None
|
sl@0
|
270 |
* Output parameters : None
|
sl@0
|
271 |
* Description : This is the constructor
|
sl@0
|
272 |
*/
|
sl@0
|
273 |
|
sl@0
|
274 |
|
sl@0
|
275 |
CFloggerTest009_02::CFloggerTest009_02()
|
sl@0
|
276 |
{
|
sl@0
|
277 |
// store the name of this test case
|
sl@0
|
278 |
SetTestStepName(_L("step_009_02"));
|
sl@0
|
279 |
}
|
sl@0
|
280 |
|
sl@0
|
281 |
|
sl@0
|
282 |
/**
|
sl@0
|
283 |
* Function Name :~ CFloggerTest009_02
|
sl@0
|
284 |
* Input parameters : None
|
sl@0
|
285 |
* Output parameters : None
|
sl@0
|
286 |
* Description : This is the Destructor
|
sl@0
|
287 |
*/
|
sl@0
|
288 |
|
sl@0
|
289 |
|
sl@0
|
290 |
CFloggerTest009_02::~CFloggerTest009_02()
|
sl@0
|
291 |
{
|
sl@0
|
292 |
}
|
sl@0
|
293 |
|
sl@0
|
294 |
|
sl@0
|
295 |
/**
|
sl@0
|
296 |
* Function Name : doTestStepL
|
sl@0
|
297 |
* Input parameters : None
|
sl@0
|
298 |
* Output parameters : TVerdict
|
sl@0
|
299 |
* Description : This function returns weather the test case 009_02 has
|
sl@0
|
300 |
* passed or failed
|
sl@0
|
301 |
|
sl@0
|
302 |
*/
|
sl@0
|
303 |
|
sl@0
|
304 |
|
sl@0
|
305 |
TVerdict CFloggerTest009_02::doTestStepL( )
|
sl@0
|
306 |
{
|
sl@0
|
307 |
INFO_PRINTF1(_L("Step 009.02 called "));
|
sl@0
|
308 |
|
sl@0
|
309 |
if ( executeStepL() == KErrNone )
|
sl@0
|
310 |
SetTestStepResult(EPass);
|
sl@0
|
311 |
|
sl@0
|
312 |
else
|
sl@0
|
313 |
SetTestStepResult(EFail);
|
sl@0
|
314 |
|
sl@0
|
315 |
|
sl@0
|
316 |
User::After(KTimeForDisplay);
|
sl@0
|
317 |
return TestStepResult();
|
sl@0
|
318 |
}
|
sl@0
|
319 |
|
sl@0
|
320 |
|
sl@0
|
321 |
/**
|
sl@0
|
322 |
* Function Name : executeStepL
|
sl@0
|
323 |
* Input parameters : None
|
sl@0
|
324 |
* Output parameters : TInt
|
sl@0
|
325 |
* Description : This function writes the test data in to the log file
|
sl@0
|
326 |
* This function check the test message is present in the
|
sl@0
|
327 |
* log file
|
sl@0
|
328 |
*/
|
sl@0
|
329 |
|
sl@0
|
330 |
|
sl@0
|
331 |
TInt CFloggerTest009_02::executeStepL()
|
sl@0
|
332 |
{
|
sl@0
|
333 |
TInt ret = KErrGeneral;
|
sl@0
|
334 |
ret = DoTestConnect();
|
sl@0
|
335 |
|
sl@0
|
336 |
CleanupClosePushL(iFlogger);
|
sl@0
|
337 |
if (ret == KErrNone)
|
sl@0
|
338 |
ret = DoTestWrite();
|
sl@0
|
339 |
if (ret == KErrNone)
|
sl@0
|
340 |
ret = DoTestCheckWriteL();
|
sl@0
|
341 |
|
sl@0
|
342 |
CleanupStack::PopAndDestroy(); //logger
|
sl@0
|
343 |
|
sl@0
|
344 |
User::After(1000000);
|
sl@0
|
345 |
return ret;
|
sl@0
|
346 |
}
|
sl@0
|
347 |
|
sl@0
|
348 |
/**
|
sl@0
|
349 |
* Function Name : executeStepL
|
sl@0
|
350 |
* Input parameters : None
|
sl@0
|
351 |
* Output parameters : TInt
|
sl@0
|
352 |
* Description : This function writes the test data in to the log file
|
sl@0
|
353 |
* This function check the test message is present in the
|
sl@0
|
354 |
* log file
|
sl@0
|
355 |
*/
|
sl@0
|
356 |
|
sl@0
|
357 |
|
sl@0
|
358 |
TInt CFloggerTest009_02::executeStepL(TBool)
|
sl@0
|
359 |
{
|
sl@0
|
360 |
return KErrGeneral;
|
sl@0
|
361 |
}
|
sl@0
|
362 |
|
sl@0
|
363 |
/**
|
sl@0
|
364 |
* Function Name : DoTestConnect
|
sl@0
|
365 |
* Input parameters : None
|
sl@0
|
366 |
* Output parameters : TInt
|
sl@0
|
367 |
* Description : This function establishes a connection to file logger
|
sl@0
|
368 |
* and sets the system and component name in file logger.
|
sl@0
|
369 |
|
sl@0
|
370 |
*/
|
sl@0
|
371 |
|
sl@0
|
372 |
|
sl@0
|
373 |
TInt CFloggerTest009_02::DoTestConnect()
|
sl@0
|
374 |
{
|
sl@0
|
375 |
TInt ret = KErrGeneral;
|
sl@0
|
376 |
TPtrC8 ptrSubSystem;
|
sl@0
|
377 |
TPtrC8 ptrComponent;
|
sl@0
|
378 |
ptrSubSystem.Set(_L8("SubSystem"));
|
sl@0
|
379 |
ptrComponent.Set(_L8("Component"));
|
sl@0
|
380 |
|
sl@0
|
381 |
ret = iFlogger.Connect(); //Call connect() of Flogger
|
sl@0
|
382 |
if (ret == KErrNone)
|
sl@0
|
383 |
ret = iFlogger.SetLogTags(ptrSubSystem, ptrComponent); //SetLogTags() of Flogger called
|
sl@0
|
384 |
|
sl@0
|
385 |
if (ret == KErrNone)
|
sl@0
|
386 |
ret = iFlogger.ClearLog(); //clear the contents from the log
|
sl@0
|
387 |
|
sl@0
|
388 |
return ret;
|
sl@0
|
389 |
}
|
sl@0
|
390 |
|
sl@0
|
391 |
|
sl@0
|
392 |
/**
|
sl@0
|
393 |
* Function Name : DoTestWrite
|
sl@0
|
394 |
* Input parameters : None
|
sl@0
|
395 |
* Output parameters : TInt
|
sl@0
|
396 |
* Description : This function writes the data to the file logger
|
sl@0
|
397 |
|
sl@0
|
398 |
*/
|
sl@0
|
399 |
|
sl@0
|
400 |
|
sl@0
|
401 |
TInt CFloggerTest009_02::DoTestWrite()
|
sl@0
|
402 |
{
|
sl@0
|
403 |
//KTestLongMessage contains a very long test message
|
sl@0
|
404 |
_LIT8(KTestLongMessage,"TC 9_02: This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message %d");
|
sl@0
|
405 |
DoTestWriteFormat(KTestLongMessage, 100);
|
sl@0
|
406 |
ForceLogFlush(iFlogger);
|
sl@0
|
407 |
return KErrNone;
|
sl@0
|
408 |
}
|
sl@0
|
409 |
|
sl@0
|
410 |
|
sl@0
|
411 |
/**
|
sl@0
|
412 |
* Function Name : DoTestWriteFormat
|
sl@0
|
413 |
* Input parameters : TRefByValue<const TDesC8>
|
sl@0
|
414 |
* Output parameters : TInt
|
sl@0
|
415 |
* Description : This function writes formatted data to the file logger
|
sl@0
|
416 |
|
sl@0
|
417 |
*/
|
sl@0
|
418 |
|
sl@0
|
419 |
|
sl@0
|
420 |
TInt CFloggerTest009_02::DoTestWriteFormat(TRefByValue<const TDesC8> aFmt,...)
|
sl@0
|
421 |
{
|
sl@0
|
422 |
VA_LIST list;
|
sl@0
|
423 |
VA_START(list,aFmt);
|
sl@0
|
424 |
TRAPD(res, iFlogger.WriteFormat(aFmt,list));
|
sl@0
|
425 |
return res;
|
sl@0
|
426 |
}
|
sl@0
|
427 |
|
sl@0
|
428 |
|
sl@0
|
429 |
/**
|
sl@0
|
430 |
* Function Name : DoTestCheckWriteL
|
sl@0
|
431 |
* Input parameters : None
|
sl@0
|
432 |
* Output parameters : TInt
|
sl@0
|
433 |
* Description : This function checks the weather test data was written
|
sl@0
|
434 |
* in to the log file by DoTestWriteL() or not.
|
sl@0
|
435 |
|
sl@0
|
436 |
*/
|
sl@0
|
437 |
|
sl@0
|
438 |
|
sl@0
|
439 |
|
sl@0
|
440 |
TInt CFloggerTest009_02::DoTestCheckWriteL()
|
sl@0
|
441 |
{
|
sl@0
|
442 |
User::After(KTimeToLog);
|
sl@0
|
443 |
RFile theFile;
|
sl@0
|
444 |
HBufC8 * hBuffer;
|
sl@0
|
445 |
TInt listfilesize,returnCode;
|
sl@0
|
446 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
447 |
TBuf8<256> testData; //To hold the test descriptor
|
sl@0
|
448 |
_LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path
|
sl@0
|
449 |
|
sl@0
|
450 |
//The following contains the string of length 200(max)
|
sl@0
|
451 |
//which is written to the log file
|
sl@0
|
452 |
//_LIT(KTestLongMessage, "This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message");
|
sl@0
|
453 |
_LIT(KTestLongMessage, "TC 9_02: This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long");
|
sl@0
|
454 |
|
sl@0
|
455 |
//_LIT8(KOOMError, "#Logs may be lost out of memory!!");
|
sl@0
|
456 |
|
sl@0
|
457 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
458 |
|
sl@0
|
459 |
//Open the file in the read mode
|
sl@0
|
460 |
User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
|
sl@0
|
461 |
|
sl@0
|
462 |
CleanupClosePushL(theFile);
|
sl@0
|
463 |
|
sl@0
|
464 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
465 |
|
sl@0
|
466 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
467 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
468 |
|
sl@0
|
469 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
470 |
|
sl@0
|
471 |
// Read from position 0: start of file
|
sl@0
|
472 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
473 |
|
sl@0
|
474 |
testData.Copy(KTestLongMessage); //Copy the test descriptor
|
sl@0
|
475 |
returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
476 |
//from the file
|
sl@0
|
477 |
|
sl@0
|
478 |
|
sl@0
|
479 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
480 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
481 |
if (returnCode > 0)
|
sl@0
|
482 |
return KErrNone;
|
sl@0
|
483 |
else
|
sl@0
|
484 |
return KErrGeneral;
|
sl@0
|
485 |
|
sl@0
|
486 |
|
sl@0
|
487 |
}
|
sl@0
|
488 |
|
sl@0
|
489 |
|
sl@0
|
490 |
|
sl@0
|
491 |
|
sl@0
|
492 |
|
sl@0
|
493 |
/**
|
sl@0
|
494 |
* Function Name : CFloggerTest009_03
|
sl@0
|
495 |
* Input parameters : None
|
sl@0
|
496 |
* Output parameters : None
|
sl@0
|
497 |
* Description : This is the constructor
|
sl@0
|
498 |
*/
|
sl@0
|
499 |
|
sl@0
|
500 |
|
sl@0
|
501 |
CFloggerTest009_03::CFloggerTest009_03()
|
sl@0
|
502 |
{
|
sl@0
|
503 |
// store the name of this test case
|
sl@0
|
504 |
SetTestStepName(_L("step_009_03"));
|
sl@0
|
505 |
}
|
sl@0
|
506 |
|
sl@0
|
507 |
|
sl@0
|
508 |
/**
|
sl@0
|
509 |
* Function Name :~ CFloggerTest009_03
|
sl@0
|
510 |
* Input parameters : None
|
sl@0
|
511 |
* Output parameters : None
|
sl@0
|
512 |
* Description : This is the Destructor
|
sl@0
|
513 |
*/
|
sl@0
|
514 |
|
sl@0
|
515 |
|
sl@0
|
516 |
CFloggerTest009_03::~CFloggerTest009_03()
|
sl@0
|
517 |
{
|
sl@0
|
518 |
}
|
sl@0
|
519 |
|
sl@0
|
520 |
|
sl@0
|
521 |
/**
|
sl@0
|
522 |
* Function Name : doTestStepL
|
sl@0
|
523 |
* Input parameters : None
|
sl@0
|
524 |
* Output parameters : TVerdict
|
sl@0
|
525 |
* Description : This function is responsible for doing the heap test analysis
|
sl@0
|
526 |
|
sl@0
|
527 |
*/
|
sl@0
|
528 |
|
sl@0
|
529 |
|
sl@0
|
530 |
TVerdict CFloggerTest009_03::doTestStepL( )
|
sl@0
|
531 |
{
|
sl@0
|
532 |
INFO_PRINTF1(_L("Step 009.03 called "));
|
sl@0
|
533 |
|
sl@0
|
534 |
CFloggerTest009_01* step009_01 = new CFloggerTest009_01;
|
sl@0
|
535 |
CleanupStack::PushL(step009_01);
|
sl@0
|
536 |
doTestStepWithHeapFailureL( *step009_01, 1, 20, KErrNone, ETrue);
|
sl@0
|
537 |
|
sl@0
|
538 |
CleanupStack::PopAndDestroy(step009_01);
|
sl@0
|
539 |
User::After(KTimeForDisplay);
|
sl@0
|
540 |
return TestStepResult();
|
sl@0
|
541 |
}
|
sl@0
|
542 |
|