|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "IpuTestUtils.h" |
|
17 |
|
18 // |
|
19 // Constants |
|
20 _LIT(KTestPanic, "IpuTestHarness"); |
|
21 const TInt KFailedTestsGranularity = 10; |
|
22 const TInt KMaxLogEntrySize = 256; |
|
23 |
|
24 // |
|
25 // CIpuTestHarness |
|
26 // |
|
27 CIpuTestHarness::CIpuTestHarness(const TDesC& aTitle) |
|
28 : iTest(aTitle) |
|
29 // |
|
30 // Default c'tor |
|
31 { |
|
32 iTest.Title(); |
|
33 iCanStartTest = ETrue; |
|
34 } |
|
35 |
|
36 CIpuTestHarness::~CIpuTestHarness() |
|
37 // |
|
38 // D'tor |
|
39 { |
|
40 TTime endtime; |
|
41 endtime.UniversalTime(); |
|
42 |
|
43 // Do resource handle leak test? |
|
44 if (iDoResourceLeakTest) |
|
45 ResourceLeakTest(); |
|
46 |
|
47 // End of tests - see if failed or ok |
|
48 if (iFailedTests->Count()) |
|
49 { |
|
50 TestHarnessFailed(); |
|
51 } |
|
52 else |
|
53 { |
|
54 TestHarnessComplete(); |
|
55 } |
|
56 |
|
57 iFailedTests->ResetAndDestroy(); |
|
58 delete iFailedTests; |
|
59 |
|
60 // Log finish time |
|
61 TDateTime t = endtime.DateTime(); |
|
62 LogIt(_L("Ended @ %d:%d:%d:%d"),t.Hour(),t.Minute(),t.Second(),t.MicroSecond()); |
|
63 TTime difftime(endtime.Int64() - iStartTime.Int64()); |
|
64 t = difftime.DateTime(); |
|
65 LogIt(_L("Execution time %d:%d:%d:%d"),t.Hour(),t.Minute(),t.Second(),t.MicroSecond()); |
|
66 |
|
67 // Close logs and test harness |
|
68 iFlogger.CloseLog(); |
|
69 |
|
70 // iTest test harness performs UHEAP MARK/UNMARK check upon creation/destruction |
|
71 // therefore, it must be destroyed last since it is created first in |
|
72 // CIpuTestHarness |
|
73 iTest.Close(); |
|
74 } |
|
75 |
|
76 EXPORT_C CIpuTestHarness* CIpuTestHarness::NewLC(const TDesC& aTitle) |
|
77 // |
|
78 // Static factory c'tor |
|
79 { |
|
80 CIpuTestHarness* self = new (ELeave) CIpuTestHarness(aTitle); |
|
81 CleanupStack::PushL(self); |
|
82 self->ConstructL(aTitle); |
|
83 return self; |
|
84 } |
|
85 |
|
86 EXPORT_C CIpuTestHarness* CIpuTestHarness::NewL(const TDesC& aTitle) |
|
87 // |
|
88 // Static factiry c'tor |
|
89 { |
|
90 CIpuTestHarness* self = CIpuTestHarness::NewLC(aTitle); |
|
91 CleanupStack::Pop(); |
|
92 return self; |
|
93 } |
|
94 |
|
95 void CIpuTestHarness::ConstructL(const TDesC& aTitle) |
|
96 // |
|
97 // Non-trivial c'tor |
|
98 { |
|
99 // Create iFailedTests |
|
100 iFailedTests = new (ELeave) CArrayPtrFlat<CTestInfo> (KFailedTestsGranularity); |
|
101 |
|
102 // Start up logging server connection |
|
103 TBuf<64> temp(aTitle); |
|
104 DefaultLogFileName(temp); |
|
105 CreateFlogger(temp, EFalse, EFalse); |
|
106 |
|
107 iStartTime.UniversalTime(); |
|
108 TDateTime t = iStartTime.DateTime(); |
|
109 LogIt(_L("Started @ %d:%d:%d:%d"),t.Hour(),t.Minute(),t.Second(),t.MicroSecond()); |
|
110 |
|
111 // Find number of open resource handles |
|
112 TInt processHandleCount=0; |
|
113 RThread().HandleCount(processHandleCount,iStartHandleCount); |
|
114 } |
|
115 |
|
116 EXPORT_C void CIpuTestHarness::StartTestL(const TDesC& aName) |
|
117 // |
|
118 // Logs start of test aName |
|
119 { |
|
120 if (iCanStartTest) |
|
121 { |
|
122 // - increment test count |
|
123 ++iTestCount; |
|
124 |
|
125 if (iTestMode == ETestModeNormal) // don't add this info when we are doing memory leak testing otherwise it |
|
126 // would get leaked! |
|
127 { |
|
128 |
|
129 // Add this test to failed test list - set errorcode to zero |
|
130 CTestInfo* temp = CTestInfo::NewLC(aName, iTestCount, 0); |
|
131 iFailedTests->AppendL(temp); |
|
132 CleanupStack::Pop(); // temp |
|
133 |
|
134 // Stop new test being started until this one has ended |
|
135 iTest.Start(aName); |
|
136 iCanStartTest = EFalse; |
|
137 } |
|
138 |
|
139 |
|
140 TBuf<KMaxFileName + 4> buf; |
|
141 buf.Format(KTestStartingWithDesc, iTestCount, &aName); |
|
142 WriteComment(buf); |
|
143 |
|
144 // Reset iStepNumber - start at 1 |
|
145 iStepNumber = 1; |
|
146 } |
|
147 else |
|
148 { |
|
149 // Panic client - bad usage - not allowed to nest tests |
|
150 Panic(EBadStartTest); |
|
151 } |
|
152 } |
|
153 |
|
154 EXPORT_C void CIpuTestHarness::NextStep(const TDesC& aStepName) |
|
155 // |
|
156 // Logs the next step in a test - for informative use. |
|
157 { |
|
158 if (!iCanStartTest) |
|
159 { |
|
160 TBuf<KMaxFileName + 4> buf; |
|
161 buf.Format(KNextTestStepWithDesc, iTestCount, iStepNumber, &aStepName); |
|
162 WriteComment(buf); |
|
163 iTest.Next(aStepName); |
|
164 ++iStepNumber; |
|
165 } |
|
166 else |
|
167 { |
|
168 // Panic client - bad usage - test not started |
|
169 Panic(EBadStartTest); |
|
170 } |
|
171 } |
|
172 |
|
173 EXPORT_C void CIpuTestHarness::EndTest(TInt aErrorCode) |
|
174 // |
|
175 // Logs end of test |
|
176 { |
|
177 if (!iCanStartTest) |
|
178 { |
|
179 if (iTestMode == ETestModeNormal) |
|
180 { |
|
181 // Get ptr to this test's entry in failed list - will be the last entry |
|
182 TBuf<KMaxFileName + 4> buf; |
|
183 TInt index = iFailedTests->Count(); |
|
184 CTestInfo* ptr = iFailedTests->At(--index); |
|
185 if (aErrorCode) |
|
186 { |
|
187 // Set the error code |
|
188 ptr->SetErrorCode(aErrorCode); |
|
189 buf.Format(KTestFailed, iTestCount, aErrorCode); |
|
190 WriteComment(buf); |
|
191 } |
|
192 else |
|
193 { |
|
194 // Remove entry from list of failed tests |
|
195 delete ptr; |
|
196 iFailedTests->Delete(index); |
|
197 } |
|
198 |
|
199 } |
|
200 // Allow new test to start |
|
201 iTest.End(); |
|
202 iCanStartTest = ETrue; |
|
203 } |
|
204 else |
|
205 { |
|
206 if (iTestMode == ETestModeNormal) |
|
207 // Panic client - bad usage - test not started |
|
208 Panic(EBadEndTest); |
|
209 // don't panic when we are memory leak testing as EndTestL will never get called to reset the test properly |
|
210 } |
|
211 } |
|
212 |
|
213 EXPORT_C void CIpuTestHarness::LogIt(TRefByValue<const TDesC> aFmt, ...) |
|
214 // |
|
215 // Messages to the front end emulator and to the Inu log |
|
216 { |
|
217 VA_LIST list; |
|
218 VA_START(list,aFmt); |
|
219 |
|
220 TBuf<KMaxFileName + 4> buf; |
|
221 buf.Append(KTestCommentPrepend); |
|
222 buf.AppendFormatList(aFmt,list); |
|
223 VA_END(list); |
|
224 |
|
225 WriteComment(buf); |
|
226 } |
|
227 |
|
228 EXPORT_C void CIpuTestHarness::operator()(TInt aResult,TInt aLineNum) |
|
229 // |
|
230 // Overload operator () |
|
231 { |
|
232 iTest(aResult, aLineNum); |
|
233 } |
|
234 |
|
235 EXPORT_C void CIpuTestHarness::operator()(TInt aResult) |
|
236 // |
|
237 // Overload operator () |
|
238 { |
|
239 iTest(aResult); |
|
240 } |
|
241 |
|
242 EXPORT_C void CIpuTestHarness::PressAnyKey() |
|
243 // |
|
244 // Request a key press from user and wait - unless we are running a script |
|
245 { |
|
246 if (!iScriptRunning) |
|
247 { |
|
248 iTest.Printf(TRefByValue<const TDesC>_L("\nPress a key")); |
|
249 iTest.Getch(); |
|
250 } |
|
251 } |
|
252 |
|
253 EXPORT_C void CIpuTestHarness::DumpData(HBufC8& aData, TBool logIt) |
|
254 // |
|
255 // Do a formatted dump of binary data, optionally logging it |
|
256 { |
|
257 // Iterate the supplied block of data in blocks of 16 bytes |
|
258 TInt pos = 0; |
|
259 TBuf<KMaxLogEntrySize> logLine; |
|
260 TBuf<KMaxLogEntrySize> anEntry; |
|
261 while (pos < aData.Length()) |
|
262 { |
|
263 anEntry.Format(TRefByValue<const TDesC>_L("%04x : "), pos); |
|
264 logLine.Append(anEntry); |
|
265 |
|
266 // Hex output |
|
267 TInt offset = 0; |
|
268 for (offset = 0; offset < 16; offset++) |
|
269 { |
|
270 if (pos + offset < aData.Length()) |
|
271 { |
|
272 TInt nextByte = aData[pos + offset]; |
|
273 anEntry.Format(TRefByValue<const TDesC>_L("%02x "), nextByte); |
|
274 logLine.Append(anEntry); |
|
275 } |
|
276 else |
|
277 { |
|
278 anEntry.Format(TRefByValue<const TDesC>_L(" ")); |
|
279 logLine.Append(anEntry); |
|
280 } |
|
281 } |
|
282 anEntry.Format(TRefByValue<const TDesC>_L(": ")); |
|
283 logLine.Append(anEntry); |
|
284 |
|
285 // Char output |
|
286 for (offset = 0; offset < 16; offset++) |
|
287 { |
|
288 if (pos + offset < aData.Length()) |
|
289 { |
|
290 TInt nextByte = aData[pos + offset]; |
|
291 if ((nextByte >= 32) && (nextByte <= 127)) |
|
292 { |
|
293 anEntry.Format(TRefByValue<const TDesC>_L("%c"), nextByte); |
|
294 logLine.Append(anEntry); |
|
295 } |
|
296 else |
|
297 { |
|
298 anEntry.Format(TRefByValue<const TDesC>_L(".")); |
|
299 logLine.Append(anEntry); |
|
300 } |
|
301 } |
|
302 else |
|
303 { |
|
304 anEntry.Format(TRefByValue<const TDesC>_L(" ")); |
|
305 logLine.Append(anEntry); |
|
306 } |
|
307 } |
|
308 if (logIt) |
|
309 { |
|
310 LogIt(TRefByValue<const TDesC>_L("%S"), &logLine); |
|
311 } |
|
312 else |
|
313 { |
|
314 iTest.Printf(TRefByValue<const TDesC>_L("%S\n"), &logLine); |
|
315 } |
|
316 logLine.Zero(); |
|
317 |
|
318 // Advance to next 16 byte segment |
|
319 pos += 16; |
|
320 } |
|
321 } |
|
322 |
|
323 EXPORT_C void CIpuTestHarness::GetAnEntry(const TDesC& ourPrompt, TDes& currentstring) |
|
324 // |
|
325 // Get an input string from the user, displaying a supplied prompt and default string value |
|
326 { |
|
327 // If we're scripting, try reading from script first |
|
328 TInt readScriptErr = KErrNotFound; |
|
329 if (iScriptRunning) |
|
330 { |
|
331 readScriptErr = ReadLineFromScript(currentstring); |
|
332 } |
|
333 if (!readScriptErr) |
|
334 return; |
|
335 |
|
336 // Either not scripting, or hit end of script - continue with user input |
|
337 TBuf16<KMaxUserEntrySize> ourLine; |
|
338 TBuf<KMaxUserEntrySize> tempstring; //tempstring is a unicode descriptor |
|
339 //create a temporary buffer where the |
|
340 //unicode strings are stored in order to |
|
341 //be displayed |
|
342 ourLine.Zero (); |
|
343 tempstring.Copy(currentstring); //Copy current string to Unicode buffer |
|
344 TKeyCode key = EKeyNull; //current string buffer is 8 bits wide. |
|
345 //Unicode string bufffer (tempstring) is 16 bits wide. |
|
346 for (;;) |
|
347 { |
|
348 if (ourLine.Length () == 0) |
|
349 { |
|
350 iTest.Console()->SetPos (0, iTest.Console()->WhereY ()); |
|
351 iTest.Console()->Printf (_L ("%S"), &ourPrompt); |
|
352 if (tempstring.Length () != 0) //get tempstring's number of items |
|
353 iTest.Console()->Printf (_L (" = %S"), &tempstring); //if not zero print them to iTest.Console() |
|
354 iTest.Console()->Printf (_L (" : ")); |
|
355 iTest.Console()->ClearToEndOfLine (); |
|
356 } |
|
357 key = iTest.Getch(); |
|
358 |
|
359 if (key == EKeyBackspace) |
|
360 { |
|
361 if (ourLine.Length() !=0) |
|
362 { |
|
363 ourLine.SetLength(ourLine.Length()-1); |
|
364 iTest.Console()->Printf (_L ("%c"), key); |
|
365 iTest.Console()->SetPos(iTest.Console()->WhereX(),iTest.Console()->WhereY()); |
|
366 iTest.Console()->ClearToEndOfLine(); |
|
367 } // end if (ourLine.Length() !=0) |
|
368 } // end if (key == KeyBackSpace) |
|
369 |
|
370 |
|
371 if (key == EKeyDelete) |
|
372 { |
|
373 ourLine.Zero(); |
|
374 iTest.Console()->SetPos (0, iTest.Console()->WhereY ()); |
|
375 iTest.Console()->ClearToEndOfLine (); |
|
376 tempstring.Copy(ourLine); |
|
377 break; |
|
378 } |
|
379 |
|
380 if (key == EKeyEnter) |
|
381 break; |
|
382 |
|
383 if (key < 32) |
|
384 { |
|
385 continue; |
|
386 } |
|
387 |
|
388 ourLine.Append (key); |
|
389 iTest.Console()->Printf (_L ("%c"), key); |
|
390 iTest.Console()->SetPos(iTest.Console()->WhereX(),iTest.Console()->WhereY()); |
|
391 iTest.Console()->ClearToEndOfLine(); |
|
392 if (ourLine.Length () == ourLine.MaxLength ()) |
|
393 break; |
|
394 } // end of for statement |
|
395 |
|
396 if ((key == EKeyEnter) && (ourLine.Length () == 0)) |
|
397 tempstring.Copy (currentstring); //copy contents of 8 bit "ourLine" descriptor |
|
398 |
|
399 iTest.Console()->SetPos (0, iTest.Console()->WhereY ()); |
|
400 iTest.Console()->ClearToEndOfLine (); |
|
401 iTest.Console()->Printf (_L ("%S"), &ourPrompt); |
|
402 |
|
403 if ((key == EKeyEnter) && (ourLine.Length() !=0)) |
|
404 tempstring.Copy(ourLine); |
|
405 if (tempstring.Length () != 0) //if temstring length is not zero |
|
406 { |
|
407 iTest.Console()->Printf (_L (" = %S\n"), &tempstring); //print the contents to iTest.Console() |
|
408 LogIt(_L ("%S = %S\n"), &ourPrompt, &tempstring); |
|
409 } |
|
410 |
|
411 else |
|
412 //iTest.Console()->Printf (_L (" is empty")); |
|
413 iTest.Console()->Printf (_L ("\n")); |
|
414 currentstring.Copy(tempstring); //copy 16 bit tempstring descriptor back |
|
415 } |
|
416 |
|
417 |
|
418 EXPORT_C TInt CIpuTestHarness::GetSelection(const TDesC& ourPrompt, const TDesC& validChoices) |
|
419 // |
|
420 // Present the user with a list of options, and get their selection |
|
421 { |
|
422 // If we're scripting, try reading from script first |
|
423 TInt readScriptErr = KErrNotFound; |
|
424 if (iScriptRunning) |
|
425 { |
|
426 TBuf<1> oneCharBuf; |
|
427 readScriptErr = ReadLineFromScript(oneCharBuf); |
|
428 if (!readScriptErr) |
|
429 { |
|
430 return validChoices.Locate((TChar)oneCharBuf[0]); |
|
431 } |
|
432 } |
|
433 |
|
434 // Either not scripting, or hit end of script - continue with user input |
|
435 TKeyCode key = EKeyNull; |
|
436 iTest.Console()->SetPos (0, iTest.Console()->WhereY ()); |
|
437 iTest.Console()->Printf(_L("%S "), &ourPrompt); |
|
438 iTest.Console()->Printf(_L("[%S] :"), &validChoices); |
|
439 TInt retVal = KErrNotFound; |
|
440 while (retVal == KErrNotFound) |
|
441 { |
|
442 key = iTest.Getch(); |
|
443 |
|
444 // Check that key is in the list of valid choices |
|
445 retVal = validChoices.Locate((TChar)key); |
|
446 } |
|
447 iTest.Console()->Printf(_L("%c\n\n"), key); |
|
448 return retVal; |
|
449 } |
|
450 |
|
451 |
|
452 EXPORT_C void CIpuTestHarness::SetScript(RFile& scriptFile) |
|
453 // |
|
454 // Sets the file to be used for a test script - ie. a file that contains commands used by |
|
455 // GetEntry() and GetSelection() |
|
456 { |
|
457 iScriptFile = &scriptFile; |
|
458 iScriptRunning = ETrue; |
|
459 LogIt(_L("***SCRIPT STARTING***\n")); |
|
460 } |
|
461 |
|
462 TInt CIpuTestHarness::ReadLineFromScript(TDes& aBuffer) |
|
463 // |
|
464 // Reads the next line from the script file, and sets the passed-in descriptor with its contents. |
|
465 // Returns KErrNone if reading succeeded; KErrNotFound if the EOF was reached. When EOF is reached, |
|
466 // the file is closed. |
|
467 { |
|
468 // ********************************* |
|
469 // Assume script is 8-bit text file |
|
470 // ********************************* |
|
471 TBool isAComment = ETrue; |
|
472 TInt err = KErrNone; |
|
473 TBuf<512> line; |
|
474 while (isAComment && !err) |
|
475 { |
|
476 TFileText text; |
|
477 text.Set(*iScriptFile); |
|
478 line.SetLength(0); |
|
479 for(;;) |
|
480 { |
|
481 TBuf8<2> c; |
|
482 err = iScriptFile->Read(c,1); |
|
483 if (err && err != KErrEof) |
|
484 { |
|
485 iTest.Printf(_L("Error reading file: %d\n"), err); |
|
486 break; |
|
487 } |
|
488 if (c.Length() == 0) |
|
489 { |
|
490 err = KErrEof; |
|
491 break; |
|
492 } |
|
493 else |
|
494 { |
|
495 if (c[0] == '\n') // break out if it is CR |
|
496 break; |
|
497 else if (c[0] != (TUint8)(0x0d)) // otherwise append the char, _unless_ it is a LF |
|
498 line.Append(c[0]); |
|
499 } |
|
500 } |
|
501 if (err == KErrNone && line.Locate('/') != 0) // comment (only works if it's the first character) |
|
502 { |
|
503 isAComment = EFalse; |
|
504 } |
|
505 } |
|
506 |
|
507 // The line read is not a comment, or have hit end of file |
|
508 if (!err) |
|
509 { |
|
510 // copy to passed in descriptor, but do not allow an overflow |
|
511 aBuffer.Copy(line.Left(aBuffer.MaxLength())); |
|
512 LogIt(_L("***SCRIPT : read command '%S' ***\n"), &aBuffer); |
|
513 } |
|
514 else |
|
515 { |
|
516 iScriptFile->Close(); |
|
517 err = KErrNotFound; |
|
518 iScriptRunning = EFalse; |
|
519 LogIt(_L("***SCRIPT ENDED***\n")); |
|
520 } |
|
521 return err; |
|
522 } |
|
523 |
|
524 void CIpuTestHarness::Panic(TInt aPanic) |
|
525 // |
|
526 // Panic the client program. |
|
527 { |
|
528 User::Panic(KTestPanic,aPanic); |
|
529 } |
|
530 |
|
531 void CIpuTestHarness::TestHarnessComplete() |
|
532 // |
|
533 // Test harness completed without failures |
|
534 { |
|
535 _LIT(KTestCompleteFormat, "Total Tests %d, Failed Tests %d"); |
|
536 TBuf<50> text; |
|
537 text.AppendFormat(KTestCompleteFormat, iTestCount, iFailedTests->Count()); |
|
538 WriteComment(text); |
|
539 WriteComment(KTestHarnessCompleted); |
|
540 } |
|
541 |
|
542 void CIpuTestHarness::TestHarnessFailed() |
|
543 // |
|
544 // Test harness has a failure - log information |
|
545 { |
|
546 TBuf<KMaxFileName + 4> buf; |
|
547 buf.Format(KTestHarnessFailed, iFailedTests->Count()); |
|
548 WriteComment(buf); |
|
549 // Log fialed tests' information |
|
550 for (TInt ii=0; ii<iFailedTests->Count(); ++ii) |
|
551 { |
|
552 CTestInfo* failed = iFailedTests->At(ii); |
|
553 TPtrC name = failed->Name(); |
|
554 LogIt(KTestFailInfo, failed->Number(), &name, failed->ErrorCode()); |
|
555 } |
|
556 } |
|
557 |
|
558 void CIpuTestHarness::ResourceLeakTest() |
|
559 // |
|
560 // Creates a new test that fails if any there are any leaked resource handles |
|
561 { |
|
562 // Start new test |
|
563 _LIT(KResourceTestName, "Resource Handle Leak Test"); |
|
564 TRAPD(testError, StartTestL(KResourceTestName)); |
|
565 if(testError==KErrNone) |
|
566 { |
|
567 // Find number of opened handles |
|
568 TInt processHandleCount=0; |
|
569 TInt threadHandleCount=0; |
|
570 RThread().HandleCount(processHandleCount,threadHandleCount); |
|
571 TInt openHandleCount = iStartHandleCount-threadHandleCount; |
|
572 TInt err = KErrNone; |
|
573 if ( openHandleCount !=0 ) |
|
574 { |
|
575 err = KErrGeneral; |
|
576 LogIt(_L("Number leaked handles is %D"), openHandleCount); |
|
577 } |
|
578 EndTest(err); |
|
579 } |
|
580 else |
|
581 { |
|
582 _LIT(KTxtResourceTestRunError, "Unable to complete Resource Leak Test, error: %d"); |
|
583 LogIt(KTxtResourceTestRunError, testError); |
|
584 EndTest(testError); |
|
585 } |
|
586 } |
|
587 |
|
588 // |
|
589 // CTestInfo |
|
590 // |
|
591 CIpuTestHarness::CTestInfo::CTestInfo() |
|
592 // |
|
593 // Default c'tor |
|
594 { |
|
595 } |
|
596 |
|
597 CIpuTestHarness::CTestInfo::~CTestInfo() |
|
598 // |
|
599 // D'tor |
|
600 { |
|
601 delete iName; |
|
602 } |
|
603 |
|
604 CIpuTestHarness::CTestInfo* CIpuTestHarness::CTestInfo::NewLC(const TDesC& aName, TInt aNumber, TInt aErrorCode) |
|
605 // |
|
606 // Static factory c'tor |
|
607 { |
|
608 CTestInfo* self = new (ELeave) CTestInfo(); |
|
609 CleanupStack::PushL(self); |
|
610 self->ConstructL(aName, aNumber, aErrorCode); |
|
611 return self; |
|
612 } |
|
613 |
|
614 CIpuTestHarness::CTestInfo* CIpuTestHarness::CTestInfo::NewL(const TDesC& aName, TInt aNumber, TInt aErrorCode) |
|
615 // |
|
616 // Static factory c'tor |
|
617 { |
|
618 CTestInfo* self = NewLC(aName, aNumber, aErrorCode); |
|
619 CleanupStack::Pop(); // self |
|
620 return self; |
|
621 } |
|
622 |
|
623 void CIpuTestHarness::CTestInfo::ConstructL(const TDesC& aName, TInt aNumber, TInt aErrorCode) |
|
624 // |
|
625 // Non-trivial c'tor |
|
626 { |
|
627 iName = aName.AllocLC(); |
|
628 CleanupStack::Pop(); // iName |
|
629 |
|
630 iNumber = aNumber; |
|
631 iErrorCode = aErrorCode; |
|
632 } |
|
633 |
|
634 void CIpuTestHarness::CTestInfo::SetNameL(const TDesC& aName) |
|
635 // |
|
636 // Sets iName |
|
637 { |
|
638 HBufC* temp = aName.AllocLC(); |
|
639 CleanupStack::Pop(); // temp |
|
640 delete iName; |
|
641 iName = temp; |
|
642 } |
|
643 |
|
644 void CIpuTestHarness::CTestInfo::SetNumber(TInt aNumber) |
|
645 // |
|
646 // Sets iNumber |
|
647 { |
|
648 iNumber = aNumber; |
|
649 } |
|
650 |
|
651 void CIpuTestHarness::CTestInfo::SetErrorCode(TInt aErrorCode) |
|
652 // |
|
653 // Sets iErrorCode |
|
654 { |
|
655 iErrorCode = aErrorCode; |
|
656 } |