|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Model definition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "alfperfappmodel.h" |
|
20 #include <coemain.h> |
|
21 #include <barsread.h> |
|
22 #include <badesca.h> |
|
23 #include <bautils.h> |
|
24 #include <eikenv.h> |
|
25 |
|
26 #include "alfperfapp.hrh" |
|
27 #include "alfperfapptestcaseselectionview.h" |
|
28 |
|
29 /** |
|
30 * Granularity of execution array. |
|
31 */ |
|
32 const TInt KAlfPerfAppModelExecuteArrayGranularity = 4; |
|
33 |
|
34 /** |
|
35 * Maximum amount of test suites. |
|
36 */ |
|
37 const TInt KAlfPerfAppMaxTestSuites = 255; |
|
38 |
|
39 /** |
|
40 * Maximum amount of test cases. |
|
41 */ |
|
42 const TInt KAlfPerfAppMaxTestCases = 255; |
|
43 |
|
44 /** |
|
45 * Space reserved for this amount of items in execute array. |
|
46 */ |
|
47 const TInt KAlfPerfAppReserveExecution = 100; |
|
48 |
|
49 /** |
|
50 * Class to hold test case information. |
|
51 */ |
|
52 class CAlfPerfAppModelTestCase : public CBase |
|
53 { |
|
54 public: |
|
55 CAlfPerfAppModelTestCase( HBufC* aName, TInt aId, TInt aFlags, TInt aSequenceLength); |
|
56 ~CAlfPerfAppModelTestCase(); |
|
57 void Get( TPtrC& aName, TInt& aId, TInt& aTestCaseFlags, TInt& aTestCaseSequenceLength ) const; |
|
58 TInt Flags(); |
|
59 TInt SequenceIndex(); |
|
60 |
|
61 private: |
|
62 HBufC* iName; |
|
63 // Case ID is negative if this is a sequence case. This need to be taken |
|
64 // into account when doing comparisons. |
|
65 TInt iId; |
|
66 TInt iFlags; |
|
67 TInt iSequenceLength; |
|
68 }; |
|
69 |
|
70 /** |
|
71 * Class to hold test suite information. |
|
72 */ |
|
73 class CAlfPerfAppModelTestSuite : public CBase |
|
74 { |
|
75 public: |
|
76 CAlfPerfAppModelTestSuite( HBufC* aSuite, TInt aFlags ); |
|
77 ~CAlfPerfAppModelTestSuite(); |
|
78 void AppendL( CAlfPerfAppModelTestCase* aCase ); |
|
79 |
|
80 TPtrC Name() const; |
|
81 TInt Flags() const; |
|
82 |
|
83 TInt TestCaseCount() const; |
|
84 void GetTestCase( TInt aIndex, TPtrC& aName, TInt& aId, |
|
85 TInt& aTestCaseFlags, TInt& aTestCaseSequenceLength) const; |
|
86 TInt FindNameById( TPtrC& aName, TInt aId ) const; |
|
87 |
|
88 private: |
|
89 HBufC* iName; |
|
90 TInt iFlags; |
|
91 |
|
92 RPointerArray< CAlfPerfAppModelTestCase > iCases; |
|
93 }; |
|
94 |
|
95 // ============================ MEMBER FUNCTIONS =============================== |
|
96 |
|
97 CAlfPerfAppModel* CAlfPerfAppModel::NewL() |
|
98 { |
|
99 CAlfPerfAppModel* self = new (ELeave) CAlfPerfAppModel; |
|
100 CleanupStack::PushL(self); |
|
101 self->ConstructL(); |
|
102 CleanupStack::Pop(self); // self; |
|
103 return self; |
|
104 } |
|
105 |
|
106 CAlfPerfAppModel::~CAlfPerfAppModel() |
|
107 { |
|
108 iExecuteTestCases.Close(); |
|
109 iSuites.ResetAndDestroy(); |
|
110 delete iErrorMessages; |
|
111 |
|
112 // Close the target file |
|
113 iTargetFile.Close(); |
|
114 iSummaryFile.Close(); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // Loads array of test sets. Each test set contains several test cases. |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CAlfPerfAppModel::LoadTestSetL( TInt aResourceId ) |
|
122 { |
|
123 // Delete previous suites. |
|
124 iSuites.ResetAndDestroy(); |
|
125 iSuites.Close(); |
|
126 |
|
127 TResourceReader reader; |
|
128 CCoeEnv::Static()->CreateResourceReaderLC( reader, aResourceId ); |
|
129 |
|
130 const TInt suiteCount = reader.ReadInt16(); |
|
131 if ( suiteCount > KAlfPerfAppMaxTestSuites ) |
|
132 { |
|
133 User::Leave( KErrArgument ); |
|
134 } |
|
135 |
|
136 for ( TInt ii = 0; ii < suiteCount; ii++ ) |
|
137 { |
|
138 HBufC* suiteName = reader.ReadHBufCL(); |
|
139 CleanupStack::PushL( suiteName ); |
|
140 |
|
141 const TInt flags = reader.ReadInt16(); |
|
142 |
|
143 CAlfPerfAppModelTestSuite* suite = new (ELeave) |
|
144 CAlfPerfAppModelTestSuite( suiteName, flags ); |
|
145 CleanupStack::Pop( suiteName ); |
|
146 CleanupStack::PushL( suite ); |
|
147 |
|
148 const TInt testCaseCount = reader.ReadInt16(); |
|
149 if ( testCaseCount > KAlfPerfAppMaxTestCases ) |
|
150 { |
|
151 User::Leave( KErrArgument ); |
|
152 } |
|
153 |
|
154 for ( TInt jj = 0; jj < testCaseCount; jj++ ) |
|
155 { |
|
156 TInt caseId = reader.ReadInt16(); |
|
157 HBufC* name = reader.ReadHBufCL(); |
|
158 CleanupStack::PushL( name ); |
|
159 const TInt flags = reader.ReadInt16(); |
|
160 const TInt sequenceLength = reader.ReadInt16(); |
|
161 |
|
162 // Mark sequence cases |
|
163 if(sequenceLength > 0) |
|
164 { |
|
165 caseId *= -1; |
|
166 } |
|
167 |
|
168 CAlfPerfAppModelTestCase* testCase = |
|
169 new (ELeave) CAlfPerfAppModelTestCase( name, caseId, flags, sequenceLength ); |
|
170 CleanupStack::Pop( name ); |
|
171 #ifdef ALFPERFAPP_ENABLE_INACTIVE_FLAG_CASES |
|
172 // If ALFPERFAPP_ENABLE_INACTIVE_FLAG_CASES is defined, just ignore flags |
|
173 CleanupStack::PushL( testCase ); |
|
174 suite->AppendL( testCase ); |
|
175 CleanupStack::Pop( testCase ); |
|
176 #else |
|
177 // Otherwise check that one of the flags is not EAlfPerfAppTestCaseFlagRequiresInActiveFlag |
|
178 if(!(testCase->Flags() & EAlfPerfAppTestCaseFlagRequiresInActiveFlag)) |
|
179 { |
|
180 CleanupStack::PushL( testCase ); |
|
181 suite->AppendL( testCase ); |
|
182 CleanupStack::Pop( testCase ); |
|
183 } |
|
184 else |
|
185 { |
|
186 delete testCase; |
|
187 } |
|
188 #endif // ALFPERFAPP_ENABLE_INACTIVE_FLAG_CASES |
|
189 |
|
190 } |
|
191 |
|
192 iSuites.AppendL( suite ); |
|
193 CleanupStack::Pop( suite ); |
|
194 } |
|
195 |
|
196 CleanupStack::PopAndDestroy(); |
|
197 } |
|
198 |
|
199 TInt CAlfPerfAppModel::SuiteCount() const |
|
200 { |
|
201 return iSuites.Count(); |
|
202 } |
|
203 |
|
204 TPtrC CAlfPerfAppModel::SuiteName( TInt aSuiteIndex ) const |
|
205 { |
|
206 return iSuites[ aSuiteIndex ]->Name(); |
|
207 } |
|
208 |
|
209 TInt CAlfPerfAppModel::SuiteFlags( TInt aSuiteIndex ) const |
|
210 { |
|
211 return iSuites[ aSuiteIndex ]->Flags(); |
|
212 } |
|
213 |
|
214 TInt CAlfPerfAppModel::TestCaseCount( TInt aSuiteIndex ) const |
|
215 { |
|
216 return iSuites[ aSuiteIndex ]->TestCaseCount(); |
|
217 } |
|
218 |
|
219 void CAlfPerfAppModel::GetTestCase( |
|
220 TInt aSuiteIndex, |
|
221 TInt aTestCaseIndex, |
|
222 TPtrC& aTestCaseName, |
|
223 TInt& aTestCaseId, |
|
224 TInt& aTestCaseFlags, |
|
225 TInt& aTestCaseSequenceLength) const |
|
226 { |
|
227 iSuites[ aSuiteIndex ]->GetTestCase( |
|
228 aTestCaseIndex, aTestCaseName, aTestCaseId, aTestCaseFlags, aTestCaseSequenceLength ); |
|
229 } |
|
230 |
|
231 TInt CAlfPerfAppModel::FindById( |
|
232 TInt aCaseId, |
|
233 TPtrC& aSuiteName, |
|
234 TPtrC& aTestCaseName ) const |
|
235 { |
|
236 const TInt count = iSuites.Count(); |
|
237 TInt result = KErrNotFound; |
|
238 |
|
239 for ( TInt ii = 0; ii < count; ii++ ) |
|
240 { |
|
241 if ( iSuites[ ii ]->FindNameById( aTestCaseName, aCaseId ) != |
|
242 KErrNotFound ) |
|
243 { |
|
244 aSuiteName.Set( iSuites[ ii ]->Name() ); |
|
245 result = KErrNone; |
|
246 break; |
|
247 } |
|
248 } |
|
249 |
|
250 return result; |
|
251 } |
|
252 |
|
253 void CAlfPerfAppModel::ResetExecuteArray() |
|
254 { |
|
255 // Clear array without releasing memory |
|
256 while ( iExecuteTestCases.Count() ) |
|
257 { |
|
258 iExecuteTestCases.Remove( iExecuteTestCases.Count() - 1 ); |
|
259 } |
|
260 } |
|
261 |
|
262 void CAlfPerfAppModel::AddToExecuteArrayL( TInt aCaseId ) |
|
263 { |
|
264 iExecuteTestCases.AppendL( aCaseId ); |
|
265 } |
|
266 |
|
267 TBool CAlfPerfAppModel::GetFromExecuteArray( TInt& aCaseId ) |
|
268 { |
|
269 TBool result = EFalse; |
|
270 if ( iExecuteTestCases.Count() ) |
|
271 { |
|
272 result = ETrue; |
|
273 aCaseId = iExecuteTestCases[ 0 ]; |
|
274 iExecuteTestCases.Remove( 0 ); |
|
275 } |
|
276 |
|
277 return result; |
|
278 } |
|
279 |
|
280 void CAlfPerfAppModel::AddToResultFilesL( const TTestCaseResultItem& aItem) |
|
281 { |
|
282 iResultItemsNotAddedToFile = EFalse; |
|
283 |
|
284 static TUint32 timeStampAtCaseStart = 0; |
|
285 static TUint32 timeStampAtPhaseStart = 0; |
|
286 static TUint frameCountAtPhaseStart = 0; |
|
287 static TInt currentCase = 0; |
|
288 static TInt currentPhase = 0; |
|
289 static TBool firstCase = ETrue; |
|
290 TBool caseChanged = EFalse; |
|
291 |
|
292 if ( firstCase || currentCase != aItem.iCaseId ) |
|
293 { |
|
294 // Test case changed. |
|
295 currentCase = aItem.iCaseId; |
|
296 timeStampAtCaseStart = aItem.iTimeStamp; |
|
297 caseChanged = ETrue; |
|
298 firstCase = EFalse; |
|
299 } |
|
300 |
|
301 if ( caseChanged || currentPhase != aItem.iPhase ) |
|
302 { |
|
303 // Test case phase changed. |
|
304 currentPhase = aItem.iPhase; |
|
305 timeStampAtPhaseStart = aItem.iTimeStamp; |
|
306 frameCountAtPhaseStart = aItem.iFrameCount; |
|
307 } |
|
308 |
|
309 |
|
310 // Get Suite and Case name |
|
311 TPtrC testSuite; |
|
312 TPtrC testCase; |
|
313 FindById( aItem.iCaseId, testSuite, testCase ); |
|
314 TBuf<KAlfPerfAppMaxCharsInLine> testSuiteName(testSuite); |
|
315 TBuf8<KAlfPerfAppMaxCharsInLine> testSuiteName8; |
|
316 testSuiteName8.Copy(testSuiteName); |
|
317 TBuf<KAlfPerfAppMaxCharsInLine> testCaseName(testCase); |
|
318 TBuf8<KAlfPerfAppMaxCharsInLine> testCaseName8; |
|
319 testCaseName8.Copy(testCaseName); |
|
320 |
|
321 |
|
322 TUint32 msSinceCase = |
|
323 CAlfPerfAppTestCaseSelectionView::DeltaFromCurrentToPrevious( aItem.iTimeStamp, timeStampAtCaseStart ); |
|
324 TUint32 msSincePhase = |
|
325 CAlfPerfAppTestCaseSelectionView::DeltaFromCurrentToPrevious( aItem.iTimeStamp, timeStampAtPhaseStart ); |
|
326 TUint framesSincePhase = |
|
327 aItem.iFrameCount - frameCountAtPhaseStart; |
|
328 |
|
329 TReal32 fps = 0.0; |
|
330 if ( msSincePhase != 0 ) |
|
331 { |
|
332 fps = framesSincePhase; |
|
333 fps *= 1000; |
|
334 fps /= msSincePhase; |
|
335 } |
|
336 |
|
337 // Write to main file |
|
338 TBuf8<KAlfPerfAppMaxCharsInLine * 2> line; // * 2 because casespecific results can be 256 chars |
|
339 line.Format( KAlfPerfAppPrintFormatData, |
|
340 &testSuiteName8, &testCaseName8,aItem.iCaseId, aItem.iPhase, |
|
341 aItem.iTimeStamp, |
|
342 aItem.iAppCells, aItem.iAppMemory, aItem.iAppFree, |
|
343 aItem.iServerCells, aItem.iServerMemory, aItem.iServerFree, |
|
344 aItem.iSystemMemory, aItem.iSystemFree, |
|
345 framesSincePhase, msSinceCase, msSincePhase, |
|
346 fps, &aItem.specificResult8); |
|
347 iTargetFile.Write(line); |
|
348 |
|
349 // Write to summary file |
|
350 static TInt lastPhase = -1; // -1 to mark first time |
|
351 static TInt appMemoryPhaseStart = 0; // Value doensn't matter because next |
|
352 static TInt serverMemoryPhaseStart = 0;// if fails at the first time |
|
353 static TInt systemMemoryPhaseStart = 0; |
|
354 |
|
355 |
|
356 // Only print this if this was the second time this phase is here (end of phase results) |
|
357 if(lastPhase == aItem.iPhase) |
|
358 { |
|
359 line.Format(KAlfPerfAppSummaryPrintFormatData, |
|
360 &testSuiteName8, &testCaseName8,aItem.iCaseId, aItem.iPhase, |
|
361 aItem.iAppMemory - appMemoryPhaseStart, |
|
362 aItem.iServerMemory - serverMemoryPhaseStart, |
|
363 aItem.iSystemMemory - systemMemoryPhaseStart, |
|
364 framesSincePhase,msSincePhase,fps,&aItem.specificResult8); |
|
365 iSummaryFile.Write(line); |
|
366 } |
|
367 else |
|
368 { |
|
369 // If this was the beginning of phase, record memory values |
|
370 appMemoryPhaseStart = aItem.iAppMemory; |
|
371 serverMemoryPhaseStart = aItem.iServerMemory; |
|
372 systemMemoryPhaseStart = aItem.iSystemMemory; |
|
373 } |
|
374 // Set the lastPhase |
|
375 lastPhase = aItem.iPhase; |
|
376 } |
|
377 |
|
378 void CAlfPerfAppModel::AddToErrorArrayL( const TDesC& aMessage ) |
|
379 { |
|
380 if ( !iErrorMessages ) |
|
381 { |
|
382 iErrorMessages = new (ELeave) CDesC16ArrayFlat( 8 ); |
|
383 } |
|
384 |
|
385 iErrorMessages->AppendL( aMessage ); |
|
386 } |
|
387 |
|
388 TInt CAlfPerfAppModel::ErrorArrayCount() |
|
389 { |
|
390 TInt count = 0; |
|
391 if ( iErrorMessages ) |
|
392 { |
|
393 count = iErrorMessages->MdcaCount(); |
|
394 } |
|
395 return count; |
|
396 } |
|
397 |
|
398 void CAlfPerfAppModel::GetFromErrorArray( TInt aIndex, TPtrC& aMessage ) |
|
399 { |
|
400 aMessage.Set( KNullDesC ); |
|
401 if ( iErrorMessages ) |
|
402 { |
|
403 if ( aIndex >= 0 && aIndex < iErrorMessages->MdcaCount() ) |
|
404 { |
|
405 aMessage.Set( iErrorMessages->MdcaPoint( aIndex ) ); |
|
406 } |
|
407 } |
|
408 } |
|
409 |
|
410 void CAlfPerfAppModel::ResetErrorArray() |
|
411 { |
|
412 delete iErrorMessages; |
|
413 iErrorMessages = NULL; |
|
414 } |
|
415 |
|
416 TBool CAlfPerfAppModel::ResultsNotAddedToFile() |
|
417 { |
|
418 return iResultItemsNotAddedToFile; |
|
419 } |
|
420 |
|
421 RFile* CAlfPerfAppModel::ResultFile() |
|
422 { |
|
423 return &iTargetFile; |
|
424 } |
|
425 |
|
426 TFileName CAlfPerfAppModel::TargetPath() |
|
427 { |
|
428 return iTargetPath; |
|
429 } |
|
430 |
|
431 TBool CAlfPerfAppModel::TargetFilesExisted() |
|
432 { |
|
433 return iFilesExisted; |
|
434 } |
|
435 |
|
436 void CAlfPerfAppModel::OpenFilesL(TBool reset) |
|
437 { |
|
438 TBuf8<KAlfPerfAppMaxCharsInLine> line; |
|
439 |
|
440 // If the files are open, close them |
|
441 if(iFilesOpened) |
|
442 { |
|
443 iTargetFile.Close(); |
|
444 iSummaryFile.Close(); |
|
445 iResultItemsNotAddedToFile = ETrue; |
|
446 } |
|
447 |
|
448 iTargetFileServerSession = CEikonEnv::Static()->FsSession(); |
|
449 |
|
450 // Ready the target and summary file names |
|
451 iTargetPath = KAlfPerfAppOutputFilePath2; |
|
452 iTargetFileName = KAlfPerfAppOutputFilePath2; |
|
453 iSummaryFileName = KAlfPerfAppOutputFilePath2; |
|
454 if (!BaflUtils::FolderExists(iTargetFileServerSession, iTargetFileName)) |
|
455 { |
|
456 iTargetPath = KAlfPerfAppOutputFilePath1; |
|
457 iTargetFileName = KAlfPerfAppOutputFilePath1; |
|
458 iSummaryFileName = KAlfPerfAppOutputFilePath1; |
|
459 } |
|
460 |
|
461 iTargetFileName.Append( KAlfPerfAppPrintPathSeparator ); |
|
462 iTargetFileName.Append( KAlfPerfAppOutputFileName ); |
|
463 iSummaryFileName.Append( KAlfPerfAppPrintPathSeparator ); |
|
464 iSummaryFileName.Append(KAlfPerfAppSummaryFileName); |
|
465 |
|
466 // Check if the files are already in place |
|
467 TBool targetFileWasThere = BaflUtils::FileExists(iTargetFileServerSession,iTargetFileName); |
|
468 TBool summaryFileWasThere = BaflUtils::FileExists(iTargetFileServerSession,iSummaryFileName); |
|
469 |
|
470 iFilesExisted = targetFileWasThere || summaryFileWasThere; |
|
471 |
|
472 // Create the directory and files |
|
473 iTargetFileServerSession.MkDirAll(iTargetFileName); |
|
474 |
|
475 // If caller forced clearing of files |
|
476 if(reset) |
|
477 { |
|
478 // Files were closed in the beginning of this function |
|
479 BaflUtils::DeleteFile(iTargetFileServerSession,iTargetFileName); |
|
480 BaflUtils::DeleteFile(iTargetFileServerSession,iSummaryFileName); |
|
481 targetFileWasThere = EFalse; |
|
482 summaryFileWasThere = EFalse; |
|
483 } |
|
484 |
|
485 |
|
486 |
|
487 // Create or reopen the target file |
|
488 TInt targetLoc = 0; |
|
489 if(targetFileWasThere) |
|
490 { |
|
491 User::LeaveIfError(iTargetFile.Open(iTargetFileServerSession, |
|
492 iTargetFileName, EFileWrite|EFileShareExclusive)); |
|
493 iTargetFile.Seek(ESeekEnd,targetLoc); |
|
494 } |
|
495 else |
|
496 { |
|
497 User::LeaveIfError(iTargetFile.Create(iTargetFileServerSession, |
|
498 iTargetFileName, EFileWrite|EFileShareExclusive)); |
|
499 line.Format( KAlfPerfAppPrintFormatHeader ); |
|
500 iTargetFile.Write(line); |
|
501 } |
|
502 |
|
503 // Create or reopen the summary file |
|
504 if(summaryFileWasThere) |
|
505 { |
|
506 User::LeaveIfError(iSummaryFile.Open(iTargetFileServerSession, |
|
507 iSummaryFileName, EFileWrite|EFileShareExclusive)); |
|
508 iSummaryFile.Seek(ESeekEnd,targetLoc); |
|
509 } |
|
510 else |
|
511 { |
|
512 User::LeaveIfError(iSummaryFile.Create(iTargetFileServerSession, |
|
513 iSummaryFileName, EFileWrite|EFileShareExclusive)); |
|
514 line.Format(KAlfPerfAppSummaryPrintFormatHeader); |
|
515 iSummaryFile.Write(line); |
|
516 } |
|
517 |
|
518 iResultItemsNotAddedToFile = ETrue; |
|
519 } |
|
520 |
|
521 |
|
522 CAlfPerfAppModel::CAlfPerfAppModel() |
|
523 : iExecuteTestCases( KAlfPerfAppModelExecuteArrayGranularity ) |
|
524 { |
|
525 } |
|
526 |
|
527 void CAlfPerfAppModel::ConstructL() |
|
528 { |
|
529 |
|
530 iExecuteTestCases.ReserveL( KAlfPerfAppReserveExecution ); |
|
531 |
|
532 // Let's open the target files |
|
533 iFilesOpened = EFalse; |
|
534 OpenFilesL(); // Don't force clearing |
|
535 iFilesOpened = ETrue; |
|
536 } |
|
537 |
|
538 // |
|
539 // Implementation of CAlfPerfAppTestCase: |
|
540 // |
|
541 |
|
542 CAlfPerfAppModelTestCase::CAlfPerfAppModelTestCase( HBufC* aName, TInt aId, TInt aFlags, TInt aSequenceLength ) |
|
543 : iName( aName ), iId( aId ), iFlags(aFlags), iSequenceLength(aSequenceLength) |
|
544 { |
|
545 } |
|
546 |
|
547 CAlfPerfAppModelTestCase::~CAlfPerfAppModelTestCase() |
|
548 { |
|
549 delete iName; |
|
550 } |
|
551 |
|
552 void CAlfPerfAppModelTestCase::Get( TPtrC& aName, TInt& aId,TInt& aTestCaseFlags, TInt& aTestCaseSequenceLength ) const |
|
553 { |
|
554 aName.Set( KNullDesC ); |
|
555 if ( iName ) |
|
556 { |
|
557 aName.Set( *iName ); |
|
558 } |
|
559 aId = iId; |
|
560 aTestCaseFlags = iFlags; |
|
561 aTestCaseSequenceLength = iSequenceLength; |
|
562 } |
|
563 |
|
564 TInt CAlfPerfAppModelTestCase::Flags() |
|
565 { |
|
566 return iFlags; |
|
567 } |
|
568 |
|
569 TInt CAlfPerfAppModelTestCase::SequenceIndex() |
|
570 { |
|
571 return iSequenceLength; |
|
572 } |
|
573 |
|
574 // |
|
575 // Implementation of CAlfPerfAppTestSuite: |
|
576 // |
|
577 |
|
578 CAlfPerfAppModelTestSuite::CAlfPerfAppModelTestSuite( HBufC* aSuite, TInt aFlags ) |
|
579 : iName( aSuite ), iFlags( aFlags ), iCases( 4 ) |
|
580 { |
|
581 } |
|
582 |
|
583 CAlfPerfAppModelTestSuite::~CAlfPerfAppModelTestSuite() |
|
584 { |
|
585 delete iName; |
|
586 iCases.ResetAndDestroy(); |
|
587 } |
|
588 |
|
589 void CAlfPerfAppModelTestSuite::AppendL( CAlfPerfAppModelTestCase* aCase ) |
|
590 { |
|
591 iCases.AppendL( aCase ); |
|
592 } |
|
593 |
|
594 TPtrC CAlfPerfAppModelTestSuite::Name() const |
|
595 { |
|
596 TPtrC name( KNullDesC ); |
|
597 if ( iName ) |
|
598 { |
|
599 name.Set( *iName ); |
|
600 } |
|
601 return name; |
|
602 } |
|
603 |
|
604 TInt CAlfPerfAppModelTestSuite::Flags() const |
|
605 { |
|
606 return iFlags; |
|
607 } |
|
608 |
|
609 TInt CAlfPerfAppModelTestSuite::TestCaseCount() const |
|
610 { |
|
611 return iCases.Count(); |
|
612 } |
|
613 |
|
614 void CAlfPerfAppModelTestSuite::GetTestCase( |
|
615 TInt aIndex, TPtrC& aName, TInt& aId, |
|
616 TInt& aTestCaseFlags, TInt& aTestCaseSequenceLength ) const |
|
617 { |
|
618 return iCases[ aIndex ]->Get( aName, aId, aTestCaseFlags, aTestCaseSequenceLength ); |
|
619 } |
|
620 |
|
621 |
|
622 TInt CAlfPerfAppModelTestSuite::FindNameById( TPtrC& aName, TInt aId ) const |
|
623 { |
|
624 const TInt count = iCases.Count(); |
|
625 TInt result = KErrNotFound; |
|
626 |
|
627 for ( TInt ii = 0; ii < count; ii++ ) |
|
628 { |
|
629 TPtrC name; |
|
630 TInt id; |
|
631 TInt flags; |
|
632 TInt sequenceLength; |
|
633 |
|
634 iCases[ ii ]->Get( name, id, flags, sequenceLength ); |
|
635 |
|
636 if ( aId == id ) |
|
637 { |
|
638 result = KErrNone; |
|
639 aName.Set( name ); |
|
640 break; |
|
641 } |
|
642 } |
|
643 |
|
644 return result; |
|
645 } |