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 017.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 "TestMessage.h"
|
sl@0
|
22 |
#include <f32file.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
//User includes
|
sl@0
|
26 |
#include "teststepcomsdbg.h"
|
sl@0
|
27 |
#include "step_017_xx.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
|
sl@0
|
30 |
/**
|
sl@0
|
31 |
* Function Name : CFloggerTest017_01
|
sl@0
|
32 |
* Input parameters : None
|
sl@0
|
33 |
* Output parameters : None
|
sl@0
|
34 |
* Description : This is the constructor
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
|
sl@0
|
37 |
|
sl@0
|
38 |
CFloggerTest017_01::CFloggerTest017_01()
|
sl@0
|
39 |
{
|
sl@0
|
40 |
// store the name of this test case
|
sl@0
|
41 |
SetTestStepName(_L("step_017_01"));
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
|
sl@0
|
45 |
/**
|
sl@0
|
46 |
* Function Name :~ CFloggerTest017_01
|
sl@0
|
47 |
* Input parameters : None
|
sl@0
|
48 |
* Output parameters : None
|
sl@0
|
49 |
* Description : This is the Destructor
|
sl@0
|
50 |
*/
|
sl@0
|
51 |
|
sl@0
|
52 |
|
sl@0
|
53 |
CFloggerTest017_01::~CFloggerTest017_01()
|
sl@0
|
54 |
{
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
|
sl@0
|
58 |
/**
|
sl@0
|
59 |
* Function Name : doTestStepL
|
sl@0
|
60 |
* Input parameters : None
|
sl@0
|
61 |
* Output parameters : TVerdict
|
sl@0
|
62 |
* Description : This function returns weather the test case 017_01 has
|
sl@0
|
63 |
* passed or failed
|
sl@0
|
64 |
|
sl@0
|
65 |
*/
|
sl@0
|
66 |
|
sl@0
|
67 |
|
sl@0
|
68 |
TVerdict CFloggerTest017_01::doTestStepL( )
|
sl@0
|
69 |
{
|
sl@0
|
70 |
INFO_PRINTF1(_L("Step 017.01 called "));
|
sl@0
|
71 |
|
sl@0
|
72 |
if ( executeStepL(EFalse) == KErrNone )
|
sl@0
|
73 |
SetTestStepResult(EPass);
|
sl@0
|
74 |
|
sl@0
|
75 |
else
|
sl@0
|
76 |
SetTestStepResult(EFail);
|
sl@0
|
77 |
|
sl@0
|
78 |
|
sl@0
|
79 |
User::After(KTimeForDisplay1);
|
sl@0
|
80 |
return TestStepResult();
|
sl@0
|
81 |
}
|
sl@0
|
82 |
/**
|
sl@0
|
83 |
* Function Name : executeStepL
|
sl@0
|
84 |
* Input parameters : None
|
sl@0
|
85 |
* Output parameters : TInt
|
sl@0
|
86 |
* Description : This function writes the test data in to the log file
|
sl@0
|
87 |
* This function check the test message is present in the
|
sl@0
|
88 |
* log file
|
sl@0
|
89 |
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
|
sl@0
|
92 |
|
sl@0
|
93 |
TInt CFloggerTest017_01::executeStepL()
|
sl@0
|
94 |
{
|
sl@0
|
95 |
return KErrGeneral;
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
/**
|
sl@0
|
99 |
* Function Name : executeStepL
|
sl@0
|
100 |
* Input parameters : None
|
sl@0
|
101 |
* Output parameters : TInt
|
sl@0
|
102 |
* Description : This function writes the test data in to the log file
|
sl@0
|
103 |
* This function check the test message is present in the
|
sl@0
|
104 |
* log file
|
sl@0
|
105 |
|
sl@0
|
106 |
*/
|
sl@0
|
107 |
|
sl@0
|
108 |
|
sl@0
|
109 |
TInt CFloggerTest017_01::executeStepL(TBool heapTest)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
TInt ret = KErrGeneral;
|
sl@0
|
112 |
|
sl@0
|
113 |
ret = DoTestWrite();
|
sl@0
|
114 |
if (ret == KErrNone)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
User::After(KTimeToLog);
|
sl@0
|
117 |
TRAPD(r, ret = DoTestCheckWriteL() );
|
sl@0
|
118 |
if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
|
sl@0
|
119 |
{
|
sl@0
|
120 |
ret = KErrNoMemory;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
else if (r != KErrNone)
|
sl@0
|
123 |
{
|
sl@0
|
124 |
ret = r;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
}
|
sl@0
|
127 |
return ret;
|
sl@0
|
128 |
}
|
sl@0
|
129 |
|
sl@0
|
130 |
|
sl@0
|
131 |
/**
|
sl@0
|
132 |
* Function Name : DoTestWrite
|
sl@0
|
133 |
* Input parameters : None
|
sl@0
|
134 |
* Output parameters : TInt
|
sl@0
|
135 |
* Description : This function writes the data to the file logger in hexa format
|
sl@0
|
136 |
|
sl@0
|
137 |
*/
|
sl@0
|
138 |
|
sl@0
|
139 |
|
sl@0
|
140 |
TInt CFloggerTest017_01::DoTestWrite()
|
sl@0
|
141 |
{
|
sl@0
|
142 |
_LIT8(KDescText, "TC 17_1:Test Msg----"); //Test body descriptor
|
sl@0
|
143 |
|
sl@0
|
144 |
//Write the test datas in the hexa format
|
sl@0
|
145 |
RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KHexTestHeader);
|
sl@0
|
146 |
|
sl@0
|
147 |
// connect so we can flush file buffer for heap check since timer is killed in heap checks
|
sl@0
|
148 |
RFileLogger theFlogger;
|
sl@0
|
149 |
theFlogger.Connect();
|
sl@0
|
150 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
151 |
ForceLogFlush(theFlogger);
|
sl@0
|
152 |
theFlogger.Close();
|
sl@0
|
153 |
return KErrNone;
|
sl@0
|
154 |
}
|
sl@0
|
155 |
|
sl@0
|
156 |
|
sl@0
|
157 |
/**
|
sl@0
|
158 |
* Function Name : DoTestCheckWriteL
|
sl@0
|
159 |
* Input parameters : None
|
sl@0
|
160 |
* Output parameters : TInt
|
sl@0
|
161 |
* Description : This function checks the weather test data was written
|
sl@0
|
162 |
* in to the log file by DoTestWrite() or not.
|
sl@0
|
163 |
|
sl@0
|
164 |
*/
|
sl@0
|
165 |
|
sl@0
|
166 |
|
sl@0
|
167 |
TInt CFloggerTest017_01::DoTestCheckWriteL()
|
sl@0
|
168 |
{
|
sl@0
|
169 |
User::After(KTimeToLog);
|
sl@0
|
170 |
|
sl@0
|
171 |
RFile theFile;
|
sl@0
|
172 |
HBufC8 * hBuffer;
|
sl@0
|
173 |
TInt listfilesize;
|
sl@0
|
174 |
TInt returnCode;
|
sl@0
|
175 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
176 |
_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
|
sl@0
|
177 |
|
sl@0
|
178 |
_LIT8(KBodyTxt,"TC 17_1:Test Msg");// First 16 chars of Test body descriptor
|
sl@0
|
179 |
|
sl@0
|
180 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
181 |
|
sl@0
|
182 |
//Open the file in the read mode
|
sl@0
|
183 |
User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)) ;
|
sl@0
|
184 |
|
sl@0
|
185 |
|
sl@0
|
186 |
User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
187 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
188 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
189 |
|
sl@0
|
190 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
191 |
|
sl@0
|
192 |
// Read from position 0, i.e starting of file
|
sl@0
|
193 |
returnCode = theFile.Read(ptrString);
|
sl@0
|
194 |
|
sl@0
|
195 |
returnCode = ptrString.Find(KHexTestHeader); //find the test header descriptor in
|
sl@0
|
196 |
//the buffer read from the file
|
sl@0
|
197 |
|
sl@0
|
198 |
if (returnCode > 0) //The header is present
|
sl@0
|
199 |
{
|
sl@0
|
200 |
returnCode = ptrString.Find(KHexTestMargin); //find the test margin descriptor in
|
sl@0
|
201 |
//the buffer read from the file
|
sl@0
|
202 |
}
|
sl@0
|
203 |
|
sl@0
|
204 |
if (returnCode > 0) //The margin is present
|
sl@0
|
205 |
{
|
sl@0
|
206 |
returnCode = ptrString.Find(KBodyTxt); //find the test descriptor in the
|
sl@0
|
207 |
//buffer read from the file
|
sl@0
|
208 |
}
|
sl@0
|
209 |
|
sl@0
|
210 |
theFile.Close();
|
sl@0
|
211 |
fileSystem.Close(); //Close the file server
|
sl@0
|
212 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
213 |
|
sl@0
|
214 |
if (returnCode > 0) //The test body descriptor is present
|
sl@0
|
215 |
return KErrNone;
|
sl@0
|
216 |
else
|
sl@0
|
217 |
return KErrNotFound;
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
|
sl@0
|
221 |
|
sl@0
|
222 |
|
sl@0
|
223 |
|
sl@0
|
224 |
/**
|
sl@0
|
225 |
* Function Name : CFloggerTest017_02
|
sl@0
|
226 |
* Input parameters : None
|
sl@0
|
227 |
* Output parameters : None
|
sl@0
|
228 |
* Description : This is the constructor
|
sl@0
|
229 |
*/
|
sl@0
|
230 |
|
sl@0
|
231 |
|
sl@0
|
232 |
CFloggerTest017_02::CFloggerTest017_02()
|
sl@0
|
233 |
{
|
sl@0
|
234 |
// store the name of this test case
|
sl@0
|
235 |
SetTestStepName(_L("step_017_02"));
|
sl@0
|
236 |
}
|
sl@0
|
237 |
|
sl@0
|
238 |
|
sl@0
|
239 |
/**
|
sl@0
|
240 |
* Function Name :~ CFloggerTest017_02
|
sl@0
|
241 |
* Input parameters : None
|
sl@0
|
242 |
* Output parameters : None
|
sl@0
|
243 |
* Description : This is the Destructor
|
sl@0
|
244 |
*/
|
sl@0
|
245 |
|
sl@0
|
246 |
|
sl@0
|
247 |
CFloggerTest017_02::~CFloggerTest017_02()
|
sl@0
|
248 |
{
|
sl@0
|
249 |
}
|
sl@0
|
250 |
|
sl@0
|
251 |
|
sl@0
|
252 |
/**
|
sl@0
|
253 |
* Function Name : doTestStepL
|
sl@0
|
254 |
* Input parameters : None
|
sl@0
|
255 |
* Output parameters : TVerdict
|
sl@0
|
256 |
* Description : This function returns weather the test case 017_02 has
|
sl@0
|
257 |
* passed or failed
|
sl@0
|
258 |
|
sl@0
|
259 |
*/
|
sl@0
|
260 |
|
sl@0
|
261 |
|
sl@0
|
262 |
TVerdict CFloggerTest017_02::doTestStepL( )
|
sl@0
|
263 |
{
|
sl@0
|
264 |
INFO_PRINTF1(_L("Step 017.02 called "));
|
sl@0
|
265 |
|
sl@0
|
266 |
if ( executeStepL() == KErrNone )
|
sl@0
|
267 |
SetTestStepResult(EPass);
|
sl@0
|
268 |
|
sl@0
|
269 |
else
|
sl@0
|
270 |
SetTestStepResult(EFail);
|
sl@0
|
271 |
|
sl@0
|
272 |
|
sl@0
|
273 |
User::After(KTimeForDisplay1);
|
sl@0
|
274 |
return TestStepResult();
|
sl@0
|
275 |
}
|
sl@0
|
276 |
|
sl@0
|
277 |
/**
|
sl@0
|
278 |
* Function Name : executeStepL
|
sl@0
|
279 |
* Input parameters : None
|
sl@0
|
280 |
* Output parameters : TInt
|
sl@0
|
281 |
* Description : This function writes the test data in to the log file
|
sl@0
|
282 |
* This function check the test message is present in the
|
sl@0
|
283 |
* log file
|
sl@0
|
284 |
|
sl@0
|
285 |
*/
|
sl@0
|
286 |
|
sl@0
|
287 |
|
sl@0
|
288 |
|
sl@0
|
289 |
TInt CFloggerTest017_02::executeStepL(TBool)
|
sl@0
|
290 |
{
|
sl@0
|
291 |
return KErrGeneral;
|
sl@0
|
292 |
}
|
sl@0
|
293 |
/**
|
sl@0
|
294 |
* Function Name : executeStepL
|
sl@0
|
295 |
* Input parameters : None
|
sl@0
|
296 |
* Output parameters : TInt
|
sl@0
|
297 |
* Description : This function writes the test data in to the log file
|
sl@0
|
298 |
* This function check the test message is present in the
|
sl@0
|
299 |
* log file
|
sl@0
|
300 |
|
sl@0
|
301 |
*/
|
sl@0
|
302 |
|
sl@0
|
303 |
|
sl@0
|
304 |
|
sl@0
|
305 |
TInt CFloggerTest017_02::executeStepL( )
|
sl@0
|
306 |
{
|
sl@0
|
307 |
User::After(1000*1000); //Need this or connect will return KErrServerTerminated
|
sl@0
|
308 |
TInt ret = KErrGeneral;
|
sl@0
|
309 |
|
sl@0
|
310 |
ret = DoTestWrite();
|
sl@0
|
311 |
if (ret == KErrNone )
|
sl@0
|
312 |
{
|
sl@0
|
313 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
314 |
if (r != KErrNone)
|
sl@0
|
315 |
ret = r;
|
sl@0
|
316 |
}
|
sl@0
|
317 |
|
sl@0
|
318 |
return ret;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
|
sl@0
|
322 |
/**
|
sl@0
|
323 |
* Function Name : DoTestWrite
|
sl@0
|
324 |
* Input parameters : None
|
sl@0
|
325 |
* Output parameters : TInt
|
sl@0
|
326 |
* Description : This function writes the data to the file logger
|
sl@0
|
327 |
|
sl@0
|
328 |
*/
|
sl@0
|
329 |
|
sl@0
|
330 |
|
sl@0
|
331 |
TInt CFloggerTest017_02::DoTestWrite()
|
sl@0
|
332 |
{
|
sl@0
|
333 |
|
sl@0
|
334 |
RFileLogger theFlogger;
|
sl@0
|
335 |
TInt ret = KErrNone;
|
sl@0
|
336 |
|
sl@0
|
337 |
ret = theFlogger.Connect(); //Just to clear the old log message
|
sl@0
|
338 |
if (ret == KErrNone)
|
sl@0
|
339 |
ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
|
sl@0
|
340 |
if (ret == KErrNone)
|
sl@0
|
341 |
ret = theFlogger.ClearLog();
|
sl@0
|
342 |
if (ret == KErrNone)
|
sl@0
|
343 |
theFlogger.Close();
|
sl@0
|
344 |
|
sl@0
|
345 |
if (ret == KErrNone)
|
sl@0
|
346 |
{
|
sl@0
|
347 |
_LIT8(KDescText,"TC 17_2:Test Msg");
|
sl@0
|
348 |
|
sl@0
|
349 |
//Write the test datas in the hexa format
|
sl@0
|
350 |
RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KEightSpaces8);
|
sl@0
|
351 |
|
sl@0
|
352 |
return KErrNone;
|
sl@0
|
353 |
}
|
sl@0
|
354 |
return ret;
|
sl@0
|
355 |
}
|
sl@0
|
356 |
|
sl@0
|
357 |
|
sl@0
|
358 |
/**
|
sl@0
|
359 |
* Function Name : DoTestCheckWriteL
|
sl@0
|
360 |
* Input parameters : None
|
sl@0
|
361 |
* Output parameters : TInt
|
sl@0
|
362 |
* Description : This function checks the weather test data was written
|
sl@0
|
363 |
* in to the log file by DoTestWrite() or not.
|
sl@0
|
364 |
|
sl@0
|
365 |
*/
|
sl@0
|
366 |
|
sl@0
|
367 |
|
sl@0
|
368 |
TInt CFloggerTest017_02::DoTestCheckWriteL()
|
sl@0
|
369 |
{
|
sl@0
|
370 |
User::After(KTimeToLog);
|
sl@0
|
371 |
RFile theFile;
|
sl@0
|
372 |
HBufC8 * hBuffer;
|
sl@0
|
373 |
TInt listfilesize;
|
sl@0
|
374 |
TInt returnCode;
|
sl@0
|
375 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
376 |
TBuf8<256> testData; //To hold the test descriptor
|
sl@0
|
377 |
_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
|
sl@0
|
378 |
|
sl@0
|
379 |
_LIT8(KOOMError, "#Logs may be lost out of memory!!"); // Error message
|
sl@0
|
380 |
|
sl@0
|
381 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
382 |
|
sl@0
|
383 |
//Open the file in the read mode
|
sl@0
|
384 |
User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
|
sl@0
|
385 |
|
sl@0
|
386 |
CleanupClosePushL(theFile);
|
sl@0
|
387 |
|
sl@0
|
388 |
User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
389 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
390 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
391 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
392 |
|
sl@0
|
393 |
// Read from position 0: start of file
|
sl@0
|
394 |
returnCode = theFile.Read(ptrString);
|
sl@0
|
395 |
|
sl@0
|
396 |
testData.FillZ();
|
sl@0
|
397 |
testData.Copy(KEightSpaces8); //Copy the test descriptor
|
sl@0
|
398 |
returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
399 |
//from the file
|
sl@0
|
400 |
|
sl@0
|
401 |
if (returnCode == KErrNotFound) // Check for the error message in the log
|
sl@0
|
402 |
{
|
sl@0
|
403 |
returnCode = ptrString.Find(KOOMError);
|
sl@0
|
404 |
if (returnCode > 0)
|
sl@0
|
405 |
User::Leave(KErrNoMemory);
|
sl@0
|
406 |
}
|
sl@0
|
407 |
|
sl@0
|
408 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
409 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
410 |
if (returnCode > 0)
|
sl@0
|
411 |
return KErrNone;
|
sl@0
|
412 |
else
|
sl@0
|
413 |
return KErrGeneral;
|
sl@0
|
414 |
}
|
sl@0
|
415 |
|
sl@0
|
416 |
|
sl@0
|
417 |
|
sl@0
|
418 |
/**
|
sl@0
|
419 |
* Function Name : CFloggerTest017_03
|
sl@0
|
420 |
* Input parameters : None
|
sl@0
|
421 |
* Output parameters : None
|
sl@0
|
422 |
* Description : This is the constructor
|
sl@0
|
423 |
* Description : This is the constructor
|
sl@0
|
424 |
*/
|
sl@0
|
425 |
|
sl@0
|
426 |
|
sl@0
|
427 |
CFloggerTest017_03::CFloggerTest017_03()
|
sl@0
|
428 |
{
|
sl@0
|
429 |
// store the name of this test case
|
sl@0
|
430 |
SetTestStepName(_L("step_017_03"));
|
sl@0
|
431 |
}
|
sl@0
|
432 |
|
sl@0
|
433 |
|
sl@0
|
434 |
/**
|
sl@0
|
435 |
* Function Name :~ CFloggerTest017_03
|
sl@0
|
436 |
* Input parameters : None
|
sl@0
|
437 |
* Output parameters : None
|
sl@0
|
438 |
* Description : This is the Destructor
|
sl@0
|
439 |
*/
|
sl@0
|
440 |
|
sl@0
|
441 |
|
sl@0
|
442 |
CFloggerTest017_03::~CFloggerTest017_03()
|
sl@0
|
443 |
{
|
sl@0
|
444 |
}
|
sl@0
|
445 |
|
sl@0
|
446 |
|
sl@0
|
447 |
/**
|
sl@0
|
448 |
* Function Name : doTestStepL
|
sl@0
|
449 |
* Input parameters : None
|
sl@0
|
450 |
* Output parameters : TVerdict
|
sl@0
|
451 |
* Description : This function returns weather the test case 017_03 has
|
sl@0
|
452 |
* passed or failed
|
sl@0
|
453 |
|
sl@0
|
454 |
*/
|
sl@0
|
455 |
|
sl@0
|
456 |
|
sl@0
|
457 |
TVerdict CFloggerTest017_03::doTestStepL( )
|
sl@0
|
458 |
{
|
sl@0
|
459 |
INFO_PRINTF1(_L("Step 017.03 called "));
|
sl@0
|
460 |
|
sl@0
|
461 |
if ( executeStepL() == KErrNone )
|
sl@0
|
462 |
SetTestStepResult(EPass);
|
sl@0
|
463 |
|
sl@0
|
464 |
else
|
sl@0
|
465 |
SetTestStepResult(EFail);
|
sl@0
|
466 |
|
sl@0
|
467 |
|
sl@0
|
468 |
User::After(KTimeForDisplay1);
|
sl@0
|
469 |
return TestStepResult();
|
sl@0
|
470 |
}
|
sl@0
|
471 |
|
sl@0
|
472 |
|
sl@0
|
473 |
/**
|
sl@0
|
474 |
* Function Name : executeStepL
|
sl@0
|
475 |
* Input parameters : None
|
sl@0
|
476 |
* Output parameters : TInt
|
sl@0
|
477 |
* Description : This function writes the test data in to the log file
|
sl@0
|
478 |
* This function check the test message is present in the
|
sl@0
|
479 |
* log file
|
sl@0
|
480 |
|
sl@0
|
481 |
*/
|
sl@0
|
482 |
|
sl@0
|
483 |
|
sl@0
|
484 |
TInt CFloggerTest017_03::executeStepL( )
|
sl@0
|
485 |
{
|
sl@0
|
486 |
User::After(1000*1000); //Need this or connect will return KErrServerTerminated
|
sl@0
|
487 |
TInt ret = KErrGeneral;
|
sl@0
|
488 |
|
sl@0
|
489 |
ret = DoTestWrite();
|
sl@0
|
490 |
if (ret == KErrNone )
|
sl@0
|
491 |
{
|
sl@0
|
492 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
493 |
if (ret != KErrNone)
|
sl@0
|
494 |
ret = r;
|
sl@0
|
495 |
}
|
sl@0
|
496 |
|
sl@0
|
497 |
return ret;
|
sl@0
|
498 |
}
|
sl@0
|
499 |
|
sl@0
|
500 |
/**
|
sl@0
|
501 |
* Function Name : executeStepL
|
sl@0
|
502 |
* Input parameters : None
|
sl@0
|
503 |
* Output parameters : TInt
|
sl@0
|
504 |
* Description : This function writes the test data in to the log file
|
sl@0
|
505 |
* This function check the test message is present in the
|
sl@0
|
506 |
* log file
|
sl@0
|
507 |
|
sl@0
|
508 |
*/
|
sl@0
|
509 |
|
sl@0
|
510 |
|
sl@0
|
511 |
TInt CFloggerTest017_03::executeStepL(TBool)
|
sl@0
|
512 |
{
|
sl@0
|
513 |
return KErrGeneral;
|
sl@0
|
514 |
}
|
sl@0
|
515 |
|
sl@0
|
516 |
//**
|
sl@0
|
517 |
/* Function Name : DoTestWrite
|
sl@0
|
518 |
* Input parameters : None
|
sl@0
|
519 |
* Output parameters : TInt
|
sl@0
|
520 |
* Description : This function writes the data to the file logger
|
sl@0
|
521 |
|
sl@0
|
522 |
*/
|
sl@0
|
523 |
|
sl@0
|
524 |
|
sl@0
|
525 |
TInt CFloggerTest017_03::DoTestWrite()
|
sl@0
|
526 |
{
|
sl@0
|
527 |
|
sl@0
|
528 |
RFileLogger theFlogger;
|
sl@0
|
529 |
TInt ret = KErrNone;
|
sl@0
|
530 |
|
sl@0
|
531 |
ret = theFlogger.Connect(); //Just to clear the old log message
|
sl@0
|
532 |
if (ret == KErrNone)
|
sl@0
|
533 |
ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
|
sl@0
|
534 |
if (ret == KErrNone)
|
sl@0
|
535 |
ret = theFlogger.ClearLog();
|
sl@0
|
536 |
if (ret == KErrNone)
|
sl@0
|
537 |
theFlogger.Close();
|
sl@0
|
538 |
|
sl@0
|
539 |
if (ret == KErrNone)
|
sl@0
|
540 |
{
|
sl@0
|
541 |
_LIT8(KDescText,"TC 17_3:Test Msg"); //8 bit test descriptor
|
sl@0
|
542 |
|
sl@0
|
543 |
//Write the test datas in the hexa format
|
sl@0
|
544 |
RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText);
|
sl@0
|
545 |
|
sl@0
|
546 |
|
sl@0
|
547 |
return KErrNone;
|
sl@0
|
548 |
}
|
sl@0
|
549 |
return ret;
|
sl@0
|
550 |
}
|
sl@0
|
551 |
|
sl@0
|
552 |
|
sl@0
|
553 |
/**
|
sl@0
|
554 |
* Function Name : DoTestCheckWriteL
|
sl@0
|
555 |
* Input parameters : None
|
sl@0
|
556 |
* Output parameters : TInt
|
sl@0
|
557 |
* Description : This function checks the weather test data was written
|
sl@0
|
558 |
* in to the log file by DoTestWrite() or not.
|
sl@0
|
559 |
|
sl@0
|
560 |
*/
|
sl@0
|
561 |
|
sl@0
|
562 |
|
sl@0
|
563 |
TInt CFloggerTest017_03::DoTestCheckWriteL()
|
sl@0
|
564 |
{
|
sl@0
|
565 |
|
sl@0
|
566 |
User::After(KTimeToLog);
|
sl@0
|
567 |
RFile theFile;
|
sl@0
|
568 |
HBufC8 * hBuffer;
|
sl@0
|
569 |
TInt listfilesize;
|
sl@0
|
570 |
TInt returnCode;
|
sl@0
|
571 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
572 |
TBuf8<256> testData; //To hold the test descriptor
|
sl@0
|
573 |
_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
|
sl@0
|
574 |
|
sl@0
|
575 |
_LIT8(KBodyTxt,"TC 17_3:Test Msg");// Test body descriptor
|
sl@0
|
576 |
|
sl@0
|
577 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
578 |
|
sl@0
|
579 |
//Open the file in the read mode
|
sl@0
|
580 |
User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
|
sl@0
|
581 |
CleanupClosePushL(theFile);
|
sl@0
|
582 |
|
sl@0
|
583 |
User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
584 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
585 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
586 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
587 |
|
sl@0
|
588 |
// Read from position 0: start of file
|
sl@0
|
589 |
returnCode=theFile.Read(ptrString);
|
sl@0
|
590 |
|
sl@0
|
591 |
testData.Copy(KBodyTxt); //Copy the test descriptor
|
sl@0
|
592 |
returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
593 |
//from the file
|
sl@0
|
594 |
|
sl@0
|
595 |
if (returnCode == KErrNotFound) //Find the error message
|
sl@0
|
596 |
{
|
sl@0
|
597 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
598 |
if (returnCode > 0)
|
sl@0
|
599 |
User::Leave(KErrNoMemory);
|
sl@0
|
600 |
}
|
sl@0
|
601 |
|
sl@0
|
602 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
603 |
CleanupStack::PopAndDestroy(); //theFile object
|
sl@0
|
604 |
if (returnCode > 0)
|
sl@0
|
605 |
return KErrNone;
|
sl@0
|
606 |
else
|
sl@0
|
607 |
return KErrGeneral;
|
sl@0
|
608 |
}
|
sl@0
|
609 |
|
sl@0
|
610 |
|
sl@0
|
611 |
|
sl@0
|
612 |
/**
|
sl@0
|
613 |
* Function Name : CFloggerTest017_04
|
sl@0
|
614 |
* Input parameters : None
|
sl@0
|
615 |
* Output parameters : None
|
sl@0
|
616 |
* Description : This is the constructor
|
sl@0
|
617 |
*/
|
sl@0
|
618 |
|
sl@0
|
619 |
|
sl@0
|
620 |
CFloggerTest017_04::CFloggerTest017_04()
|
sl@0
|
621 |
{
|
sl@0
|
622 |
// store the name of this test case
|
sl@0
|
623 |
SetTestStepName(_L("step_017_04"));
|
sl@0
|
624 |
}
|
sl@0
|
625 |
|
sl@0
|
626 |
|
sl@0
|
627 |
/**
|
sl@0
|
628 |
* Function Name :~ CFloggerTest017_04
|
sl@0
|
629 |
* Input parameters : None
|
sl@0
|
630 |
* Output parameters : None
|
sl@0
|
631 |
* Description : This is the Destructor
|
sl@0
|
632 |
*/
|
sl@0
|
633 |
|
sl@0
|
634 |
|
sl@0
|
635 |
CFloggerTest017_04::~CFloggerTest017_04()
|
sl@0
|
636 |
{
|
sl@0
|
637 |
}
|
sl@0
|
638 |
|
sl@0
|
639 |
/**
|
sl@0
|
640 |
* Function Name : doTestStepL
|
sl@0
|
641 |
* Input parameters : None
|
sl@0
|
642 |
* Output parameters : TVerdict
|
sl@0
|
643 |
* Description : This function returns weather the test case 017_04 has
|
sl@0
|
644 |
* passed or failed
|
sl@0
|
645 |
|
sl@0
|
646 |
*/
|
sl@0
|
647 |
|
sl@0
|
648 |
|
sl@0
|
649 |
TVerdict CFloggerTest017_04::doTestStepL( )
|
sl@0
|
650 |
{
|
sl@0
|
651 |
INFO_PRINTF1(_L("Step 017.04 called "));
|
sl@0
|
652 |
|
sl@0
|
653 |
if ( executeStepL() == KErrNone )
|
sl@0
|
654 |
SetTestStepResult(EPass);
|
sl@0
|
655 |
|
sl@0
|
656 |
else
|
sl@0
|
657 |
SetTestStepResult(EFail);
|
sl@0
|
658 |
|
sl@0
|
659 |
|
sl@0
|
660 |
User::After(KTimeForDisplay1);
|
sl@0
|
661 |
return TestStepResult();
|
sl@0
|
662 |
}
|
sl@0
|
663 |
|
sl@0
|
664 |
|
sl@0
|
665 |
/**
|
sl@0
|
666 |
* Function Name : executeStepL
|
sl@0
|
667 |
* Input parameters : None
|
sl@0
|
668 |
* Output parameters : TInt
|
sl@0
|
669 |
* Description : This function writes the test data in to the log file
|
sl@0
|
670 |
* This function check the test message is present in the
|
sl@0
|
671 |
* log file
|
sl@0
|
672 |
|
sl@0
|
673 |
*/
|
sl@0
|
674 |
|
sl@0
|
675 |
|
sl@0
|
676 |
TInt CFloggerTest017_04::executeStepL( )
|
sl@0
|
677 |
{
|
sl@0
|
678 |
User::After(1000*1000); //Need this or connect will return KErrServerTerminated
|
sl@0
|
679 |
TInt ret = KErrGeneral;
|
sl@0
|
680 |
|
sl@0
|
681 |
ret = DoTestWrite();
|
sl@0
|
682 |
if (ret == KErrNone )
|
sl@0
|
683 |
{
|
sl@0
|
684 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
685 |
if (ret != KErrNone)
|
sl@0
|
686 |
ret = r;
|
sl@0
|
687 |
}
|
sl@0
|
688 |
|
sl@0
|
689 |
return ret;
|
sl@0
|
690 |
}
|
sl@0
|
691 |
/**
|
sl@0
|
692 |
* Function Name : executeStepL
|
sl@0
|
693 |
* Input parameters : None
|
sl@0
|
694 |
* Output parameters : TInt
|
sl@0
|
695 |
* Description : This function writes the test data in to the log file
|
sl@0
|
696 |
* This function check the test message is present in the
|
sl@0
|
697 |
* log file
|
sl@0
|
698 |
|
sl@0
|
699 |
*/
|
sl@0
|
700 |
|
sl@0
|
701 |
|
sl@0
|
702 |
TInt CFloggerTest017_04::executeStepL(TBool)
|
sl@0
|
703 |
{
|
sl@0
|
704 |
return KErrGeneral;
|
sl@0
|
705 |
}
|
sl@0
|
706 |
|
sl@0
|
707 |
/**
|
sl@0
|
708 |
* Function Name : DoTestWrite
|
sl@0
|
709 |
* Input parameters : None
|
sl@0
|
710 |
* Output parameters : TInt
|
sl@0
|
711 |
* Description : This function writes the data to the file logger
|
sl@0
|
712 |
|
sl@0
|
713 |
*/
|
sl@0
|
714 |
|
sl@0
|
715 |
|
sl@0
|
716 |
TInt CFloggerTest017_04::DoTestWrite()
|
sl@0
|
717 |
{
|
sl@0
|
718 |
_LIT8(KDescText,"TC 17_4:Test Msg");
|
sl@0
|
719 |
|
sl@0
|
720 |
RFileLogger theFlogger;
|
sl@0
|
721 |
TInt ret = KErrNone;
|
sl@0
|
722 |
ret = theFlogger.Connect(); //Just to clear the old log message
|
sl@0
|
723 |
if (ret == KErrNone)
|
sl@0
|
724 |
ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
|
sl@0
|
725 |
if (ret == KErrNone)
|
sl@0
|
726 |
ret = theFlogger.ClearLog();
|
sl@0
|
727 |
if (ret == KErrNone)
|
sl@0
|
728 |
theFlogger.Close();
|
sl@0
|
729 |
if (ret == KErrNone)
|
sl@0
|
730 |
{
|
sl@0
|
731 |
//Write the test datas in the hexa format
|
sl@0
|
732 |
RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KDescText, KNullDesC8);
|
sl@0
|
733 |
|
sl@0
|
734 |
return KErrNone;
|
sl@0
|
735 |
}
|
sl@0
|
736 |
return ret;
|
sl@0
|
737 |
}
|
sl@0
|
738 |
|
sl@0
|
739 |
|
sl@0
|
740 |
/**
|
sl@0
|
741 |
* Function Name : DoTestCheckWriteL
|
sl@0
|
742 |
* Input parameters : None
|
sl@0
|
743 |
* Output parameters : TInt
|
sl@0
|
744 |
* Description : This function checks the weather test data was written
|
sl@0
|
745 |
* in to the log file by DoTestWrite() or not.
|
sl@0
|
746 |
|
sl@0
|
747 |
*/
|
sl@0
|
748 |
|
sl@0
|
749 |
|
sl@0
|
750 |
TInt CFloggerTest017_04::DoTestCheckWriteL()
|
sl@0
|
751 |
{
|
sl@0
|
752 |
User::After(KTimeToLog);
|
sl@0
|
753 |
RFile theFile;
|
sl@0
|
754 |
HBufC8 * hBuffer;
|
sl@0
|
755 |
TInt listfilesize;
|
sl@0
|
756 |
TInt returnCode;
|
sl@0
|
757 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
758 |
TBuf8<256> testData; //To hold the test descriptor
|
sl@0
|
759 |
_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
|
sl@0
|
760 |
|
sl@0
|
761 |
_LIT(KBodyTxt,"TC 17_4:Test Msg");// Test body descriptor
|
sl@0
|
762 |
TUint numSuccessful = 0;
|
sl@0
|
763 |
|
sl@0
|
764 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
765 |
|
sl@0
|
766 |
//Open the file in the read mode
|
sl@0
|
767 |
User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
|
sl@0
|
768 |
CleanupClosePushL(theFile);
|
sl@0
|
769 |
|
sl@0
|
770 |
User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
771 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
772 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
773 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
774 |
|
sl@0
|
775 |
// Read from position 0: start of file
|
sl@0
|
776 |
returnCode = theFile.Read(ptrString);
|
sl@0
|
777 |
|
sl@0
|
778 |
|
sl@0
|
779 |
testData.Copy(KBodyTxt); //Copy the test descriptor
|
sl@0
|
780 |
returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
781 |
//from the file
|
sl@0
|
782 |
|
sl@0
|
783 |
if (returnCode > 0)
|
sl@0
|
784 |
numSuccessful++;
|
sl@0
|
785 |
|
sl@0
|
786 |
returnCode=ptrString.Find(KHexTestHeader); //find the test descriptor in the buffer read
|
sl@0
|
787 |
|
sl@0
|
788 |
if (returnCode == KErrNotFound)
|
sl@0
|
789 |
numSuccessful++;
|
sl@0
|
790 |
|
sl@0
|
791 |
|
sl@0
|
792 |
if (returnCode == KErrNotFound) //Find the error message
|
sl@0
|
793 |
{
|
sl@0
|
794 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
795 |
if (returnCode > 0)
|
sl@0
|
796 |
User::Leave(KErrNoMemory);
|
sl@0
|
797 |
}
|
sl@0
|
798 |
|
sl@0
|
799 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
800 |
CleanupStack::PopAndDestroy(); //theFile object
|
sl@0
|
801 |
|
sl@0
|
802 |
if (numSuccessful == 2)
|
sl@0
|
803 |
return KErrNone;
|
sl@0
|
804 |
else
|
sl@0
|
805 |
return KErrGeneral;
|
sl@0
|
806 |
}
|
sl@0
|
807 |
|
sl@0
|
808 |
|
sl@0
|
809 |
|
sl@0
|
810 |
|
sl@0
|
811 |
/**
|
sl@0
|
812 |
* Function Name : CFloggerTest017_05
|
sl@0
|
813 |
* Input parameters : None
|
sl@0
|
814 |
* Output parameters : None
|
sl@0
|
815 |
* Description : This is the constructor
|
sl@0
|
816 |
*/
|
sl@0
|
817 |
|
sl@0
|
818 |
|
sl@0
|
819 |
CFloggerTest017_05::CFloggerTest017_05()
|
sl@0
|
820 |
{
|
sl@0
|
821 |
// store the name of this test case
|
sl@0
|
822 |
SetTestStepName(_L("step_017_05"));
|
sl@0
|
823 |
}
|
sl@0
|
824 |
|
sl@0
|
825 |
|
sl@0
|
826 |
/**
|
sl@0
|
827 |
* Function Name :~ CFloggerTest017_05
|
sl@0
|
828 |
* Input parameters : None
|
sl@0
|
829 |
* Output parameters : None
|
sl@0
|
830 |
* Description : This is the Destructor
|
sl@0
|
831 |
*/
|
sl@0
|
832 |
|
sl@0
|
833 |
|
sl@0
|
834 |
CFloggerTest017_05::~CFloggerTest017_05()
|
sl@0
|
835 |
{
|
sl@0
|
836 |
}
|
sl@0
|
837 |
|
sl@0
|
838 |
/**
|
sl@0
|
839 |
* Function Name : doTestStepL
|
sl@0
|
840 |
* Input parameters : None
|
sl@0
|
841 |
* Output parameters : TVerdict
|
sl@0
|
842 |
* Description : This function returns weather the test case 017_05 has
|
sl@0
|
843 |
* passed or failed
|
sl@0
|
844 |
|
sl@0
|
845 |
*/
|
sl@0
|
846 |
|
sl@0
|
847 |
|
sl@0
|
848 |
TVerdict CFloggerTest017_05::doTestStepL( )
|
sl@0
|
849 |
{
|
sl@0
|
850 |
INFO_PRINTF1(_L("Step 017.05 called "));
|
sl@0
|
851 |
|
sl@0
|
852 |
if ( executeStepL() == KErrNone )
|
sl@0
|
853 |
SetTestStepResult(EPass);
|
sl@0
|
854 |
|
sl@0
|
855 |
else
|
sl@0
|
856 |
SetTestStepResult(EFail);
|
sl@0
|
857 |
|
sl@0
|
858 |
|
sl@0
|
859 |
User::After(KTimeForDisplay1);
|
sl@0
|
860 |
return TestStepResult();
|
sl@0
|
861 |
}
|
sl@0
|
862 |
|
sl@0
|
863 |
/**
|
sl@0
|
864 |
* Function Name : executeStepL
|
sl@0
|
865 |
* Input parameters : None
|
sl@0
|
866 |
* Output parameters : TInt
|
sl@0
|
867 |
* Description : This function writes the test data in to the log file
|
sl@0
|
868 |
* This function check the test message is present in the
|
sl@0
|
869 |
* log file
|
sl@0
|
870 |
|
sl@0
|
871 |
*/
|
sl@0
|
872 |
|
sl@0
|
873 |
|
sl@0
|
874 |
TInt CFloggerTest017_05::executeStepL(TBool)
|
sl@0
|
875 |
{
|
sl@0
|
876 |
return KErrGeneral;
|
sl@0
|
877 |
}
|
sl@0
|
878 |
/**
|
sl@0
|
879 |
* Function Name : executeStepL
|
sl@0
|
880 |
* Input parameters : None
|
sl@0
|
881 |
* Output parameters : TInt
|
sl@0
|
882 |
* Description : This function writes the test data in to the log file
|
sl@0
|
883 |
* This function check the test message is present in the
|
sl@0
|
884 |
* log file
|
sl@0
|
885 |
|
sl@0
|
886 |
*/
|
sl@0
|
887 |
|
sl@0
|
888 |
|
sl@0
|
889 |
TInt CFloggerTest017_05::executeStepL( )
|
sl@0
|
890 |
{
|
sl@0
|
891 |
User::After(KTimeToLog); //Need this or connect will return KErrServerTerminated
|
sl@0
|
892 |
TInt ret = KErrGeneral;
|
sl@0
|
893 |
|
sl@0
|
894 |
ret = DoTestWrite();
|
sl@0
|
895 |
if (ret == KErrNone )
|
sl@0
|
896 |
{
|
sl@0
|
897 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
898 |
if (ret != KErrNone)
|
sl@0
|
899 |
ret = r;
|
sl@0
|
900 |
}
|
sl@0
|
901 |
return ret;
|
sl@0
|
902 |
}
|
sl@0
|
903 |
|
sl@0
|
904 |
|
sl@0
|
905 |
/**
|
sl@0
|
906 |
* Function Name : DoTestWrite
|
sl@0
|
907 |
* Input parameters : None
|
sl@0
|
908 |
* Output parameters : TInt
|
sl@0
|
909 |
* Description : This function writes the data to the file logger
|
sl@0
|
910 |
|
sl@0
|
911 |
*/
|
sl@0
|
912 |
|
sl@0
|
913 |
|
sl@0
|
914 |
TInt CFloggerTest017_05::DoTestWrite()
|
sl@0
|
915 |
{
|
sl@0
|
916 |
RFileLogger theFlogger;
|
sl@0
|
917 |
TInt ret = KErrNone;
|
sl@0
|
918 |
|
sl@0
|
919 |
ret = theFlogger.Connect(); //Just to clear the old log message
|
sl@0
|
920 |
if (ret == KErrNone)
|
sl@0
|
921 |
ret = theFlogger.SetLogTags(KStdSubsysTag8,KStdCompTag8);
|
sl@0
|
922 |
if (ret == KErrNone)
|
sl@0
|
923 |
ret = theFlogger.ClearLog();
|
sl@0
|
924 |
if (ret == KErrNone)
|
sl@0
|
925 |
theFlogger.Close();
|
sl@0
|
926 |
|
sl@0
|
927 |
if (ret == KErrNone)
|
sl@0
|
928 |
{
|
sl@0
|
929 |
//Write the test datas in the hexa format
|
sl@0
|
930 |
RFileLogger::HexDump(KStdSubsysTag8,KStdCompTag8, KNullDesC8);
|
sl@0
|
931 |
return KErrNone;
|
sl@0
|
932 |
}
|
sl@0
|
933 |
return ret;
|
sl@0
|
934 |
}
|
sl@0
|
935 |
|
sl@0
|
936 |
|
sl@0
|
937 |
/**
|
sl@0
|
938 |
* Function Name : DoTestCheckWriteL
|
sl@0
|
939 |
* Input parameters : None
|
sl@0
|
940 |
* Output parameters : TInt
|
sl@0
|
941 |
* Description : This function checks the weather test data was written
|
sl@0
|
942 |
* in to the log file by DoTestWrite() or not.
|
sl@0
|
943 |
|
sl@0
|
944 |
*/
|
sl@0
|
945 |
|
sl@0
|
946 |
|
sl@0
|
947 |
TInt CFloggerTest017_05::DoTestCheckWriteL()
|
sl@0
|
948 |
{
|
sl@0
|
949 |
User::After(KTimeToLog);
|
sl@0
|
950 |
RFile theFile;
|
sl@0
|
951 |
HBufC8 * hBuffer;
|
sl@0
|
952 |
TInt listfilesize;
|
sl@0
|
953 |
TInt returnCode;
|
sl@0
|
954 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
955 |
_LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path
|
sl@0
|
956 |
_LIT8(KExpectedString,"0000 :");
|
sl@0
|
957 |
|
sl@0
|
958 |
_LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message
|
sl@0
|
959 |
|
sl@0
|
960 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
961 |
|
sl@0
|
962 |
//Open the file in the read mode
|
sl@0
|
963 |
User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
|
sl@0
|
964 |
CleanupClosePushL(theFile);
|
sl@0
|
965 |
|
sl@0
|
966 |
|
sl@0
|
967 |
User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
968 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
969 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
970 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
971 |
|
sl@0
|
972 |
// Read from position 0: start of file
|
sl@0
|
973 |
returnCode = theFile.Read(ptrString);
|
sl@0
|
974 |
|
sl@0
|
975 |
//check for no OOM msg
|
sl@0
|
976 |
returnCode = ptrString.Find(KOOMError);
|
sl@0
|
977 |
if (returnCode > 0)
|
sl@0
|
978 |
{
|
sl@0
|
979 |
User::Leave(KErrNoMemory);
|
sl@0
|
980 |
}
|
sl@0
|
981 |
|
sl@0
|
982 |
|
sl@0
|
983 |
// we expect the output to be pretty blank, so not much to search for
|
sl@0
|
984 |
// except make sure the standard "0000: " ins't even there
|
sl@0
|
985 |
returnCode = ptrString.Find(KExpectedString); //find the test descriptor in the buffer read
|
sl@0
|
986 |
//from the file
|
sl@0
|
987 |
|
sl@0
|
988 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
989 |
CleanupStack::PopAndDestroy(); //theFile object
|
sl@0
|
990 |
if (returnCode == KErrNotFound)
|
sl@0
|
991 |
return KErrNone;
|
sl@0
|
992 |
else
|
sl@0
|
993 |
return KErrGeneral;
|
sl@0
|
994 |
}
|
sl@0
|
995 |
|
sl@0
|
996 |
|
sl@0
|
997 |
|
sl@0
|
998 |
/*
|
sl@0
|
999 |
* Function Name : CFloggerTest017_06
|
sl@0
|
1000 |
* Input parameters : None
|
sl@0
|
1001 |
* Output parameters : None
|
sl@0
|
1002 |
* Description : This is the constructor
|
sl@0
|
1003 |
*/
|
sl@0
|
1004 |
|
sl@0
|
1005 |
|
sl@0
|
1006 |
CFloggerTest017_06::CFloggerTest017_06()
|
sl@0
|
1007 |
{
|
sl@0
|
1008 |
// store the name of this test case
|
sl@0
|
1009 |
SetTestStepName(_L("step_017_06"));
|
sl@0
|
1010 |
}
|
sl@0
|
1011 |
|
sl@0
|
1012 |
|
sl@0
|
1013 |
/**
|
sl@0
|
1014 |
* Function Name :~ CFloggerTest017_06
|
sl@0
|
1015 |
* Input parameters : None
|
sl@0
|
1016 |
* Output parameters : None
|
sl@0
|
1017 |
* Description : This is the Destructor
|
sl@0
|
1018 |
*/
|
sl@0
|
1019 |
|
sl@0
|
1020 |
|
sl@0
|
1021 |
CFloggerTest017_06::~CFloggerTest017_06()
|
sl@0
|
1022 |
{
|
sl@0
|
1023 |
}
|
sl@0
|
1024 |
|
sl@0
|
1025 |
|
sl@0
|
1026 |
/**
|
sl@0
|
1027 |
* Function Name : doTestStepL
|
sl@0
|
1028 |
* Input parameters : None
|
sl@0
|
1029 |
* Output parameters : TVerdict
|
sl@0
|
1030 |
* Description : This function is responsible for doing the heap test analysis
|
sl@0
|
1031 |
|
sl@0
|
1032 |
*/
|
sl@0
|
1033 |
|
sl@0
|
1034 |
|
sl@0
|
1035 |
|
sl@0
|
1036 |
TVerdict CFloggerTest017_06::doTestStepL( )
|
sl@0
|
1037 |
{
|
sl@0
|
1038 |
INFO_PRINTF1(_L("Step 017.06 called "));
|
sl@0
|
1039 |
|
sl@0
|
1040 |
CFloggerTest017_01* step017_01 = new CFloggerTest017_01;
|
sl@0
|
1041 |
CleanupStack::PushL(step017_01);
|
sl@0
|
1042 |
doTestStepWithHeapFailureL( *step017_01, 1, 20, KErrNone, ETrue);
|
sl@0
|
1043 |
|
sl@0
|
1044 |
CleanupStack::PopAndDestroy(step017_01);
|
sl@0
|
1045 |
User::After(KTimeForDisplay);
|
sl@0
|
1046 |
return TestStepResult();
|
sl@0
|
1047 |
}
|
sl@0
|
1048 |
|