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 012.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 "teststepcomsdbg.h"
|
sl@0
|
21 |
#include "TestMessage.h"
|
sl@0
|
22 |
#include "step_012_xx.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
#include <comms-infras/commsdebugutility.h>
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
/**
|
sl@0
|
28 |
* Function Name : CFloggerTest012_01
|
sl@0
|
29 |
* Input parameters : None
|
sl@0
|
30 |
* Output parameters : None
|
sl@0
|
31 |
* Description : This is the constructor
|
sl@0
|
32 |
*/
|
sl@0
|
33 |
|
sl@0
|
34 |
|
sl@0
|
35 |
CFloggerTest012_01::CFloggerTest012_01()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
// store the name of this test case
|
sl@0
|
38 |
SetTestStepName(_L("step_012_01"));
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
|
sl@0
|
42 |
/**
|
sl@0
|
43 |
* Function Name :~ CFloggerTest012_01
|
sl@0
|
44 |
* Input parameters : None
|
sl@0
|
45 |
* Output parameters : None
|
sl@0
|
46 |
* Description : This is the Destructor
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
|
sl@0
|
49 |
|
sl@0
|
50 |
CFloggerTest012_01::~CFloggerTest012_01()
|
sl@0
|
51 |
{
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
|
sl@0
|
55 |
/**
|
sl@0
|
56 |
* Function Name : doTestStepL
|
sl@0
|
57 |
* Input parameters : None
|
sl@0
|
58 |
* Output parameters : TVerdict
|
sl@0
|
59 |
* Description : This function returns weather the test case 012_01 has
|
sl@0
|
60 |
* passed or failed
|
sl@0
|
61 |
|
sl@0
|
62 |
*/
|
sl@0
|
63 |
|
sl@0
|
64 |
|
sl@0
|
65 |
TVerdict CFloggerTest012_01::doTestStepL( )
|
sl@0
|
66 |
{
|
sl@0
|
67 |
|
sl@0
|
68 |
INFO_PRINTF1(_L("Step 012.01 called "));
|
sl@0
|
69 |
|
sl@0
|
70 |
if ( executeStepL(EFalse) == KErrNone )
|
sl@0
|
71 |
SetTestStepResult(EPass);
|
sl@0
|
72 |
|
sl@0
|
73 |
else
|
sl@0
|
74 |
SetTestStepResult(EFail);
|
sl@0
|
75 |
|
sl@0
|
76 |
|
sl@0
|
77 |
User::After(KTimeForDisplay1);
|
sl@0
|
78 |
return TestStepResult();
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
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 CFloggerTest012_01::executeStepL(TBool heapTest)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
TInt ret = KErrGeneral;
|
sl@0
|
96 |
|
sl@0
|
97 |
ret = DoTestWrite();
|
sl@0
|
98 |
if (ret == KErrNone )
|
sl@0
|
99 |
{
|
sl@0
|
100 |
User::After(KTimeToLog);
|
sl@0
|
101 |
TRAPD(r, ret = DoTestCheckWriteL() );
|
sl@0
|
102 |
if ((heapTest) && ((ret == KErrNotFound) || (r != KErrNone)))
|
sl@0
|
103 |
{
|
sl@0
|
104 |
ret = KErrNoMemory;
|
sl@0
|
105 |
}
|
sl@0
|
106 |
else if (r != KErrNone)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
ret = r;
|
sl@0
|
109 |
}
|
sl@0
|
110 |
}
|
sl@0
|
111 |
return ret;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
/**
|
sl@0
|
114 |
* Function Name : executeStepL
|
sl@0
|
115 |
* Input parameters : None
|
sl@0
|
116 |
* Output parameters : TInt
|
sl@0
|
117 |
* Description : This function writes the test data in to the log file
|
sl@0
|
118 |
* This function check the test message is present in the
|
sl@0
|
119 |
* log file
|
sl@0
|
120 |
|
sl@0
|
121 |
*/
|
sl@0
|
122 |
|
sl@0
|
123 |
|
sl@0
|
124 |
TInt CFloggerTest012_01::executeStepL()
|
sl@0
|
125 |
{
|
sl@0
|
126 |
return KErrGeneral;
|
sl@0
|
127 |
}
|
sl@0
|
128 |
|
sl@0
|
129 |
|
sl@0
|
130 |
/**
|
sl@0
|
131 |
* Function Name : DoTestWrite
|
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
|
sl@0
|
136 |
|
sl@0
|
137 |
*/
|
sl@0
|
138 |
|
sl@0
|
139 |
|
sl@0
|
140 |
TInt CFloggerTest012_01::DoTestWrite()
|
sl@0
|
141 |
{
|
sl@0
|
142 |
_LIT16(KTestMessageOne,"TEST 12.01: The value of test integer variable :%d"); //unicode test decriptor
|
sl@0
|
143 |
RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8, KTestMessageOne, 100);
|
sl@0
|
144 |
|
sl@0
|
145 |
// connect so we can flush file buffer for heap check
|
sl@0
|
146 |
RFileLogger theFlogger;
|
sl@0
|
147 |
theFlogger.Connect();
|
sl@0
|
148 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
149 |
ForceLogFlush(theFlogger);
|
sl@0
|
150 |
theFlogger.Close();
|
sl@0
|
151 |
|
sl@0
|
152 |
return KErrNone;
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
|
sl@0
|
156 |
/**
|
sl@0
|
157 |
* Function Name : DoTestCheckWriteL
|
sl@0
|
158 |
* Input parameters : None
|
sl@0
|
159 |
* Output parameters : TInt
|
sl@0
|
160 |
* Description : This function checks the weather test data was written
|
sl@0
|
161 |
* in to the log file by DoTestWriteL() or not.
|
sl@0
|
162 |
|
sl@0
|
163 |
*/
|
sl@0
|
164 |
|
sl@0
|
165 |
|
sl@0
|
166 |
TInt CFloggerTest012_01::DoTestCheckWriteL()
|
sl@0
|
167 |
{
|
sl@0
|
168 |
RFile theFile;
|
sl@0
|
169 |
HBufC8 * hBuffer;
|
sl@0
|
170 |
TInt listfilesize;
|
sl@0
|
171 |
TInt returnCode;
|
sl@0
|
172 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
173 |
TBuf8<256> testData; //To hold the test descriptor
|
sl@0
|
174 |
_LIT(KLogFile, "c:\\logs\\log.txt"); // log file name and path
|
sl@0
|
175 |
|
sl@0
|
176 |
_LIT8(KTestMessageOne,"TEST 12.01: The value of test integer variable :%d"); //unicode test decriptor
|
sl@0
|
177 |
testData.Format(KTestMessageOne,100);
|
sl@0
|
178 |
|
sl@0
|
179 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
180 |
|
sl@0
|
181 |
//Open the file in the read mode
|
sl@0
|
182 |
User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
|
sl@0
|
183 |
|
sl@0
|
184 |
|
sl@0
|
185 |
returnCode = theFile.Size(listfilesize); //Size of the file
|
sl@0
|
186 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
187 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
188 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer read from file
|
sl@0
|
189 |
|
sl@0
|
190 |
// Read from position 0: starting of file
|
sl@0
|
191 |
returnCode = theFile.Read(ptrString);
|
sl@0
|
192 |
|
sl@0
|
193 |
returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
194 |
//from the file
|
sl@0
|
195 |
|
sl@0
|
196 |
theFile.Close();
|
sl@0
|
197 |
fileSystem.Close();
|
sl@0
|
198 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
199 |
if (returnCode > 0)
|
sl@0
|
200 |
return KErrNone;
|
sl@0
|
201 |
else
|
sl@0
|
202 |
return KErrNotFound;
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
|
sl@0
|
206 |
TInt CFloggerTest012_01::DoHeapTestWrite()
|
sl@0
|
207 |
{
|
sl@0
|
208 |
|
sl@0
|
209 |
_LIT16(KTestMessageOne,"TEST 12.04: Heap Test: The value of test integer variable :%d"); //unicode test decriptor
|
sl@0
|
210 |
RFileLogger::WriteFormat(KStdSubsysTag8, KStdCompTag8, KTestMessageOne, 100);
|
sl@0
|
211 |
return KErrNone;
|
sl@0
|
212 |
}
|
sl@0
|
213 |
|
sl@0
|
214 |
|
sl@0
|
215 |
/**
|
sl@0
|
216 |
* Function Name : CFloggerTest012_02
|
sl@0
|
217 |
* Input parameters : None
|
sl@0
|
218 |
* Output parameters : None
|
sl@0
|
219 |
* Description : This is the constructor
|
sl@0
|
220 |
*/
|
sl@0
|
221 |
|
sl@0
|
222 |
|
sl@0
|
223 |
CFloggerTest012_02::CFloggerTest012_02()
|
sl@0
|
224 |
{
|
sl@0
|
225 |
// store the name of this test case
|
sl@0
|
226 |
SetTestStepName(_L("step_012_02"));
|
sl@0
|
227 |
}
|
sl@0
|
228 |
|
sl@0
|
229 |
|
sl@0
|
230 |
/**
|
sl@0
|
231 |
* Function Name :~ CFloggerTest012_02
|
sl@0
|
232 |
* Input parameters : None
|
sl@0
|
233 |
* Output parameters : None
|
sl@0
|
234 |
* Description : This is the Destructor
|
sl@0
|
235 |
*/
|
sl@0
|
236 |
|
sl@0
|
237 |
|
sl@0
|
238 |
CFloggerTest012_02::~CFloggerTest012_02()
|
sl@0
|
239 |
{
|
sl@0
|
240 |
iFlogger.Close();
|
sl@0
|
241 |
}
|
sl@0
|
242 |
|
sl@0
|
243 |
|
sl@0
|
244 |
|
sl@0
|
245 |
/**
|
sl@0
|
246 |
* Function Name : doTestStepL
|
sl@0
|
247 |
* Input parameters : None
|
sl@0
|
248 |
* Output parameters : TVerdict
|
sl@0
|
249 |
* Description : This function returns weather the test case 012_02 has
|
sl@0
|
250 |
* passed or failed
|
sl@0
|
251 |
|
sl@0
|
252 |
*/
|
sl@0
|
253 |
|
sl@0
|
254 |
|
sl@0
|
255 |
TVerdict CFloggerTest012_02::doTestStepL( )
|
sl@0
|
256 |
{
|
sl@0
|
257 |
INFO_PRINTF1(_L("Step 011.02 called "));
|
sl@0
|
258 |
|
sl@0
|
259 |
if ( executeStepL() == KErrNone )
|
sl@0
|
260 |
SetTestStepResult(EPass);
|
sl@0
|
261 |
|
sl@0
|
262 |
else
|
sl@0
|
263 |
SetTestStepResult(EFail);
|
sl@0
|
264 |
|
sl@0
|
265 |
|
sl@0
|
266 |
User::After(KTimeForDisplay1);
|
sl@0
|
267 |
return TestStepResult();
|
sl@0
|
268 |
}
|
sl@0
|
269 |
|
sl@0
|
270 |
/**
|
sl@0
|
271 |
* Function Name : executeStepL
|
sl@0
|
272 |
* Input parameters : None
|
sl@0
|
273 |
* Output parameters : TInt
|
sl@0
|
274 |
* Description : This function writes the test data in to the log file
|
sl@0
|
275 |
* This function check the test message is present in the
|
sl@0
|
276 |
* log file
|
sl@0
|
277 |
|
sl@0
|
278 |
*/
|
sl@0
|
279 |
|
sl@0
|
280 |
|
sl@0
|
281 |
TInt CFloggerTest012_02::executeStepL(TBool)
|
sl@0
|
282 |
{
|
sl@0
|
283 |
return KErrGeneral;
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
/**
|
sl@0
|
287 |
* Function Name : executeStepL
|
sl@0
|
288 |
* Input parameters : None
|
sl@0
|
289 |
* Output parameters : TInt
|
sl@0
|
290 |
* Description : This function writes the test data in to the log file
|
sl@0
|
291 |
* This function check the test message is present in the
|
sl@0
|
292 |
* log file
|
sl@0
|
293 |
|
sl@0
|
294 |
*/
|
sl@0
|
295 |
|
sl@0
|
296 |
|
sl@0
|
297 |
TInt CFloggerTest012_02::executeStepL()
|
sl@0
|
298 |
{
|
sl@0
|
299 |
TInt ret = KErrGeneral;
|
sl@0
|
300 |
|
sl@0
|
301 |
ret = DoTestWrite();
|
sl@0
|
302 |
if (ret == KErrNone )
|
sl@0
|
303 |
{
|
sl@0
|
304 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
305 |
if ( r != KErrNone)
|
sl@0
|
306 |
ret = r;
|
sl@0
|
307 |
}
|
sl@0
|
308 |
return ret;
|
sl@0
|
309 |
}
|
sl@0
|
310 |
|
sl@0
|
311 |
/**
|
sl@0
|
312 |
* Function Name : DoTestWrite
|
sl@0
|
313 |
* Input parameters : None
|
sl@0
|
314 |
* Output parameters : TInt
|
sl@0
|
315 |
* Description : This function writes the data to the file logger
|
sl@0
|
316 |
|
sl@0
|
317 |
*/
|
sl@0
|
318 |
|
sl@0
|
319 |
|
sl@0
|
320 |
TInt CFloggerTest012_02::DoTestWrite()
|
sl@0
|
321 |
{
|
sl@0
|
322 |
|
sl@0
|
323 |
//unicode test decriptor
|
sl@0
|
324 |
_LIT16(KTestMessageTwo,"TEST 12.02: The value of first test integer variable :%d The value of second test integer variable : %d");
|
sl@0
|
325 |
|
sl@0
|
326 |
RFileLogger ::WriteFormat(KStdSubsysTag8, KStdCompTag8, KTestMessageTwo, 100, 200);
|
sl@0
|
327 |
|
sl@0
|
328 |
|
sl@0
|
329 |
return KErrNone;
|
sl@0
|
330 |
}
|
sl@0
|
331 |
|
sl@0
|
332 |
|
sl@0
|
333 |
/**
|
sl@0
|
334 |
* Function Name : DoTestCheckWriteL
|
sl@0
|
335 |
* Input parameters : None
|
sl@0
|
336 |
* Output parameters : TInt
|
sl@0
|
337 |
* Description : This function checks the weather test data was written
|
sl@0
|
338 |
* in to the log file by DoTestWriteL() or not.
|
sl@0
|
339 |
|
sl@0
|
340 |
*/
|
sl@0
|
341 |
|
sl@0
|
342 |
|
sl@0
|
343 |
TInt CFloggerTest012_02::DoTestCheckWriteL()
|
sl@0
|
344 |
{
|
sl@0
|
345 |
|
sl@0
|
346 |
|
sl@0
|
347 |
User::After(KTimeToLog);
|
sl@0
|
348 |
|
sl@0
|
349 |
RFile theFile;
|
sl@0
|
350 |
HBufC8 * hBuffer;
|
sl@0
|
351 |
TInt listfilesize;
|
sl@0
|
352 |
TInt returnCode;
|
sl@0
|
353 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
354 |
TBuf8<256> testData; //To hold the test descriptor
|
sl@0
|
355 |
_LIT(KLogFile, "c:\\logs\\log.txt"); // log file name and path
|
sl@0
|
356 |
|
sl@0
|
357 |
_LIT8(KTestMessageTwo,"TEST 12.02: The value of first test integer variable :%d The value of second test integer variable : %d");
|
sl@0
|
358 |
testData.Format(KTestMessageTwo,100, 200);
|
sl@0
|
359 |
|
sl@0
|
360 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
361 |
|
sl@0
|
362 |
//Open the file in the read mode
|
sl@0
|
363 |
User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
|
sl@0
|
364 |
|
sl@0
|
365 |
|
sl@0
|
366 |
returnCode = theFile.Size(listfilesize); //Size of the file
|
sl@0
|
367 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
368 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
369 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
370 |
|
sl@0
|
371 |
// Read from position 0: start of file
|
sl@0
|
372 |
returnCode = theFile.Read(ptrString);
|
sl@0
|
373 |
|
sl@0
|
374 |
returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
375 |
//from the file
|
sl@0
|
376 |
theFile.Close();
|
sl@0
|
377 |
fileSystem.Close();
|
sl@0
|
378 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
379 |
if (returnCode > 0)
|
sl@0
|
380 |
return KErrNone;
|
sl@0
|
381 |
else
|
sl@0
|
382 |
return KErrGeneral;
|
sl@0
|
383 |
}
|
sl@0
|
384 |
|
sl@0
|
385 |
|
sl@0
|
386 |
/**
|
sl@0
|
387 |
* Function Name : CFloggerTest012_03
|
sl@0
|
388 |
* Input parameters : None
|
sl@0
|
389 |
* Output parameters : None
|
sl@0
|
390 |
* Description : This is the constructor
|
sl@0
|
391 |
*/
|
sl@0
|
392 |
|
sl@0
|
393 |
|
sl@0
|
394 |
CFloggerTest012_03::CFloggerTest012_03()
|
sl@0
|
395 |
{
|
sl@0
|
396 |
// store the name of this test case
|
sl@0
|
397 |
SetTestStepName(_L("step_012_03"));
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
/**
|
sl@0
|
401 |
* Function Name :~ CFloggerTest012_03
|
sl@0
|
402 |
* Input parameters : None
|
sl@0
|
403 |
* Output parameters : None
|
sl@0
|
404 |
* Description : This is the Destructor
|
sl@0
|
405 |
*/
|
sl@0
|
406 |
|
sl@0
|
407 |
|
sl@0
|
408 |
CFloggerTest012_03::~CFloggerTest012_03()
|
sl@0
|
409 |
{
|
sl@0
|
410 |
}
|
sl@0
|
411 |
|
sl@0
|
412 |
|
sl@0
|
413 |
/**
|
sl@0
|
414 |
* Function Name : doTestStepL
|
sl@0
|
415 |
* Input parameters : None
|
sl@0
|
416 |
* Output parameters : TVerdict
|
sl@0
|
417 |
* Description : This function returns weather the test case 012_03 has
|
sl@0
|
418 |
* passed or failed
|
sl@0
|
419 |
|
sl@0
|
420 |
*/
|
sl@0
|
421 |
|
sl@0
|
422 |
|
sl@0
|
423 |
TVerdict CFloggerTest012_03::doTestStepL( )
|
sl@0
|
424 |
{
|
sl@0
|
425 |
INFO_PRINTF1(_L("Step 012.03 called "));
|
sl@0
|
426 |
|
sl@0
|
427 |
if ( executeStepL() == KErrNone )
|
sl@0
|
428 |
SetTestStepResult(EPass);
|
sl@0
|
429 |
|
sl@0
|
430 |
else
|
sl@0
|
431 |
SetTestStepResult(EFail);
|
sl@0
|
432 |
|
sl@0
|
433 |
|
sl@0
|
434 |
User::After(KTimeForDisplay1);
|
sl@0
|
435 |
return TestStepResult();
|
sl@0
|
436 |
}
|
sl@0
|
437 |
|
sl@0
|
438 |
/**
|
sl@0
|
439 |
* Function Name : executeStepL
|
sl@0
|
440 |
* Input parameters : None
|
sl@0
|
441 |
* Output parameters : TInt
|
sl@0
|
442 |
* Description : This function writes the test data in to the log file
|
sl@0
|
443 |
* This function check the test message is present in the
|
sl@0
|
444 |
* log file
|
sl@0
|
445 |
|
sl@0
|
446 |
*/
|
sl@0
|
447 |
|
sl@0
|
448 |
|
sl@0
|
449 |
TInt CFloggerTest012_03::executeStepL(TBool)
|
sl@0
|
450 |
{
|
sl@0
|
451 |
return KErrGeneral;
|
sl@0
|
452 |
}
|
sl@0
|
453 |
|
sl@0
|
454 |
/**
|
sl@0
|
455 |
* Function Name : executeStepL
|
sl@0
|
456 |
* Input parameters : None
|
sl@0
|
457 |
* Output parameters : TInt
|
sl@0
|
458 |
* Description : This function writes the test data in to the log file
|
sl@0
|
459 |
* This function check the test message is present in the
|
sl@0
|
460 |
* log file
|
sl@0
|
461 |
|
sl@0
|
462 |
*/
|
sl@0
|
463 |
|
sl@0
|
464 |
|
sl@0
|
465 |
TInt CFloggerTest012_03::executeStepL()
|
sl@0
|
466 |
{
|
sl@0
|
467 |
TInt ret = KErrGeneral;
|
sl@0
|
468 |
User::After(1000*100); //Need this or connect will return KErrServerTerminated
|
sl@0
|
469 |
ret = DoTestWrite();
|
sl@0
|
470 |
if (ret == KErrNone )
|
sl@0
|
471 |
{
|
sl@0
|
472 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
473 |
if ( r != KErrNone)
|
sl@0
|
474 |
ret = r;
|
sl@0
|
475 |
}
|
sl@0
|
476 |
return ret;
|
sl@0
|
477 |
|
sl@0
|
478 |
}
|
sl@0
|
479 |
|
sl@0
|
480 |
|
sl@0
|
481 |
/**
|
sl@0
|
482 |
* Function Name : DoTestWrite
|
sl@0
|
483 |
* Input parameters : None
|
sl@0
|
484 |
* Output parameters : TInt
|
sl@0
|
485 |
* Description : This function writes the data to the file logger
|
sl@0
|
486 |
|
sl@0
|
487 |
*/
|
sl@0
|
488 |
|
sl@0
|
489 |
|
sl@0
|
490 |
TInt CFloggerTest012_03::DoTestWrite()
|
sl@0
|
491 |
{
|
sl@0
|
492 |
_LIT(KTestLongMessage,"TEST 12.03: 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 ");
|
sl@0
|
493 |
|
sl@0
|
494 |
RFileLogger ::WriteFormat(KStdSubsysTag8, KStdCompTag8, KTestLongMessage);
|
sl@0
|
495 |
return KErrNone;
|
sl@0
|
496 |
}
|
sl@0
|
497 |
|
sl@0
|
498 |
|
sl@0
|
499 |
|
sl@0
|
500 |
/**
|
sl@0
|
501 |
* Function Name : DoTestCheckWriteL
|
sl@0
|
502 |
* Input parameters : None
|
sl@0
|
503 |
* Output parameters : TInt
|
sl@0
|
504 |
* Description : This function checks the weather test data was written
|
sl@0
|
505 |
* in to the log file by DoTestWriteL() or not.
|
sl@0
|
506 |
|
sl@0
|
507 |
*/
|
sl@0
|
508 |
|
sl@0
|
509 |
|
sl@0
|
510 |
TInt CFloggerTest012_03::DoTestCheckWriteL()
|
sl@0
|
511 |
{
|
sl@0
|
512 |
User::After(KTimeToLog);
|
sl@0
|
513 |
|
sl@0
|
514 |
RFile theFile;
|
sl@0
|
515 |
HBufC8 * hBuffer;
|
sl@0
|
516 |
TInt listfilesize,returnCode;
|
sl@0
|
517 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
518 |
TBuf8<256> testData; //To hold the test descriptor
|
sl@0
|
519 |
_LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path
|
sl@0
|
520 |
|
sl@0
|
521 |
//The following contains the string of length 200(max)
|
sl@0
|
522 |
//which is written to the log file
|
sl@0
|
523 |
//_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
|
524 |
_LIT(KTestLongMessage, "TEST 12.03: 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");
|
sl@0
|
525 |
|
sl@0
|
526 |
//_LIT8(KOOMError, "#Logs may be lost out of memory!!");
|
sl@0
|
527 |
|
sl@0
|
528 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
529 |
|
sl@0
|
530 |
//Open the file in the read mode
|
sl@0
|
531 |
User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead));
|
sl@0
|
532 |
|
sl@0
|
533 |
CleanupClosePushL(theFile);
|
sl@0
|
534 |
|
sl@0
|
535 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
536 |
|
sl@0
|
537 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
538 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
539 |
|
sl@0
|
540 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
541 |
|
sl@0
|
542 |
// Read from position 0: start of file
|
sl@0
|
543 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
544 |
|
sl@0
|
545 |
testData.Copy(KTestLongMessage); //Copy the test descriptor
|
sl@0
|
546 |
returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
547 |
//from the file
|
sl@0
|
548 |
|
sl@0
|
549 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
550 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
551 |
if (returnCode > 0)
|
sl@0
|
552 |
return KErrNone;
|
sl@0
|
553 |
else
|
sl@0
|
554 |
return KErrGeneral;
|
sl@0
|
555 |
|
sl@0
|
556 |
}
|
sl@0
|
557 |
|
sl@0
|
558 |
|
sl@0
|
559 |
/**
|
sl@0
|
560 |
* Function Name : CFloggerTest005_02
|
sl@0
|
561 |
* Input parameters : None
|
sl@0
|
562 |
* Output parameters : None
|
sl@0
|
563 |
* Description : This is the constructor
|
sl@0
|
564 |
*/
|
sl@0
|
565 |
|
sl@0
|
566 |
|
sl@0
|
567 |
CFloggerTest012_04::CFloggerTest012_04()
|
sl@0
|
568 |
{
|
sl@0
|
569 |
// store the name of this test case
|
sl@0
|
570 |
SetTestStepName(_L("step_012_04"));
|
sl@0
|
571 |
}
|
sl@0
|
572 |
|
sl@0
|
573 |
|
sl@0
|
574 |
/**
|
sl@0
|
575 |
* Function Name :~ CFloggerTest005_02
|
sl@0
|
576 |
* Input parameters : None
|
sl@0
|
577 |
* Output parameters : None
|
sl@0
|
578 |
* Description : This is the Destructor
|
sl@0
|
579 |
*/
|
sl@0
|
580 |
|
sl@0
|
581 |
|
sl@0
|
582 |
CFloggerTest012_04::~CFloggerTest012_04()
|
sl@0
|
583 |
{
|
sl@0
|
584 |
}
|
sl@0
|
585 |
|
sl@0
|
586 |
/**
|
sl@0
|
587 |
* Function Name : doTestStepL
|
sl@0
|
588 |
* Input parameters : None
|
sl@0
|
589 |
* Output parameters : TVerdict
|
sl@0
|
590 |
* Description : This function is responsible for doing the heap test analysis
|
sl@0
|
591 |
|
sl@0
|
592 |
*/
|
sl@0
|
593 |
TVerdict CFloggerTest012_04::doTestStepL( )
|
sl@0
|
594 |
{
|
sl@0
|
595 |
INFO_PRINTF1(_L("Step 012.04 called "));
|
sl@0
|
596 |
|
sl@0
|
597 |
CFloggerTest012_01* step012_01 = new CFloggerTest012_01;
|
sl@0
|
598 |
CleanupStack::PushL(step012_01);
|
sl@0
|
599 |
doTestStepWithHeapFailureL( *step012_01, 1,20, KErrNone, ETrue);
|
sl@0
|
600 |
|
sl@0
|
601 |
CleanupStack::PopAndDestroy(step012_01);
|
sl@0
|
602 |
User::After(KTimeForDisplay);
|
sl@0
|
603 |
return TestStepResult();
|
sl@0
|
604 |
}
|
sl@0
|
605 |
|
sl@0
|
606 |
|
sl@0
|
607 |
|
sl@0
|
608 |
|