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 |
// See the test specification for details of what these test cases do.
|
sl@0
|
15 |
#include "teststepcomsdbg.h"
|
sl@0
|
16 |
#include "TestMessage.h"
|
sl@0
|
17 |
#include "step_030_xx.h"
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <comms-infras/commsdebugutility.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
/**
|
sl@0
|
25 |
* This is the Constructor
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
|
sl@0
|
28 |
|
sl@0
|
29 |
CFloggerTest030_Tag_Setup::CFloggerTest030_Tag_Setup()
|
sl@0
|
30 |
{
|
sl@0
|
31 |
// Store the name of this test case
|
sl@0
|
32 |
SetTestStepName(_L("step_030_Tag_Setup"));
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
|
sl@0
|
36 |
/**
|
sl@0
|
37 |
* This is the Destructor
|
sl@0
|
38 |
*/
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
CFloggerTest030_Tag_Setup::~CFloggerTest030_Tag_Setup()
|
sl@0
|
42 |
{
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
|
sl@0
|
46 |
/**
|
sl@0
|
47 |
* This function returns whether the test case has
|
sl@0
|
48 |
* passed or failed
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
|
sl@0
|
51 |
|
sl@0
|
52 |
TVerdict CFloggerTest030_Tag_Setup::doTestStepL( )
|
sl@0
|
53 |
{
|
sl@0
|
54 |
if ( executeStepL() == KErrNone )
|
sl@0
|
55 |
SetTestStepResult(EPass);
|
sl@0
|
56 |
|
sl@0
|
57 |
else
|
sl@0
|
58 |
SetTestStepResult(EFail);
|
sl@0
|
59 |
|
sl@0
|
60 |
//INFO_PRINTF1(_L("leaving Step 030_Tag_Setup "));
|
sl@0
|
61 |
User::After(KTimeForDisplay);
|
sl@0
|
62 |
|
sl@0
|
63 |
|
sl@0
|
64 |
return TestStepResult();
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
|
sl@0
|
68 |
TInt CFloggerTest030_Tag_Setup::executeStepL(TBool)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
return KErrGeneral;
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
TInt CFloggerTest030_Tag_Setup::executeStepL()
|
sl@0
|
74 |
{
|
sl@0
|
75 |
return constructFloggerIniL(KTagTestsIniFileSettings);
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
|
sl@0
|
79 |
|
sl@0
|
80 |
|
sl@0
|
81 |
|
sl@0
|
82 |
/**
|
sl@0
|
83 |
* 030_TagSetLogTag01: Test that flogger handles empty tags
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
|
sl@0
|
86 |
CFloggerTest030_TagSetLogTag01::CFloggerTest030_TagSetLogTag01()
|
sl@0
|
87 |
{
|
sl@0
|
88 |
// Store the name of this test case
|
sl@0
|
89 |
SetTestStepName(_L("step_030_TagSetLogTag01"));
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
|
sl@0
|
93 |
|
sl@0
|
94 |
|
sl@0
|
95 |
CFloggerTest030_TagSetLogTag01::~CFloggerTest030_TagSetLogTag01()
|
sl@0
|
96 |
{
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
|
sl@0
|
100 |
|
sl@0
|
101 |
|
sl@0
|
102 |
TVerdict CFloggerTest030_TagSetLogTag01::doTestStepL( )
|
sl@0
|
103 |
{
|
sl@0
|
104 |
if ( executeStepL() == KErrNone )
|
sl@0
|
105 |
SetTestStepResult(EPass);
|
sl@0
|
106 |
|
sl@0
|
107 |
else
|
sl@0
|
108 |
SetTestStepResult(EFail);
|
sl@0
|
109 |
|
sl@0
|
110 |
User::After(KTimeForDisplay);
|
sl@0
|
111 |
|
sl@0
|
112 |
|
sl@0
|
113 |
return TestStepResult();
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
TInt CFloggerTest030_TagSetLogTag01::executeStepL(TBool)
|
sl@0
|
117 |
{
|
sl@0
|
118 |
return KErrGeneral;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
|
sl@0
|
122 |
TInt CFloggerTest030_TagSetLogTag01::executeStepL()
|
sl@0
|
123 |
{
|
sl@0
|
124 |
|
sl@0
|
125 |
TInt ret ;
|
sl@0
|
126 |
RFileLogger theFlogger;
|
sl@0
|
127 |
ret = theFlogger.Connect();
|
sl@0
|
128 |
|
sl@0
|
129 |
if ( ret == KErrNone)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
132 |
theFlogger.ClearLog();
|
sl@0
|
133 |
theFlogger.SetLogTags(KNullDesC8, KNullDesC8);
|
sl@0
|
134 |
theFlogger.Write(KTestMessage);
|
sl@0
|
135 |
theFlogger.Close();
|
sl@0
|
136 |
User::After(KTimeToLog);
|
sl@0
|
137 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
138 |
if (r != KErrNone)
|
sl@0
|
139 |
ret = r;
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
return ret;
|
sl@0
|
143 |
|
sl@0
|
144 |
}
|
sl@0
|
145 |
|
sl@0
|
146 |
|
sl@0
|
147 |
|
sl@0
|
148 |
|
sl@0
|
149 |
TInt CFloggerTest030_TagSetLogTag01::DoTestCheckWriteL()
|
sl@0
|
150 |
{
|
sl@0
|
151 |
RFile theFile;
|
sl@0
|
152 |
HBufC8 * hBuffer;
|
sl@0
|
153 |
TInt listfilesize,returnCode;
|
sl@0
|
154 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
155 |
TUint numSuccessful = 0;
|
sl@0
|
156 |
|
sl@0
|
157 |
|
sl@0
|
158 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
159 |
CleanupClosePushL(fileSystem);
|
sl@0
|
160 |
|
sl@0
|
161 |
//Open the file in the read mode
|
sl@0
|
162 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
163 |
|
sl@0
|
164 |
CleanupClosePushL(theFile);
|
sl@0
|
165 |
|
sl@0
|
166 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
167 |
|
sl@0
|
168 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
169 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
170 |
|
sl@0
|
171 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
172 |
|
sl@0
|
173 |
// Read from position 0: start of file
|
sl@0
|
174 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
175 |
|
sl@0
|
176 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
177 |
//from the file
|
sl@0
|
178 |
|
sl@0
|
179 |
if (returnCode == KErrNotFound)
|
sl@0
|
180 |
{
|
sl@0
|
181 |
numSuccessful++;
|
sl@0
|
182 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
183 |
if (returnCode > 0)
|
sl@0
|
184 |
User::Leave(KErrNoMemory);
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
|
sl@0
|
188 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
189 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
190 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
191 |
|
sl@0
|
192 |
if (numSuccessful == 1)
|
sl@0
|
193 |
return KErrNone;
|
sl@0
|
194 |
else
|
sl@0
|
195 |
return KErrNotFound;
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
|
sl@0
|
199 |
|
sl@0
|
200 |
|
sl@0
|
201 |
/**
|
sl@0
|
202 |
* 030_TagSetLogTag02: Test that flogger handles empty subsys tag
|
sl@0
|
203 |
*/
|
sl@0
|
204 |
|
sl@0
|
205 |
CFloggerTest030_TagSetLogTag02::CFloggerTest030_TagSetLogTag02()
|
sl@0
|
206 |
{
|
sl@0
|
207 |
// Store the name of this test case
|
sl@0
|
208 |
SetTestStepName(_L("step_030_TagSetLogTag02"));
|
sl@0
|
209 |
}
|
sl@0
|
210 |
|
sl@0
|
211 |
|
sl@0
|
212 |
|
sl@0
|
213 |
|
sl@0
|
214 |
CFloggerTest030_TagSetLogTag02::~CFloggerTest030_TagSetLogTag02()
|
sl@0
|
215 |
{
|
sl@0
|
216 |
}
|
sl@0
|
217 |
|
sl@0
|
218 |
|
sl@0
|
219 |
|
sl@0
|
220 |
|
sl@0
|
221 |
TVerdict CFloggerTest030_TagSetLogTag02::doTestStepL( )
|
sl@0
|
222 |
{
|
sl@0
|
223 |
if ( executeStepL() == KErrNone )
|
sl@0
|
224 |
SetTestStepResult(EPass);
|
sl@0
|
225 |
|
sl@0
|
226 |
else
|
sl@0
|
227 |
SetTestStepResult(EFail);
|
sl@0
|
228 |
|
sl@0
|
229 |
User::After(KTimeForDisplay);
|
sl@0
|
230 |
|
sl@0
|
231 |
|
sl@0
|
232 |
return TestStepResult();
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
|
sl@0
|
236 |
TInt CFloggerTest030_TagSetLogTag02::executeStepL(TBool)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
return KErrGeneral;
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
TInt CFloggerTest030_TagSetLogTag02::executeStepL()
|
sl@0
|
242 |
{
|
sl@0
|
243 |
|
sl@0
|
244 |
TInt ret ;
|
sl@0
|
245 |
RFileLogger theFlogger;
|
sl@0
|
246 |
ret = theFlogger.Connect();
|
sl@0
|
247 |
|
sl@0
|
248 |
if ( ret == KErrNone)
|
sl@0
|
249 |
{
|
sl@0
|
250 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
251 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
252 |
theFlogger.ClearLog();
|
sl@0
|
253 |
theFlogger.SetLogTags(KNullDesC8, KStdCompTag8);
|
sl@0
|
254 |
theFlogger.Write(KTestMessage);
|
sl@0
|
255 |
theFlogger.Close();
|
sl@0
|
256 |
User::After(KTimeToLog);
|
sl@0
|
257 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
258 |
if (r != KErrNone)
|
sl@0
|
259 |
ret = r;
|
sl@0
|
260 |
}
|
sl@0
|
261 |
|
sl@0
|
262 |
return ret;
|
sl@0
|
263 |
|
sl@0
|
264 |
}
|
sl@0
|
265 |
|
sl@0
|
266 |
|
sl@0
|
267 |
|
sl@0
|
268 |
|
sl@0
|
269 |
TInt CFloggerTest030_TagSetLogTag02::DoTestCheckWriteL()
|
sl@0
|
270 |
{
|
sl@0
|
271 |
RFile theFile;
|
sl@0
|
272 |
HBufC8 * hBuffer;
|
sl@0
|
273 |
TInt listfilesize,returnCode;
|
sl@0
|
274 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
275 |
TUint numSuccessful = 0;
|
sl@0
|
276 |
|
sl@0
|
277 |
|
sl@0
|
278 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
279 |
CleanupClosePushL(fileSystem);
|
sl@0
|
280 |
|
sl@0
|
281 |
//Open the file in the read mode
|
sl@0
|
282 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
283 |
|
sl@0
|
284 |
CleanupClosePushL(theFile);
|
sl@0
|
285 |
|
sl@0
|
286 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
287 |
|
sl@0
|
288 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
289 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
290 |
|
sl@0
|
291 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
292 |
|
sl@0
|
293 |
// Read from position 0: start of file
|
sl@0
|
294 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
295 |
|
sl@0
|
296 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
297 |
//from the file
|
sl@0
|
298 |
|
sl@0
|
299 |
if (returnCode == KErrNotFound)
|
sl@0
|
300 |
{
|
sl@0
|
301 |
numSuccessful++;
|
sl@0
|
302 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
303 |
if (returnCode > 0)
|
sl@0
|
304 |
User::Leave(KErrNoMemory);
|
sl@0
|
305 |
}
|
sl@0
|
306 |
|
sl@0
|
307 |
|
sl@0
|
308 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
309 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
310 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
311 |
|
sl@0
|
312 |
if (numSuccessful == 1)
|
sl@0
|
313 |
return KErrNone;
|
sl@0
|
314 |
else
|
sl@0
|
315 |
return KErrNotFound;
|
sl@0
|
316 |
}
|
sl@0
|
317 |
|
sl@0
|
318 |
|
sl@0
|
319 |
|
sl@0
|
320 |
/**
|
sl@0
|
321 |
* 030_TagSetLogTag03: Test that flogger handles empty component tag
|
sl@0
|
322 |
*/
|
sl@0
|
323 |
|
sl@0
|
324 |
CFloggerTest030_TagSetLogTag03::CFloggerTest030_TagSetLogTag03()
|
sl@0
|
325 |
{
|
sl@0
|
326 |
// Store the name of this test case
|
sl@0
|
327 |
SetTestStepName(_L("step_030_TagSetLogTag03"));
|
sl@0
|
328 |
}
|
sl@0
|
329 |
|
sl@0
|
330 |
|
sl@0
|
331 |
|
sl@0
|
332 |
|
sl@0
|
333 |
CFloggerTest030_TagSetLogTag03::~CFloggerTest030_TagSetLogTag03()
|
sl@0
|
334 |
{
|
sl@0
|
335 |
}
|
sl@0
|
336 |
|
sl@0
|
337 |
|
sl@0
|
338 |
|
sl@0
|
339 |
|
sl@0
|
340 |
TVerdict CFloggerTest030_TagSetLogTag03::doTestStepL( )
|
sl@0
|
341 |
{
|
sl@0
|
342 |
if ( executeStepL() == KErrNone )
|
sl@0
|
343 |
SetTestStepResult(EPass);
|
sl@0
|
344 |
|
sl@0
|
345 |
else
|
sl@0
|
346 |
SetTestStepResult(EFail);
|
sl@0
|
347 |
|
sl@0
|
348 |
User::After(KTimeForDisplay);
|
sl@0
|
349 |
|
sl@0
|
350 |
|
sl@0
|
351 |
return TestStepResult();
|
sl@0
|
352 |
}
|
sl@0
|
353 |
|
sl@0
|
354 |
TInt CFloggerTest030_TagSetLogTag03::executeStepL(TBool)
|
sl@0
|
355 |
{
|
sl@0
|
356 |
return KErrGeneral;
|
sl@0
|
357 |
}
|
sl@0
|
358 |
|
sl@0
|
359 |
|
sl@0
|
360 |
TInt CFloggerTest030_TagSetLogTag03::executeStepL()
|
sl@0
|
361 |
{
|
sl@0
|
362 |
|
sl@0
|
363 |
TInt ret ;
|
sl@0
|
364 |
RFileLogger theFlogger;
|
sl@0
|
365 |
ret = theFlogger.Connect();
|
sl@0
|
366 |
|
sl@0
|
367 |
if ( ret == KErrNone)
|
sl@0
|
368 |
{
|
sl@0
|
369 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
370 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
371 |
theFlogger.ClearLog();
|
sl@0
|
372 |
theFlogger.SetLogTags(KStdSubsysTag8, KNullDesC8);
|
sl@0
|
373 |
theFlogger.Write(KTestMessage);
|
sl@0
|
374 |
theFlogger.Close();
|
sl@0
|
375 |
User::After(KTimeToLog);
|
sl@0
|
376 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
377 |
if (r != KErrNone)
|
sl@0
|
378 |
ret = r;
|
sl@0
|
379 |
}
|
sl@0
|
380 |
|
sl@0
|
381 |
return ret;
|
sl@0
|
382 |
|
sl@0
|
383 |
}
|
sl@0
|
384 |
|
sl@0
|
385 |
|
sl@0
|
386 |
|
sl@0
|
387 |
|
sl@0
|
388 |
TInt CFloggerTest030_TagSetLogTag03::DoTestCheckWriteL()
|
sl@0
|
389 |
{
|
sl@0
|
390 |
RFile theFile;
|
sl@0
|
391 |
HBufC8 * hBuffer;
|
sl@0
|
392 |
TInt listfilesize,returnCode;
|
sl@0
|
393 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
394 |
TUint numSuccessful = 0;
|
sl@0
|
395 |
|
sl@0
|
396 |
|
sl@0
|
397 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
398 |
CleanupClosePushL(fileSystem);
|
sl@0
|
399 |
|
sl@0
|
400 |
//Open the file in the read mode
|
sl@0
|
401 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
402 |
|
sl@0
|
403 |
CleanupClosePushL(theFile);
|
sl@0
|
404 |
|
sl@0
|
405 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
406 |
|
sl@0
|
407 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
408 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
409 |
|
sl@0
|
410 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
411 |
|
sl@0
|
412 |
// Read from position 0: start of file
|
sl@0
|
413 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
414 |
|
sl@0
|
415 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
416 |
//from the file
|
sl@0
|
417 |
|
sl@0
|
418 |
if (returnCode == KErrNotFound)
|
sl@0
|
419 |
{
|
sl@0
|
420 |
numSuccessful++;
|
sl@0
|
421 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
422 |
if (returnCode > 0)
|
sl@0
|
423 |
User::Leave(KErrNoMemory);
|
sl@0
|
424 |
}
|
sl@0
|
425 |
|
sl@0
|
426 |
|
sl@0
|
427 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
428 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
429 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
430 |
|
sl@0
|
431 |
if (numSuccessful == 1)
|
sl@0
|
432 |
return KErrNone;
|
sl@0
|
433 |
else
|
sl@0
|
434 |
return KErrNotFound;
|
sl@0
|
435 |
}
|
sl@0
|
436 |
|
sl@0
|
437 |
|
sl@0
|
438 |
|
sl@0
|
439 |
|
sl@0
|
440 |
/**
|
sl@0
|
441 |
* 030_TagSetLogTag04: Test that flogger handles spaces in tags
|
sl@0
|
442 |
*/
|
sl@0
|
443 |
|
sl@0
|
444 |
CFloggerTest030_TagSetLogTag04::CFloggerTest030_TagSetLogTag04()
|
sl@0
|
445 |
{
|
sl@0
|
446 |
// Store the name of this test case
|
sl@0
|
447 |
SetTestStepName(_L("step_030_TagSetLogTag04"));
|
sl@0
|
448 |
}
|
sl@0
|
449 |
|
sl@0
|
450 |
|
sl@0
|
451 |
|
sl@0
|
452 |
|
sl@0
|
453 |
CFloggerTest030_TagSetLogTag04::~CFloggerTest030_TagSetLogTag04()
|
sl@0
|
454 |
{
|
sl@0
|
455 |
}
|
sl@0
|
456 |
|
sl@0
|
457 |
|
sl@0
|
458 |
|
sl@0
|
459 |
|
sl@0
|
460 |
TVerdict CFloggerTest030_TagSetLogTag04::doTestStepL( )
|
sl@0
|
461 |
{
|
sl@0
|
462 |
if ( executeStepL() == KErrNone )
|
sl@0
|
463 |
SetTestStepResult(EPass);
|
sl@0
|
464 |
|
sl@0
|
465 |
else
|
sl@0
|
466 |
SetTestStepResult(EFail);
|
sl@0
|
467 |
|
sl@0
|
468 |
User::After(KTimeForDisplay);
|
sl@0
|
469 |
|
sl@0
|
470 |
|
sl@0
|
471 |
return TestStepResult();
|
sl@0
|
472 |
}
|
sl@0
|
473 |
|
sl@0
|
474 |
|
sl@0
|
475 |
TInt CFloggerTest030_TagSetLogTag04::executeStepL(TBool)
|
sl@0
|
476 |
{
|
sl@0
|
477 |
return KErrGeneral;
|
sl@0
|
478 |
}
|
sl@0
|
479 |
|
sl@0
|
480 |
TInt CFloggerTest030_TagSetLogTag04::executeStepL()
|
sl@0
|
481 |
{
|
sl@0
|
482 |
|
sl@0
|
483 |
TInt ret ;
|
sl@0
|
484 |
RFileLogger theFlogger;
|
sl@0
|
485 |
ret = theFlogger.Connect();
|
sl@0
|
486 |
|
sl@0
|
487 |
if ( ret == KErrNone)
|
sl@0
|
488 |
{
|
sl@0
|
489 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
490 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
491 |
theFlogger.ClearLog();
|
sl@0
|
492 |
theFlogger.SetLogTags(KStdSubsysTag8, KCompTagWithSpaceChars8);
|
sl@0
|
493 |
theFlogger.Write(KTestMessage);
|
sl@0
|
494 |
theFlogger.Close();
|
sl@0
|
495 |
User::After(KTimeToLog);
|
sl@0
|
496 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
497 |
if (r != KErrNone)
|
sl@0
|
498 |
ret = r;
|
sl@0
|
499 |
}
|
sl@0
|
500 |
|
sl@0
|
501 |
return ret;
|
sl@0
|
502 |
|
sl@0
|
503 |
}
|
sl@0
|
504 |
|
sl@0
|
505 |
|
sl@0
|
506 |
|
sl@0
|
507 |
|
sl@0
|
508 |
TInt CFloggerTest030_TagSetLogTag04::DoTestCheckWriteL()
|
sl@0
|
509 |
{
|
sl@0
|
510 |
RFile theFile;
|
sl@0
|
511 |
HBufC8 * hBuffer;
|
sl@0
|
512 |
TInt listfilesize,returnCode;
|
sl@0
|
513 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
514 |
TUint numSuccessful = 0;
|
sl@0
|
515 |
|
sl@0
|
516 |
|
sl@0
|
517 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
518 |
CleanupClosePushL(fileSystem);
|
sl@0
|
519 |
|
sl@0
|
520 |
//Open the file in the read mode
|
sl@0
|
521 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
522 |
|
sl@0
|
523 |
CleanupClosePushL(theFile);
|
sl@0
|
524 |
|
sl@0
|
525 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
526 |
|
sl@0
|
527 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
528 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
529 |
|
sl@0
|
530 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
531 |
|
sl@0
|
532 |
// Read from position 0: start of file
|
sl@0
|
533 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
534 |
|
sl@0
|
535 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
536 |
//from the file
|
sl@0
|
537 |
|
sl@0
|
538 |
if (returnCode == KErrNotFound)
|
sl@0
|
539 |
{
|
sl@0
|
540 |
numSuccessful++;
|
sl@0
|
541 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
542 |
if (returnCode > 0)
|
sl@0
|
543 |
User::Leave(KErrNoMemory);
|
sl@0
|
544 |
}
|
sl@0
|
545 |
|
sl@0
|
546 |
|
sl@0
|
547 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
548 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
549 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
550 |
|
sl@0
|
551 |
if (numSuccessful == 1)
|
sl@0
|
552 |
return KErrNone;
|
sl@0
|
553 |
else
|
sl@0
|
554 |
return KErrNotFound;
|
sl@0
|
555 |
}
|
sl@0
|
556 |
|
sl@0
|
557 |
|
sl@0
|
558 |
|
sl@0
|
559 |
|
sl@0
|
560 |
|
sl@0
|
561 |
/**
|
sl@0
|
562 |
* 030_TagSetLogTag05: Test that flogger handles punctuation in tags
|
sl@0
|
563 |
*/
|
sl@0
|
564 |
|
sl@0
|
565 |
CFloggerTest030_TagSetLogTag05::CFloggerTest030_TagSetLogTag05()
|
sl@0
|
566 |
{
|
sl@0
|
567 |
// Store the name of this test case
|
sl@0
|
568 |
SetTestStepName(_L("step_030_TagSetLogTag05"));
|
sl@0
|
569 |
}
|
sl@0
|
570 |
|
sl@0
|
571 |
|
sl@0
|
572 |
|
sl@0
|
573 |
|
sl@0
|
574 |
CFloggerTest030_TagSetLogTag05::~CFloggerTest030_TagSetLogTag05()
|
sl@0
|
575 |
{
|
sl@0
|
576 |
}
|
sl@0
|
577 |
|
sl@0
|
578 |
|
sl@0
|
579 |
|
sl@0
|
580 |
|
sl@0
|
581 |
TVerdict CFloggerTest030_TagSetLogTag05::doTestStepL( )
|
sl@0
|
582 |
{
|
sl@0
|
583 |
if ( executeStepL() == KErrNone )
|
sl@0
|
584 |
SetTestStepResult(EPass);
|
sl@0
|
585 |
|
sl@0
|
586 |
else
|
sl@0
|
587 |
SetTestStepResult(EFail);
|
sl@0
|
588 |
|
sl@0
|
589 |
User::After(KTimeForDisplay);
|
sl@0
|
590 |
|
sl@0
|
591 |
|
sl@0
|
592 |
return TestStepResult();
|
sl@0
|
593 |
}
|
sl@0
|
594 |
|
sl@0
|
595 |
|
sl@0
|
596 |
TInt CFloggerTest030_TagSetLogTag05::executeStepL(TBool)
|
sl@0
|
597 |
{
|
sl@0
|
598 |
return KErrGeneral;
|
sl@0
|
599 |
}
|
sl@0
|
600 |
|
sl@0
|
601 |
TInt CFloggerTest030_TagSetLogTag05::executeStepL()
|
sl@0
|
602 |
{
|
sl@0
|
603 |
|
sl@0
|
604 |
TInt ret ;
|
sl@0
|
605 |
RFileLogger theFlogger;
|
sl@0
|
606 |
ret = theFlogger.Connect();
|
sl@0
|
607 |
|
sl@0
|
608 |
if ( ret == KErrNone)
|
sl@0
|
609 |
{
|
sl@0
|
610 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
611 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
612 |
theFlogger.ClearLog();
|
sl@0
|
613 |
theFlogger.SetLogTags(KSubsysTagWithPunctuationChars8, KCompTagWithPunctuationChars8);
|
sl@0
|
614 |
theFlogger.Write(KTestMessage);
|
sl@0
|
615 |
theFlogger.Close();
|
sl@0
|
616 |
User::After(KTimeToLog);
|
sl@0
|
617 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
618 |
if (r != KErrNone)
|
sl@0
|
619 |
ret = r;
|
sl@0
|
620 |
}
|
sl@0
|
621 |
|
sl@0
|
622 |
return ret;
|
sl@0
|
623 |
|
sl@0
|
624 |
}
|
sl@0
|
625 |
|
sl@0
|
626 |
|
sl@0
|
627 |
|
sl@0
|
628 |
|
sl@0
|
629 |
TInt CFloggerTest030_TagSetLogTag05::DoTestCheckWriteL()
|
sl@0
|
630 |
{
|
sl@0
|
631 |
RFile theFile;
|
sl@0
|
632 |
HBufC8 * hBuffer;
|
sl@0
|
633 |
TInt listfilesize,returnCode;
|
sl@0
|
634 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
635 |
TUint numSuccessful = 0;
|
sl@0
|
636 |
|
sl@0
|
637 |
|
sl@0
|
638 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
639 |
CleanupClosePushL(fileSystem);
|
sl@0
|
640 |
|
sl@0
|
641 |
//Open the file in the read mode
|
sl@0
|
642 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
643 |
|
sl@0
|
644 |
CleanupClosePushL(theFile);
|
sl@0
|
645 |
|
sl@0
|
646 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
647 |
|
sl@0
|
648 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
649 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
650 |
|
sl@0
|
651 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
652 |
|
sl@0
|
653 |
// Read from position 0: start of file
|
sl@0
|
654 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
655 |
|
sl@0
|
656 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
657 |
//from the file
|
sl@0
|
658 |
|
sl@0
|
659 |
if (returnCode == KErrNotFound)
|
sl@0
|
660 |
{
|
sl@0
|
661 |
numSuccessful++;
|
sl@0
|
662 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
663 |
if (returnCode > 0)
|
sl@0
|
664 |
User::Leave(KErrNoMemory);
|
sl@0
|
665 |
}
|
sl@0
|
666 |
|
sl@0
|
667 |
|
sl@0
|
668 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
669 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
670 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
671 |
|
sl@0
|
672 |
if (numSuccessful == 1)
|
sl@0
|
673 |
return KErrNone;
|
sl@0
|
674 |
else
|
sl@0
|
675 |
return KErrNotFound;
|
sl@0
|
676 |
}
|
sl@0
|
677 |
|
sl@0
|
678 |
|
sl@0
|
679 |
/**
|
sl@0
|
680 |
* 030_TagSetLogTag06: Test that flogger handles long tags
|
sl@0
|
681 |
*/
|
sl@0
|
682 |
|
sl@0
|
683 |
CFloggerTest030_TagSetLogTag06::CFloggerTest030_TagSetLogTag06()
|
sl@0
|
684 |
{
|
sl@0
|
685 |
// Store the name of this test case
|
sl@0
|
686 |
SetTestStepName(_L("step_030_TagSetLogTag06"));
|
sl@0
|
687 |
}
|
sl@0
|
688 |
|
sl@0
|
689 |
|
sl@0
|
690 |
|
sl@0
|
691 |
|
sl@0
|
692 |
CFloggerTest030_TagSetLogTag06::~CFloggerTest030_TagSetLogTag06()
|
sl@0
|
693 |
{
|
sl@0
|
694 |
}
|
sl@0
|
695 |
|
sl@0
|
696 |
|
sl@0
|
697 |
|
sl@0
|
698 |
|
sl@0
|
699 |
TVerdict CFloggerTest030_TagSetLogTag06::doTestStepL( )
|
sl@0
|
700 |
{
|
sl@0
|
701 |
if ( executeStepL() == KErrNone )
|
sl@0
|
702 |
SetTestStepResult(EPass);
|
sl@0
|
703 |
|
sl@0
|
704 |
else
|
sl@0
|
705 |
SetTestStepResult(EFail);
|
sl@0
|
706 |
|
sl@0
|
707 |
User::After(KTimeForDisplay);
|
sl@0
|
708 |
|
sl@0
|
709 |
|
sl@0
|
710 |
return TestStepResult();
|
sl@0
|
711 |
}
|
sl@0
|
712 |
|
sl@0
|
713 |
|
sl@0
|
714 |
TInt CFloggerTest030_TagSetLogTag06::executeStepL(TBool)
|
sl@0
|
715 |
{
|
sl@0
|
716 |
return KErrGeneral;
|
sl@0
|
717 |
}
|
sl@0
|
718 |
|
sl@0
|
719 |
TInt CFloggerTest030_TagSetLogTag06::executeStepL()
|
sl@0
|
720 |
{
|
sl@0
|
721 |
|
sl@0
|
722 |
TInt ret ;
|
sl@0
|
723 |
RFileLogger theFlogger;
|
sl@0
|
724 |
ret = theFlogger.Connect();
|
sl@0
|
725 |
|
sl@0
|
726 |
if ( ret == KErrNone)
|
sl@0
|
727 |
{
|
sl@0
|
728 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
729 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
730 |
theFlogger.ClearLog();
|
sl@0
|
731 |
theFlogger.SetLogTags(KSubsysTag16char8, KCompTag16char8);
|
sl@0
|
732 |
theFlogger.Write(KTestMessage8);
|
sl@0
|
733 |
theFlogger.Close();
|
sl@0
|
734 |
User::After(KTimeToLog);
|
sl@0
|
735 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
736 |
if (r != KErrNone)
|
sl@0
|
737 |
ret = r;
|
sl@0
|
738 |
}
|
sl@0
|
739 |
|
sl@0
|
740 |
return ret;
|
sl@0
|
741 |
|
sl@0
|
742 |
}
|
sl@0
|
743 |
|
sl@0
|
744 |
|
sl@0
|
745 |
|
sl@0
|
746 |
|
sl@0
|
747 |
TInt CFloggerTest030_TagSetLogTag06::DoTestCheckWriteL()
|
sl@0
|
748 |
{
|
sl@0
|
749 |
RFile theFile;
|
sl@0
|
750 |
HBufC8 * hBuffer;
|
sl@0
|
751 |
TInt listfilesize,returnCode;
|
sl@0
|
752 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
753 |
TUint numSuccessful = 0;
|
sl@0
|
754 |
|
sl@0
|
755 |
|
sl@0
|
756 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
757 |
CleanupClosePushL(fileSystem);
|
sl@0
|
758 |
|
sl@0
|
759 |
//Open the file in the read mode
|
sl@0
|
760 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
761 |
|
sl@0
|
762 |
CleanupClosePushL(theFile);
|
sl@0
|
763 |
|
sl@0
|
764 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
765 |
|
sl@0
|
766 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
767 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
768 |
|
sl@0
|
769 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
770 |
|
sl@0
|
771 |
// Read from position 0: start of file
|
sl@0
|
772 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
773 |
|
sl@0
|
774 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
775 |
//from the file
|
sl@0
|
776 |
|
sl@0
|
777 |
if (returnCode > 0)
|
sl@0
|
778 |
{
|
sl@0
|
779 |
numSuccessful++;
|
sl@0
|
780 |
}
|
sl@0
|
781 |
else if (returnCode == KErrNotFound)
|
sl@0
|
782 |
{
|
sl@0
|
783 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
784 |
if (returnCode > 0)
|
sl@0
|
785 |
User::Leave(KErrNoMemory);
|
sl@0
|
786 |
}
|
sl@0
|
787 |
|
sl@0
|
788 |
|
sl@0
|
789 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
790 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
791 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
792 |
|
sl@0
|
793 |
if (numSuccessful == 1)
|
sl@0
|
794 |
return KErrNone;
|
sl@0
|
795 |
else
|
sl@0
|
796 |
return KErrNotFound;
|
sl@0
|
797 |
}
|
sl@0
|
798 |
|
sl@0
|
799 |
|
sl@0
|
800 |
|
sl@0
|
801 |
|
sl@0
|
802 |
/**
|
sl@0
|
803 |
* 030_TagSetLogTag07: Test that flogger handles long tags
|
sl@0
|
804 |
*/
|
sl@0
|
805 |
|
sl@0
|
806 |
CFloggerTest030_TagSetLogTag07::CFloggerTest030_TagSetLogTag07()
|
sl@0
|
807 |
{
|
sl@0
|
808 |
// Store the name of this test case
|
sl@0
|
809 |
SetTestStepName(_L("step_030_TagSetLogTag07"));
|
sl@0
|
810 |
}
|
sl@0
|
811 |
|
sl@0
|
812 |
|
sl@0
|
813 |
|
sl@0
|
814 |
|
sl@0
|
815 |
CFloggerTest030_TagSetLogTag07::~CFloggerTest030_TagSetLogTag07()
|
sl@0
|
816 |
{
|
sl@0
|
817 |
}
|
sl@0
|
818 |
|
sl@0
|
819 |
|
sl@0
|
820 |
|
sl@0
|
821 |
|
sl@0
|
822 |
TVerdict CFloggerTest030_TagSetLogTag07::doTestStepL( )
|
sl@0
|
823 |
{
|
sl@0
|
824 |
if ( executeStepL() == KErrNone )
|
sl@0
|
825 |
SetTestStepResult(EPass);
|
sl@0
|
826 |
|
sl@0
|
827 |
else
|
sl@0
|
828 |
SetTestStepResult(EFail);
|
sl@0
|
829 |
|
sl@0
|
830 |
User::After(KTimeForDisplay);
|
sl@0
|
831 |
|
sl@0
|
832 |
|
sl@0
|
833 |
return TestStepResult();
|
sl@0
|
834 |
}
|
sl@0
|
835 |
|
sl@0
|
836 |
|
sl@0
|
837 |
TInt CFloggerTest030_TagSetLogTag07::executeStepL(TBool)
|
sl@0
|
838 |
{
|
sl@0
|
839 |
return KErrGeneral;
|
sl@0
|
840 |
}
|
sl@0
|
841 |
|
sl@0
|
842 |
TInt CFloggerTest030_TagSetLogTag07::executeStepL()
|
sl@0
|
843 |
{
|
sl@0
|
844 |
|
sl@0
|
845 |
TInt ret ;
|
sl@0
|
846 |
RFileLogger theFlogger;
|
sl@0
|
847 |
ret = theFlogger.Connect();
|
sl@0
|
848 |
|
sl@0
|
849 |
if ( ret == KErrNone)
|
sl@0
|
850 |
{
|
sl@0
|
851 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
852 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
853 |
theFlogger.ClearLog();
|
sl@0
|
854 |
theFlogger.SetLogTags(KSubsysTag17char8, KCompTag17char8);
|
sl@0
|
855 |
theFlogger.Write(KTestMessage8);
|
sl@0
|
856 |
theFlogger.Close();
|
sl@0
|
857 |
User::After(KTimeToLog);
|
sl@0
|
858 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
859 |
if (r != KErrNone)
|
sl@0
|
860 |
ret = r;
|
sl@0
|
861 |
}
|
sl@0
|
862 |
|
sl@0
|
863 |
return ret;
|
sl@0
|
864 |
|
sl@0
|
865 |
}
|
sl@0
|
866 |
|
sl@0
|
867 |
|
sl@0
|
868 |
|
sl@0
|
869 |
|
sl@0
|
870 |
TInt CFloggerTest030_TagSetLogTag07::DoTestCheckWriteL()
|
sl@0
|
871 |
{
|
sl@0
|
872 |
RFile theFile;
|
sl@0
|
873 |
HBufC8 * hBuffer;
|
sl@0
|
874 |
TInt listfilesize,returnCode;
|
sl@0
|
875 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
876 |
TUint numSuccessful = 0;
|
sl@0
|
877 |
|
sl@0
|
878 |
|
sl@0
|
879 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
880 |
CleanupClosePushL(fileSystem);
|
sl@0
|
881 |
|
sl@0
|
882 |
//Open the file in the read mode
|
sl@0
|
883 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
884 |
|
sl@0
|
885 |
CleanupClosePushL(theFile);
|
sl@0
|
886 |
|
sl@0
|
887 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
888 |
|
sl@0
|
889 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
890 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
891 |
|
sl@0
|
892 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
893 |
|
sl@0
|
894 |
// Read from position 0: start of file
|
sl@0
|
895 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
896 |
|
sl@0
|
897 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
898 |
//from the file
|
sl@0
|
899 |
|
sl@0
|
900 |
if (returnCode > 0)
|
sl@0
|
901 |
{
|
sl@0
|
902 |
numSuccessful++;
|
sl@0
|
903 |
}
|
sl@0
|
904 |
else if (returnCode == KErrNotFound)
|
sl@0
|
905 |
{
|
sl@0
|
906 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
907 |
if (returnCode > 0)
|
sl@0
|
908 |
User::Leave(KErrNoMemory);
|
sl@0
|
909 |
}
|
sl@0
|
910 |
|
sl@0
|
911 |
// We expect to see the string "subsystem0123456" but not "subsystem01234567"
|
sl@0
|
912 |
returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read
|
sl@0
|
913 |
|
sl@0
|
914 |
if (returnCode > 0)
|
sl@0
|
915 |
{
|
sl@0
|
916 |
numSuccessful++;
|
sl@0
|
917 |
}
|
sl@0
|
918 |
|
sl@0
|
919 |
returnCode = ptrString.Find(KSubsysTag17char8); //find the test descriptor in the buffer read
|
sl@0
|
920 |
|
sl@0
|
921 |
if (returnCode == KErrNotFound)
|
sl@0
|
922 |
{
|
sl@0
|
923 |
numSuccessful++;
|
sl@0
|
924 |
}
|
sl@0
|
925 |
|
sl@0
|
926 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
927 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
928 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
929 |
|
sl@0
|
930 |
if (numSuccessful == 3)
|
sl@0
|
931 |
return KErrNone;
|
sl@0
|
932 |
else
|
sl@0
|
933 |
return KErrNotFound;
|
sl@0
|
934 |
}
|
sl@0
|
935 |
|
sl@0
|
936 |
|
sl@0
|
937 |
|
sl@0
|
938 |
|
sl@0
|
939 |
/**
|
sl@0
|
940 |
* 030_TagSetLogTag08: Test that flogger handles very long tags
|
sl@0
|
941 |
*/
|
sl@0
|
942 |
|
sl@0
|
943 |
CFloggerTest030_TagSetLogTag08::CFloggerTest030_TagSetLogTag08()
|
sl@0
|
944 |
{
|
sl@0
|
945 |
// Store the name of this test case
|
sl@0
|
946 |
SetTestStepName(_L("step_030_TagSetLogTag08"));
|
sl@0
|
947 |
}
|
sl@0
|
948 |
|
sl@0
|
949 |
|
sl@0
|
950 |
|
sl@0
|
951 |
|
sl@0
|
952 |
CFloggerTest030_TagSetLogTag08::~CFloggerTest030_TagSetLogTag08()
|
sl@0
|
953 |
{
|
sl@0
|
954 |
}
|
sl@0
|
955 |
|
sl@0
|
956 |
|
sl@0
|
957 |
|
sl@0
|
958 |
|
sl@0
|
959 |
TVerdict CFloggerTest030_TagSetLogTag08::doTestStepL( )
|
sl@0
|
960 |
{
|
sl@0
|
961 |
if ( executeStepL() == KErrNone )
|
sl@0
|
962 |
SetTestStepResult(EPass);
|
sl@0
|
963 |
|
sl@0
|
964 |
else
|
sl@0
|
965 |
SetTestStepResult(EFail);
|
sl@0
|
966 |
|
sl@0
|
967 |
User::After(KTimeForDisplay);
|
sl@0
|
968 |
|
sl@0
|
969 |
|
sl@0
|
970 |
return TestStepResult();
|
sl@0
|
971 |
}
|
sl@0
|
972 |
|
sl@0
|
973 |
|
sl@0
|
974 |
TInt CFloggerTest030_TagSetLogTag08::executeStepL(TBool)
|
sl@0
|
975 |
{
|
sl@0
|
976 |
return KErrGeneral;
|
sl@0
|
977 |
}
|
sl@0
|
978 |
|
sl@0
|
979 |
TInt CFloggerTest030_TagSetLogTag08::executeStepL()
|
sl@0
|
980 |
{
|
sl@0
|
981 |
|
sl@0
|
982 |
TInt ret ;
|
sl@0
|
983 |
RFileLogger theFlogger;
|
sl@0
|
984 |
ret = theFlogger.Connect();
|
sl@0
|
985 |
|
sl@0
|
986 |
if ( ret == KErrNone)
|
sl@0
|
987 |
{
|
sl@0
|
988 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
989 |
theFlogger.ClearLog();
|
sl@0
|
990 |
theFlogger.SetLogTags(KSubsysTag66char8, KCompTag66char8);
|
sl@0
|
991 |
theFlogger.Write(KTestMessage);
|
sl@0
|
992 |
theFlogger.Close();
|
sl@0
|
993 |
User::After(KTimeToLog);
|
sl@0
|
994 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
995 |
if (r != KErrNone)
|
sl@0
|
996 |
ret = r;
|
sl@0
|
997 |
}
|
sl@0
|
998 |
|
sl@0
|
999 |
return ret;
|
sl@0
|
1000 |
|
sl@0
|
1001 |
}
|
sl@0
|
1002 |
|
sl@0
|
1003 |
|
sl@0
|
1004 |
|
sl@0
|
1005 |
|
sl@0
|
1006 |
TInt CFloggerTest030_TagSetLogTag08::DoTestCheckWriteL()
|
sl@0
|
1007 |
{
|
sl@0
|
1008 |
RFile theFile;
|
sl@0
|
1009 |
HBufC8 * hBuffer;
|
sl@0
|
1010 |
TInt listfilesize,returnCode;
|
sl@0
|
1011 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
1012 |
TUint numSuccessful = 0;
|
sl@0
|
1013 |
|
sl@0
|
1014 |
|
sl@0
|
1015 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
1016 |
CleanupClosePushL(fileSystem);
|
sl@0
|
1017 |
|
sl@0
|
1018 |
//Open the file in the read mode
|
sl@0
|
1019 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
1020 |
|
sl@0
|
1021 |
CleanupClosePushL(theFile);
|
sl@0
|
1022 |
|
sl@0
|
1023 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
1024 |
|
sl@0
|
1025 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
1026 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
1027 |
|
sl@0
|
1028 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
1029 |
|
sl@0
|
1030 |
// Read from position 0: start of file
|
sl@0
|
1031 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
1032 |
|
sl@0
|
1033 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
1034 |
//from the file
|
sl@0
|
1035 |
|
sl@0
|
1036 |
if (returnCode > 0)
|
sl@0
|
1037 |
{
|
sl@0
|
1038 |
numSuccessful++;
|
sl@0
|
1039 |
}
|
sl@0
|
1040 |
else if (returnCode == KErrNotFound)
|
sl@0
|
1041 |
{
|
sl@0
|
1042 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
1043 |
if (returnCode > 0)
|
sl@0
|
1044 |
User::Leave(KErrNoMemory);
|
sl@0
|
1045 |
}
|
sl@0
|
1046 |
|
sl@0
|
1047 |
// We expect to see the string "subsystem0123456" but not "subsystem01234567"
|
sl@0
|
1048 |
returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read
|
sl@0
|
1049 |
|
sl@0
|
1050 |
if (returnCode > 0)
|
sl@0
|
1051 |
{
|
sl@0
|
1052 |
numSuccessful++;
|
sl@0
|
1053 |
}
|
sl@0
|
1054 |
|
sl@0
|
1055 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
1056 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
1057 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
1058 |
|
sl@0
|
1059 |
if (numSuccessful == 2)
|
sl@0
|
1060 |
return KErrNone;
|
sl@0
|
1061 |
else
|
sl@0
|
1062 |
return KErrNotFound;
|
sl@0
|
1063 |
}
|
sl@0
|
1064 |
|
sl@0
|
1065 |
|
sl@0
|
1066 |
|
sl@0
|
1067 |
|
sl@0
|
1068 |
/***************************************************************************************/
|
sl@0
|
1069 |
|
sl@0
|
1070 |
/**
|
sl@0
|
1071 |
* 030_TagCreateLog01: Test that flogger handles empty tags
|
sl@0
|
1072 |
*/
|
sl@0
|
1073 |
|
sl@0
|
1074 |
CFloggerTest030_TagCreateLog01::CFloggerTest030_TagCreateLog01()
|
sl@0
|
1075 |
{
|
sl@0
|
1076 |
// Store the name of this test case
|
sl@0
|
1077 |
SetTestStepName(_L("step_030_TagCreateLog01"));
|
sl@0
|
1078 |
}
|
sl@0
|
1079 |
|
sl@0
|
1080 |
|
sl@0
|
1081 |
|
sl@0
|
1082 |
|
sl@0
|
1083 |
CFloggerTest030_TagCreateLog01::~CFloggerTest030_TagCreateLog01()
|
sl@0
|
1084 |
{
|
sl@0
|
1085 |
}
|
sl@0
|
1086 |
|
sl@0
|
1087 |
|
sl@0
|
1088 |
|
sl@0
|
1089 |
|
sl@0
|
1090 |
TVerdict CFloggerTest030_TagCreateLog01::doTestStepL( )
|
sl@0
|
1091 |
{
|
sl@0
|
1092 |
if ( executeStepL() == KErrNone )
|
sl@0
|
1093 |
SetTestStepResult(EPass);
|
sl@0
|
1094 |
|
sl@0
|
1095 |
else
|
sl@0
|
1096 |
SetTestStepResult(EFail);
|
sl@0
|
1097 |
|
sl@0
|
1098 |
User::After(KTimeForDisplay);
|
sl@0
|
1099 |
|
sl@0
|
1100 |
|
sl@0
|
1101 |
return TestStepResult();
|
sl@0
|
1102 |
}
|
sl@0
|
1103 |
|
sl@0
|
1104 |
|
sl@0
|
1105 |
TInt CFloggerTest030_TagCreateLog01::executeStepL(TBool)
|
sl@0
|
1106 |
{
|
sl@0
|
1107 |
return KErrGeneral;
|
sl@0
|
1108 |
}
|
sl@0
|
1109 |
|
sl@0
|
1110 |
TInt CFloggerTest030_TagCreateLog01::executeStepL()
|
sl@0
|
1111 |
{
|
sl@0
|
1112 |
|
sl@0
|
1113 |
TInt ret ;
|
sl@0
|
1114 |
RFileLogger theFlogger;
|
sl@0
|
1115 |
ret = theFlogger.Connect();
|
sl@0
|
1116 |
|
sl@0
|
1117 |
if ( ret == KErrNone)
|
sl@0
|
1118 |
{
|
sl@0
|
1119 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
1120 |
theFlogger.ClearLog();
|
sl@0
|
1121 |
theFlogger.CreateLog(KNullDesC16, KNullDesC16, EFileLoggingModeOverwrite);
|
sl@0
|
1122 |
theFlogger.Write(KTestMessage);
|
sl@0
|
1123 |
theFlogger.Close();
|
sl@0
|
1124 |
User::After(KTimeToLog);
|
sl@0
|
1125 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
1126 |
if (r != KErrNone)
|
sl@0
|
1127 |
ret = r;
|
sl@0
|
1128 |
}
|
sl@0
|
1129 |
|
sl@0
|
1130 |
return ret;
|
sl@0
|
1131 |
|
sl@0
|
1132 |
}
|
sl@0
|
1133 |
|
sl@0
|
1134 |
|
sl@0
|
1135 |
|
sl@0
|
1136 |
|
sl@0
|
1137 |
TInt CFloggerTest030_TagCreateLog01::DoTestCheckWriteL()
|
sl@0
|
1138 |
{
|
sl@0
|
1139 |
RFile theFile;
|
sl@0
|
1140 |
HBufC8 * hBuffer;
|
sl@0
|
1141 |
TInt listfilesize,returnCode;
|
sl@0
|
1142 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
1143 |
TUint numSuccessful = 0;
|
sl@0
|
1144 |
|
sl@0
|
1145 |
|
sl@0
|
1146 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
1147 |
CleanupClosePushL(fileSystem);
|
sl@0
|
1148 |
|
sl@0
|
1149 |
//Open the file in the read mode
|
sl@0
|
1150 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
1151 |
|
sl@0
|
1152 |
CleanupClosePushL(theFile);
|
sl@0
|
1153 |
|
sl@0
|
1154 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
1155 |
|
sl@0
|
1156 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
1157 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
1158 |
|
sl@0
|
1159 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
1160 |
|
sl@0
|
1161 |
// Read from position 0: start of file
|
sl@0
|
1162 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
1163 |
|
sl@0
|
1164 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
1165 |
//from the file
|
sl@0
|
1166 |
|
sl@0
|
1167 |
if (returnCode == KErrNotFound)
|
sl@0
|
1168 |
{
|
sl@0
|
1169 |
numSuccessful++;
|
sl@0
|
1170 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
1171 |
if (returnCode > 0)
|
sl@0
|
1172 |
User::Leave(KErrNoMemory);
|
sl@0
|
1173 |
}
|
sl@0
|
1174 |
|
sl@0
|
1175 |
|
sl@0
|
1176 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
1177 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
1178 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
1179 |
|
sl@0
|
1180 |
if (numSuccessful == 1)
|
sl@0
|
1181 |
return KErrNone;
|
sl@0
|
1182 |
else
|
sl@0
|
1183 |
return KErrNotFound;
|
sl@0
|
1184 |
}
|
sl@0
|
1185 |
|
sl@0
|
1186 |
|
sl@0
|
1187 |
|
sl@0
|
1188 |
|
sl@0
|
1189 |
/**
|
sl@0
|
1190 |
* 030_TagCreateLog02: Test that flogger handles empty subsys tag
|
sl@0
|
1191 |
*/
|
sl@0
|
1192 |
|
sl@0
|
1193 |
CFloggerTest030_TagCreateLog02::CFloggerTest030_TagCreateLog02()
|
sl@0
|
1194 |
{
|
sl@0
|
1195 |
// Store the name of this test case
|
sl@0
|
1196 |
SetTestStepName(_L("step_030_TagCreateLog02"));
|
sl@0
|
1197 |
}
|
sl@0
|
1198 |
|
sl@0
|
1199 |
|
sl@0
|
1200 |
|
sl@0
|
1201 |
|
sl@0
|
1202 |
CFloggerTest030_TagCreateLog02::~CFloggerTest030_TagCreateLog02()
|
sl@0
|
1203 |
{
|
sl@0
|
1204 |
}
|
sl@0
|
1205 |
|
sl@0
|
1206 |
|
sl@0
|
1207 |
|
sl@0
|
1208 |
|
sl@0
|
1209 |
TVerdict CFloggerTest030_TagCreateLog02::doTestStepL( )
|
sl@0
|
1210 |
{
|
sl@0
|
1211 |
if ( executeStepL() == KErrNone )
|
sl@0
|
1212 |
SetTestStepResult(EPass);
|
sl@0
|
1213 |
|
sl@0
|
1214 |
else
|
sl@0
|
1215 |
SetTestStepResult(EFail);
|
sl@0
|
1216 |
|
sl@0
|
1217 |
User::After(KTimeForDisplay);
|
sl@0
|
1218 |
|
sl@0
|
1219 |
|
sl@0
|
1220 |
return TestStepResult();
|
sl@0
|
1221 |
}
|
sl@0
|
1222 |
|
sl@0
|
1223 |
TInt CFloggerTest030_TagCreateLog02::executeStepL(TBool)
|
sl@0
|
1224 |
{
|
sl@0
|
1225 |
return KErrGeneral;
|
sl@0
|
1226 |
}
|
sl@0
|
1227 |
|
sl@0
|
1228 |
|
sl@0
|
1229 |
TInt CFloggerTest030_TagCreateLog02::executeStepL()
|
sl@0
|
1230 |
{
|
sl@0
|
1231 |
|
sl@0
|
1232 |
TInt ret ;
|
sl@0
|
1233 |
RFileLogger theFlogger;
|
sl@0
|
1234 |
ret = theFlogger.Connect();
|
sl@0
|
1235 |
|
sl@0
|
1236 |
if ( ret == KErrNone)
|
sl@0
|
1237 |
{
|
sl@0
|
1238 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
1239 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
1240 |
theFlogger.ClearLog();
|
sl@0
|
1241 |
theFlogger.CreateLog(KNullDesC16, KStdCompTag16, EFileLoggingModeOverwrite);
|
sl@0
|
1242 |
theFlogger.Write(KTestMessage);
|
sl@0
|
1243 |
theFlogger.Close();
|
sl@0
|
1244 |
User::After(KTimeToLog);
|
sl@0
|
1245 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
1246 |
if (r != KErrNone)
|
sl@0
|
1247 |
ret = r;
|
sl@0
|
1248 |
}
|
sl@0
|
1249 |
|
sl@0
|
1250 |
return ret;
|
sl@0
|
1251 |
|
sl@0
|
1252 |
}
|
sl@0
|
1253 |
|
sl@0
|
1254 |
|
sl@0
|
1255 |
|
sl@0
|
1256 |
|
sl@0
|
1257 |
TInt CFloggerTest030_TagCreateLog02::DoTestCheckWriteL()
|
sl@0
|
1258 |
{
|
sl@0
|
1259 |
RFile theFile;
|
sl@0
|
1260 |
HBufC8 * hBuffer;
|
sl@0
|
1261 |
TInt listfilesize,returnCode;
|
sl@0
|
1262 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
1263 |
TUint numSuccessful = 0;
|
sl@0
|
1264 |
|
sl@0
|
1265 |
|
sl@0
|
1266 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
1267 |
CleanupClosePushL(fileSystem);
|
sl@0
|
1268 |
|
sl@0
|
1269 |
//Open the file in the read mode
|
sl@0
|
1270 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
1271 |
|
sl@0
|
1272 |
CleanupClosePushL(theFile);
|
sl@0
|
1273 |
|
sl@0
|
1274 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
1275 |
|
sl@0
|
1276 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
1277 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
1278 |
|
sl@0
|
1279 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
1280 |
|
sl@0
|
1281 |
// Read from position 0: start of file
|
sl@0
|
1282 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
1283 |
|
sl@0
|
1284 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
1285 |
//from the file
|
sl@0
|
1286 |
|
sl@0
|
1287 |
if (returnCode == KErrNotFound)
|
sl@0
|
1288 |
{
|
sl@0
|
1289 |
numSuccessful++;
|
sl@0
|
1290 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
1291 |
if (returnCode > 0)
|
sl@0
|
1292 |
User::Leave(KErrNoMemory);
|
sl@0
|
1293 |
}
|
sl@0
|
1294 |
|
sl@0
|
1295 |
|
sl@0
|
1296 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
1297 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
1298 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
1299 |
|
sl@0
|
1300 |
if (numSuccessful == 1)
|
sl@0
|
1301 |
return KErrNone;
|
sl@0
|
1302 |
else
|
sl@0
|
1303 |
return KErrNotFound;
|
sl@0
|
1304 |
}
|
sl@0
|
1305 |
|
sl@0
|
1306 |
|
sl@0
|
1307 |
|
sl@0
|
1308 |
/**
|
sl@0
|
1309 |
* 030_TagCreateLog03: Test that flogger handles empty component tag
|
sl@0
|
1310 |
*/
|
sl@0
|
1311 |
|
sl@0
|
1312 |
CFloggerTest030_TagCreateLog03::CFloggerTest030_TagCreateLog03()
|
sl@0
|
1313 |
{
|
sl@0
|
1314 |
// Store the name of this test case
|
sl@0
|
1315 |
SetTestStepName(_L("step_030_TagCreateLog03"));
|
sl@0
|
1316 |
}
|
sl@0
|
1317 |
|
sl@0
|
1318 |
|
sl@0
|
1319 |
|
sl@0
|
1320 |
|
sl@0
|
1321 |
CFloggerTest030_TagCreateLog03::~CFloggerTest030_TagCreateLog03()
|
sl@0
|
1322 |
{
|
sl@0
|
1323 |
}
|
sl@0
|
1324 |
|
sl@0
|
1325 |
|
sl@0
|
1326 |
|
sl@0
|
1327 |
|
sl@0
|
1328 |
TVerdict CFloggerTest030_TagCreateLog03::doTestStepL( )
|
sl@0
|
1329 |
{
|
sl@0
|
1330 |
if ( executeStepL() == KErrNone )
|
sl@0
|
1331 |
SetTestStepResult(EPass);
|
sl@0
|
1332 |
|
sl@0
|
1333 |
else
|
sl@0
|
1334 |
SetTestStepResult(EFail);
|
sl@0
|
1335 |
|
sl@0
|
1336 |
User::After(KTimeForDisplay);
|
sl@0
|
1337 |
|
sl@0
|
1338 |
|
sl@0
|
1339 |
return TestStepResult();
|
sl@0
|
1340 |
}
|
sl@0
|
1341 |
|
sl@0
|
1342 |
|
sl@0
|
1343 |
TInt CFloggerTest030_TagCreateLog03::executeStepL(TBool)
|
sl@0
|
1344 |
{
|
sl@0
|
1345 |
return KErrGeneral;
|
sl@0
|
1346 |
}
|
sl@0
|
1347 |
|
sl@0
|
1348 |
TInt CFloggerTest030_TagCreateLog03::executeStepL()
|
sl@0
|
1349 |
{
|
sl@0
|
1350 |
|
sl@0
|
1351 |
TInt ret ;
|
sl@0
|
1352 |
RFileLogger theFlogger;
|
sl@0
|
1353 |
ret = theFlogger.Connect();
|
sl@0
|
1354 |
|
sl@0
|
1355 |
if ( ret == KErrNone)
|
sl@0
|
1356 |
{
|
sl@0
|
1357 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
1358 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
1359 |
theFlogger.ClearLog();
|
sl@0
|
1360 |
theFlogger.CreateLog(KStdSubsysTag16, KNullDesC16, EFileLoggingModeOverwrite);
|
sl@0
|
1361 |
theFlogger.Write(KTestMessage);
|
sl@0
|
1362 |
theFlogger.Close();
|
sl@0
|
1363 |
User::After(KTimeToLog);
|
sl@0
|
1364 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
1365 |
if (r != KErrNone)
|
sl@0
|
1366 |
ret = r;
|
sl@0
|
1367 |
}
|
sl@0
|
1368 |
|
sl@0
|
1369 |
return ret;
|
sl@0
|
1370 |
|
sl@0
|
1371 |
}
|
sl@0
|
1372 |
|
sl@0
|
1373 |
|
sl@0
|
1374 |
|
sl@0
|
1375 |
|
sl@0
|
1376 |
TInt CFloggerTest030_TagCreateLog03::DoTestCheckWriteL()
|
sl@0
|
1377 |
{
|
sl@0
|
1378 |
RFile theFile;
|
sl@0
|
1379 |
HBufC8 * hBuffer;
|
sl@0
|
1380 |
TInt listfilesize,returnCode;
|
sl@0
|
1381 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
1382 |
TUint numSuccessful = 0;
|
sl@0
|
1383 |
|
sl@0
|
1384 |
|
sl@0
|
1385 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
1386 |
CleanupClosePushL(fileSystem);
|
sl@0
|
1387 |
|
sl@0
|
1388 |
//Open the file in the read mode
|
sl@0
|
1389 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
1390 |
|
sl@0
|
1391 |
CleanupClosePushL(theFile);
|
sl@0
|
1392 |
|
sl@0
|
1393 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
1394 |
|
sl@0
|
1395 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
1396 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
1397 |
|
sl@0
|
1398 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
1399 |
|
sl@0
|
1400 |
// Read from position 0: start of file
|
sl@0
|
1401 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
1402 |
|
sl@0
|
1403 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
1404 |
//from the file
|
sl@0
|
1405 |
|
sl@0
|
1406 |
if (returnCode == KErrNotFound)
|
sl@0
|
1407 |
{
|
sl@0
|
1408 |
numSuccessful++;
|
sl@0
|
1409 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
1410 |
if (returnCode > 0)
|
sl@0
|
1411 |
User::Leave(KErrNoMemory);
|
sl@0
|
1412 |
}
|
sl@0
|
1413 |
|
sl@0
|
1414 |
|
sl@0
|
1415 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
1416 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
1417 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
1418 |
|
sl@0
|
1419 |
if (numSuccessful == 1)
|
sl@0
|
1420 |
return KErrNone;
|
sl@0
|
1421 |
else
|
sl@0
|
1422 |
return KErrNotFound;
|
sl@0
|
1423 |
}
|
sl@0
|
1424 |
|
sl@0
|
1425 |
|
sl@0
|
1426 |
|
sl@0
|
1427 |
|
sl@0
|
1428 |
/**
|
sl@0
|
1429 |
* 030_TagCreateLog04: Test that flogger handles spaces in tags
|
sl@0
|
1430 |
*/
|
sl@0
|
1431 |
|
sl@0
|
1432 |
CFloggerTest030_TagCreateLog04::CFloggerTest030_TagCreateLog04()
|
sl@0
|
1433 |
{
|
sl@0
|
1434 |
// Store the name of this test case
|
sl@0
|
1435 |
SetTestStepName(_L("step_030_TagCreateLog04"));
|
sl@0
|
1436 |
}
|
sl@0
|
1437 |
|
sl@0
|
1438 |
|
sl@0
|
1439 |
|
sl@0
|
1440 |
|
sl@0
|
1441 |
CFloggerTest030_TagCreateLog04::~CFloggerTest030_TagCreateLog04()
|
sl@0
|
1442 |
{
|
sl@0
|
1443 |
}
|
sl@0
|
1444 |
|
sl@0
|
1445 |
|
sl@0
|
1446 |
|
sl@0
|
1447 |
|
sl@0
|
1448 |
TVerdict CFloggerTest030_TagCreateLog04::doTestStepL( )
|
sl@0
|
1449 |
{
|
sl@0
|
1450 |
if ( executeStepL() == KErrNone )
|
sl@0
|
1451 |
SetTestStepResult(EPass);
|
sl@0
|
1452 |
|
sl@0
|
1453 |
else
|
sl@0
|
1454 |
SetTestStepResult(EFail);
|
sl@0
|
1455 |
|
sl@0
|
1456 |
User::After(KTimeForDisplay);
|
sl@0
|
1457 |
|
sl@0
|
1458 |
|
sl@0
|
1459 |
return TestStepResult();
|
sl@0
|
1460 |
}
|
sl@0
|
1461 |
|
sl@0
|
1462 |
|
sl@0
|
1463 |
TInt CFloggerTest030_TagCreateLog04::executeStepL(TBool)
|
sl@0
|
1464 |
{
|
sl@0
|
1465 |
return KErrGeneral;
|
sl@0
|
1466 |
}
|
sl@0
|
1467 |
|
sl@0
|
1468 |
TInt CFloggerTest030_TagCreateLog04::executeStepL()
|
sl@0
|
1469 |
{
|
sl@0
|
1470 |
|
sl@0
|
1471 |
TInt ret ;
|
sl@0
|
1472 |
RFileLogger theFlogger;
|
sl@0
|
1473 |
ret = theFlogger.Connect();
|
sl@0
|
1474 |
|
sl@0
|
1475 |
if ( ret == KErrNone)
|
sl@0
|
1476 |
{
|
sl@0
|
1477 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
1478 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
1479 |
theFlogger.ClearLog();
|
sl@0
|
1480 |
theFlogger.CreateLog(KStdSubsysTag16, KCompTagWithSpaceChars16, EFileLoggingModeOverwrite);
|
sl@0
|
1481 |
theFlogger.Write(KTestMessage);
|
sl@0
|
1482 |
theFlogger.Close();
|
sl@0
|
1483 |
User::After(KTimeToLog);
|
sl@0
|
1484 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
1485 |
if (r != KErrNone)
|
sl@0
|
1486 |
ret = r;
|
sl@0
|
1487 |
}
|
sl@0
|
1488 |
|
sl@0
|
1489 |
return ret;
|
sl@0
|
1490 |
|
sl@0
|
1491 |
}
|
sl@0
|
1492 |
|
sl@0
|
1493 |
|
sl@0
|
1494 |
|
sl@0
|
1495 |
|
sl@0
|
1496 |
TInt CFloggerTest030_TagCreateLog04::DoTestCheckWriteL()
|
sl@0
|
1497 |
{
|
sl@0
|
1498 |
RFile theFile;
|
sl@0
|
1499 |
HBufC8 * hBuffer;
|
sl@0
|
1500 |
TInt listfilesize,returnCode;
|
sl@0
|
1501 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
1502 |
TUint numSuccessful = 0;
|
sl@0
|
1503 |
|
sl@0
|
1504 |
|
sl@0
|
1505 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
1506 |
CleanupClosePushL(fileSystem);
|
sl@0
|
1507 |
|
sl@0
|
1508 |
//Open the file in the read mode
|
sl@0
|
1509 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
1510 |
|
sl@0
|
1511 |
CleanupClosePushL(theFile);
|
sl@0
|
1512 |
|
sl@0
|
1513 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
1514 |
|
sl@0
|
1515 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
1516 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
1517 |
|
sl@0
|
1518 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
1519 |
|
sl@0
|
1520 |
// Read from position 0: start of file
|
sl@0
|
1521 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
1522 |
|
sl@0
|
1523 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
1524 |
//from the file
|
sl@0
|
1525 |
|
sl@0
|
1526 |
if (returnCode == KErrNotFound)
|
sl@0
|
1527 |
{
|
sl@0
|
1528 |
numSuccessful++;
|
sl@0
|
1529 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
1530 |
if (returnCode > 0)
|
sl@0
|
1531 |
User::Leave(KErrNoMemory);
|
sl@0
|
1532 |
}
|
sl@0
|
1533 |
|
sl@0
|
1534 |
|
sl@0
|
1535 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
1536 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
1537 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
1538 |
|
sl@0
|
1539 |
if (numSuccessful == 1)
|
sl@0
|
1540 |
return KErrNone;
|
sl@0
|
1541 |
else
|
sl@0
|
1542 |
return KErrNotFound;
|
sl@0
|
1543 |
}
|
sl@0
|
1544 |
|
sl@0
|
1545 |
|
sl@0
|
1546 |
|
sl@0
|
1547 |
|
sl@0
|
1548 |
|
sl@0
|
1549 |
/**
|
sl@0
|
1550 |
* 030_TagCreateLog05: Test that flogger handles punctuation in tags
|
sl@0
|
1551 |
*/
|
sl@0
|
1552 |
|
sl@0
|
1553 |
CFloggerTest030_TagCreateLog05::CFloggerTest030_TagCreateLog05()
|
sl@0
|
1554 |
{
|
sl@0
|
1555 |
// Store the name of this test case
|
sl@0
|
1556 |
SetTestStepName(_L("step_030_TagCreateLog05"));
|
sl@0
|
1557 |
}
|
sl@0
|
1558 |
|
sl@0
|
1559 |
|
sl@0
|
1560 |
|
sl@0
|
1561 |
|
sl@0
|
1562 |
CFloggerTest030_TagCreateLog05::~CFloggerTest030_TagCreateLog05()
|
sl@0
|
1563 |
{
|
sl@0
|
1564 |
}
|
sl@0
|
1565 |
|
sl@0
|
1566 |
|
sl@0
|
1567 |
|
sl@0
|
1568 |
|
sl@0
|
1569 |
TVerdict CFloggerTest030_TagCreateLog05::doTestStepL( )
|
sl@0
|
1570 |
{
|
sl@0
|
1571 |
if ( executeStepL() == KErrNone )
|
sl@0
|
1572 |
SetTestStepResult(EPass);
|
sl@0
|
1573 |
|
sl@0
|
1574 |
else
|
sl@0
|
1575 |
SetTestStepResult(EFail);
|
sl@0
|
1576 |
|
sl@0
|
1577 |
User::After(KTimeForDisplay);
|
sl@0
|
1578 |
|
sl@0
|
1579 |
|
sl@0
|
1580 |
return TestStepResult();
|
sl@0
|
1581 |
}
|
sl@0
|
1582 |
|
sl@0
|
1583 |
|
sl@0
|
1584 |
TInt CFloggerTest030_TagCreateLog05::executeStepL(TBool)
|
sl@0
|
1585 |
{
|
sl@0
|
1586 |
return KErrGeneral;
|
sl@0
|
1587 |
}
|
sl@0
|
1588 |
|
sl@0
|
1589 |
TInt CFloggerTest030_TagCreateLog05::executeStepL()
|
sl@0
|
1590 |
{
|
sl@0
|
1591 |
|
sl@0
|
1592 |
TInt ret ;
|
sl@0
|
1593 |
RFileLogger theFlogger;
|
sl@0
|
1594 |
ret = theFlogger.Connect();
|
sl@0
|
1595 |
|
sl@0
|
1596 |
if ( ret == KErrNone)
|
sl@0
|
1597 |
{
|
sl@0
|
1598 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
1599 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
1600 |
theFlogger.ClearLog();
|
sl@0
|
1601 |
theFlogger.CreateLog(KSubsysTagWithPunctuationChars16, KCompTagWithPunctuationChars16, EFileLoggingModeOverwrite);
|
sl@0
|
1602 |
theFlogger.Write(KTestMessage);
|
sl@0
|
1603 |
theFlogger.Close();
|
sl@0
|
1604 |
User::After(KTimeToLog);
|
sl@0
|
1605 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
1606 |
if (r != KErrNone)
|
sl@0
|
1607 |
ret = r;
|
sl@0
|
1608 |
}
|
sl@0
|
1609 |
|
sl@0
|
1610 |
return ret;
|
sl@0
|
1611 |
|
sl@0
|
1612 |
}
|
sl@0
|
1613 |
|
sl@0
|
1614 |
|
sl@0
|
1615 |
|
sl@0
|
1616 |
|
sl@0
|
1617 |
TInt CFloggerTest030_TagCreateLog05::DoTestCheckWriteL()
|
sl@0
|
1618 |
{
|
sl@0
|
1619 |
RFile theFile;
|
sl@0
|
1620 |
HBufC8 * hBuffer;
|
sl@0
|
1621 |
TInt listfilesize,returnCode;
|
sl@0
|
1622 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
1623 |
TUint numSuccessful = 0;
|
sl@0
|
1624 |
|
sl@0
|
1625 |
|
sl@0
|
1626 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
1627 |
CleanupClosePushL(fileSystem);
|
sl@0
|
1628 |
|
sl@0
|
1629 |
//Open the file in the read mode
|
sl@0
|
1630 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
1631 |
|
sl@0
|
1632 |
CleanupClosePushL(theFile);
|
sl@0
|
1633 |
|
sl@0
|
1634 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
1635 |
|
sl@0
|
1636 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
1637 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
1638 |
|
sl@0
|
1639 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
1640 |
|
sl@0
|
1641 |
// Read from position 0: start of file
|
sl@0
|
1642 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
1643 |
|
sl@0
|
1644 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
1645 |
//from the file
|
sl@0
|
1646 |
|
sl@0
|
1647 |
if (returnCode == KErrNotFound)
|
sl@0
|
1648 |
{
|
sl@0
|
1649 |
numSuccessful++;
|
sl@0
|
1650 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
1651 |
if (returnCode > 0)
|
sl@0
|
1652 |
User::Leave(KErrNoMemory);
|
sl@0
|
1653 |
}
|
sl@0
|
1654 |
|
sl@0
|
1655 |
|
sl@0
|
1656 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
1657 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
1658 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
1659 |
|
sl@0
|
1660 |
if (numSuccessful == 1)
|
sl@0
|
1661 |
return KErrNone;
|
sl@0
|
1662 |
else
|
sl@0
|
1663 |
return KErrNotFound;
|
sl@0
|
1664 |
}
|
sl@0
|
1665 |
|
sl@0
|
1666 |
|
sl@0
|
1667 |
|
sl@0
|
1668 |
/**
|
sl@0
|
1669 |
* 030_TagCreateLog06: Test that flogger handles length 16 tags
|
sl@0
|
1670 |
*/
|
sl@0
|
1671 |
|
sl@0
|
1672 |
CFloggerTest030_TagCreateLog06::CFloggerTest030_TagCreateLog06()
|
sl@0
|
1673 |
{
|
sl@0
|
1674 |
// Store the name of this test case
|
sl@0
|
1675 |
SetTestStepName(_L("step_030_TagCreateLog06"));
|
sl@0
|
1676 |
}
|
sl@0
|
1677 |
|
sl@0
|
1678 |
|
sl@0
|
1679 |
|
sl@0
|
1680 |
|
sl@0
|
1681 |
CFloggerTest030_TagCreateLog06::~CFloggerTest030_TagCreateLog06()
|
sl@0
|
1682 |
{
|
sl@0
|
1683 |
}
|
sl@0
|
1684 |
|
sl@0
|
1685 |
|
sl@0
|
1686 |
|
sl@0
|
1687 |
|
sl@0
|
1688 |
TVerdict CFloggerTest030_TagCreateLog06::doTestStepL( )
|
sl@0
|
1689 |
{
|
sl@0
|
1690 |
if ( executeStepL() == KErrNone )
|
sl@0
|
1691 |
SetTestStepResult(EPass);
|
sl@0
|
1692 |
|
sl@0
|
1693 |
else
|
sl@0
|
1694 |
SetTestStepResult(EFail);
|
sl@0
|
1695 |
|
sl@0
|
1696 |
User::After(KTimeForDisplay);
|
sl@0
|
1697 |
|
sl@0
|
1698 |
|
sl@0
|
1699 |
return TestStepResult();
|
sl@0
|
1700 |
}
|
sl@0
|
1701 |
|
sl@0
|
1702 |
|
sl@0
|
1703 |
TInt CFloggerTest030_TagCreateLog06::executeStepL(TBool)
|
sl@0
|
1704 |
{
|
sl@0
|
1705 |
return KErrGeneral;
|
sl@0
|
1706 |
}
|
sl@0
|
1707 |
|
sl@0
|
1708 |
TInt CFloggerTest030_TagCreateLog06::executeStepL()
|
sl@0
|
1709 |
{
|
sl@0
|
1710 |
|
sl@0
|
1711 |
TInt ret ;
|
sl@0
|
1712 |
RFileLogger theFlogger;
|
sl@0
|
1713 |
ret = theFlogger.Connect();
|
sl@0
|
1714 |
|
sl@0
|
1715 |
if ( ret == KErrNone)
|
sl@0
|
1716 |
{
|
sl@0
|
1717 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
1718 |
theFlogger.ClearLog();
|
sl@0
|
1719 |
theFlogger.CreateLog(KSubsysTag16char16, KCompTag16char16, EFileLoggingModeOverwrite);
|
sl@0
|
1720 |
theFlogger.Write(KTestMessage);
|
sl@0
|
1721 |
theFlogger.Close();
|
sl@0
|
1722 |
User::After(KTimeToLog);
|
sl@0
|
1723 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
1724 |
if (r != KErrNone)
|
sl@0
|
1725 |
ret = r;
|
sl@0
|
1726 |
}
|
sl@0
|
1727 |
|
sl@0
|
1728 |
return ret;
|
sl@0
|
1729 |
|
sl@0
|
1730 |
}
|
sl@0
|
1731 |
|
sl@0
|
1732 |
|
sl@0
|
1733 |
|
sl@0
|
1734 |
|
sl@0
|
1735 |
|
sl@0
|
1736 |
TInt CFloggerTest030_TagCreateLog06::DoTestCheckWriteL()
|
sl@0
|
1737 |
{
|
sl@0
|
1738 |
RFile theFile;
|
sl@0
|
1739 |
HBufC8 * hBuffer;
|
sl@0
|
1740 |
TInt listfilesize,returnCode;
|
sl@0
|
1741 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
1742 |
TBuf8<256> testData; //To hold the test descriptor
|
sl@0
|
1743 |
|
sl@0
|
1744 |
|
sl@0
|
1745 |
_LIT8(KOOMError, "#Logs may be lost out of memory!!");
|
sl@0
|
1746 |
|
sl@0
|
1747 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
1748 |
|
sl@0
|
1749 |
//Open the file in the read mode
|
sl@0
|
1750 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
1751 |
|
sl@0
|
1752 |
CleanupClosePushL(theFile);
|
sl@0
|
1753 |
|
sl@0
|
1754 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
1755 |
|
sl@0
|
1756 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
1757 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
1758 |
|
sl@0
|
1759 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
1760 |
|
sl@0
|
1761 |
// Read from position 0: start of file
|
sl@0
|
1762 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
1763 |
|
sl@0
|
1764 |
testData.Copy(KTestMessage); //Copy the test descriptor
|
sl@0
|
1765 |
returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
1766 |
//from the file
|
sl@0
|
1767 |
|
sl@0
|
1768 |
if (returnCode == KErrNotFound)
|
sl@0
|
1769 |
{
|
sl@0
|
1770 |
returnCode = ptrString.Find(KOOMError);
|
sl@0
|
1771 |
if (returnCode > 0)
|
sl@0
|
1772 |
User::Leave(KErrNoMemory);
|
sl@0
|
1773 |
}
|
sl@0
|
1774 |
|
sl@0
|
1775 |
|
sl@0
|
1776 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
1777 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
1778 |
if (returnCode > 0)
|
sl@0
|
1779 |
return KErrNone;
|
sl@0
|
1780 |
else
|
sl@0
|
1781 |
return KErrNotFound;
|
sl@0
|
1782 |
}
|
sl@0
|
1783 |
|
sl@0
|
1784 |
|
sl@0
|
1785 |
|
sl@0
|
1786 |
|
sl@0
|
1787 |
|
sl@0
|
1788 |
|
sl@0
|
1789 |
|
sl@0
|
1790 |
|
sl@0
|
1791 |
/**
|
sl@0
|
1792 |
* 030_TagCreateLog07: Test that flogger handles length 17 tags by truncating
|
sl@0
|
1793 |
*/
|
sl@0
|
1794 |
|
sl@0
|
1795 |
CFloggerTest030_TagCreateLog07::CFloggerTest030_TagCreateLog07()
|
sl@0
|
1796 |
{
|
sl@0
|
1797 |
// Store the name of this test case
|
sl@0
|
1798 |
SetTestStepName(_L("step_030_TagCreateLog07"));
|
sl@0
|
1799 |
}
|
sl@0
|
1800 |
|
sl@0
|
1801 |
|
sl@0
|
1802 |
|
sl@0
|
1803 |
|
sl@0
|
1804 |
CFloggerTest030_TagCreateLog07::~CFloggerTest030_TagCreateLog07()
|
sl@0
|
1805 |
{
|
sl@0
|
1806 |
}
|
sl@0
|
1807 |
|
sl@0
|
1808 |
|
sl@0
|
1809 |
|
sl@0
|
1810 |
|
sl@0
|
1811 |
TVerdict CFloggerTest030_TagCreateLog07::doTestStepL( )
|
sl@0
|
1812 |
{
|
sl@0
|
1813 |
if ( executeStepL() == KErrNone )
|
sl@0
|
1814 |
SetTestStepResult(EPass);
|
sl@0
|
1815 |
|
sl@0
|
1816 |
else
|
sl@0
|
1817 |
SetTestStepResult(EFail);
|
sl@0
|
1818 |
|
sl@0
|
1819 |
User::After(KTimeForDisplay);
|
sl@0
|
1820 |
|
sl@0
|
1821 |
|
sl@0
|
1822 |
return TestStepResult();
|
sl@0
|
1823 |
}
|
sl@0
|
1824 |
|
sl@0
|
1825 |
|
sl@0
|
1826 |
TInt CFloggerTest030_TagCreateLog07::executeStepL(TBool)
|
sl@0
|
1827 |
{
|
sl@0
|
1828 |
return KErrGeneral;
|
sl@0
|
1829 |
}
|
sl@0
|
1830 |
|
sl@0
|
1831 |
TInt CFloggerTest030_TagCreateLog07::executeStepL()
|
sl@0
|
1832 |
{
|
sl@0
|
1833 |
|
sl@0
|
1834 |
TInt ret ;
|
sl@0
|
1835 |
RFileLogger theFlogger;
|
sl@0
|
1836 |
ret = theFlogger.Connect();
|
sl@0
|
1837 |
|
sl@0
|
1838 |
if ( ret == KErrNone)
|
sl@0
|
1839 |
{
|
sl@0
|
1840 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
1841 |
theFlogger.ClearLog();
|
sl@0
|
1842 |
theFlogger.CreateLog(KSubsysTag17char16, KCompTag17char16, EFileLoggingModeOverwrite);
|
sl@0
|
1843 |
theFlogger.Write(KTestMessage);
|
sl@0
|
1844 |
theFlogger.Close();
|
sl@0
|
1845 |
User::After(KTimeToLog);
|
sl@0
|
1846 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
1847 |
if (r != KErrNone)
|
sl@0
|
1848 |
ret = r;
|
sl@0
|
1849 |
}
|
sl@0
|
1850 |
|
sl@0
|
1851 |
return ret;
|
sl@0
|
1852 |
|
sl@0
|
1853 |
}
|
sl@0
|
1854 |
|
sl@0
|
1855 |
|
sl@0
|
1856 |
|
sl@0
|
1857 |
/**
|
sl@0
|
1858 |
* This function checks whether test data was written
|
sl@0
|
1859 |
* in to the log file .
|
sl@0
|
1860 |
*/
|
sl@0
|
1861 |
|
sl@0
|
1862 |
|
sl@0
|
1863 |
TInt CFloggerTest030_TagCreateLog07::DoTestCheckWriteL()
|
sl@0
|
1864 |
{
|
sl@0
|
1865 |
RFile theFile;
|
sl@0
|
1866 |
HBufC8 * hBuffer;
|
sl@0
|
1867 |
TInt listfilesize,returnCode;
|
sl@0
|
1868 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
1869 |
TBuf8<256> testData; //To hold the test descriptor
|
sl@0
|
1870 |
TInt numSuccessful = 0;
|
sl@0
|
1871 |
|
sl@0
|
1872 |
|
sl@0
|
1873 |
_LIT8(KOOMError, "#Logs may be lost out of memory!!");
|
sl@0
|
1874 |
|
sl@0
|
1875 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
1876 |
|
sl@0
|
1877 |
//Open the file in the read mode
|
sl@0
|
1878 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
1879 |
|
sl@0
|
1880 |
CleanupClosePushL(theFile);
|
sl@0
|
1881 |
|
sl@0
|
1882 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
1883 |
|
sl@0
|
1884 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
1885 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
1886 |
|
sl@0
|
1887 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
1888 |
|
sl@0
|
1889 |
// Read from position 0: start of file
|
sl@0
|
1890 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
1891 |
|
sl@0
|
1892 |
testData.Copy(KTestMessage); //Copy the test descriptor
|
sl@0
|
1893 |
returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
1894 |
//from the file
|
sl@0
|
1895 |
if (returnCode > 0)
|
sl@0
|
1896 |
{
|
sl@0
|
1897 |
numSuccessful++;
|
sl@0
|
1898 |
}
|
sl@0
|
1899 |
|
sl@0
|
1900 |
// We expect to see the string "subsystem0123456" but not "subsystem01234567"
|
sl@0
|
1901 |
testData.Copy(KSubsysTag16char16); //Copy the test descriptor
|
sl@0
|
1902 |
returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
1903 |
|
sl@0
|
1904 |
if (returnCode > 0)
|
sl@0
|
1905 |
{
|
sl@0
|
1906 |
numSuccessful++;
|
sl@0
|
1907 |
}
|
sl@0
|
1908 |
|
sl@0
|
1909 |
testData.Copy(KSubsysTag17char16); //Copy the test descriptor
|
sl@0
|
1910 |
returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read
|
sl@0
|
1911 |
|
sl@0
|
1912 |
if (returnCode == KErrNotFound)
|
sl@0
|
1913 |
{
|
sl@0
|
1914 |
numSuccessful++;
|
sl@0
|
1915 |
}
|
sl@0
|
1916 |
|
sl@0
|
1917 |
if (returnCode == KErrNotFound)
|
sl@0
|
1918 |
{
|
sl@0
|
1919 |
returnCode = ptrString.Find(KOOMError);
|
sl@0
|
1920 |
if (returnCode > 0)
|
sl@0
|
1921 |
User::Leave(KErrNoMemory);
|
sl@0
|
1922 |
}
|
sl@0
|
1923 |
|
sl@0
|
1924 |
|
sl@0
|
1925 |
|
sl@0
|
1926 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
1927 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
1928 |
if (numSuccessful == 3)
|
sl@0
|
1929 |
return KErrNone;
|
sl@0
|
1930 |
else
|
sl@0
|
1931 |
return KErrNotFound;
|
sl@0
|
1932 |
}
|
sl@0
|
1933 |
|
sl@0
|
1934 |
|
sl@0
|
1935 |
/**
|
sl@0
|
1936 |
* 030_TagCreateLog08: Test that flogger handles very long tags
|
sl@0
|
1937 |
*/
|
sl@0
|
1938 |
|
sl@0
|
1939 |
CFloggerTest030_TagCreateLog08::CFloggerTest030_TagCreateLog08()
|
sl@0
|
1940 |
{
|
sl@0
|
1941 |
// Store the name of this test case
|
sl@0
|
1942 |
SetTestStepName(_L("step_030_TagCreateLog08"));
|
sl@0
|
1943 |
}
|
sl@0
|
1944 |
|
sl@0
|
1945 |
|
sl@0
|
1946 |
|
sl@0
|
1947 |
|
sl@0
|
1948 |
CFloggerTest030_TagCreateLog08::~CFloggerTest030_TagCreateLog08()
|
sl@0
|
1949 |
{
|
sl@0
|
1950 |
}
|
sl@0
|
1951 |
|
sl@0
|
1952 |
|
sl@0
|
1953 |
|
sl@0
|
1954 |
|
sl@0
|
1955 |
TVerdict CFloggerTest030_TagCreateLog08::doTestStepL( )
|
sl@0
|
1956 |
{
|
sl@0
|
1957 |
if ( executeStepL() == KErrNone )
|
sl@0
|
1958 |
SetTestStepResult(EPass);
|
sl@0
|
1959 |
|
sl@0
|
1960 |
else
|
sl@0
|
1961 |
SetTestStepResult(EFail);
|
sl@0
|
1962 |
|
sl@0
|
1963 |
User::After(KTimeForDisplay);
|
sl@0
|
1964 |
|
sl@0
|
1965 |
|
sl@0
|
1966 |
return TestStepResult();
|
sl@0
|
1967 |
}
|
sl@0
|
1968 |
|
sl@0
|
1969 |
|
sl@0
|
1970 |
TInt CFloggerTest030_TagCreateLog08::executeStepL(TBool)
|
sl@0
|
1971 |
{
|
sl@0
|
1972 |
return KErrGeneral;
|
sl@0
|
1973 |
}
|
sl@0
|
1974 |
|
sl@0
|
1975 |
TInt CFloggerTest030_TagCreateLog08::executeStepL()
|
sl@0
|
1976 |
{
|
sl@0
|
1977 |
|
sl@0
|
1978 |
TInt ret ;
|
sl@0
|
1979 |
RFileLogger theFlogger;
|
sl@0
|
1980 |
ret = theFlogger.Connect();
|
sl@0
|
1981 |
|
sl@0
|
1982 |
if ( ret == KErrNone)
|
sl@0
|
1983 |
{
|
sl@0
|
1984 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
1985 |
theFlogger.ClearLog();
|
sl@0
|
1986 |
theFlogger.CreateLog(KSubsysTag66char16, KCompTag66char16, EFileLoggingModeOverwrite);
|
sl@0
|
1987 |
theFlogger.Write(KTestMessage);
|
sl@0
|
1988 |
theFlogger.Close();
|
sl@0
|
1989 |
User::After(KTimeToLog);
|
sl@0
|
1990 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
1991 |
if (r != KErrNone)
|
sl@0
|
1992 |
ret = r;
|
sl@0
|
1993 |
}
|
sl@0
|
1994 |
|
sl@0
|
1995 |
return ret;
|
sl@0
|
1996 |
|
sl@0
|
1997 |
}
|
sl@0
|
1998 |
|
sl@0
|
1999 |
|
sl@0
|
2000 |
|
sl@0
|
2001 |
|
sl@0
|
2002 |
TInt CFloggerTest030_TagCreateLog08::DoTestCheckWriteL()
|
sl@0
|
2003 |
{
|
sl@0
|
2004 |
RFile theFile;
|
sl@0
|
2005 |
HBufC8 * hBuffer;
|
sl@0
|
2006 |
TInt listfilesize,returnCode;
|
sl@0
|
2007 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
2008 |
TUint numSuccessful = 0;
|
sl@0
|
2009 |
|
sl@0
|
2010 |
|
sl@0
|
2011 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
2012 |
CleanupClosePushL(fileSystem);
|
sl@0
|
2013 |
|
sl@0
|
2014 |
//Open the file in the read mode
|
sl@0
|
2015 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
2016 |
|
sl@0
|
2017 |
CleanupClosePushL(theFile);
|
sl@0
|
2018 |
|
sl@0
|
2019 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
2020 |
|
sl@0
|
2021 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
2022 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
2023 |
|
sl@0
|
2024 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
2025 |
|
sl@0
|
2026 |
// Read from position 0: start of file
|
sl@0
|
2027 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
2028 |
|
sl@0
|
2029 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
2030 |
//from the file
|
sl@0
|
2031 |
|
sl@0
|
2032 |
if (returnCode > 0)
|
sl@0
|
2033 |
{
|
sl@0
|
2034 |
numSuccessful++;
|
sl@0
|
2035 |
}
|
sl@0
|
2036 |
else if (returnCode == KErrNotFound)
|
sl@0
|
2037 |
{
|
sl@0
|
2038 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
2039 |
if (returnCode > 0)
|
sl@0
|
2040 |
User::Leave(KErrNoMemory);
|
sl@0
|
2041 |
}
|
sl@0
|
2042 |
|
sl@0
|
2043 |
// We expect to see the string "subsystem0123456" but not "subsystem01234567"
|
sl@0
|
2044 |
returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read
|
sl@0
|
2045 |
|
sl@0
|
2046 |
if (returnCode > 0)
|
sl@0
|
2047 |
{
|
sl@0
|
2048 |
numSuccessful++;
|
sl@0
|
2049 |
}
|
sl@0
|
2050 |
|
sl@0
|
2051 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
2052 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
2053 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
2054 |
|
sl@0
|
2055 |
if (numSuccessful == 2)
|
sl@0
|
2056 |
return KErrNone;
|
sl@0
|
2057 |
else
|
sl@0
|
2058 |
return KErrNotFound;
|
sl@0
|
2059 |
}
|
sl@0
|
2060 |
|
sl@0
|
2061 |
|
sl@0
|
2062 |
|
sl@0
|
2063 |
|
sl@0
|
2064 |
/***************************************************************************************/
|
sl@0
|
2065 |
|
sl@0
|
2066 |
|
sl@0
|
2067 |
/**
|
sl@0
|
2068 |
* 030_TagWrite01: Test that flogger handles empty tags
|
sl@0
|
2069 |
*/
|
sl@0
|
2070 |
|
sl@0
|
2071 |
CFloggerTest030_TagWrite01::CFloggerTest030_TagWrite01()
|
sl@0
|
2072 |
{
|
sl@0
|
2073 |
// Store the name of this test case
|
sl@0
|
2074 |
SetTestStepName(_L("step_030_TagWrite01"));
|
sl@0
|
2075 |
}
|
sl@0
|
2076 |
|
sl@0
|
2077 |
|
sl@0
|
2078 |
|
sl@0
|
2079 |
|
sl@0
|
2080 |
CFloggerTest030_TagWrite01::~CFloggerTest030_TagWrite01()
|
sl@0
|
2081 |
{
|
sl@0
|
2082 |
}
|
sl@0
|
2083 |
|
sl@0
|
2084 |
|
sl@0
|
2085 |
|
sl@0
|
2086 |
|
sl@0
|
2087 |
TVerdict CFloggerTest030_TagWrite01::doTestStepL( )
|
sl@0
|
2088 |
{
|
sl@0
|
2089 |
if ( executeStepL() == KErrNone )
|
sl@0
|
2090 |
SetTestStepResult(EPass);
|
sl@0
|
2091 |
|
sl@0
|
2092 |
else
|
sl@0
|
2093 |
SetTestStepResult(EFail);
|
sl@0
|
2094 |
|
sl@0
|
2095 |
User::After(KTimeForDisplay);
|
sl@0
|
2096 |
|
sl@0
|
2097 |
|
sl@0
|
2098 |
return TestStepResult();
|
sl@0
|
2099 |
}
|
sl@0
|
2100 |
|
sl@0
|
2101 |
|
sl@0
|
2102 |
TInt CFloggerTest030_TagWrite01::executeStepL(TBool)
|
sl@0
|
2103 |
{
|
sl@0
|
2104 |
return KErrGeneral;
|
sl@0
|
2105 |
}
|
sl@0
|
2106 |
|
sl@0
|
2107 |
TInt CFloggerTest030_TagWrite01::executeStepL()
|
sl@0
|
2108 |
{
|
sl@0
|
2109 |
|
sl@0
|
2110 |
TInt ret ;
|
sl@0
|
2111 |
RFileLogger theFlogger;
|
sl@0
|
2112 |
ret = theFlogger.Connect();
|
sl@0
|
2113 |
|
sl@0
|
2114 |
if ( ret == KErrNone)
|
sl@0
|
2115 |
{
|
sl@0
|
2116 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
2117 |
theFlogger.ClearLog();
|
sl@0
|
2118 |
theFlogger.Close();
|
sl@0
|
2119 |
RFileLogger::Write(KNullDesC8, KNullDesC8,KTestMessage);
|
sl@0
|
2120 |
User::After(KTimeToLog);
|
sl@0
|
2121 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
2122 |
if (r != KErrNone)
|
sl@0
|
2123 |
ret = r;
|
sl@0
|
2124 |
}
|
sl@0
|
2125 |
|
sl@0
|
2126 |
return ret;
|
sl@0
|
2127 |
|
sl@0
|
2128 |
}
|
sl@0
|
2129 |
|
sl@0
|
2130 |
|
sl@0
|
2131 |
|
sl@0
|
2132 |
|
sl@0
|
2133 |
TInt CFloggerTest030_TagWrite01::DoTestCheckWriteL()
|
sl@0
|
2134 |
{
|
sl@0
|
2135 |
RFile theFile;
|
sl@0
|
2136 |
HBufC8 * hBuffer;
|
sl@0
|
2137 |
TInt listfilesize,returnCode;
|
sl@0
|
2138 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
2139 |
TUint numSuccessful = 0;
|
sl@0
|
2140 |
|
sl@0
|
2141 |
|
sl@0
|
2142 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
2143 |
CleanupClosePushL(fileSystem);
|
sl@0
|
2144 |
|
sl@0
|
2145 |
//Open the file in the read mode
|
sl@0
|
2146 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
2147 |
|
sl@0
|
2148 |
CleanupClosePushL(theFile);
|
sl@0
|
2149 |
|
sl@0
|
2150 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
2151 |
|
sl@0
|
2152 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
2153 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
2154 |
|
sl@0
|
2155 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
2156 |
|
sl@0
|
2157 |
// Read from position 0: start of file
|
sl@0
|
2158 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
2159 |
|
sl@0
|
2160 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
2161 |
//from the file
|
sl@0
|
2162 |
|
sl@0
|
2163 |
if (returnCode == KErrNotFound)
|
sl@0
|
2164 |
{
|
sl@0
|
2165 |
numSuccessful++;
|
sl@0
|
2166 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
2167 |
if (returnCode > 0)
|
sl@0
|
2168 |
User::Leave(KErrNoMemory);
|
sl@0
|
2169 |
}
|
sl@0
|
2170 |
|
sl@0
|
2171 |
|
sl@0
|
2172 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
2173 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
2174 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
2175 |
|
sl@0
|
2176 |
if (numSuccessful == 1)
|
sl@0
|
2177 |
return KErrNone;
|
sl@0
|
2178 |
else
|
sl@0
|
2179 |
return KErrNotFound;
|
sl@0
|
2180 |
}
|
sl@0
|
2181 |
|
sl@0
|
2182 |
|
sl@0
|
2183 |
|
sl@0
|
2184 |
|
sl@0
|
2185 |
/**
|
sl@0
|
2186 |
* 030_TagWrite02: Test that flogger handles empty subsys tag
|
sl@0
|
2187 |
*/
|
sl@0
|
2188 |
|
sl@0
|
2189 |
CFloggerTest030_TagWrite02::CFloggerTest030_TagWrite02()
|
sl@0
|
2190 |
{
|
sl@0
|
2191 |
// Store the name of this test case
|
sl@0
|
2192 |
SetTestStepName(_L("step_030_TagWrite02"));
|
sl@0
|
2193 |
}
|
sl@0
|
2194 |
|
sl@0
|
2195 |
|
sl@0
|
2196 |
|
sl@0
|
2197 |
|
sl@0
|
2198 |
CFloggerTest030_TagWrite02::~CFloggerTest030_TagWrite02()
|
sl@0
|
2199 |
{
|
sl@0
|
2200 |
}
|
sl@0
|
2201 |
|
sl@0
|
2202 |
|
sl@0
|
2203 |
|
sl@0
|
2204 |
|
sl@0
|
2205 |
TVerdict CFloggerTest030_TagWrite02::doTestStepL( )
|
sl@0
|
2206 |
{
|
sl@0
|
2207 |
if ( executeStepL() == KErrNone )
|
sl@0
|
2208 |
SetTestStepResult(EPass);
|
sl@0
|
2209 |
|
sl@0
|
2210 |
else
|
sl@0
|
2211 |
SetTestStepResult(EFail);
|
sl@0
|
2212 |
|
sl@0
|
2213 |
User::After(KTimeForDisplay);
|
sl@0
|
2214 |
|
sl@0
|
2215 |
|
sl@0
|
2216 |
return TestStepResult();
|
sl@0
|
2217 |
}
|
sl@0
|
2218 |
|
sl@0
|
2219 |
|
sl@0
|
2220 |
TInt CFloggerTest030_TagWrite02::executeStepL(TBool)
|
sl@0
|
2221 |
{
|
sl@0
|
2222 |
return KErrGeneral;
|
sl@0
|
2223 |
}
|
sl@0
|
2224 |
|
sl@0
|
2225 |
TInt CFloggerTest030_TagWrite02::executeStepL()
|
sl@0
|
2226 |
{
|
sl@0
|
2227 |
|
sl@0
|
2228 |
TInt ret ;
|
sl@0
|
2229 |
RFileLogger theFlogger;
|
sl@0
|
2230 |
ret = theFlogger.Connect();
|
sl@0
|
2231 |
|
sl@0
|
2232 |
if ( ret == KErrNone)
|
sl@0
|
2233 |
{
|
sl@0
|
2234 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
2235 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
2236 |
theFlogger.ClearLog();
|
sl@0
|
2237 |
theFlogger.Close();
|
sl@0
|
2238 |
RFileLogger::Write(KNullDesC8, KStdCompTag8,KTestMessage);
|
sl@0
|
2239 |
User::After(KTimeToLog);
|
sl@0
|
2240 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
2241 |
if (r != KErrNone)
|
sl@0
|
2242 |
ret = r;
|
sl@0
|
2243 |
}
|
sl@0
|
2244 |
|
sl@0
|
2245 |
return ret;
|
sl@0
|
2246 |
|
sl@0
|
2247 |
}
|
sl@0
|
2248 |
|
sl@0
|
2249 |
|
sl@0
|
2250 |
|
sl@0
|
2251 |
|
sl@0
|
2252 |
TInt CFloggerTest030_TagWrite02::DoTestCheckWriteL()
|
sl@0
|
2253 |
{
|
sl@0
|
2254 |
RFile theFile;
|
sl@0
|
2255 |
HBufC8 * hBuffer;
|
sl@0
|
2256 |
TInt listfilesize,returnCode;
|
sl@0
|
2257 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
2258 |
TUint numSuccessful = 0;
|
sl@0
|
2259 |
|
sl@0
|
2260 |
|
sl@0
|
2261 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
2262 |
CleanupClosePushL(fileSystem);
|
sl@0
|
2263 |
|
sl@0
|
2264 |
//Open the file in the read mode
|
sl@0
|
2265 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
2266 |
|
sl@0
|
2267 |
CleanupClosePushL(theFile);
|
sl@0
|
2268 |
|
sl@0
|
2269 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
2270 |
|
sl@0
|
2271 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
2272 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
2273 |
|
sl@0
|
2274 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
2275 |
|
sl@0
|
2276 |
// Read from position 0: start of file
|
sl@0
|
2277 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
2278 |
|
sl@0
|
2279 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
2280 |
//from the file
|
sl@0
|
2281 |
|
sl@0
|
2282 |
if (returnCode == KErrNotFound)
|
sl@0
|
2283 |
{
|
sl@0
|
2284 |
numSuccessful++;
|
sl@0
|
2285 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
2286 |
if (returnCode > 0)
|
sl@0
|
2287 |
User::Leave(KErrNoMemory);
|
sl@0
|
2288 |
}
|
sl@0
|
2289 |
|
sl@0
|
2290 |
|
sl@0
|
2291 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
2292 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
2293 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
2294 |
|
sl@0
|
2295 |
if (numSuccessful == 1)
|
sl@0
|
2296 |
return KErrNone;
|
sl@0
|
2297 |
else
|
sl@0
|
2298 |
return KErrNotFound;
|
sl@0
|
2299 |
}
|
sl@0
|
2300 |
|
sl@0
|
2301 |
|
sl@0
|
2302 |
|
sl@0
|
2303 |
/**
|
sl@0
|
2304 |
* 030_TagWrite03: Test that flogger handles empty component tag
|
sl@0
|
2305 |
*/
|
sl@0
|
2306 |
|
sl@0
|
2307 |
CFloggerTest030_TagWrite03::CFloggerTest030_TagWrite03()
|
sl@0
|
2308 |
{
|
sl@0
|
2309 |
// Store the name of this test case
|
sl@0
|
2310 |
SetTestStepName(_L("step_030_TagWrite03"));
|
sl@0
|
2311 |
}
|
sl@0
|
2312 |
|
sl@0
|
2313 |
|
sl@0
|
2314 |
|
sl@0
|
2315 |
|
sl@0
|
2316 |
CFloggerTest030_TagWrite03::~CFloggerTest030_TagWrite03()
|
sl@0
|
2317 |
{
|
sl@0
|
2318 |
}
|
sl@0
|
2319 |
|
sl@0
|
2320 |
|
sl@0
|
2321 |
|
sl@0
|
2322 |
|
sl@0
|
2323 |
TVerdict CFloggerTest030_TagWrite03::doTestStepL( )
|
sl@0
|
2324 |
{
|
sl@0
|
2325 |
if ( executeStepL() == KErrNone )
|
sl@0
|
2326 |
SetTestStepResult(EPass);
|
sl@0
|
2327 |
|
sl@0
|
2328 |
else
|
sl@0
|
2329 |
SetTestStepResult(EFail);
|
sl@0
|
2330 |
|
sl@0
|
2331 |
User::After(KTimeForDisplay);
|
sl@0
|
2332 |
|
sl@0
|
2333 |
|
sl@0
|
2334 |
return TestStepResult();
|
sl@0
|
2335 |
}
|
sl@0
|
2336 |
|
sl@0
|
2337 |
|
sl@0
|
2338 |
TInt CFloggerTest030_TagWrite03::executeStepL(TBool)
|
sl@0
|
2339 |
{
|
sl@0
|
2340 |
return KErrGeneral;
|
sl@0
|
2341 |
}
|
sl@0
|
2342 |
|
sl@0
|
2343 |
TInt CFloggerTest030_TagWrite03::executeStepL()
|
sl@0
|
2344 |
{
|
sl@0
|
2345 |
|
sl@0
|
2346 |
TInt ret ;
|
sl@0
|
2347 |
RFileLogger theFlogger;
|
sl@0
|
2348 |
ret = theFlogger.Connect();
|
sl@0
|
2349 |
|
sl@0
|
2350 |
if ( ret == KErrNone)
|
sl@0
|
2351 |
{
|
sl@0
|
2352 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
2353 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
2354 |
theFlogger.ClearLog();
|
sl@0
|
2355 |
theFlogger.Close();
|
sl@0
|
2356 |
RFileLogger::Write(KStdSubsysTag8, KNullDesC8,KTestMessage);
|
sl@0
|
2357 |
User::After(KTimeToLog);
|
sl@0
|
2358 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
2359 |
if (r != KErrNone)
|
sl@0
|
2360 |
ret = r;
|
sl@0
|
2361 |
}
|
sl@0
|
2362 |
|
sl@0
|
2363 |
return ret;
|
sl@0
|
2364 |
|
sl@0
|
2365 |
}
|
sl@0
|
2366 |
|
sl@0
|
2367 |
|
sl@0
|
2368 |
|
sl@0
|
2369 |
|
sl@0
|
2370 |
TInt CFloggerTest030_TagWrite03::DoTestCheckWriteL()
|
sl@0
|
2371 |
{
|
sl@0
|
2372 |
RFile theFile;
|
sl@0
|
2373 |
HBufC8 * hBuffer;
|
sl@0
|
2374 |
TInt listfilesize,returnCode;
|
sl@0
|
2375 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
2376 |
TUint numSuccessful = 0;
|
sl@0
|
2377 |
|
sl@0
|
2378 |
|
sl@0
|
2379 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
2380 |
CleanupClosePushL(fileSystem);
|
sl@0
|
2381 |
|
sl@0
|
2382 |
//Open the file in the read mode
|
sl@0
|
2383 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
2384 |
|
sl@0
|
2385 |
CleanupClosePushL(theFile);
|
sl@0
|
2386 |
|
sl@0
|
2387 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
2388 |
|
sl@0
|
2389 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
2390 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
2391 |
|
sl@0
|
2392 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
2393 |
|
sl@0
|
2394 |
// Read from position 0: start of file
|
sl@0
|
2395 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
2396 |
|
sl@0
|
2397 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
2398 |
//from the file
|
sl@0
|
2399 |
|
sl@0
|
2400 |
if (returnCode == KErrNotFound)
|
sl@0
|
2401 |
{
|
sl@0
|
2402 |
numSuccessful++;
|
sl@0
|
2403 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
2404 |
if (returnCode > 0)
|
sl@0
|
2405 |
User::Leave(KErrNoMemory);
|
sl@0
|
2406 |
}
|
sl@0
|
2407 |
|
sl@0
|
2408 |
|
sl@0
|
2409 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
2410 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
2411 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
2412 |
|
sl@0
|
2413 |
if (numSuccessful == 1)
|
sl@0
|
2414 |
return KErrNone;
|
sl@0
|
2415 |
else
|
sl@0
|
2416 |
return KErrNotFound;
|
sl@0
|
2417 |
}
|
sl@0
|
2418 |
|
sl@0
|
2419 |
|
sl@0
|
2420 |
|
sl@0
|
2421 |
|
sl@0
|
2422 |
/**
|
sl@0
|
2423 |
* 030_TagWrite04: Test that flogger handles spaces in tags
|
sl@0
|
2424 |
*/
|
sl@0
|
2425 |
|
sl@0
|
2426 |
CFloggerTest030_TagWrite04::CFloggerTest030_TagWrite04()
|
sl@0
|
2427 |
{
|
sl@0
|
2428 |
// Store the name of this test case
|
sl@0
|
2429 |
SetTestStepName(_L("step_030_TagWrite04"));
|
sl@0
|
2430 |
}
|
sl@0
|
2431 |
|
sl@0
|
2432 |
|
sl@0
|
2433 |
|
sl@0
|
2434 |
|
sl@0
|
2435 |
CFloggerTest030_TagWrite04::~CFloggerTest030_TagWrite04()
|
sl@0
|
2436 |
{
|
sl@0
|
2437 |
}
|
sl@0
|
2438 |
|
sl@0
|
2439 |
|
sl@0
|
2440 |
|
sl@0
|
2441 |
|
sl@0
|
2442 |
TVerdict CFloggerTest030_TagWrite04::doTestStepL( )
|
sl@0
|
2443 |
{
|
sl@0
|
2444 |
if ( executeStepL() == KErrNone )
|
sl@0
|
2445 |
SetTestStepResult(EPass);
|
sl@0
|
2446 |
|
sl@0
|
2447 |
else
|
sl@0
|
2448 |
SetTestStepResult(EFail);
|
sl@0
|
2449 |
|
sl@0
|
2450 |
User::After(KTimeForDisplay);
|
sl@0
|
2451 |
|
sl@0
|
2452 |
|
sl@0
|
2453 |
return TestStepResult();
|
sl@0
|
2454 |
}
|
sl@0
|
2455 |
|
sl@0
|
2456 |
|
sl@0
|
2457 |
TInt CFloggerTest030_TagWrite04::executeStepL(TBool)
|
sl@0
|
2458 |
{
|
sl@0
|
2459 |
return KErrGeneral;
|
sl@0
|
2460 |
}
|
sl@0
|
2461 |
|
sl@0
|
2462 |
TInt CFloggerTest030_TagWrite04::executeStepL()
|
sl@0
|
2463 |
{
|
sl@0
|
2464 |
|
sl@0
|
2465 |
TInt ret ;
|
sl@0
|
2466 |
RFileLogger theFlogger;
|
sl@0
|
2467 |
ret = theFlogger.Connect();
|
sl@0
|
2468 |
|
sl@0
|
2469 |
if ( ret == KErrNone)
|
sl@0
|
2470 |
{
|
sl@0
|
2471 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
2472 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
2473 |
theFlogger.ClearLog();
|
sl@0
|
2474 |
theFlogger.Close();
|
sl@0
|
2475 |
RFileLogger::Write(KStdSubsysTag8, KCompTagWithSpaceChars8,KTestMessage);
|
sl@0
|
2476 |
User::After(KTimeToLog);
|
sl@0
|
2477 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
2478 |
if (r != KErrNone)
|
sl@0
|
2479 |
ret = r;
|
sl@0
|
2480 |
}
|
sl@0
|
2481 |
|
sl@0
|
2482 |
return ret;
|
sl@0
|
2483 |
|
sl@0
|
2484 |
}
|
sl@0
|
2485 |
|
sl@0
|
2486 |
|
sl@0
|
2487 |
|
sl@0
|
2488 |
|
sl@0
|
2489 |
TInt CFloggerTest030_TagWrite04::DoTestCheckWriteL()
|
sl@0
|
2490 |
{
|
sl@0
|
2491 |
RFile theFile;
|
sl@0
|
2492 |
HBufC8 * hBuffer;
|
sl@0
|
2493 |
TInt listfilesize,returnCode;
|
sl@0
|
2494 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
2495 |
TUint numSuccessful = 0;
|
sl@0
|
2496 |
|
sl@0
|
2497 |
|
sl@0
|
2498 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
2499 |
CleanupClosePushL(fileSystem);
|
sl@0
|
2500 |
|
sl@0
|
2501 |
//Open the file in the read mode
|
sl@0
|
2502 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
2503 |
|
sl@0
|
2504 |
CleanupClosePushL(theFile);
|
sl@0
|
2505 |
|
sl@0
|
2506 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
2507 |
|
sl@0
|
2508 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
2509 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
2510 |
|
sl@0
|
2511 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
2512 |
|
sl@0
|
2513 |
// Read from position 0: start of file
|
sl@0
|
2514 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
2515 |
|
sl@0
|
2516 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
2517 |
//from the file
|
sl@0
|
2518 |
|
sl@0
|
2519 |
if (returnCode == KErrNotFound)
|
sl@0
|
2520 |
{
|
sl@0
|
2521 |
numSuccessful++;
|
sl@0
|
2522 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
2523 |
if (returnCode > 0)
|
sl@0
|
2524 |
User::Leave(KErrNoMemory);
|
sl@0
|
2525 |
}
|
sl@0
|
2526 |
|
sl@0
|
2527 |
|
sl@0
|
2528 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
2529 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
2530 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
2531 |
|
sl@0
|
2532 |
if (numSuccessful == 1)
|
sl@0
|
2533 |
return KErrNone;
|
sl@0
|
2534 |
else
|
sl@0
|
2535 |
return KErrNotFound;
|
sl@0
|
2536 |
}
|
sl@0
|
2537 |
|
sl@0
|
2538 |
|
sl@0
|
2539 |
|
sl@0
|
2540 |
|
sl@0
|
2541 |
|
sl@0
|
2542 |
/**
|
sl@0
|
2543 |
* 030_TagWrite05: Test that flogger handles punctuation in tags
|
sl@0
|
2544 |
*/
|
sl@0
|
2545 |
|
sl@0
|
2546 |
CFloggerTest030_TagWrite05::CFloggerTest030_TagWrite05()
|
sl@0
|
2547 |
{
|
sl@0
|
2548 |
// Store the name of this test case
|
sl@0
|
2549 |
SetTestStepName(_L("step_030_TagWrite05"));
|
sl@0
|
2550 |
}
|
sl@0
|
2551 |
|
sl@0
|
2552 |
|
sl@0
|
2553 |
|
sl@0
|
2554 |
|
sl@0
|
2555 |
CFloggerTest030_TagWrite05::~CFloggerTest030_TagWrite05()
|
sl@0
|
2556 |
{
|
sl@0
|
2557 |
}
|
sl@0
|
2558 |
|
sl@0
|
2559 |
|
sl@0
|
2560 |
|
sl@0
|
2561 |
|
sl@0
|
2562 |
TVerdict CFloggerTest030_TagWrite05::doTestStepL( )
|
sl@0
|
2563 |
{
|
sl@0
|
2564 |
if ( executeStepL() == KErrNone )
|
sl@0
|
2565 |
SetTestStepResult(EPass);
|
sl@0
|
2566 |
|
sl@0
|
2567 |
else
|
sl@0
|
2568 |
SetTestStepResult(EFail);
|
sl@0
|
2569 |
|
sl@0
|
2570 |
User::After(KTimeForDisplay);
|
sl@0
|
2571 |
|
sl@0
|
2572 |
|
sl@0
|
2573 |
return TestStepResult();
|
sl@0
|
2574 |
}
|
sl@0
|
2575 |
|
sl@0
|
2576 |
TInt CFloggerTest030_TagWrite05::executeStepL(TBool)
|
sl@0
|
2577 |
{
|
sl@0
|
2578 |
return KErrGeneral;
|
sl@0
|
2579 |
}
|
sl@0
|
2580 |
|
sl@0
|
2581 |
|
sl@0
|
2582 |
TInt CFloggerTest030_TagWrite05::executeStepL()
|
sl@0
|
2583 |
{
|
sl@0
|
2584 |
|
sl@0
|
2585 |
TInt ret ;
|
sl@0
|
2586 |
RFileLogger theFlogger;
|
sl@0
|
2587 |
ret = theFlogger.Connect();
|
sl@0
|
2588 |
|
sl@0
|
2589 |
if ( ret == KErrNone)
|
sl@0
|
2590 |
{
|
sl@0
|
2591 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
2592 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
2593 |
theFlogger.ClearLog();
|
sl@0
|
2594 |
theFlogger.Close();
|
sl@0
|
2595 |
RFileLogger::Write(KSubsysTagWithPunctuationChars8, KCompTagWithPunctuationChars8,KTestMessage);
|
sl@0
|
2596 |
User::After(KTimeToLog);
|
sl@0
|
2597 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
2598 |
if (r != KErrNone)
|
sl@0
|
2599 |
ret = r;
|
sl@0
|
2600 |
}
|
sl@0
|
2601 |
|
sl@0
|
2602 |
return ret;
|
sl@0
|
2603 |
|
sl@0
|
2604 |
}
|
sl@0
|
2605 |
|
sl@0
|
2606 |
|
sl@0
|
2607 |
|
sl@0
|
2608 |
|
sl@0
|
2609 |
TInt CFloggerTest030_TagWrite05::DoTestCheckWriteL()
|
sl@0
|
2610 |
{
|
sl@0
|
2611 |
RFile theFile;
|
sl@0
|
2612 |
HBufC8 * hBuffer;
|
sl@0
|
2613 |
TInt listfilesize,returnCode;
|
sl@0
|
2614 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
2615 |
TUint numSuccessful = 0;
|
sl@0
|
2616 |
|
sl@0
|
2617 |
|
sl@0
|
2618 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
2619 |
CleanupClosePushL(fileSystem);
|
sl@0
|
2620 |
|
sl@0
|
2621 |
//Open the file in the read mode
|
sl@0
|
2622 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
2623 |
|
sl@0
|
2624 |
CleanupClosePushL(theFile);
|
sl@0
|
2625 |
|
sl@0
|
2626 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
2627 |
|
sl@0
|
2628 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
2629 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
2630 |
|
sl@0
|
2631 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
2632 |
|
sl@0
|
2633 |
// Read from position 0: start of file
|
sl@0
|
2634 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
2635 |
|
sl@0
|
2636 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
2637 |
//from the file
|
sl@0
|
2638 |
|
sl@0
|
2639 |
if (returnCode == KErrNotFound)
|
sl@0
|
2640 |
{
|
sl@0
|
2641 |
numSuccessful++;
|
sl@0
|
2642 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
2643 |
if (returnCode > 0)
|
sl@0
|
2644 |
User::Leave(KErrNoMemory);
|
sl@0
|
2645 |
}
|
sl@0
|
2646 |
|
sl@0
|
2647 |
|
sl@0
|
2648 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
2649 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
2650 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
2651 |
|
sl@0
|
2652 |
if (numSuccessful == 1)
|
sl@0
|
2653 |
return KErrNone;
|
sl@0
|
2654 |
else
|
sl@0
|
2655 |
return KErrNotFound;
|
sl@0
|
2656 |
}
|
sl@0
|
2657 |
|
sl@0
|
2658 |
|
sl@0
|
2659 |
/**
|
sl@0
|
2660 |
* 030_TagWrite06: Test that flogger handles long tags
|
sl@0
|
2661 |
*/
|
sl@0
|
2662 |
|
sl@0
|
2663 |
CFloggerTest030_TagWrite06::CFloggerTest030_TagWrite06()
|
sl@0
|
2664 |
{
|
sl@0
|
2665 |
// Store the name of this test case
|
sl@0
|
2666 |
SetTestStepName(_L("step_030_TagWrite06"));
|
sl@0
|
2667 |
}
|
sl@0
|
2668 |
|
sl@0
|
2669 |
|
sl@0
|
2670 |
|
sl@0
|
2671 |
|
sl@0
|
2672 |
CFloggerTest030_TagWrite06::~CFloggerTest030_TagWrite06()
|
sl@0
|
2673 |
{
|
sl@0
|
2674 |
}
|
sl@0
|
2675 |
|
sl@0
|
2676 |
|
sl@0
|
2677 |
|
sl@0
|
2678 |
|
sl@0
|
2679 |
TVerdict CFloggerTest030_TagWrite06::doTestStepL( )
|
sl@0
|
2680 |
{
|
sl@0
|
2681 |
if ( executeStepL() == KErrNone )
|
sl@0
|
2682 |
SetTestStepResult(EPass);
|
sl@0
|
2683 |
|
sl@0
|
2684 |
else
|
sl@0
|
2685 |
SetTestStepResult(EFail);
|
sl@0
|
2686 |
|
sl@0
|
2687 |
User::After(KTimeForDisplay);
|
sl@0
|
2688 |
|
sl@0
|
2689 |
|
sl@0
|
2690 |
return TestStepResult();
|
sl@0
|
2691 |
}
|
sl@0
|
2692 |
|
sl@0
|
2693 |
|
sl@0
|
2694 |
TInt CFloggerTest030_TagWrite06::executeStepL(TBool)
|
sl@0
|
2695 |
{
|
sl@0
|
2696 |
return KErrGeneral;
|
sl@0
|
2697 |
}
|
sl@0
|
2698 |
|
sl@0
|
2699 |
TInt CFloggerTest030_TagWrite06::executeStepL()
|
sl@0
|
2700 |
{
|
sl@0
|
2701 |
|
sl@0
|
2702 |
TInt ret ;
|
sl@0
|
2703 |
RFileLogger theFlogger;
|
sl@0
|
2704 |
ret = theFlogger.Connect();
|
sl@0
|
2705 |
|
sl@0
|
2706 |
if ( ret == KErrNone)
|
sl@0
|
2707 |
{
|
sl@0
|
2708 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
2709 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
2710 |
theFlogger.ClearLog();
|
sl@0
|
2711 |
theFlogger.Close();
|
sl@0
|
2712 |
RFileLogger::Write(KSubsysTag16char8, KCompTag16char8,KTestMessage8);
|
sl@0
|
2713 |
User::After(KTimeToLog);
|
sl@0
|
2714 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
2715 |
if (r != KErrNone)
|
sl@0
|
2716 |
ret = r;
|
sl@0
|
2717 |
}
|
sl@0
|
2718 |
|
sl@0
|
2719 |
return ret;
|
sl@0
|
2720 |
|
sl@0
|
2721 |
}
|
sl@0
|
2722 |
|
sl@0
|
2723 |
|
sl@0
|
2724 |
|
sl@0
|
2725 |
|
sl@0
|
2726 |
TInt CFloggerTest030_TagWrite06::DoTestCheckWriteL()
|
sl@0
|
2727 |
{
|
sl@0
|
2728 |
RFile theFile;
|
sl@0
|
2729 |
HBufC8 * hBuffer;
|
sl@0
|
2730 |
TInt listfilesize,returnCode;
|
sl@0
|
2731 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
2732 |
TUint numSuccessful = 0;
|
sl@0
|
2733 |
|
sl@0
|
2734 |
|
sl@0
|
2735 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
2736 |
CleanupClosePushL(fileSystem);
|
sl@0
|
2737 |
|
sl@0
|
2738 |
//Open the file in the read mode
|
sl@0
|
2739 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
2740 |
|
sl@0
|
2741 |
CleanupClosePushL(theFile);
|
sl@0
|
2742 |
|
sl@0
|
2743 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
2744 |
|
sl@0
|
2745 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
2746 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
2747 |
|
sl@0
|
2748 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
2749 |
|
sl@0
|
2750 |
// Read from position 0: start of file
|
sl@0
|
2751 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
2752 |
|
sl@0
|
2753 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
2754 |
//from the file
|
sl@0
|
2755 |
|
sl@0
|
2756 |
if (returnCode > 0)
|
sl@0
|
2757 |
{
|
sl@0
|
2758 |
numSuccessful++;
|
sl@0
|
2759 |
}
|
sl@0
|
2760 |
else if (returnCode == KErrNotFound)
|
sl@0
|
2761 |
{
|
sl@0
|
2762 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
2763 |
if (returnCode > 0)
|
sl@0
|
2764 |
User::Leave(KErrNoMemory);
|
sl@0
|
2765 |
}
|
sl@0
|
2766 |
|
sl@0
|
2767 |
|
sl@0
|
2768 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
2769 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
2770 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
2771 |
|
sl@0
|
2772 |
if (numSuccessful == 1)
|
sl@0
|
2773 |
return KErrNone;
|
sl@0
|
2774 |
else
|
sl@0
|
2775 |
return KErrNotFound;
|
sl@0
|
2776 |
}
|
sl@0
|
2777 |
|
sl@0
|
2778 |
|
sl@0
|
2779 |
|
sl@0
|
2780 |
|
sl@0
|
2781 |
/**
|
sl@0
|
2782 |
* 030_TagWrite07: Test that flogger handles long tags
|
sl@0
|
2783 |
*/
|
sl@0
|
2784 |
|
sl@0
|
2785 |
CFloggerTest030_TagWrite07::CFloggerTest030_TagWrite07()
|
sl@0
|
2786 |
{
|
sl@0
|
2787 |
// Store the name of this test case
|
sl@0
|
2788 |
SetTestStepName(_L("step_030_TagWrite07"));
|
sl@0
|
2789 |
}
|
sl@0
|
2790 |
|
sl@0
|
2791 |
|
sl@0
|
2792 |
|
sl@0
|
2793 |
|
sl@0
|
2794 |
CFloggerTest030_TagWrite07::~CFloggerTest030_TagWrite07()
|
sl@0
|
2795 |
{
|
sl@0
|
2796 |
}
|
sl@0
|
2797 |
|
sl@0
|
2798 |
|
sl@0
|
2799 |
|
sl@0
|
2800 |
|
sl@0
|
2801 |
TVerdict CFloggerTest030_TagWrite07::doTestStepL( )
|
sl@0
|
2802 |
{
|
sl@0
|
2803 |
if ( executeStepL() == KErrNone )
|
sl@0
|
2804 |
SetTestStepResult(EPass);
|
sl@0
|
2805 |
|
sl@0
|
2806 |
else
|
sl@0
|
2807 |
SetTestStepResult(EFail);
|
sl@0
|
2808 |
|
sl@0
|
2809 |
User::After(KTimeForDisplay);
|
sl@0
|
2810 |
|
sl@0
|
2811 |
|
sl@0
|
2812 |
return TestStepResult();
|
sl@0
|
2813 |
}
|
sl@0
|
2814 |
|
sl@0
|
2815 |
|
sl@0
|
2816 |
TInt CFloggerTest030_TagWrite07::executeStepL(TBool)
|
sl@0
|
2817 |
{
|
sl@0
|
2818 |
return KErrGeneral;
|
sl@0
|
2819 |
}
|
sl@0
|
2820 |
|
sl@0
|
2821 |
TInt CFloggerTest030_TagWrite07::executeStepL()
|
sl@0
|
2822 |
{
|
sl@0
|
2823 |
|
sl@0
|
2824 |
TInt ret ;
|
sl@0
|
2825 |
RFileLogger theFlogger;
|
sl@0
|
2826 |
ret = theFlogger.Connect();
|
sl@0
|
2827 |
|
sl@0
|
2828 |
if ( ret == KErrNone)
|
sl@0
|
2829 |
{
|
sl@0
|
2830 |
//Create Log by passing the subsystem and component name as parameters
|
sl@0
|
2831 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
2832 |
theFlogger.ClearLog();
|
sl@0
|
2833 |
theFlogger.Close();
|
sl@0
|
2834 |
RFileLogger::Write(KSubsysTag17char8, KCompTag17char8,KTestMessage8);
|
sl@0
|
2835 |
User::After(KTimeToLog);
|
sl@0
|
2836 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
2837 |
if (r != KErrNone)
|
sl@0
|
2838 |
ret = r;
|
sl@0
|
2839 |
}
|
sl@0
|
2840 |
|
sl@0
|
2841 |
return ret;
|
sl@0
|
2842 |
|
sl@0
|
2843 |
}
|
sl@0
|
2844 |
|
sl@0
|
2845 |
|
sl@0
|
2846 |
|
sl@0
|
2847 |
|
sl@0
|
2848 |
TInt CFloggerTest030_TagWrite07::DoTestCheckWriteL()
|
sl@0
|
2849 |
{
|
sl@0
|
2850 |
RFile theFile;
|
sl@0
|
2851 |
HBufC8 * hBuffer;
|
sl@0
|
2852 |
TInt listfilesize,returnCode;
|
sl@0
|
2853 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
2854 |
TUint numSuccessful = 0;
|
sl@0
|
2855 |
|
sl@0
|
2856 |
|
sl@0
|
2857 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
2858 |
CleanupClosePushL(fileSystem);
|
sl@0
|
2859 |
|
sl@0
|
2860 |
//Open the file in the read mode
|
sl@0
|
2861 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
2862 |
|
sl@0
|
2863 |
CleanupClosePushL(theFile);
|
sl@0
|
2864 |
|
sl@0
|
2865 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
2866 |
|
sl@0
|
2867 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
2868 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
2869 |
|
sl@0
|
2870 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
2871 |
|
sl@0
|
2872 |
// Read from position 0: start of file
|
sl@0
|
2873 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
2874 |
|
sl@0
|
2875 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
2876 |
//from the file
|
sl@0
|
2877 |
|
sl@0
|
2878 |
if (returnCode > 0)
|
sl@0
|
2879 |
{
|
sl@0
|
2880 |
numSuccessful++;
|
sl@0
|
2881 |
}
|
sl@0
|
2882 |
else if (returnCode == KErrNotFound)
|
sl@0
|
2883 |
{
|
sl@0
|
2884 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
2885 |
if (returnCode > 0)
|
sl@0
|
2886 |
User::Leave(KErrNoMemory);
|
sl@0
|
2887 |
}
|
sl@0
|
2888 |
|
sl@0
|
2889 |
// We expect to see the string "subsystem0123456" but not "subsystem01234567"
|
sl@0
|
2890 |
returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read
|
sl@0
|
2891 |
|
sl@0
|
2892 |
if (returnCode > 0)
|
sl@0
|
2893 |
{
|
sl@0
|
2894 |
numSuccessful++;
|
sl@0
|
2895 |
}
|
sl@0
|
2896 |
|
sl@0
|
2897 |
returnCode = ptrString.Find(KSubsysTag17char8); //find the test descriptor in the buffer read
|
sl@0
|
2898 |
|
sl@0
|
2899 |
if (returnCode == KErrNotFound)
|
sl@0
|
2900 |
{
|
sl@0
|
2901 |
numSuccessful++;
|
sl@0
|
2902 |
}
|
sl@0
|
2903 |
|
sl@0
|
2904 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
2905 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
2906 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
2907 |
|
sl@0
|
2908 |
if (numSuccessful == 3)
|
sl@0
|
2909 |
return KErrNone;
|
sl@0
|
2910 |
else
|
sl@0
|
2911 |
return KErrNotFound;
|
sl@0
|
2912 |
}
|
sl@0
|
2913 |
|
sl@0
|
2914 |
|
sl@0
|
2915 |
|
sl@0
|
2916 |
|
sl@0
|
2917 |
/**
|
sl@0
|
2918 |
* 030_TagWrite08: Test that flogger handles very long tags
|
sl@0
|
2919 |
*/
|
sl@0
|
2920 |
|
sl@0
|
2921 |
CFloggerTest030_TagWrite08::CFloggerTest030_TagWrite08()
|
sl@0
|
2922 |
{
|
sl@0
|
2923 |
// Store the name of this test case
|
sl@0
|
2924 |
SetTestStepName(_L("step_030_TagWrite08"));
|
sl@0
|
2925 |
}
|
sl@0
|
2926 |
|
sl@0
|
2927 |
|
sl@0
|
2928 |
|
sl@0
|
2929 |
|
sl@0
|
2930 |
CFloggerTest030_TagWrite08::~CFloggerTest030_TagWrite08()
|
sl@0
|
2931 |
{
|
sl@0
|
2932 |
}
|
sl@0
|
2933 |
|
sl@0
|
2934 |
|
sl@0
|
2935 |
|
sl@0
|
2936 |
|
sl@0
|
2937 |
TVerdict CFloggerTest030_TagWrite08::doTestStepL( )
|
sl@0
|
2938 |
{
|
sl@0
|
2939 |
if ( executeStepL() == KErrNone )
|
sl@0
|
2940 |
SetTestStepResult(EPass);
|
sl@0
|
2941 |
|
sl@0
|
2942 |
else
|
sl@0
|
2943 |
SetTestStepResult(EFail);
|
sl@0
|
2944 |
|
sl@0
|
2945 |
User::After(KTimeForDisplay);
|
sl@0
|
2946 |
|
sl@0
|
2947 |
|
sl@0
|
2948 |
return TestStepResult();
|
sl@0
|
2949 |
}
|
sl@0
|
2950 |
|
sl@0
|
2951 |
|
sl@0
|
2952 |
TInt CFloggerTest030_TagWrite08::executeStepL(TBool)
|
sl@0
|
2953 |
{
|
sl@0
|
2954 |
return KErrGeneral;
|
sl@0
|
2955 |
}
|
sl@0
|
2956 |
|
sl@0
|
2957 |
TInt CFloggerTest030_TagWrite08::executeStepL()
|
sl@0
|
2958 |
{
|
sl@0
|
2959 |
|
sl@0
|
2960 |
TInt ret ;
|
sl@0
|
2961 |
RFileLogger theFlogger;
|
sl@0
|
2962 |
ret = theFlogger.Connect();
|
sl@0
|
2963 |
|
sl@0
|
2964 |
if ( ret == KErrNone)
|
sl@0
|
2965 |
{
|
sl@0
|
2966 |
theFlogger.SetLogTags(KStdSubsysTag8, KStdCompTag8);
|
sl@0
|
2967 |
theFlogger.ClearLog();
|
sl@0
|
2968 |
theFlogger.Close();
|
sl@0
|
2969 |
RFileLogger::Write(KSubsysTag66char8, KCompTag66char8,KTestMessage);
|
sl@0
|
2970 |
User::After(KTimeToLog);
|
sl@0
|
2971 |
TRAPD(r, ret = DoTestCheckWriteL());
|
sl@0
|
2972 |
if (r != KErrNone)
|
sl@0
|
2973 |
ret = r;
|
sl@0
|
2974 |
}
|
sl@0
|
2975 |
|
sl@0
|
2976 |
return ret;
|
sl@0
|
2977 |
|
sl@0
|
2978 |
}
|
sl@0
|
2979 |
|
sl@0
|
2980 |
|
sl@0
|
2981 |
|
sl@0
|
2982 |
|
sl@0
|
2983 |
TInt CFloggerTest030_TagWrite08::DoTestCheckWriteL()
|
sl@0
|
2984 |
{
|
sl@0
|
2985 |
RFile theFile;
|
sl@0
|
2986 |
HBufC8 * hBuffer;
|
sl@0
|
2987 |
TInt listfilesize,returnCode;
|
sl@0
|
2988 |
RFs fileSystem; //For file operation create a file system
|
sl@0
|
2989 |
TUint numSuccessful = 0;
|
sl@0
|
2990 |
|
sl@0
|
2991 |
|
sl@0
|
2992 |
User::LeaveIfError(fileSystem.Connect());
|
sl@0
|
2993 |
CleanupClosePushL(fileSystem);
|
sl@0
|
2994 |
|
sl@0
|
2995 |
//Open the file in the read mode
|
sl@0
|
2996 |
User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead));
|
sl@0
|
2997 |
|
sl@0
|
2998 |
CleanupClosePushL(theFile);
|
sl@0
|
2999 |
|
sl@0
|
3000 |
User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file
|
sl@0
|
3001 |
|
sl@0
|
3002 |
hBuffer = HBufC8::New(listfilesize); //Allocate the buffer
|
sl@0
|
3003 |
CleanupStack::PushL(hBuffer);
|
sl@0
|
3004 |
|
sl@0
|
3005 |
TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer
|
sl@0
|
3006 |
|
sl@0
|
3007 |
// Read from position 0: start of file
|
sl@0
|
3008 |
User::LeaveIfError(returnCode = theFile.Read(ptrString));
|
sl@0
|
3009 |
|
sl@0
|
3010 |
returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read
|
sl@0
|
3011 |
//from the file
|
sl@0
|
3012 |
|
sl@0
|
3013 |
if (returnCode > 0)
|
sl@0
|
3014 |
{
|
sl@0
|
3015 |
numSuccessful++;
|
sl@0
|
3016 |
}
|
sl@0
|
3017 |
else if (returnCode == KErrNotFound)
|
sl@0
|
3018 |
{
|
sl@0
|
3019 |
returnCode = ptrString.Find(KErrOOM);
|
sl@0
|
3020 |
if (returnCode > 0)
|
sl@0
|
3021 |
User::Leave(KErrNoMemory);
|
sl@0
|
3022 |
}
|
sl@0
|
3023 |
|
sl@0
|
3024 |
// We expect to see the string "subsystem0123456" but not "subsystem01234567"
|
sl@0
|
3025 |
returnCode = ptrString.Find(KSubsysTag16char8); //find the test descriptor in the buffer read
|
sl@0
|
3026 |
|
sl@0
|
3027 |
if (returnCode > 0)
|
sl@0
|
3028 |
{
|
sl@0
|
3029 |
numSuccessful++;
|
sl@0
|
3030 |
}
|
sl@0
|
3031 |
|
sl@0
|
3032 |
CleanupStack::PopAndDestroy(hBuffer);
|
sl@0
|
3033 |
CleanupStack::PopAndDestroy(); //theFile
|
sl@0
|
3034 |
CleanupStack::PopAndDestroy(); //fileSystem
|
sl@0
|
3035 |
|
sl@0
|
3036 |
if (numSuccessful == 2)
|
sl@0
|
3037 |
return KErrNone;
|
sl@0
|
3038 |
else
|
sl@0
|
3039 |
return KErrNotFound;
|
sl@0
|
3040 |
}
|
sl@0
|
3041 |
|
sl@0
|
3042 |
|