1 /* |
|
2 * Copyright (c) 2009 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: This module contains implementation of CUIStore |
|
15 * and CModule class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32base.h> |
|
21 #include <e32svr.h> |
|
22 #include <f32file.h> |
|
23 #include <e32uid.h> |
|
24 #include <collate.h> |
|
25 |
|
26 #include <StifLogger.h> |
|
27 |
|
28 #include "Logging.h" |
|
29 #include <stifinternal/UIStore.h> |
|
30 #include <stifinternal/UIEngine.h> |
|
31 #include <stifinternal/UIStoreContainer.h> |
|
32 #include "UIStorePopup.h" |
|
33 #include <stifinternal/UIEngineContainer.h> |
|
34 |
|
35 |
|
36 // EXTERNAL DATA STRUCTURES |
|
37 |
|
38 // EXTERNAL FUNCTION PROTOTYPES |
|
39 |
|
40 // CONSTANTS |
|
41 //@spe _LIT(KNameTxt,"TEST FRAMEWORK"); |
|
42 //@spe _LIT(KNameBase,"BASE"); |
|
43 _LIT( KUIStore, "CUiStore" ); |
|
44 _LIT( KUIStoreIf, "CUiStoreIf" ); |
|
45 //_LIT( KUIStoreDefaultDir, "C:\\TestFramework\\" ); |
|
46 |
|
47 _LIT( KUIStoreSetStart, "[TestSetStart]" ); |
|
48 _LIT( KUIStoreSetEnd, "[TestSetEnd]" ); |
|
49 _LIT( KUIStoreSetCaseStart, "[TestSetCaseStart]" ); |
|
50 _LIT( KUIStoreSetCaseEnd, "[TestSetCaseEnd]" ); |
|
51 _LIT( KUIStoreCaseModuleName, "ModuleName=" ); |
|
52 _LIT( KUIStoreTestCaseTitle, "Title=" ); |
|
53 _LIT( KUIStoreTestCaseFile, "TestCaseFile="); |
|
54 _LIT( KUIStoreTestCaseNum, "TestCaseNum="); |
|
55 _LIT( KUIStoreCaseExpectedResult, "ExpectedResult="); |
|
56 _LIT( KUIStoreCasePriority, "Priority="); |
|
57 _LIT( KUIStoreCaseTimeout, "Timeout="); |
|
58 _LIT( KUIStoreLastStartedCaseIndex, "LastStartedCaseIndex="); |
|
59 |
|
60 |
|
61 _LIT( KUIStoreDefaultRebootFile, "TestFrameworkUIReboot.txt" ); |
|
62 _LIT( KUIStoreStartTest, "[StartTestCase]" ); |
|
63 _LIT( KUIStoreStartTestEnd, "[StartTestCaseEnd]" ); |
|
64 |
|
65 _LIT( KUIStoreCaseStatus, "TestCaseStatus="); |
|
66 _LIT( KUIStoreCaseExecutionResult, "TestCaseExecutionResult="); |
|
67 _LIT( KUIStoreCaseResult, "TestCaseResult="); |
|
68 _LIT( KUIStoreCaseStartTime, "TestCaseStartTime="); |
|
69 _LIT( KUIStoreCaseEndTime, "TestCaseEndTime="); |
|
70 |
|
71 const TInt KRcpHeaderLen = 16; |
|
72 const TInt KFixedStartedCaseIndex = 10; |
|
73 |
|
74 // MACROS |
|
75 #ifdef LOGGER |
|
76 #undef LOGGER |
|
77 #endif |
|
78 #define LOGGER iLogger |
|
79 |
|
80 // LOCAL CONSTANTS AND MACROS |
|
81 static const TUid KUidTestModule = { 0x101FB3E7 }; |
|
82 |
|
83 // MODULE DATA STRUCTURES |
|
84 |
|
85 // LOCAL FUNCTION PROTOTYPES |
|
86 |
|
87 // FORWARD DECLARATIONS |
|
88 |
|
89 |
|
90 // ==================== LOCAL FUNCTIONS ======================================= |
|
91 |
|
92 // None |
|
93 |
|
94 // ================= MEMBER FUNCTIONS ========================================= |
|
95 |
|
96 /* |
|
97 ------------------------------------------------------------------------------- |
|
98 |
|
99 Class: CUIStore |
|
100 |
|
101 Method: NewL |
|
102 |
|
103 Description: Construct the CUIStore class |
|
104 |
|
105 Parameters: None |
|
106 |
|
107 Return Values: CUIStore* New object |
|
108 |
|
109 Errors/Exceptions: Leaves if memory allocation fails or |
|
110 ConstructL leaves. |
|
111 |
|
112 Status: Draft |
|
113 |
|
114 ------------------------------------------------------------------------------- |
|
115 */ |
|
116 CUIStore* CUIStore::NewL( CUIStoreIf* aUIStoreIf ) |
|
117 { |
|
118 |
|
119 CUIStore* self = new ( ELeave ) CUIStore( aUIStoreIf ); |
|
120 CleanupStack::PushL( self ); |
|
121 self->ConstructL(); |
|
122 CleanupStack::Pop( self ); |
|
123 |
|
124 return self; |
|
125 |
|
126 } |
|
127 |
|
128 |
|
129 /* |
|
130 ------------------------------------------------------------------------------- |
|
131 |
|
132 Class: CUIStore |
|
133 |
|
134 Method: ConstructL |
|
135 |
|
136 Description: Second level constructor. |
|
137 |
|
138 Construct the console |
|
139 Construct module and case containers |
|
140 Retrieve command line parameters |
|
141 Connect to test engine |
|
142 |
|
143 Parameters: None |
|
144 |
|
145 Return Values: None |
|
146 |
|
147 Errors/Exceptions: Leaves if memory allocation fails or fileserver or |
|
148 test engine can't be connected. |
|
149 |
|
150 Status: Draft |
|
151 |
|
152 ------------------------------------------------------------------------------- |
|
153 */ |
|
154 void CUIStore::ConstructL( ) |
|
155 { |
|
156 } |
|
157 |
|
158 |
|
159 /* |
|
160 ------------------------------------------------------------------------------- |
|
161 |
|
162 Class: CUIStore |
|
163 |
|
164 Method: CUIStore |
|
165 |
|
166 Description: Constructor. |
|
167 Initialize non-zero member variables. |
|
168 |
|
169 Parameters: None |
|
170 |
|
171 Return Values: None |
|
172 |
|
173 Errors/Exceptions: None |
|
174 |
|
175 Status: Draft |
|
176 |
|
177 ------------------------------------------------------------------------------- |
|
178 */ |
|
179 CUIStore::CUIStore( CUIStoreIf* aUIStoreIf ): |
|
180 iUIStoreIf( aUIStoreIf ), |
|
181 iUpdateNeeded( ETrue ), |
|
182 iActivePopupPriority( EPopupPriorityLow ) |
|
183 { |
|
184 } |
|
185 |
|
186 /* |
|
187 ------------------------------------------------------------------------------- |
|
188 |
|
189 Class: CUIStore |
|
190 |
|
191 Method: ~CUIStore |
|
192 |
|
193 Description: Destructor |
|
194 |
|
195 Parameters: None |
|
196 |
|
197 Return Values: None |
|
198 |
|
199 Errors/Exceptions: None |
|
200 |
|
201 Status: Draft |
|
202 |
|
203 ------------------------------------------------------------------------------- |
|
204 */ |
|
205 CUIStore::~CUIStore( ) |
|
206 { |
|
207 |
|
208 iFileList.ResetAndDestroy(); |
|
209 iFileList.Close(); |
|
210 iStartedTestSets.ResetAndDestroy(); |
|
211 iStartedTestSets.Close(); |
|
212 |
|
213 iStartedTestCases.ResetAndDestroy(); |
|
214 iStartedTestCases.Close(); |
|
215 |
|
216 iTestSets.ResetAndDestroy(); |
|
217 iTestSets.Close(); |
|
218 |
|
219 iTestCases.ResetAndDestroy(); |
|
220 iTestCases.Close(); |
|
221 |
|
222 iPopups.ResetAndDestroy(); |
|
223 iPopups.Close(); |
|
224 |
|
225 delete iUIEngine; |
|
226 iUIEngine = 0; |
|
227 |
|
228 } |
|
229 /* |
|
230 ------------------------------------------------------------------------------- |
|
231 |
|
232 Class: CStifTFwIf |
|
233 |
|
234 Method: Open |
|
235 |
|
236 Description: Open test engine. |
|
237 |
|
238 Parameters: TDesC& aTestFrameworkIni: in: Initialization file to Test Framework |
|
239 |
|
240 Return Values: Symbian OS error: Error code |
|
241 |
|
242 Errors/Exceptions: None |
|
243 |
|
244 Status: Draft |
|
245 |
|
246 ------------------------------------------------------------------------------- |
|
247 */ |
|
248 EXPORT_C TInt CUIStore::Open( const TDesC& aTestFrameworkIni ) |
|
249 { |
|
250 |
|
251 if( aTestFrameworkIni.Length() > KMaxFileName ) |
|
252 { |
|
253 return KErrArgument; |
|
254 } |
|
255 |
|
256 TRAPD( err, |
|
257 iUIEngine = CUIEngine::NewL( this ); |
|
258 ); |
|
259 if( err != KErrNone ) |
|
260 { |
|
261 return err; |
|
262 } |
|
263 |
|
264 TFileName ini( aTestFrameworkIni ); |
|
265 // Check given ini file |
|
266 TRAP( err, CheckIniL( ini ) ); |
|
267 |
|
268 // Store folder of initialization file to open it again when looking for filters |
|
269 RDebug::Print(_L("CUIStore stores name of ini file [%S]"), &ini); |
|
270 iTestFrameworkIni.Copy(ini); |
|
271 |
|
272 return iUIEngine->Open( ini ); |
|
273 |
|
274 } |
|
275 |
|
276 |
|
277 /* |
|
278 ------------------------------------------------------------------------------- |
|
279 |
|
280 Class: CUIStore |
|
281 |
|
282 Method: Close |
|
283 |
|
284 Description: Close test engine. |
|
285 |
|
286 Parameters: None |
|
287 |
|
288 Return Values: TInt KErrNone: Always returned KErrNone |
|
289 |
|
290 Errors/Exceptions: None |
|
291 |
|
292 Status: Draft |
|
293 |
|
294 ------------------------------------------------------------------------------- |
|
295 */ |
|
296 EXPORT_C TInt CUIStore::Close() |
|
297 { |
|
298 |
|
299 TInt ret = KErrNone; |
|
300 if( iUIEngine != NULL ) |
|
301 { |
|
302 ret = iUIEngine->Close(); |
|
303 |
|
304 delete iUIEngine; |
|
305 iUIEngine = 0; |
|
306 } |
|
307 |
|
308 return ret; |
|
309 |
|
310 } |
|
311 |
|
312 /* |
|
313 ------------------------------------------------------------------------------- |
|
314 |
|
315 Class: CUIStore |
|
316 |
|
317 Method: AddTestModule |
|
318 |
|
319 Description: Add test module to module list of test engine |
|
320 |
|
321 Parameters: TDesC& aModuleName: in: Testmodule, which is added to module list |
|
322 TDesC& aIniFile: in: Initialization file to the test module |
|
323 |
|
324 Return Values: Symbian OS error: Error code |
|
325 |
|
326 Errors/Exceptions: None |
|
327 |
|
328 Status: Draft |
|
329 |
|
330 ------------------------------------------------------------------------------- |
|
331 */ |
|
332 EXPORT_C TInt CUIStore::AddTestModule( const TDesC& aModuleName, |
|
333 const TDesC& aIniFile ) |
|
334 { |
|
335 |
|
336 TInt ret = iUIEngine->AddTestModule( aModuleName, aIniFile ); |
|
337 |
|
338 RefreshAllCases(); |
|
339 |
|
340 return ret; |
|
341 |
|
342 } |
|
343 |
|
344 |
|
345 /* |
|
346 ------------------------------------------------------------------------------- |
|
347 |
|
348 Class: CUIStore |
|
349 |
|
350 Method: RemoveTestModule |
|
351 |
|
352 Description: Add test module to module list of test engine |
|
353 |
|
354 Parameters: TDesC& aModuleName: in: Testmodule, which is removed of module list |
|
355 |
|
356 Return Values: Symbian OS error: Error code |
|
357 |
|
358 Errors/Exceptions: None |
|
359 |
|
360 Status: Draft |
|
361 |
|
362 ------------------------------------------------------------------------------- |
|
363 */ |
|
364 EXPORT_C TInt CUIStore::RemoveTestModule( const TDesC& aModuleName ) |
|
365 { |
|
366 |
|
367 TInt ret = iUIEngine->RemoveTestModule( aModuleName ); |
|
368 |
|
369 RefreshAllCases(); |
|
370 |
|
371 return ret; |
|
372 |
|
373 } |
|
374 |
|
375 |
|
376 /* |
|
377 ------------------------------------------------------------------------------- |
|
378 |
|
379 Class: CUIStore |
|
380 |
|
381 Method: AddTestCaseFile |
|
382 |
|
383 Description: Add test case file to test case file list of test engine |
|
384 |
|
385 Parameters: TDesC& aModuleName: in: Testmodule, which own test cases of test case list. |
|
386 TDesC& aCaseFile: in: Test case list, which is added to test case list |
|
387 |
|
388 Return Values: Symbian OS error: Error code |
|
389 |
|
390 Errors/Exceptions: None |
|
391 |
|
392 Status: Draft |
|
393 |
|
394 ------------------------------------------------------------------------------- |
|
395 */ |
|
396 EXPORT_C TInt CUIStore::AddTestCaseFile( const TDesC& aModuleName, |
|
397 const TDesC& aCaseFile ) |
|
398 { |
|
399 |
|
400 TInt ret = iUIEngine->AddTestCaseFile( aModuleName, aCaseFile ); |
|
401 |
|
402 RefreshAllCases(); |
|
403 |
|
404 return ret; |
|
405 |
|
406 } |
|
407 |
|
408 |
|
409 /* |
|
410 ------------------------------------------------------------------------------- |
|
411 |
|
412 Class: CUIStore |
|
413 |
|
414 Method: RemoveTestCaseFile |
|
415 |
|
416 Description: Remove test case file of test case file list of test engine |
|
417 |
|
418 Parameters: TDesC& aModuleName: in: Testmodule, which own test cases of test case list |
|
419 TDesC& aCaseFile: in: Test case list, which is removed of test case list |
|
420 |
|
421 Return Values: Symbian OS error: Error code |
|
422 |
|
423 Errors/Exceptions: None |
|
424 |
|
425 Status: Draft |
|
426 |
|
427 ------------------------------------------------------------------------------- |
|
428 */ |
|
429 EXPORT_C TInt CUIStore::RemoveTestCaseFile( const TDesC& aModuleName, |
|
430 const TDesC& aCaseFile ) |
|
431 { |
|
432 |
|
433 TInt ret = iUIEngine->RemoveTestCaseFile( aModuleName, aCaseFile ); |
|
434 |
|
435 RefreshAllCases(); |
|
436 |
|
437 return ret; |
|
438 |
|
439 } |
|
440 |
|
441 /* |
|
442 ------------------------------------------------------------------------------- |
|
443 |
|
444 Class: CUIStore |
|
445 |
|
446 Method: StartTestCase |
|
447 |
|
448 Description: Start selected test case identified with CTestInfo. |
|
449 anIndex contains index in StartedTestCase array, |
|
450 which is valid only during execution of calling |
|
451 function. |
|
452 |
|
453 Parameters: const CTestInfo& aTestInfo: in: Test case info |
|
454 TInt& anIndex: out: Index to StartedTestCaseArray returned |
|
455 |
|
456 Return Values: Symbian OS error code |
|
457 |
|
458 Errors/Exceptions: None |
|
459 |
|
460 Status: Draft |
|
461 |
|
462 ------------------------------------------------------------------------------- |
|
463 */ |
|
464 EXPORT_C TInt CUIStore::StartTestCase( const CTestInfo& aTestInfo, |
|
465 TInt& anIndex ) |
|
466 { |
|
467 |
|
468 CUIEngineContainer* container = NULL; |
|
469 TInt ret = iUIEngine->StartTestCase( container, aTestInfo ); |
|
470 |
|
471 if( ret != KErrNone ) |
|
472 { |
|
473 return ret; |
|
474 } |
|
475 |
|
476 CStartedTestCase* testCase = NULL; |
|
477 TRAP( ret, |
|
478 testCase = CStartedTestCase::NewL( aTestInfo, *container ); |
|
479 ); |
|
480 if( ret != KErrNone ) |
|
481 { |
|
482 iUIEngine->AbortStartedTestCase( container ); |
|
483 return ret; |
|
484 } |
|
485 |
|
486 ret = iStartedTestCases.Append( testCase ); |
|
487 if( ret != KErrNone ) |
|
488 { |
|
489 iUIEngine->AbortStartedTestCase( container ); |
|
490 delete testCase; |
|
491 return ret; |
|
492 } |
|
493 |
|
494 anIndex = iStartedTestCases.Find( testCase ); |
|
495 |
|
496 if( anIndex < 0 ) |
|
497 { |
|
498 User::Panic( KUIStore, KErrNotFound ); |
|
499 } |
|
500 |
|
501 iUIStoreIf->Update( testCase, testCase->Status() ); |
|
502 |
|
503 return KErrNone; |
|
504 |
|
505 } |
|
506 |
|
507 /* |
|
508 ------------------------------------------------------------------------------- |
|
509 |
|
510 Class: CUIStore |
|
511 |
|
512 Method: TestCases |
|
513 |
|
514 Description: Return array of existing test cases. |
|
515 |
|
516 Parameters: RRefArray<CTestInfo>& aTestCases: out: Array of test cases |
|
517 TDesC& aTestModule: in: Test module name (optional) |
|
518 TDesC& aTestCaseFile: in: Test case file name (optional) |
|
519 |
|
520 Return Values: Symbian OS error code |
|
521 |
|
522 Errors/Exceptions: None |
|
523 |
|
524 Status: Draft |
|
525 |
|
526 ------------------------------------------------------------------------------- |
|
527 */ |
|
528 EXPORT_C TInt CUIStore::TestCases( RRefArray<CTestInfo>& aTestCases, |
|
529 const TDesC& aTestModule, |
|
530 const TDesC& aTestCaseFile ) |
|
531 { |
|
532 |
|
533 TInt ret = UpdateCases(); |
|
534 if( ret != KErrNone ) |
|
535 { |
|
536 return ret; |
|
537 } |
|
538 TInt count = iTestCases.Count(); |
|
539 for( TInt i = 0; i < count; i++ ) |
|
540 { |
|
541 if( ( aTestModule.Length() > 0 ) && |
|
542 ( iTestCases[i]->ModuleName() != aTestModule ) ) |
|
543 { |
|
544 continue; |
|
545 } |
|
546 else if( ( aTestCaseFile.Length() > 0 ) && |
|
547 ( iTestCases[i]->TestCaseFile() != aTestCaseFile ) ) |
|
548 { |
|
549 continue; |
|
550 } |
|
551 aTestCases.Append( *iTestCases[i] ); |
|
552 } |
|
553 |
|
554 return KErrNone; |
|
555 |
|
556 } |
|
557 |
|
558 /* |
|
559 ------------------------------------------------------------------------------- |
|
560 |
|
561 Class: CUIStore |
|
562 |
|
563 Method: StartedTestCaseL |
|
564 |
|
565 Description: Return started (running/runned) test case |
|
566 |
|
567 Parameters: CStartedTestCase& aTestCase: out: Test case information |
|
568 TInt anIndex: in: test case index in StartedTestCaseArray |
|
569 |
|
570 Return Values: Reference to CStartedTestCase object |
|
571 |
|
572 Errors/Exceptions: Leaves if anIndex out of range |
|
573 |
|
574 Status: Draft |
|
575 |
|
576 ------------------------------------------------------------------------------- |
|
577 */ |
|
578 EXPORT_C CStartedTestCase& CUIStore::StartedTestCaseL( TInt anIndex ) |
|
579 { |
|
580 |
|
581 TInt count = iStartedTestCases.Count(); |
|
582 if( ( anIndex >= count ) || |
|
583 ( anIndex < 0 ) ) |
|
584 { |
|
585 User::Leave( KErrNotFound ); |
|
586 } |
|
587 |
|
588 return *iStartedTestCases[anIndex]; |
|
589 |
|
590 } |
|
591 |
|
592 /* |
|
593 ------------------------------------------------------------------------------- |
|
594 |
|
595 Class: CUIStore |
|
596 |
|
597 Method: StartedTestCases |
|
598 |
|
599 Description: Return started (running/runned) test cases |
|
600 |
|
601 Parameters: RRefArray<CStartedTestCase>& aTestCases: out: array of test cases |
|
602 TExecutionStatus aStatus: in: test case status (optional) |
|
603 TDesC& aTestModule: in: test module name (optional) |
|
604 TDesC& aTestCaseFile: in: test case file name (optional) |
|
605 |
|
606 Return Values: Symbian OS error code |
|
607 |
|
608 Errors/Exceptions: None |
|
609 |
|
610 Status: Draft |
|
611 |
|
612 ------------------------------------------------------------------------------- |
|
613 */ |
|
614 EXPORT_C TInt CUIStore::StartedTestCases( RRefArray<CStartedTestCase>& aTestCases, |
|
615 TInt aStatus, |
|
616 const TDesC& aTestModule, |
|
617 const TDesC& aTestCaseFile ) |
|
618 { |
|
619 |
|
620 TInt count = iStartedTestCases.Count(); |
|
621 for( TInt i = 0; i < count; i++ ) |
|
622 { |
|
623 if( ( aTestModule.Length() > 0 ) && |
|
624 ( iStartedTestCases[i]->TestInfo().ModuleName() != aTestModule ) ) |
|
625 { |
|
626 continue; |
|
627 } |
|
628 else if( ( aTestCaseFile.Length() > 0 ) && |
|
629 ( iStartedTestCases[i]->TestInfo().TestCaseFile() != aTestCaseFile ) ) |
|
630 { |
|
631 continue; |
|
632 } |
|
633 else if( ( aStatus != CUIStoreIf::EStatusAll) && |
|
634 !( iStartedTestCases[i]->Status() & aStatus ) ) |
|
635 { |
|
636 continue; |
|
637 } |
|
638 if( aTestCases.Append( *iStartedTestCases[i] ) != KErrNone ) |
|
639 { |
|
640 return KErrNoMemory; |
|
641 } |
|
642 } |
|
643 |
|
644 |
|
645 return KErrNone; |
|
646 |
|
647 } |
|
648 |
|
649 /* |
|
650 ------------------------------------------------------------------------------- |
|
651 |
|
652 Class: CUIStore |
|
653 |
|
654 Method: Modules |
|
655 |
|
656 Description: Return modules array |
|
657 |
|
658 Parameters: RRefArray<CModule>& aTestModules: out: modules array |
|
659 |
|
660 Return Values: Symbian OS error code |
|
661 |
|
662 Errors/Exceptions: None |
|
663 |
|
664 Status: Draft |
|
665 |
|
666 ------------------------------------------------------------------------------- |
|
667 */ |
|
668 EXPORT_C TInt CUIStore::Modules( RRefArray<TDesC>& aTestModules ) |
|
669 { |
|
670 |
|
671 TInt ret = UpdateCases(); |
|
672 if( ret != KErrNone ) |
|
673 { |
|
674 return ret; |
|
675 } |
|
676 |
|
677 // Go through test cases and search if there are new modules |
|
678 // and add them to aTestModules array |
|
679 TInt caseCount = iTestCases.Count(); |
|
680 TInt moduleCount = 0; |
|
681 TInt caseIndex = 0; |
|
682 TInt moduleIndex = 0; |
|
683 for ( caseIndex = 0; caseIndex < caseCount; caseIndex++ ) |
|
684 { |
|
685 // First check modules |
|
686 moduleCount = aTestModules.Count(); |
|
687 for ( moduleIndex = 0; moduleIndex < moduleCount; moduleIndex++ ) |
|
688 { |
|
689 if( iTestCases[caseIndex]->ModuleName() == |
|
690 aTestModules[moduleIndex] ) |
|
691 { |
|
692 break; |
|
693 } |
|
694 } |
|
695 if ( moduleIndex == moduleCount ) |
|
696 { |
|
697 // New module found |
|
698 if( aTestModules.Append( iTestCases[caseIndex]->ModuleName() ) != |
|
699 KErrNone ) |
|
700 { |
|
701 return KErrNoMemory; |
|
702 } |
|
703 } |
|
704 } |
|
705 |
|
706 return KErrNone; |
|
707 |
|
708 } |
|
709 |
|
710 /* |
|
711 ------------------------------------------------------------------------------- |
|
712 |
|
713 Class: CUIStore |
|
714 |
|
715 Method: TestCaseFiles |
|
716 |
|
717 Description: Return test case files |
|
718 |
|
719 Parameters: RRefArray<TDesC>& aTestCaseFiles: out: Array of test case files |
|
720 TDesC& aTestModule: in: test module name (optional) |
|
721 |
|
722 Return Values: Symbian OS error code |
|
723 |
|
724 Errors/Exceptions: None |
|
725 |
|
726 Status: Draft |
|
727 |
|
728 ------------------------------------------------------------------------------- |
|
729 */ |
|
730 EXPORT_C TInt CUIStore::TestCaseFiles( RRefArray<TDesC>& aTestCaseFiles, |
|
731 const TDesC& aTestModule ) |
|
732 { |
|
733 |
|
734 TInt ret = UpdateCases(); |
|
735 if( ret != KErrNone ) |
|
736 { |
|
737 return ret; |
|
738 } |
|
739 |
|
740 // Go through test cases and search if there are new test case files |
|
741 // for specified test module and add them to aTestCaseFiles array |
|
742 TInt caseCount = iTestCases.Count(); |
|
743 TInt fileCount = 0; |
|
744 TInt caseIndex = 0; |
|
745 TInt fileIndex = 0; |
|
746 for ( caseIndex = 0; caseIndex < caseCount; caseIndex++ ) |
|
747 { |
|
748 if( ( aTestModule.Length() > 0 ) && |
|
749 ( aTestModule != iTestCases[caseIndex]->ModuleName() ) ) |
|
750 { |
|
751 // Test case file is not for specified module |
|
752 continue; |
|
753 } |
|
754 |
|
755 // First check modules |
|
756 fileCount = aTestCaseFiles.Count(); |
|
757 for ( fileIndex = 0; fileIndex < fileCount; fileIndex++ ) |
|
758 { |
|
759 if( iTestCases[caseIndex]->TestCaseFile() == |
|
760 aTestCaseFiles[fileIndex] ) |
|
761 { |
|
762 break; |
|
763 } |
|
764 } |
|
765 if ( fileIndex == fileCount ) |
|
766 { |
|
767 // New test case file found |
|
768 if( aTestCaseFiles.Append( iTestCases[caseIndex]->TestCaseFile() ) != |
|
769 KErrNone ) |
|
770 { |
|
771 return KErrNoMemory; |
|
772 } |
|
773 } |
|
774 } |
|
775 |
|
776 return KErrNone; |
|
777 |
|
778 } |
|
779 |
|
780 /* |
|
781 ------------------------------------------------------------------------------- |
|
782 |
|
783 Class: CUIStore |
|
784 |
|
785 Method: LoadAllModules |
|
786 |
|
787 Description: Loads all TestFramework test modules from \system\libs\ directories |
|
788 of all drives. In Secure Platform from \sys\bin directories. |
|
789 |
|
790 Parameters: None |
|
791 |
|
792 Return Values: Symbian OS error code |
|
793 |
|
794 Errors/Exceptions: None |
|
795 |
|
796 Status: Draft |
|
797 |
|
798 ------------------------------------------------------------------------------- |
|
799 */ |
|
800 EXPORT_C TInt CUIStore::LoadAllModules() |
|
801 { |
|
802 |
|
803 RPointerArray<TDesC> testModules; |
|
804 |
|
805 TInt ret = ListAllModules( testModules ); |
|
806 if( ret == KErrNone ) |
|
807 { |
|
808 for (TInt i= 0; i < testModules.Count(); i++) |
|
809 { |
|
810 iLogger->Log( _L("Add test module: %S"), testModules[i] ); |
|
811 ret = iUIEngine->AddTestModule( *testModules[i], KNullDesC ); |
|
812 if( ret != KErrNone ) |
|
813 { |
|
814 iLogger->Log( _L("Add test module %S failed %d"), |
|
815 testModules[i], ret ); |
|
816 break; |
|
817 } |
|
818 } |
|
819 } |
|
820 RefreshAllCases(); |
|
821 |
|
822 testModules.ResetAndDestroy(); |
|
823 testModules.Close(); |
|
824 |
|
825 return ret; |
|
826 |
|
827 } |
|
828 |
|
829 /* |
|
830 ------------------------------------------------------------------------------- |
|
831 |
|
832 Class: CUIStore |
|
833 |
|
834 Method: ListAllModules |
|
835 |
|
836 Description: Lists all TestFramework test modules from \system\libs\ directories |
|
837 of all drives. In Secure Platform from \sys\bin directories. |
|
838 |
|
839 Parameters: None |
|
840 |
|
841 Return Values: Symbian OS error code |
|
842 |
|
843 Errors/Exceptions: None |
|
844 |
|
845 Status: Draft |
|
846 |
|
847 ------------------------------------------------------------------------------- |
|
848 */ |
|
849 EXPORT_C TInt CUIStore::ListAllModules( RPointerArray<TDesC>& aModuleNames ) |
|
850 { |
|
851 |
|
852 TRAPD( err, ListAllModulesL( aModuleNames ); ); |
|
853 return err; |
|
854 |
|
855 } |
|
856 |
|
857 /* |
|
858 ------------------------------------------------------------------------------- |
|
859 |
|
860 Class: CUIStore |
|
861 |
|
862 Method: ListAllModulesL |
|
863 |
|
864 Description: Lists all TestFramework test modules from \system\libs\ directories |
|
865 of all drives. In Secure Platform from \sys\bin directories. |
|
866 |
|
867 Parameters: None |
|
868 |
|
869 Return Values: Symbian OS error code |
|
870 |
|
871 Errors/Exceptions: None |
|
872 |
|
873 Status: Draft |
|
874 |
|
875 ------------------------------------------------------------------------------- |
|
876 */ |
|
877 void CUIStore::ListAllModulesL( RPointerArray<TDesC>& aModuleNames ) |
|
878 { |
|
879 |
|
880 TFileName libDirectory; |
|
881 RFs fsSession; |
|
882 TFileName fullName; |
|
883 |
|
884 // Connect to file server |
|
885 User::LeaveIfError( fsSession.Connect() ); // Start session |
|
886 CleanupClosePushL( fsSession ); |
|
887 |
|
888 TDriveList drivelist; |
|
889 User::LeaveIfError( fsSession.DriveList(drivelist) ); |
|
890 // A TDriveList (the list of available drives), is an array of |
|
891 // 26 bytes. Each byte with a non zero value signifies that the |
|
892 // corresponding drive is available. |
|
893 |
|
894 // 0x10000079, 0x1000008d, 0x101FB3E7 |
|
895 TUidType anEntryUid( KDynamicLibraryUid, |
|
896 KSharedLibraryUid, |
|
897 KUidTestModule ); |
|
898 TInt driveNumber; |
|
899 TChar driveLetter; |
|
900 |
|
901 CDir* testModules = NULL; |
|
902 |
|
903 for( driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++ ) |
|
904 { |
|
905 if( !drivelist[driveNumber] ) |
|
906 { |
|
907 // If drive-list entry is zero, drive is not available |
|
908 continue; |
|
909 } |
|
910 User::LeaveIfError(fsSession.DriveToChar(driveNumber,driveLetter)); |
|
911 |
|
912 libDirectory.Zero(); |
|
913 libDirectory.Append( driveLetter ); |
|
914 libDirectory.Append( _L(":\\sys\\bin\\*") ); |
|
915 |
|
916 iLogger->Log( _L("Searching modules from %S"), &libDirectory ); |
|
917 |
|
918 fsSession.GetDir( libDirectory, anEntryUid, ESortNone, testModules ); |
|
919 |
|
920 if( !testModules ) |
|
921 { |
|
922 // Continue if no test modules found |
|
923 continue; |
|
924 } |
|
925 TInt count = testModules->Count(); |
|
926 for (TInt i= 0; i < count; i++) |
|
927 { |
|
928 fullName = (*testModules)[i].iName; |
|
929 |
|
930 fullName.LowerCase(); |
|
931 // Remove optional '.DLL' from file name |
|
932 TParse parse; |
|
933 parse.Set( fullName, NULL, NULL ); |
|
934 |
|
935 if ( parse.Ext() == _L(".dll") ) |
|
936 { |
|
937 const TInt len = parse.Ext().Length(); |
|
938 fullName.Delete( fullName.Length()-len, len ); |
|
939 } |
|
940 |
|
941 // Exclude internal test modules (testcombiner, testscripter, suevent) |
|
942 _LIT(KTestCombiner, "testcombiner"); |
|
943 _LIT(KTestScripter, "testscripter"); |
|
944 _LIT(KSUEvent, "suevent"); |
|
945 if(fullName != KTestCombiner && fullName != KSUEvent && fullName != KTestScripter) |
|
946 { |
|
947 HBufC* name = fullName.AllocLC(); |
|
948 iLogger->Log( _L("Found: %S"), name ); |
|
949 User::LeaveIfError( aModuleNames.Append( name ) ); |
|
950 CleanupStack::Pop( name ); |
|
951 } |
|
952 } |
|
953 delete testModules; |
|
954 testModules = NULL; |
|
955 } |
|
956 |
|
957 CleanupStack::PopAndDestroy(); // fsSession |
|
958 |
|
959 } |
|
960 |
|
961 /* |
|
962 ------------------------------------------------------------------------------- |
|
963 |
|
964 Class: CUIStore |
|
965 |
|
966 Method: CreateTestSet |
|
967 |
|
968 Description: Create new test set. |
|
969 |
|
970 Parameters: TDesC& aSetName: in: test set name (Max length is KMaxName) |
|
971 |
|
972 Return Values: Symbian OS error code |
|
973 |
|
974 Errors/Exceptions: None |
|
975 |
|
976 Status: Draft |
|
977 |
|
978 ------------------------------------------------------------------------------- |
|
979 */ |
|
980 EXPORT_C TInt CUIStore::CreateTestSet( const TDesC& aSetName ) |
|
981 { |
|
982 |
|
983 TPtrC setName; |
|
984 TFileName tmp; |
|
985 TInt ret = ParseTestSetName( aSetName, setName, tmp ); |
|
986 if( ret != KErrNone ) |
|
987 { |
|
988 return ret; |
|
989 } |
|
990 |
|
991 CTestSetInfo* setInfo = NULL; |
|
992 if( FindSetByName( setName, setInfo ) == KErrNone ) |
|
993 { |
|
994 return KErrAlreadyExists; |
|
995 } |
|
996 TRAPD( err, |
|
997 setInfo = CTestSetInfo::NewL( setName ); |
|
998 ); |
|
999 if( err != KErrNone ) |
|
1000 { |
|
1001 return err; |
|
1002 } |
|
1003 if( iTestSets.Append( setInfo ) != KErrNone ) |
|
1004 { |
|
1005 delete setInfo; |
|
1006 return KErrNoMemory; |
|
1007 } |
|
1008 |
|
1009 return KErrNone; |
|
1010 |
|
1011 } |
|
1012 |
|
1013 /* |
|
1014 ------------------------------------------------------------------------------- |
|
1015 |
|
1016 Class: CUIStore |
|
1017 |
|
1018 Method: RemoveTestSet |
|
1019 |
|
1020 Description: Remove active test set. |
|
1021 |
|
1022 Parameters: TDesC& aSetName: in: test set name (Max length is KMaxName) |
|
1023 |
|
1024 Return Values: Symbian OS error code |
|
1025 |
|
1026 Errors/Exceptions: None |
|
1027 |
|
1028 Status: Draft |
|
1029 |
|
1030 ------------------------------------------------------------------------------- |
|
1031 */ |
|
1032 EXPORT_C TInt CUIStore::RemoveTestSet( const TDesC& aSetName ) |
|
1033 { |
|
1034 TInt err = UnloadTestSet( aSetName ); |
|
1035 if ( err != KErrNone ) |
|
1036 { |
|
1037 return err; |
|
1038 } |
|
1039 |
|
1040 TFileName setfile; |
|
1041 setfile.Append(KUIStoreDefaultDir); |
|
1042 setfile.Append(aSetName); |
|
1043 RFs fs; |
|
1044 err = fs.Connect(); |
|
1045 if( err != KErrNone ) |
|
1046 { |
|
1047 fs.Close(); |
|
1048 return err; |
|
1049 } |
|
1050 err = fs.Delete( setfile ); |
|
1051 if ( err != KErrNone ) |
|
1052 { |
|
1053 fs.Close(); |
|
1054 return err; |
|
1055 } |
|
1056 |
|
1057 return KErrNone; |
|
1058 } |
|
1059 |
|
1060 /* |
|
1061 ------------------------------------------------------------------------------- |
|
1062 |
|
1063 Class: CUIStore |
|
1064 |
|
1065 Method: UnloadTestSet |
|
1066 |
|
1067 Description: Unloads active test set. |
|
1068 |
|
1069 Parameters: TDesC& aSetName: in: test set name (Max length is KMaxName) |
|
1070 |
|
1071 Return Values: Symbian OS error code |
|
1072 |
|
1073 Errors/Exceptions: None |
|
1074 |
|
1075 Status: Draft |
|
1076 |
|
1077 ------------------------------------------------------------------------------- |
|
1078 */ |
|
1079 EXPORT_C TInt CUIStore::UnloadTestSet( const TDesC& aSetName ) |
|
1080 { |
|
1081 TPtrC setName; |
|
1082 TFileName tmp; |
|
1083 TInt ret = ParseTestSetName( aSetName, setName, tmp ); |
|
1084 if( ret != KErrNone ) |
|
1085 { |
|
1086 return ret; |
|
1087 } |
|
1088 |
|
1089 TInt count = iTestSets.Count(); |
|
1090 TInt index = 0; |
|
1091 for( ; index < count; index++ ) |
|
1092 { |
|
1093 if( iTestSets[index]->Name() == setName ) |
|
1094 { |
|
1095 break; |
|
1096 } |
|
1097 } |
|
1098 if( index == count ) |
|
1099 { |
|
1100 return KErrNotFound; |
|
1101 } |
|
1102 |
|
1103 CTestSetInfo* setInfo = iTestSets[index]; |
|
1104 iTestSets.Remove( index ); |
|
1105 |
|
1106 // If started test set keeps info about currently removed test set |
|
1107 // then remove also this info |
|
1108 CStartedTestSet *stset; |
|
1109 for(index = 0; index < iStartedTestSets.Count(); index++) |
|
1110 { |
|
1111 stset = iStartedTestSets[index]; |
|
1112 if(stset->GetOriginalTestSet() == setInfo) |
|
1113 { |
|
1114 stset->NullOriginalTestSet(); |
|
1115 } |
|
1116 } |
|
1117 |
|
1118 delete setInfo; |
|
1119 |
|
1120 return KErrNone; |
|
1121 } |
|
1122 |
|
1123 /* |
|
1124 ------------------------------------------------------------------------------- |
|
1125 |
|
1126 Class: CUIStore |
|
1127 |
|
1128 Method: TestSets |
|
1129 |
|
1130 Description: Query test sets. |
|
1131 |
|
1132 Parameters:RRefArray<CTestSetInfo>& aSetInfos: out: list of test sets |
|
1133 |
|
1134 Return Values: Symbian OS error code |
|
1135 |
|
1136 Errors/Exceptions: None |
|
1137 |
|
1138 Status: Draft |
|
1139 |
|
1140 ------------------------------------------------------------------------------- |
|
1141 */ |
|
1142 EXPORT_C TInt CUIStore::TestSets( RRefArray<CTestSetInfo>& aSetInfos ) |
|
1143 { |
|
1144 |
|
1145 TInt count = iTestSets.Count(); |
|
1146 for( TInt i=0; i<count; i++ ) |
|
1147 { |
|
1148 if( aSetInfos.Append( *iTestSets[i] ) != KErrNone ) |
|
1149 { |
|
1150 return KErrNoMemory; |
|
1151 } |
|
1152 } |
|
1153 return KErrNone; |
|
1154 |
|
1155 } |
|
1156 |
|
1157 /* |
|
1158 ------------------------------------------------------------------------------- |
|
1159 |
|
1160 Class: CUIStore |
|
1161 |
|
1162 Method: TestSets |
|
1163 |
|
1164 Description: Query test sets. |
|
1165 |
|
1166 Parameters:RRefArray<CTestSetInfo>& aSetInfos: out: list of test sets |
|
1167 |
|
1168 Return Values: Symbian OS error code |
|
1169 |
|
1170 Errors/Exceptions: None |
|
1171 |
|
1172 Status: Draft |
|
1173 |
|
1174 ------------------------------------------------------------------------------- |
|
1175 */ |
|
1176 EXPORT_C const CTestSetInfo& CUIStore::TestSetL( const TDesC& aSetName ) |
|
1177 { |
|
1178 |
|
1179 TPtrC setName; |
|
1180 TFileName tmp; |
|
1181 User::LeaveIfError( ParseTestSetName( aSetName, setName, tmp ) ); |
|
1182 |
|
1183 CTestSetInfo* setInfo = NULL; |
|
1184 User::LeaveIfError( FindSetByName( setName, setInfo ) ); |
|
1185 return *setInfo; |
|
1186 |
|
1187 } |
|
1188 |
|
1189 /* |
|
1190 ------------------------------------------------------------------------------- |
|
1191 |
|
1192 Class: CUIStore |
|
1193 |
|
1194 Method: AddToTestSet |
|
1195 |
|
1196 Description: Add test case to test set. |
|
1197 |
|
1198 Parameters: TDesC& aSetName: out: test set name |
|
1199 CTestInfo& aTestInfo: in: test case to add |
|
1200 |
|
1201 Return Values: Symbian OS error code |
|
1202 |
|
1203 Errors/Exceptions: None |
|
1204 |
|
1205 Status: Draft |
|
1206 |
|
1207 ------------------------------------------------------------------------------- |
|
1208 */ |
|
1209 EXPORT_C TInt CUIStore::AddToTestSet( const TDesC& aSetName, |
|
1210 const CTestInfo& aTestInfo ) |
|
1211 { |
|
1212 |
|
1213 TPtrC setName; |
|
1214 TFileName tmp; |
|
1215 TInt ret = ParseTestSetName( aSetName, setName, tmp ); |
|
1216 if( ret != KErrNone ) |
|
1217 { |
|
1218 return ret; |
|
1219 } |
|
1220 |
|
1221 CTestSetInfo* setInfo = NULL; |
|
1222 ret = FindSetByName( setName, setInfo ); |
|
1223 if( ret != KErrNone ) |
|
1224 { |
|
1225 return ret; |
|
1226 } |
|
1227 |
|
1228 return setInfo->AddTestCase( aTestInfo ); |
|
1229 |
|
1230 } |
|
1231 |
|
1232 /* |
|
1233 ------------------------------------------------------------------------------- |
|
1234 |
|
1235 Class: CUIStore |
|
1236 |
|
1237 Method: InsertToTestSet |
|
1238 |
|
1239 Description: Insert test case to test set. |
|
1240 |
|
1241 Parameters: TDesC& aSetName: out: test set name |
|
1242 CTestInfo& aTestInfo: in: test case to add |
|
1243 TInt aPos: in: position to add |
|
1244 |
|
1245 Return Values: Symbian OS error code |
|
1246 |
|
1247 Errors/Exceptions: None |
|
1248 |
|
1249 Status: Draft |
|
1250 |
|
1251 ------------------------------------------------------------------------------- |
|
1252 */ |
|
1253 EXPORT_C TInt CUIStore::InsertToTestSet( const TDesC& aSetName, |
|
1254 const CTestInfo& aTestInfo, |
|
1255 TInt aPos ) |
|
1256 { |
|
1257 |
|
1258 TPtrC setName; |
|
1259 TFileName tmp; |
|
1260 TInt ret = ParseTestSetName( aSetName, setName, tmp ); |
|
1261 if( ret != KErrNone ) |
|
1262 { |
|
1263 return ret; |
|
1264 } |
|
1265 |
|
1266 CTestSetInfo* setInfo = NULL; |
|
1267 ret = FindSetByName( setName, setInfo ); |
|
1268 if( ret != KErrNone ) |
|
1269 { |
|
1270 return ret; |
|
1271 } |
|
1272 |
|
1273 return setInfo->InsertTestCase( aTestInfo, aPos ); |
|
1274 |
|
1275 } |
|
1276 |
|
1277 /* |
|
1278 ------------------------------------------------------------------------------- |
|
1279 |
|
1280 Class: CUIStore |
|
1281 |
|
1282 Method: RemoveFromTestSet |
|
1283 |
|
1284 Description: Remove test case from test set. |
|
1285 |
|
1286 Parameters: TDesC& aSetName: out: test set name |
|
1287 CTestInfo& aTestInfo: in: test case to remove |
|
1288 |
|
1289 Return Values: Symbian OS error code |
|
1290 |
|
1291 Errors/Exceptions: None |
|
1292 |
|
1293 Status: Draft |
|
1294 |
|
1295 ------------------------------------------------------------------------------- |
|
1296 */ |
|
1297 EXPORT_C TInt CUIStore::RemoveFromTestSet( const TDesC& aSetName, |
|
1298 const CTestInfo& aTestInfo ) |
|
1299 { |
|
1300 |
|
1301 TPtrC setName; |
|
1302 TFileName tmp; |
|
1303 TInt ret = ParseTestSetName( aSetName, setName, tmp ); |
|
1304 if( ret != KErrNone ) |
|
1305 { |
|
1306 return ret; |
|
1307 } |
|
1308 |
|
1309 CTestSetInfo* setInfo = NULL; |
|
1310 ret = FindSetByName( setName, setInfo ); |
|
1311 if( ret != KErrNone ) |
|
1312 { |
|
1313 return ret; |
|
1314 } |
|
1315 |
|
1316 return setInfo->RemoveTestCase( aTestInfo ); |
|
1317 |
|
1318 } |
|
1319 |
|
1320 /* |
|
1321 ------------------------------------------------------------------------------- |
|
1322 |
|
1323 Class: CUIStore |
|
1324 |
|
1325 Method: SaveTestSet |
|
1326 |
|
1327 Description: Save test set. Deprecated, SaveTestSet2 to be used instead |
|
1328 |
|
1329 Parameters: TDesC&: out: test set name |
|
1330 |
|
1331 Return Values: Symbian OS error code |
|
1332 |
|
1333 Errors/Exceptions: None |
|
1334 |
|
1335 Status: Draft |
|
1336 |
|
1337 ------------------------------------------------------------------------------- |
|
1338 */ |
|
1339 EXPORT_C TInt CUIStore::SaveTestSet( const TDesC& /* aSetName */ ) |
|
1340 { |
|
1341 |
|
1342 return KErrNotSupported; |
|
1343 |
|
1344 } |
|
1345 |
|
1346 /* |
|
1347 ------------------------------------------------------------------------------- |
|
1348 |
|
1349 Class: CUIStore |
|
1350 |
|
1351 Method: SaveTestSet2 |
|
1352 |
|
1353 Description: Save test set. |
|
1354 |
|
1355 Parameters: TDes& aSetName: out: test set name |
|
1356 |
|
1357 Return Values: Symbian OS error code |
|
1358 |
|
1359 Errors/Exceptions: None |
|
1360 |
|
1361 Status: Draft |
|
1362 |
|
1363 ------------------------------------------------------------------------------- |
|
1364 */ |
|
1365 EXPORT_C TInt CUIStore::SaveTestSet2( TDes& aSetName ) |
|
1366 { |
|
1367 |
|
1368 RRefArray<TDesC> testsets; |
|
1369 |
|
1370 GetTestSetsList(testsets); |
|
1371 TBool isexist(EFalse); |
|
1372 for(TInt i=0;i<testsets.Count();i++) |
|
1373 { |
|
1374 if(testsets[i]==aSetName) |
|
1375 { |
|
1376 isexist=ETrue; |
|
1377 break; |
|
1378 } |
|
1379 |
|
1380 } |
|
1381 testsets.Reset(); |
|
1382 if(!isexist) |
|
1383 { |
|
1384 TTime current; |
|
1385 TDateTime date_rep; |
|
1386 current.HomeTime(); |
|
1387 date_rep = current.DateTime(); |
|
1388 TBuf<32> currSetName; |
|
1389 _LIT(f_ext,".set"); |
|
1390 |
|
1391 //create "test set name" string |
|
1392 currSetName.AppendNum(date_rep.Year()); |
|
1393 currSetName.Append('_'); |
|
1394 currSetName.AppendNum(date_rep.Month()+1); // Incrimination necessary, because Day and Month fields of TDateTime class are 0 based |
|
1395 currSetName.Append('_'); |
|
1396 currSetName.AppendNum(date_rep.Day()+1); |
|
1397 currSetName.Append('_'); |
|
1398 currSetName.AppendNum(date_rep.Hour()); |
|
1399 currSetName.Append('_'); |
|
1400 currSetName.AppendNum(date_rep.Minute()); |
|
1401 currSetName.Append('_'); |
|
1402 currSetName.AppendNum(date_rep.Second()); |
|
1403 currSetName.Append(f_ext); |
|
1404 |
|
1405 for(TInt i=0;i<iTestSets.Count();i++) |
|
1406 { |
|
1407 if(iTestSets[i]->Name()==aSetName) |
|
1408 { |
|
1409 iTestSets[i]->RenameTestSet(currSetName); |
|
1410 |
|
1411 } |
|
1412 |
|
1413 } |
|
1414 |
|
1415 |
|
1416 |
|
1417 aSetName.Zero(); |
|
1418 aSetName.Copy(currSetName); |
|
1419 |
|
1420 |
|
1421 |
|
1422 } |
|
1423 TPtrC setName; |
|
1424 TFileName tmp; |
|
1425 |
|
1426 |
|
1427 |
|
1428 TInt ret = ParseTestSetName( aSetName, setName, tmp ); |
|
1429 if( ret != KErrNone ) |
|
1430 { |
|
1431 return ret; |
|
1432 } |
|
1433 |
|
1434 CTestSetInfo* setInfo = NULL; |
|
1435 ret = FindSetByName( setName, setInfo ); |
|
1436 if( ret != KErrNone ) |
|
1437 { |
|
1438 return ret; |
|
1439 } |
|
1440 |
|
1441 TRAPD( err, |
|
1442 SaveTestSetL( *setInfo, aSetName ); |
|
1443 ); |
|
1444 |
|
1445 |
|
1446 |
|
1447 return err; |
|
1448 |
|
1449 } |
|
1450 |
|
1451 /* |
|
1452 ------------------------------------------------------------------------------- |
|
1453 |
|
1454 Class: CUIStore |
|
1455 |
|
1456 Method: LoadTestSet |
|
1457 |
|
1458 Description: Load test set. |
|
1459 |
|
1460 Parameters: TDesC& aSetName: out: test set name |
|
1461 |
|
1462 Return Values: Symbian OS error code |
|
1463 |
|
1464 Errors/Exceptions: None |
|
1465 |
|
1466 Status: Draft |
|
1467 |
|
1468 ------------------------------------------------------------------------------- |
|
1469 */ |
|
1470 EXPORT_C TInt CUIStore::LoadTestSet( const TDesC& aSetName ) |
|
1471 { |
|
1472 TPtrC setName; |
|
1473 TFileName tmp; |
|
1474 TInt ret = ParseTestSetName( aSetName, setName, tmp ); |
|
1475 if( ret != KErrNone ) |
|
1476 { |
|
1477 return ret; |
|
1478 } |
|
1479 CTestSetInfo* setInfo= NULL; |
|
1480 |
|
1481 FindSetByName( setName, setInfo ); |
|
1482 if(setInfo != NULL) |
|
1483 { |
|
1484 return KErrNone; |
|
1485 } |
|
1486 |
|
1487 TRAPD( err, |
|
1488 setInfo = CTestSetInfo::NewL( aSetName ); |
|
1489 ); |
|
1490 if( err != KErrNone ) |
|
1491 { |
|
1492 return err; |
|
1493 } |
|
1494 if( iTestSets.Append( setInfo ) != KErrNone ) |
|
1495 { |
|
1496 delete setInfo; |
|
1497 return KErrNoMemory; |
|
1498 } |
|
1499 |
|
1500 TRAP( err, |
|
1501 LoadTestSetL( setName, aSetName ); |
|
1502 ); |
|
1503 |
|
1504 if( err != KErrNone && err != KErrAlreadyExists ) |
|
1505 { |
|
1506 RemoveTestSet( setName ); |
|
1507 } |
|
1508 |
|
1509 return err; |
|
1510 |
|
1511 } |
|
1512 |
|
1513 /* |
|
1514 ------------------------------------------------------------------------------- |
|
1515 |
|
1516 Class: CUIStore |
|
1517 |
|
1518 Method: UpdateTestSet |
|
1519 |
|
1520 Description: Updates (on storage) earlier saved test set. |
|
1521 |
|
1522 Parameters: CTestSetInfo& aSetInfo: in: test set |
|
1523 |
|
1524 Return Values: Symbian OS error code |
|
1525 |
|
1526 Errors/Exceptions: None |
|
1527 |
|
1528 Status: Approved |
|
1529 |
|
1530 ------------------------------------------------------------------------------- |
|
1531 */ |
|
1532 EXPORT_C TInt CUIStore::UpdateTestSet(CTestSetInfo& aSetInfo) |
|
1533 { |
|
1534 TRAPD(err, |
|
1535 UpdateTestSetL(aSetInfo, aSetInfo.Name()); |
|
1536 ); |
|
1537 |
|
1538 return err; |
|
1539 } |
|
1540 |
|
1541 /* |
|
1542 ------------------------------------------------------------------------------- |
|
1543 |
|
1544 Class: CUIStore |
|
1545 |
|
1546 Method: StartTestSet |
|
1547 |
|
1548 Description: Start selected test set identified with CTestSetInfo. |
|
1549 |
|
1550 Parameters: const CTestSetInfo& aTestSetInfo: in: Started test set |
|
1551 TInt& anIndex: out index in StartedTestSet array, |
|
1552 which is valid only during execution of calling |
|
1553 function. |
|
1554 |
|
1555 Return Values: Symbian OS error code |
|
1556 |
|
1557 Errors/Exceptions: None |
|
1558 |
|
1559 Status: Draft |
|
1560 |
|
1561 ------------------------------------------------------------------------------- |
|
1562 */ |
|
1563 EXPORT_C TInt CUIStore::StartTestSet( const CTestSetInfo& aTestSetInfo, |
|
1564 TInt& anIndex, |
|
1565 CStartedTestSet::TSetType aType ) |
|
1566 { |
|
1567 return StartTestSet(aTestSetInfo, anIndex, aType, EFalse); |
|
1568 } |
|
1569 |
|
1570 /* |
|
1571 ------------------------------------------------------------------------------- |
|
1572 |
|
1573 Class: CUIStore |
|
1574 |
|
1575 Method: StartTestSet |
|
1576 |
|
1577 Description: Start selected test set identified with CTestSetInfo. |
|
1578 |
|
1579 Parameters: const CTestSetInfo& aTestSetInfo: in: Started test set |
|
1580 TInt& anIndex: out index in StartedTestSet array, |
|
1581 which is valid only during execution of calling |
|
1582 function. |
|
1583 TSetType aType: sequential or paraller |
|
1584 TBool aNotExecutedCasesMode: only test case which haven't been |
|
1585 executed yet |
|
1586 |
|
1587 Return Values: Symbian OS error code |
|
1588 |
|
1589 Errors/Exceptions: None |
|
1590 |
|
1591 Status: Approved |
|
1592 |
|
1593 ------------------------------------------------------------------------------- |
|
1594 */ |
|
1595 EXPORT_C TInt CUIStore::StartTestSet( const CTestSetInfo& aTestSetInfo, |
|
1596 TInt& anIndex, |
|
1597 CStartedTestSet::TSetType aType, |
|
1598 TBool aNotStartedCasesMode ) |
|
1599 { |
|
1600 |
|
1601 TInt ret = KErrNone; |
|
1602 |
|
1603 CStartedTestSet* set = NULL; |
|
1604 TRAPD( err, |
|
1605 set = CStartedTestSet::NewL( this, aTestSetInfo, aType ); |
|
1606 ); |
|
1607 if( err != KErrNone ) |
|
1608 { |
|
1609 return err; |
|
1610 } |
|
1611 |
|
1612 if( iStartedTestSets.Append( set ) != KErrNone ) |
|
1613 { |
|
1614 delete set; |
|
1615 return KErrNoMemory; |
|
1616 } |
|
1617 |
|
1618 // Set mode in which only still not executed test cases will be run. |
|
1619 // It applies only to sequential execution. |
|
1620 set->SetNotStartedCasesMode(aNotStartedCasesMode); |
|
1621 |
|
1622 ret = set->StartNext(); |
|
1623 |
|
1624 anIndex = iStartedTestSets.Find( set ); |
|
1625 if( anIndex < 0 ) |
|
1626 { |
|
1627 User::Panic( KUIStore, KErrNotFound ); |
|
1628 } |
|
1629 // Check that testset starting was successful |
|
1630 if( ret != KErrNone ) |
|
1631 { |
|
1632 iStartedTestSets.Remove( anIndex ); |
|
1633 anIndex = KErrNotFound; // safety |
|
1634 delete set; |
|
1635 return ret; |
|
1636 } |
|
1637 |
|
1638 return KErrNone; |
|
1639 |
|
1640 } |
|
1641 |
|
1642 /* |
|
1643 ------------------------------------------------------------------------------- |
|
1644 |
|
1645 Class: CUIStore |
|
1646 |
|
1647 Method: AbortTestSet |
|
1648 |
|
1649 Description: Abort running test set. |
|
1650 |
|
1651 Parameters: None |
|
1652 |
|
1653 Return Values: Symbian OS error code |
|
1654 |
|
1655 Errors/Exceptions: None |
|
1656 |
|
1657 Status: Draft |
|
1658 |
|
1659 ------------------------------------------------------------------------------- |
|
1660 */ |
|
1661 EXPORT_C TInt CUIStore::AbortTestSet( CStartedTestSet& aSetInfo ) |
|
1662 { |
|
1663 |
|
1664 return aSetInfo.Abort(); |
|
1665 |
|
1666 } |
|
1667 |
|
1668 |
|
1669 /* |
|
1670 ------------------------------------------------------------------------------- |
|
1671 |
|
1672 Class: CUIStore |
|
1673 |
|
1674 Method: StartedTestSetL |
|
1675 |
|
1676 Description: Return started (running/runned) test set. |
|
1677 |
|
1678 Parameters: TInt anIndex: out index in StartedTestSet array |
|
1679 |
|
1680 Return Values: CStartedTestSet&: reference to test set |
|
1681 |
|
1682 Errors/Exceptions: Leaves on error. |
|
1683 |
|
1684 Status: Draft |
|
1685 |
|
1686 ------------------------------------------------------------------------------- |
|
1687 */ |
|
1688 EXPORT_C CStartedTestSet& CUIStore::StartedTestSetL( TInt anIndex) |
|
1689 { |
|
1690 |
|
1691 if( anIndex < 0 || |
|
1692 anIndex >= iStartedTestSets.Count() ) |
|
1693 { |
|
1694 User::Leave( KErrNotFound ); |
|
1695 } |
|
1696 |
|
1697 return *iStartedTestSets[ anIndex ]; |
|
1698 |
|
1699 } |
|
1700 |
|
1701 |
|
1702 /* |
|
1703 ------------------------------------------------------------------------------- |
|
1704 |
|
1705 Class: CUIStore |
|
1706 |
|
1707 Method: StartedTestSets |
|
1708 |
|
1709 Description: Return started (running/runned) test cases |
|
1710 |
|
1711 Parameters: RRefArray<CStartedTestSet>& aTestCases: out: list of test sets |
|
1712 TInt aStatus: in: status of queried sets |
|
1713 |
|
1714 Return Values: Symbian OS error code |
|
1715 |
|
1716 Errors/Exceptions: None |
|
1717 |
|
1718 Status: Draft |
|
1719 |
|
1720 ------------------------------------------------------------------------------- |
|
1721 */ |
|
1722 EXPORT_C TInt CUIStore::StartedTestSets( RRefArray<CStartedTestSet>& aTestSets, |
|
1723 TInt aStatus ) |
|
1724 { |
|
1725 |
|
1726 TInt count = iStartedTestSets.Count(); |
|
1727 |
|
1728 for( TInt i = 0; i < count; i++ ) |
|
1729 { |
|
1730 if( ( aStatus != CUIStoreIf::ESetAll) && |
|
1731 !( iStartedTestSets[i]->Status() & aStatus ) ) |
|
1732 { |
|
1733 continue; |
|
1734 } |
|
1735 if( aTestSets.Append( *iStartedTestSets[i] ) != KErrNone ) |
|
1736 { |
|
1737 return KErrNoMemory; |
|
1738 } |
|
1739 } |
|
1740 |
|
1741 return KErrNone; |
|
1742 |
|
1743 } |
|
1744 |
|
1745 /* |
|
1746 ------------------------------------------------------------------------------- |
|
1747 |
|
1748 Class: CUIStore |
|
1749 |
|
1750 Method: LoadSavedTestCases |
|
1751 |
|
1752 Description: Load saved testcases. |
|
1753 |
|
1754 Parameters: None |
|
1755 |
|
1756 Return Values: Symbian OS error code |
|
1757 |
|
1758 Errors/Exceptions: None |
|
1759 |
|
1760 Status: Draft |
|
1761 |
|
1762 ------------------------------------------------------------------------------- |
|
1763 */ |
|
1764 EXPORT_C TInt CUIStore::LoadSavedTestCases() |
|
1765 { |
|
1766 |
|
1767 TRAPD( err, |
|
1768 LoadExecutedTestCasesL(); |
|
1769 ); |
|
1770 |
|
1771 return err; |
|
1772 |
|
1773 } |
|
1774 /* |
|
1775 ------------------------------------------------------------------------------- |
|
1776 |
|
1777 Class: CUIStore |
|
1778 |
|
1779 Method: GetTestSetsList |
|
1780 |
|
1781 Description: Returns menu item text. |
|
1782 |
|
1783 Parameters: const TInt :in: Menu index |
|
1784 |
|
1785 Return Values: const TDesC& Menu line text |
|
1786 |
|
1787 Errors/Exceptions: None |
|
1788 |
|
1789 Status: Draft |
|
1790 |
|
1791 ------------------------------------------------------------------------------- |
|
1792 */ |
|
1793 EXPORT_C TInt CUIStore::GetTestSetsList( RRefArray<TDesC>& aArray ) |
|
1794 { |
|
1795 RFs fileReader; |
|
1796 CDir* dirContents = NULL; |
|
1797 _LIT(KSetPattern,".set"); |
|
1798 TInt entNum = 0; |
|
1799 TInt ret = 0; |
|
1800 HBufC* fName = NULL; |
|
1801 |
|
1802 |
|
1803 ret = fileReader.Connect(); |
|
1804 |
|
1805 if (ret != KErrNone) |
|
1806 return ret; |
|
1807 |
|
1808 |
|
1809 ret = fileReader.GetDir(KUIStoreDefaultDir, |
|
1810 KEntryAttNormal | KEntryAttHidden | KEntryAttSystem, |
|
1811 ESortByName | EDirsFirst | EAscending, |
|
1812 dirContents); |
|
1813 fileReader.Close(); |
|
1814 if (ret != KErrNone) |
|
1815 { |
|
1816 delete dirContents; |
|
1817 return ret; |
|
1818 } |
|
1819 entNum = dirContents->Count(); |
|
1820 for (int i = 0;i<entNum;i++) |
|
1821 { |
|
1822 if ((!dirContents->operator[](i).IsDir())&& |
|
1823 dirContents->operator[](i).iName.Find(KSetPattern)!=KErrNotFound) |
|
1824 { |
|
1825 TRAPD( err, fName = HBufC::NewL(64) ); |
|
1826 if( err != KErrNone ) |
|
1827 { |
|
1828 delete dirContents; |
|
1829 return err; |
|
1830 } |
|
1831 *fName = dirContents->operator[](i).iName; |
|
1832 ret = iFileList.Append(fName); |
|
1833 if (ret != KErrNone) |
|
1834 { |
|
1835 delete fName; |
|
1836 delete dirContents; |
|
1837 return ret; |
|
1838 } |
|
1839 ret = aArray.Append(*fName); |
|
1840 if (ret != KErrNone) |
|
1841 { |
|
1842 delete fName; |
|
1843 delete dirContents; |
|
1844 return ret; |
|
1845 } |
|
1846 |
|
1847 } |
|
1848 } |
|
1849 delete dirContents; |
|
1850 return KErrNone; |
|
1851 |
|
1852 } |
|
1853 |
|
1854 |
|
1855 /* |
|
1856 ------------------------------------------------------------------------------- |
|
1857 |
|
1858 Class: CUIStore |
|
1859 |
|
1860 Method: FindSetByName |
|
1861 |
|
1862 Description: Finds test set by name. |
|
1863 |
|
1864 Parameters: const TDesC& aSetName: in: set name |
|
1865 CTestSetInfo*& aSetInfo: out: pointer to test set |
|
1866 |
|
1867 Return Values: Symbian OS error code |
|
1868 |
|
1869 Errors/Exceptions: None |
|
1870 |
|
1871 Status: Draft |
|
1872 |
|
1873 ------------------------------------------------------------------------------- |
|
1874 */ |
|
1875 TInt CUIStore::FindSetByName( const TDesC& aSetName, |
|
1876 CTestSetInfo*& aSetInfo ) |
|
1877 { |
|
1878 |
|
1879 TInt count = iTestSets.Count(); |
|
1880 for( TInt i=0; i<count; i++ ) |
|
1881 { |
|
1882 if( iTestSets[i]->Name() == aSetName ) |
|
1883 { |
|
1884 aSetInfo = iTestSets[i]; |
|
1885 return KErrNone; |
|
1886 } |
|
1887 } |
|
1888 |
|
1889 return KErrNotFound; |
|
1890 |
|
1891 } |
|
1892 |
|
1893 /* |
|
1894 ------------------------------------------------------------------------------- |
|
1895 |
|
1896 Class: CUIStore |
|
1897 |
|
1898 Method: FindSetByCase |
|
1899 |
|
1900 Description: Finds test set by name. |
|
1901 |
|
1902 Parameters: const CStartedTestCase* aTestCase: in: running test case |
|
1903 CStartedTestSet*& aSet: out: set running test case |
|
1904 |
|
1905 Return Values: KErrNotFound: test case is not runned by any test set |
|
1906 KErrNone: test case was runned by aSet |
|
1907 |
|
1908 |
|
1909 Errors/Exceptions: None |
|
1910 |
|
1911 Status: Draft |
|
1912 |
|
1913 ------------------------------------------------------------------------------- |
|
1914 */ |
|
1915 TInt CUIStore::FindStartedSetByCase( const CStartedTestCase* aTestCase, |
|
1916 CStartedTestSet*& aSet ) |
|
1917 { |
|
1918 |
|
1919 TInt count = iStartedTestSets.Count(); |
|
1920 for( TInt i=0; i<count; i++ ) |
|
1921 { |
|
1922 if( iStartedTestSets[i]->IsRunning( aTestCase ) ) |
|
1923 { |
|
1924 aSet = iStartedTestSets[i]; |
|
1925 return KErrNone; |
|
1926 } |
|
1927 } |
|
1928 |
|
1929 return KErrNotFound; |
|
1930 |
|
1931 } |
|
1932 |
|
1933 /* |
|
1934 ------------------------------------------------------------------------------- |
|
1935 |
|
1936 Class: CUIStore |
|
1937 |
|
1938 Method: LoadTestSetL |
|
1939 |
|
1940 Description: Load test set. |
|
1941 |
|
1942 Parameters: TDesC& aSetName: out: test set name |
|
1943 |
|
1944 Return Values: Symbian OS error code |
|
1945 |
|
1946 Errors/Exceptions: None |
|
1947 |
|
1948 Status: Draft |
|
1949 |
|
1950 ------------------------------------------------------------------------------- |
|
1951 */ |
|
1952 void CUIStore::LoadTestSetL( const TDesC& aSetName, const TDesC& /*aSetFileName*/ ) |
|
1953 { |
|
1954 |
|
1955 TPtrC tmp; |
|
1956 TInt num; |
|
1957 TInt high; |
|
1958 TInt64 interval; |
|
1959 |
|
1960 CStifParser* parser = CStifParser::NewL( KUIStoreDefaultDir, aSetName ); |
|
1961 |
|
1962 |
|
1963 CleanupStack::PushL( parser ); |
|
1964 |
|
1965 CStifSectionParser* section = |
|
1966 parser->SectionL( KUIStoreSetStart, KUIStoreSetEnd ); |
|
1967 CleanupStack::PushL( section ); |
|
1968 |
|
1969 CStifItemParser* item; |
|
1970 |
|
1971 // Get started test case (if possible) |
|
1972 TUint lastStartedCaseIndex = 0; |
|
1973 item = section->GetItemLineL(KUIStoreLastStartedCaseIndex); |
|
1974 if(item) |
|
1975 { |
|
1976 CleanupStack::PushL(item); |
|
1977 TInt r = item->GetInt(KUIStoreLastStartedCaseIndex, lastStartedCaseIndex); |
|
1978 CleanupStack::PopAndDestroy(item); |
|
1979 if(r != KErrNone) |
|
1980 { |
|
1981 __TRACE(KInit, (_L("Could not read [%S] from test set file. Result [%d]."), &KUIStoreLastStartedCaseIndex, r)); |
|
1982 } |
|
1983 } |
|
1984 else |
|
1985 { |
|
1986 __TRACE(KInit, (_L("Could not find [%S] from test set file."), &KUIStoreLastStartedCaseIndex)); |
|
1987 } |
|
1988 |
|
1989 |
|
1990 CTestSetInfo* setInfo = NULL; |
|
1991 User::LeaveIfError( FindSetByName( aSetName, setInfo ) ); |
|
1992 |
|
1993 // Update started case |
|
1994 setInfo->SetLastStartedCaseIndex(lastStartedCaseIndex); |
|
1995 |
|
1996 CTestInfo* testInfo = CTestInfo::NewL(); |
|
1997 CleanupStack::PushL( testInfo ); |
|
1998 |
|
1999 CStifSectionParser* subSection = |
|
2000 section->SubSectionL( KUIStoreSetCaseStart, KUIStoreSetCaseEnd ); |
|
2001 |
|
2002 while( subSection ) |
|
2003 { |
|
2004 CleanupStack::PushL( subSection ); |
|
2005 |
|
2006 // Get module name |
|
2007 // Mandatory, leave if not found |
|
2008 User::LeaveIfError( |
|
2009 subSection->GetLine( KUIStoreCaseModuleName, tmp, ENoTag ) ); |
|
2010 testInfo->SetModuleName( tmp ); |
|
2011 |
|
2012 // Get test case title |
|
2013 // Mandatory, leave if not found |
|
2014 User::LeaveIfError( |
|
2015 subSection->GetLine( KUIStoreTestCaseTitle, tmp, ENoTag ) ); |
|
2016 testInfo->SetTestCaseTitle( tmp ); |
|
2017 |
|
2018 // Get test case file |
|
2019 num = subSection->GetLine( KUIStoreTestCaseFile, tmp, ENoTag ); |
|
2020 if( ( num == KErrNone ) && |
|
2021 ( tmp.Length() > 0 ) ) |
|
2022 { |
|
2023 // Optional |
|
2024 testInfo->SetTestCaseFile( tmp ); |
|
2025 } |
|
2026 |
|
2027 // Get test case number |
|
2028 item = subSection->GetItemLineL( KUIStoreTestCaseNum ); |
|
2029 CleanupStack::PushL( item ); |
|
2030 // Mandatory, leave if not found |
|
2031 User::LeaveIfError( item->GetInt( KUIStoreTestCaseNum, num )); |
|
2032 testInfo->SetTestCaseNumber( num ); |
|
2033 CleanupStack::PopAndDestroy( item ); |
|
2034 |
|
2035 // Get test case priority |
|
2036 item = subSection->GetItemLineL( KUIStoreCasePriority ); |
|
2037 CleanupStack::PushL( item ); |
|
2038 // Mandatory, leave if not found |
|
2039 User::LeaveIfError( item->GetInt( KUIStoreCasePriority, num )); |
|
2040 testInfo->SetPriority( num ); |
|
2041 CleanupStack::PopAndDestroy( item ); |
|
2042 |
|
2043 // Get test case timeout |
|
2044 item = subSection->GetItemLineL( KUIStoreCaseTimeout ); |
|
2045 CleanupStack::PushL( item ); |
|
2046 // Mandatory, leave if not found |
|
2047 User::LeaveIfError( item->GetInt( KUIStoreCaseTimeout, num )); |
|
2048 User::LeaveIfError( item->GetNextInt( high )); |
|
2049 //@js<--remove--> interval.Set( high, num ); |
|
2050 interval = MAKE_TINT64( high, num ); |
|
2051 TTimeIntervalMicroSeconds timeout( interval ); |
|
2052 testInfo->SetTimeout( timeout ); |
|
2053 CleanupStack::PopAndDestroy( item ); |
|
2054 |
|
2055 User::LeaveIfError( setInfo->AddTestCase( *testInfo ) ); |
|
2056 |
|
2057 CleanupStack::PopAndDestroy( subSection ); |
|
2058 subSection = |
|
2059 section->NextSubSectionL( KUIStoreSetCaseStart, KUIStoreSetCaseEnd ); |
|
2060 } |
|
2061 |
|
2062 CleanupStack::PopAndDestroy( testInfo ); |
|
2063 CleanupStack::PopAndDestroy( section ); |
|
2064 CleanupStack::PopAndDestroy( parser ); |
|
2065 |
|
2066 const RRefArray<const CTestInfo>& testCases = setInfo->TestCases(); |
|
2067 LoadTestModulesAndTestCaseFilesL( testCases ); |
|
2068 |
|
2069 } |
|
2070 |
|
2071 /* |
|
2072 ------------------------------------------------------------------------------- |
|
2073 |
|
2074 Class: CUIStore |
|
2075 |
|
2076 Method: SaveTestSetL |
|
2077 |
|
2078 Description: Save test set. |
|
2079 |
|
2080 Parameters: CTestSetInfo& aSetInfo: in: test set |
|
2081 |
|
2082 Return Values: Symbian OS error code |
|
2083 |
|
2084 Errors/Exceptions: None |
|
2085 |
|
2086 Status: Approved |
|
2087 |
|
2088 ------------------------------------------------------------------------------- |
|
2089 */ |
|
2090 void CUIStore::SaveTestSetL( CTestSetInfo& aSetInfo, const TDesC& aSetFileName ) |
|
2091 { |
|
2092 //Extract path |
|
2093 TParse p; |
|
2094 p.Set(aSetFileName, NULL, NULL); |
|
2095 TPtrC path = p.DriveAndPath(); // gives path for test set |
|
2096 TPtrC fn = p.NameAndExt(); // gives filename with extension |
|
2097 if(path.Length() == 0) |
|
2098 { |
|
2099 path.Set(KUIStoreDefaultDir); |
|
2100 } |
|
2101 |
|
2102 //Create file server |
|
2103 RFs fs; |
|
2104 User::LeaveIfError(fs.Connect()); |
|
2105 CleanupClosePushL(fs); |
|
2106 |
|
2107 //Create or open file |
|
2108 RFile file; |
|
2109 TFileName filename = path; |
|
2110 filename.Append(fn); |
|
2111 |
|
2112 TInt r = file.Replace(fs, filename, EFileWrite); |
|
2113 if(r != KErrNone) |
|
2114 { |
|
2115 User::Leave(r); |
|
2116 } |
|
2117 else |
|
2118 { |
|
2119 CleanupClosePushL(file); |
|
2120 |
|
2121 RBuf buffer; |
|
2122 buffer.Create(256); |
|
2123 CleanupClosePushL(buffer); |
|
2124 |
|
2125 // Saving |
|
2126 buffer.Format(_L("%S"), &KUIStoreSetStart); |
|
2127 WriteLineL(file, buffer); |
|
2128 |
|
2129 // Saving test set causes reset of index |
|
2130 aSetInfo.SetLastStartedCaseIndex(0); |
|
2131 buffer.Format(_L("%S "), &KUIStoreLastStartedCaseIndex); |
|
2132 buffer.AppendNumFixedWidth(aSetInfo.GetLastStartedCaseIndex(), EDecimal, KFixedStartedCaseIndex); |
|
2133 WriteLineL(file, buffer); |
|
2134 |
|
2135 // Saving test cases |
|
2136 TInt count = aSetInfo.TestCases().Count(); |
|
2137 for(TInt i = 0; i < count; i++) |
|
2138 { |
|
2139 WriteLineL(file, KNullDesC); |
|
2140 buffer.Format(_L("%S"), &KUIStoreSetCaseStart); |
|
2141 WriteLineL(file, buffer); |
|
2142 |
|
2143 buffer.Format(_L("%S %S"), &KUIStoreCaseModuleName, &aSetInfo.TestCases()[i].ModuleName()); |
|
2144 WriteLineL(file, buffer); |
|
2145 buffer.Format(_L("%S %S"), &KUIStoreTestCaseTitle, &aSetInfo.TestCases()[i].TestCaseTitle()); |
|
2146 WriteLineL(file, buffer); |
|
2147 if(aSetInfo.TestCases()[i].TestCaseFile().Length() > 0) |
|
2148 { |
|
2149 buffer.Format(_L("%S %S"), &KUIStoreTestCaseFile, &aSetInfo.TestCases()[i].TestCaseFile()); |
|
2150 WriteLineL(file, buffer); |
|
2151 } |
|
2152 buffer.Format(_L("%S %d"), &KUIStoreTestCaseNum, aSetInfo.TestCases()[i].TestCaseNum()); |
|
2153 WriteLineL(file, buffer); |
|
2154 buffer.Format(_L("%S %d"), &KUIStoreCasePriority, aSetInfo.TestCases()[i].Priority()); |
|
2155 WriteLineL(file, buffer); |
|
2156 buffer.Format(_L("%S %d %d"), &KUIStoreCaseTimeout, I64LOW(aSetInfo.TestCases()[i].Timeout().Int64()), |
|
2157 I64HIGH(aSetInfo.TestCases()[i].Timeout().Int64())); |
|
2158 WriteLineL(file, buffer); |
|
2159 buffer.Format(_L("%S %d"), &KUIStoreCaseExpectedResult, aSetInfo.TestCases()[i].ExpectedResult()); |
|
2160 WriteLineL(file, buffer); |
|
2161 buffer.Format(_L("%S"), &KUIStoreSetCaseEnd); |
|
2162 WriteLineL(file, buffer); |
|
2163 } |
|
2164 |
|
2165 WriteLineL(file, KNullDesC); |
|
2166 buffer.Format(_L("%S"), &KUIStoreSetEnd); |
|
2167 WriteLineL(file, buffer); |
|
2168 |
|
2169 CleanupStack::PopAndDestroy(&buffer); |
|
2170 CleanupStack::PopAndDestroy(&file); |
|
2171 } |
|
2172 CleanupStack::PopAndDestroy(&fs); |
|
2173 } |
|
2174 |
|
2175 /* |
|
2176 ------------------------------------------------------------------------------- |
|
2177 |
|
2178 Class: CUIStore |
|
2179 |
|
2180 Method: UpdateTestSetL |
|
2181 |
|
2182 Description: Updates information in test set file. |
|
2183 |
|
2184 Parameters: CTestSetInfo& aSetInfo: in: test set |
|
2185 |
|
2186 Return Values: Symbian OS error code |
|
2187 |
|
2188 Errors/Exceptions: Leaves when writing to file fails |
|
2189 Leaves when file.seek fails |
|
2190 Leaves when can't connect to file server |
|
2191 |
|
2192 Status: Approved |
|
2193 |
|
2194 ------------------------------------------------------------------------------- |
|
2195 */ |
|
2196 void CUIStore::UpdateTestSetL(CTestSetInfo& aSetInfo, const TDesC& aSetFileName) |
|
2197 { |
|
2198 // Get path |
|
2199 TParse p; |
|
2200 p.Set(aSetFileName, NULL, NULL); |
|
2201 TPtrC path = p.DriveAndPath(); // gives path for test set |
|
2202 TPtrC fn = p.NameAndExt(); // gives filename with extension |
|
2203 if(path.Length() == 0) |
|
2204 { |
|
2205 path.Set(KUIStoreDefaultDir); |
|
2206 } |
|
2207 |
|
2208 //Create file server |
|
2209 RFs fs; |
|
2210 User::LeaveIfError(fs.Connect()); |
|
2211 CleanupClosePushL(fs); |
|
2212 |
|
2213 //Create or open file |
|
2214 RFile file; |
|
2215 TFileName filename = path; |
|
2216 filename.Append(fn); |
|
2217 TInt foundpos = KErrNotFound; |
|
2218 |
|
2219 TInt r = file.Open(fs, filename, EFileWrite); |
|
2220 if(r != KErrNone) |
|
2221 { |
|
2222 User::Leave(r); |
|
2223 } |
|
2224 else |
|
2225 { |
|
2226 CleanupClosePushL(file); |
|
2227 |
|
2228 //Search for line |
|
2229 RBuf buffer; |
|
2230 buffer.Create(256); |
|
2231 CleanupClosePushL(buffer); |
|
2232 |
|
2233 //Prepare file |
|
2234 TInt pos = 0; |
|
2235 User::LeaveIfError(file.Seek(ESeekStart, pos)); |
|
2236 |
|
2237 //Read file |
|
2238 ReadLineL(file, buffer); |
|
2239 while(buffer.Length() > 0) |
|
2240 { |
|
2241 // Keep remembering current position |
|
2242 if(buffer.Find(KUIStoreLastStartedCaseIndex) == 0) |
|
2243 { |
|
2244 foundpos = pos; |
|
2245 break; |
|
2246 } |
|
2247 // What is current position |
|
2248 pos = 0; |
|
2249 User::LeaveIfError(file.Seek(ESeekCurrent, pos)); |
|
2250 // Read next line from file |
|
2251 ReadLineL(file, buffer); |
|
2252 } |
|
2253 |
|
2254 if(foundpos != KErrNotFound) |
|
2255 { |
|
2256 // Position was found. Just update that line (save index of last |
|
2257 // started test case) |
|
2258 RBuf8 b; |
|
2259 b.Create(40); |
|
2260 CleanupClosePushL(b); |
|
2261 |
|
2262 b.Copy(KUIStoreLastStartedCaseIndex); |
|
2263 b.Append(_L8(" ")); |
|
2264 b.AppendNumFixedWidth(aSetInfo.GetLastStartedCaseIndex(), EDecimal, KFixedStartedCaseIndex); |
|
2265 User::LeaveIfError(file.Seek(ESeekStart, foundpos)); |
|
2266 User::LeaveIfError(file.Write(b)); |
|
2267 CleanupStack::PopAndDestroy(&b); |
|
2268 } |
|
2269 |
|
2270 CleanupStack::PopAndDestroy(&buffer); |
|
2271 CleanupStack::PopAndDestroy(&file); |
|
2272 } |
|
2273 CleanupStack::PopAndDestroy(&fs); |
|
2274 |
|
2275 if(foundpos == KErrNotFound) |
|
2276 { |
|
2277 // Position of KUIStoreLastStartedCaseIndex could not be found. |
|
2278 // Store the whole file. |
|
2279 SaveTestSetL(aSetInfo, aSetFileName); |
|
2280 } |
|
2281 } |
|
2282 |
|
2283 /* |
|
2284 ------------------------------------------------------------------------------- |
|
2285 |
|
2286 Class: CUIStore |
|
2287 |
|
2288 Method: ReadLineL |
|
2289 |
|
2290 Description: Read the whole line from the file. If there is enough space, |
|
2291 the whole content of line will be returned in buffer. |
|
2292 |
|
2293 Parameters: RFile& file: in: file to be read |
|
2294 TDes8& buffer: out: buffer to be returned |
|
2295 |
|
2296 Return Values: None |
|
2297 |
|
2298 Errors/Exceptions: Leaves if RFile::Read method fails |
|
2299 |
|
2300 Status: Approved |
|
2301 |
|
2302 ------------------------------------------------------------------------------- |
|
2303 */ |
|
2304 void CUIStore::ReadLineL(RFile &file, TDes& buffer) |
|
2305 { |
|
2306 TBuf8<1> c; |
|
2307 TBuf<1> c16; |
|
2308 buffer.Copy(KNullDesC); |
|
2309 |
|
2310 User::LeaveIfError(file.Read(c)); |
|
2311 while(c.Length() > 0) |
|
2312 { |
|
2313 // There is still place to write to the dest buffer |
|
2314 if(buffer.Length() < buffer.MaxLength()) |
|
2315 { |
|
2316 c16.Copy(c); |
|
2317 buffer.Append(c16); |
|
2318 } |
|
2319 // Stop reading if end of line |
|
2320 if(c[0] == 0x0A) |
|
2321 { |
|
2322 break; |
|
2323 } |
|
2324 User::LeaveIfError(file.Read(c)); |
|
2325 } |
|
2326 } |
|
2327 |
|
2328 /* |
|
2329 ------------------------------------------------------------------------------- |
|
2330 |
|
2331 Class: CUIStore |
|
2332 |
|
2333 Method: WriteLineL |
|
2334 |
|
2335 Description: Write given line to the file and adds end of line. |
|
2336 |
|
2337 Parameters: RFile& file: in: file to be written |
|
2338 TDesC& buffer: in: buffer to be written |
|
2339 |
|
2340 Return Values: None |
|
2341 |
|
2342 Errors/Exceptions: Leaves if RFile::Write method fails |
|
2343 |
|
2344 Status: Approved |
|
2345 |
|
2346 ------------------------------------------------------------------------------- |
|
2347 */ |
|
2348 void CUIStore::WriteLineL(RFile &file, const TDesC& buffer) |
|
2349 { |
|
2350 if(buffer.Length() > 0) |
|
2351 { |
|
2352 // Create 8-bit buffer |
|
2353 RBuf8 buf; |
|
2354 buf.Create(buffer.Length()); |
|
2355 CleanupClosePushL(buf); |
|
2356 |
|
2357 buf.Copy(buffer); |
|
2358 |
|
2359 // Write buffer to file + end of line |
|
2360 User::LeaveIfError(file.Write(buf)); |
|
2361 |
|
2362 // Delete 8-bit buffer |
|
2363 CleanupStack::PopAndDestroy(&buf); |
|
2364 } |
|
2365 |
|
2366 // Write end of line |
|
2367 TBuf8<2> eoline; |
|
2368 eoline.Copy(_L("\r\n")); |
|
2369 User::LeaveIfError(file.Write(eoline)); |
|
2370 } |
|
2371 |
|
2372 /* |
|
2373 ------------------------------------------------------------------------------- |
|
2374 |
|
2375 Class: CUIStore |
|
2376 |
|
2377 Method: LoadTestModulesL |
|
2378 |
|
2379 Description: Load test modules. |
|
2380 |
|
2381 Parameters: CTestSetInfo& aSetInfo: in: test set |
|
2382 |
|
2383 Return Values: Symbian OS error code |
|
2384 |
|
2385 Errors/Exceptions: None |
|
2386 |
|
2387 Status: Draft |
|
2388 |
|
2389 ------------------------------------------------------------------------------- |
|
2390 */ |
|
2391 void CUIStore::LoadTestModulesAndTestCaseFilesL( |
|
2392 const RRefArray<const CTestInfo>& aTestCases ) |
|
2393 { |
|
2394 |
|
2395 RRefArray<TDesC> testCaseFiles; |
|
2396 RRefArray<TDesC> testModules; |
|
2397 CleanupClosePushL( testCaseFiles ); |
|
2398 CleanupClosePushL( testModules ); |
|
2399 |
|
2400 User::LeaveIfError( Modules( testModules ) ); |
|
2401 |
|
2402 TInt cCount = aTestCases.Count(); |
|
2403 TInt mCount = 0; |
|
2404 TInt mInd=0; |
|
2405 TInt fCount = 0; |
|
2406 TInt fInd=0; |
|
2407 for( TInt cInd=0; cInd<cCount; cInd++ ) |
|
2408 { |
|
2409 mCount = testModules.Count(); |
|
2410 for( mInd=0; mInd<mCount; mInd++ ) |
|
2411 { |
|
2412 if( aTestCases[cInd].ModuleName() == testModules[mInd] ) |
|
2413 { |
|
2414 // Test module already loaded |
|
2415 break; |
|
2416 } |
|
2417 } |
|
2418 if( mInd == mCount ) |
|
2419 { |
|
2420 // Not found, load test module |
|
2421 if( AddTestModule( aTestCases[cInd].ModuleName() ) == KErrNone ) |
|
2422 { |
|
2423 User::LeaveIfError( |
|
2424 testModules.Append( aTestCases[cInd].ModuleName() ) ); |
|
2425 } |
|
2426 } |
|
2427 if( aTestCases[cInd].TestCaseFile().Length() == 0 ) |
|
2428 { |
|
2429 // Test case file is not used, continue |
|
2430 continue; |
|
2431 } |
|
2432 testCaseFiles.Reset(); |
|
2433 User::LeaveIfError( |
|
2434 TestCaseFiles( testCaseFiles, aTestCases[cInd].ModuleName() )); |
|
2435 fCount = testCaseFiles.Count(); |
|
2436 for( fInd=0; fInd<fCount; fInd++ ) |
|
2437 { |
|
2438 if( aTestCases[cInd].TestCaseFile() == testCaseFiles[fInd] ) |
|
2439 { |
|
2440 // Testcasefile already loaded |
|
2441 break; |
|
2442 } |
|
2443 } |
|
2444 if( fInd == fCount ) |
|
2445 { |
|
2446 // Load test module |
|
2447 if( AddTestCaseFile( aTestCases[cInd].ModuleName(), |
|
2448 aTestCases[cInd].TestCaseFile() ) == KErrNone ) |
|
2449 { |
|
2450 User::LeaveIfError( |
|
2451 testCaseFiles.Append( aTestCases[cInd].TestCaseFile() ) ); |
|
2452 } |
|
2453 } |
|
2454 } |
|
2455 |
|
2456 CleanupStack::PopAndDestroy(); // testModules |
|
2457 CleanupStack::PopAndDestroy(); // testCaseFiles |
|
2458 |
|
2459 } |
|
2460 |
|
2461 /* |
|
2462 ------------------------------------------------------------------------------- |
|
2463 |
|
2464 Class: CUIStore |
|
2465 |
|
2466 Method: TestExecuted |
|
2467 |
|
2468 Description: Test case executed callback from UI engine. |
|
2469 |
|
2470 Parameters: CUIEngineContainer* const aContainer: in: Execution container |
|
2471 TFullTestResult& aFullTestResult: in: test result |
|
2472 |
|
2473 Return Values: None |
|
2474 |
|
2475 Errors/Exceptions: None |
|
2476 |
|
2477 Status: Draft |
|
2478 |
|
2479 ------------------------------------------------------------------------------- |
|
2480 */ |
|
2481 void CUIStore::TestExecuted ( CUIEngineContainer* aContainer, |
|
2482 TFullTestResult& aFullTestResult ) |
|
2483 { |
|
2484 |
|
2485 CStartedTestCase* testCase = NULL; |
|
2486 |
|
2487 if( FindByContainer( aContainer, testCase ) != KErrNone ) |
|
2488 { |
|
2489 __TRACE( KError, ( CStifLogger::EError, _L("CUIStore::TestExecuted: Not found"))); |
|
2490 return; |
|
2491 } |
|
2492 CStartedTestSet* set = NULL; |
|
2493 TInt setStatus = 0; |
|
2494 if( FindStartedSetByCase( testCase, set ) == KErrNone ) |
|
2495 { |
|
2496 setStatus = set->Status(); |
|
2497 set->TestCompleted( testCase, aFullTestResult ); |
|
2498 setStatus |= set->Status(); |
|
2499 } |
|
2500 |
|
2501 // Check and delete all pending popup windows for test case |
|
2502 TInt count = iPopups.Count(); |
|
2503 for( TInt i = 0; i<count; i++ ) |
|
2504 { |
|
2505 if( iPopups[i]->Container() == aContainer ) |
|
2506 { |
|
2507 delete iPopups[i]; |
|
2508 iPopups.Remove( i ); |
|
2509 } |
|
2510 } |
|
2511 |
|
2512 // Get old status |
|
2513 TInt status = testCase->Status(); |
|
2514 // Set result |
|
2515 testCase->SetResult( aFullTestResult ); |
|
2516 // Get new status |
|
2517 status |= testCase->Status(); |
|
2518 // Add set status flags |
|
2519 status |= setStatus; |
|
2520 |
|
2521 iUIStoreIf->Update( testCase, status ); |
|
2522 |
|
2523 return; |
|
2524 |
|
2525 } |
|
2526 |
|
2527 /* |
|
2528 ------------------------------------------------------------------------------- |
|
2529 |
|
2530 Class: CUIStore |
|
2531 |
|
2532 Method: PrintProg |
|
2533 |
|
2534 Description: Progress information from test case execution, |
|
2535 callback from UI engine. |
|
2536 |
|
2537 Parameters: CUIEngineContainer* const aContainer: in: Execution container |
|
2538 TTestProgress& aProgress: in: print info |
|
2539 |
|
2540 Return Values: Symbian OS error code |
|
2541 |
|
2542 |
|
2543 Errors/Exceptions: None |
|
2544 |
|
2545 Status: Draft |
|
2546 |
|
2547 ------------------------------------------------------------------------------- |
|
2548 */ |
|
2549 TInt CUIStore::PrintProg ( CUIEngineContainer* aContainer, |
|
2550 TTestProgress& aProgress ) |
|
2551 { |
|
2552 if( aContainer == NULL ) |
|
2553 { |
|
2554 return KErrArgument; |
|
2555 } |
|
2556 if( ( aProgress.iDescription.Length() == 0 ) && |
|
2557 ( aProgress.iText.Length() == 0 ) ) |
|
2558 |
|
2559 { |
|
2560 return KErrArgument; |
|
2561 } |
|
2562 |
|
2563 CStartedTestCase* testCase = NULL; |
|
2564 |
|
2565 if( FindByContainer( aContainer, testCase ) != KErrNone ) |
|
2566 { |
|
2567 __TRACE( KError, ( CStifLogger::EError, _L("CUIStore::TestExecuted: Not found"))); |
|
2568 return KErrNotFound; |
|
2569 } |
|
2570 |
|
2571 TInt position = KErrNotFound; |
|
2572 TInt smallPos = KErrNotFound; |
|
2573 |
|
2574 // Search the array to find the position |
|
2575 const TInt count = testCase->PrintArray().Count(); |
|
2576 for (TInt i = 0; i < count; i++) |
|
2577 { |
|
2578 |
|
2579 // Check if that item is already on list |
|
2580 if ( testCase->PrintArray()[i]->iDescription == aProgress.iDescription && |
|
2581 testCase->PrintArray()[i]->iPosition == aProgress.iPosition ) |
|
2582 { |
|
2583 // Set it to be updated |
|
2584 position = i; |
|
2585 break; |
|
2586 } |
|
2587 |
|
2588 // Found a smaller priority item from list |
|
2589 if ( aProgress.iPosition < testCase->PrintArray()[i]->iPosition ) |
|
2590 { |
|
2591 smallPos = i; |
|
2592 break; |
|
2593 } |
|
2594 } |
|
2595 |
|
2596 // Either update item in array or add new item to array |
|
2597 if ( position != KErrNotFound ) |
|
2598 { |
|
2599 // Replace existing text |
|
2600 testCase->PrintArray()[position]->ReplaceTextL( aProgress ); |
|
2601 } |
|
2602 else |
|
2603 { |
|
2604 CTestProgress* prog = NULL; |
|
2605 TRAPD( err, |
|
2606 // Allocate new |
|
2607 prog = CTestProgress::NewL( aProgress ); |
|
2608 ); |
|
2609 if( err != KErrNone ) |
|
2610 { |
|
2611 return err; |
|
2612 } |
|
2613 if ( smallPos != KErrNotFound ) |
|
2614 { |
|
2615 if( testCase->PrintArray().Insert( prog, smallPos ) != KErrNone ) |
|
2616 { |
|
2617 delete prog; |
|
2618 return KErrNoMemory; |
|
2619 } |
|
2620 } |
|
2621 else |
|
2622 { |
|
2623 if( testCase->PrintArray().Append( prog ) != KErrNone ) |
|
2624 { |
|
2625 delete prog; |
|
2626 return KErrNoMemory; |
|
2627 } |
|
2628 } |
|
2629 } |
|
2630 |
|
2631 iUIStoreIf->Update( testCase, CUIStoreIf::EPrintUpdate ); |
|
2632 |
|
2633 return KErrNone; |
|
2634 |
|
2635 } |
|
2636 |
|
2637 /* |
|
2638 ------------------------------------------------------------------------------- |
|
2639 |
|
2640 Class: CUIStore |
|
2641 |
|
2642 Method: PrintProg |
|
2643 |
|
2644 Description: Error information from Test framework, |
|
2645 callback from UI engine. |
|
2646 |
|
2647 Parameters: CUIEngineContainer* const aContainer: in: Execution container |
|
2648 TErrorNotification& aError: in: error info |
|
2649 |
|
2650 Return Values: Symbian OS error code |
|
2651 |
|
2652 Errors/Exceptions: None |
|
2653 |
|
2654 Status: Draft |
|
2655 |
|
2656 ------------------------------------------------------------------------------- |
|
2657 */ |
|
2658 TInt CUIStore::ErrorPrint( TErrorNotification& aError ) |
|
2659 { |
|
2660 |
|
2661 if( aError.iText.Length() == 0 ) |
|
2662 { |
|
2663 return KErrArgument; |
|
2664 } |
|
2665 |
|
2666 iUIStoreIf->Error( aError ); |
|
2667 |
|
2668 return KErrNone; |
|
2669 |
|
2670 } |
|
2671 |
|
2672 /* |
|
2673 ------------------------------------------------------------------------------- |
|
2674 |
|
2675 Class: CUIStore |
|
2676 |
|
2677 Method: RemoteMsg |
|
2678 |
|
2679 Description: Remote protocol control messages handling. |
|
2680 |
|
2681 Parameters: const TDesC& aMessage: in: Remote message |
|
2682 |
|
2683 Return Values: None |
|
2684 |
|
2685 Errors/Exceptions: None |
|
2686 |
|
2687 Status: Draft |
|
2688 |
|
2689 ------------------------------------------------------------------------------- |
|
2690 */ |
|
2691 TInt CUIStore::RemoteMsg( CUIEngineContainer* aContainer, |
|
2692 const TDesC& aMessage) |
|
2693 { |
|
2694 |
|
2695 if( ( aMessage.Length() == 0 ) || |
|
2696 ( aContainer == NULL ) ) |
|
2697 { |
|
2698 return KErrArgument; |
|
2699 } |
|
2700 |
|
2701 TInt ret = KErrNone; |
|
2702 |
|
2703 TInt error = KErrNone; |
|
2704 CStifTFwIfProt* msg = NULL; |
|
2705 CStifTFwIfProt* resp = NULL; |
|
2706 TRAPD( err, msg = CStifTFwIfProt::NewL(); ); |
|
2707 if( err != KErrNone ) |
|
2708 { |
|
2709 return err; |
|
2710 } |
|
2711 TRAP( err, resp = CStifTFwIfProt::NewL(); ); |
|
2712 if( err != KErrNone ) |
|
2713 { |
|
2714 delete msg; |
|
2715 return err; |
|
2716 } |
|
2717 |
|
2718 // Parse received message |
|
2719 TRAP( err, |
|
2720 error = msg->SetL( aMessage ) |
|
2721 ); |
|
2722 if( err != KErrNone ) |
|
2723 { |
|
2724 __TRACE( KError, ( _L( "CUIStore::RemoteMsg: message header parsing failed [%d]"), err ) ); |
|
2725 delete msg; |
|
2726 delete resp; |
|
2727 return err; |
|
2728 } |
|
2729 |
|
2730 // Create response |
|
2731 TRAP( err, resp->CreateL(); ); |
|
2732 if( err != KErrNone ) |
|
2733 { |
|
2734 delete msg; |
|
2735 delete resp; |
|
2736 return err; |
|
2737 } |
|
2738 |
|
2739 resp->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgResponse ); |
|
2740 |
|
2741 if( error != KErrNone ) |
|
2742 { |
|
2743 __TRACE( KError, ( _L( "CUIStore::RemoteMsg: message parsing failed [%d]"), error ) ); |
|
2744 resp->AppendId( SETID( (TInt32)DevId(), 0 ) ); |
|
2745 resp->AppendId( msg->SrcId() ); |
|
2746 resp->Append( CStifTFwIfProt::MsgType, msg->iMsgType ); |
|
2747 resp->Append( CStifTFwIfProt::RespParam, CStifTFwIfProt::ERespResult, error ); |
|
2748 |
|
2749 aContainer->RemoteReceive( resp->Message() ); |
|
2750 |
|
2751 // Error reported with protocol message, return success |
|
2752 delete msg; |
|
2753 delete resp; |
|
2754 return KErrNone; |
|
2755 } |
|
2756 |
|
2757 TBool sendResp = ETrue; |
|
2758 |
|
2759 switch( msg->iMsgType ) |
|
2760 { |
|
2761 case CStifTFwIfProt::EMsgReserve: |
|
2762 { |
|
2763 // Check IDs |
|
2764 if( ( msg->SrcDevId() == 0 ) || |
|
2765 ( msg->SrcTestId() == 0 ) ) |
|
2766 { |
|
2767 __TRACE( KError, ( _L( "CUIStore::RemoteMsg: reserve for illegal srcid received") ) ); |
|
2768 error = KErrGeneral; |
|
2769 } |
|
2770 if( msg->DstId() != 0 ) |
|
2771 { |
|
2772 // Not a broadcast |
|
2773 if( ( msg->DstDevId() != DevId() ) || |
|
2774 ( msg->DstTestId() != 0 ) ) |
|
2775 { |
|
2776 __TRACE( KError, ( _L( "CUIStore::RemoteMsg: reserve for illegal dstid received") ) ); |
|
2777 error = KErrGeneral; |
|
2778 } |
|
2779 } |
|
2780 |
|
2781 resp->AppendId( SETID( (TInt32)DevId(), 0 ) ); |
|
2782 resp->AppendId( msg->SrcId() ); |
|
2783 resp->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgReserve ); |
|
2784 if( error != KErrNone ) |
|
2785 { |
|
2786 resp->Append( CStifTFwIfProt::RespParam, CStifTFwIfProt::ERespResult, error ); |
|
2787 } |
|
2788 } |
|
2789 break; |
|
2790 case CStifTFwIfProt::EMsgRelease: |
|
2791 { |
|
2792 // Check protocol ids |
|
2793 if( ( msg->SrcDevId() == 0 ) || |
|
2794 ( msg->SrcTestId() == 0 ) || |
|
2795 ( msg->DstTestId() != 0 ) ) |
|
2796 { |
|
2797 __TRACE( KError, ( _L( "CUIStore::RemoteMsg: release for illegal srcid or dstid received") ) ); |
|
2798 error = KErrGeneral; |
|
2799 } |
|
2800 else if( msg->DstDevId() != DevId() ) |
|
2801 { |
|
2802 __TRACE( KError, ( _L( "CUIStore::RemoteMsg: release for illegal dstid received") ) ); |
|
2803 error = KErrNotFound; |
|
2804 } |
|
2805 |
|
2806 resp->AppendId( msg->DstId() ); |
|
2807 resp->AppendId( msg->SrcId() ); |
|
2808 resp->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRelease ); |
|
2809 |
|
2810 if( error != KErrNone ) |
|
2811 { |
|
2812 resp->Append( CStifTFwIfProt::RespParam, CStifTFwIfProt::ERespResult, error ); |
|
2813 } |
|
2814 } |
|
2815 break; |
|
2816 case CStifTFwIfProt::EMsgRemote: |
|
2817 { |
|
2818 // Check protocol ids |
|
2819 if( ( msg->SrcDevId() == 0 ) || |
|
2820 ( msg->SrcTestId() == 0 ) || |
|
2821 ( msg->DstDevId() == 0 ) ) |
|
2822 { |
|
2823 __TRACE( KError, ( _L( "CUIStore::RemoteMsg: remote for illegal srcid or dstid received") ) ); |
|
2824 error = KErrGeneral; |
|
2825 } |
|
2826 else |
|
2827 { |
|
2828 __TRACE( KError, ( _L( "CUIStore::RemoteMsg: received remote call") ) ); |
|
2829 |
|
2830 error = MsgRemote( aContainer, *msg, *resp ); |
|
2831 } |
|
2832 |
|
2833 if( error != KErrNone ) |
|
2834 { |
|
2835 resp->AppendId( msg->DstId() ); |
|
2836 resp->AppendId( msg->SrcId() ); |
|
2837 resp->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ); |
|
2838 resp->Append( msg->iCmdDes ); |
|
2839 resp->Append( CStifTFwIfProt::RespParam, |
|
2840 CStifTFwIfProt::ERespResult, |
|
2841 error ); |
|
2842 } |
|
2843 else |
|
2844 { |
|
2845 sendResp = EFalse; |
|
2846 } |
|
2847 |
|
2848 } |
|
2849 break; |
|
2850 case CStifTFwIfProt::EMsgResponse: |
|
2851 default: |
|
2852 __TRACE( KError, ( _L( "CUIStore::RemoteMsg: invalid message")) ); |
|
2853 ret = KErrNotSupported; |
|
2854 } |
|
2855 |
|
2856 if( ( ret == KErrNone ) && sendResp ) |
|
2857 { |
|
2858 aContainer->RemoteReceive( resp->Message() ); |
|
2859 } |
|
2860 |
|
2861 delete msg; |
|
2862 delete resp; |
|
2863 |
|
2864 return ret; |
|
2865 |
|
2866 } |
|
2867 |
|
2868 |
|
2869 /* |
|
2870 ------------------------------------------------------------------------------- |
|
2871 |
|
2872 Class: CUIStore |
|
2873 |
|
2874 Method: MsgRemote |
|
2875 |
|
2876 Description: Remote command |
|
2877 |
|
2878 Parameters: const TDesC& aMessage: in: |
|
2879 |
|
2880 Return Values: KErrNotSupported |
|
2881 |
|
2882 Errors/Exceptions: None |
|
2883 |
|
2884 Status: Draft |
|
2885 |
|
2886 ------------------------------------------------------------------------------- |
|
2887 */ |
|
2888 TInt CUIStore::MsgRemote( CUIEngineContainer* aContainer, |
|
2889 CStifTFwIfProt& aReq, |
|
2890 CStifTFwIfProt& aResp ) |
|
2891 { |
|
2892 |
|
2893 TInt ret = KErrNone; |
|
2894 |
|
2895 switch( aReq.iCmdType ) |
|
2896 { |
|
2897 case CStifTFwIfProt::ECmdRun: |
|
2898 ret = MsgRemoteRun( aContainer, aReq, aResp ); |
|
2899 break; |
|
2900 case CStifTFwIfProt::ECmdPause: |
|
2901 case CStifTFwIfProt::ECmdResume: |
|
2902 case CStifTFwIfProt::ECmdCancel: |
|
2903 ret = MsgRemoteTestCtl( aContainer, aReq, aResp ); |
|
2904 break; |
|
2905 case CStifTFwIfProt::ECmdRequest: |
|
2906 case CStifTFwIfProt::ECmdRelease: |
|
2907 ret = MsgRemoteEventCtl( aContainer, aReq, aResp ); |
|
2908 break; |
|
2909 case CStifTFwIfProt::ECmdSendReceive: |
|
2910 { |
|
2911 ret = MsgRemoteSendReceive( aContainer, aReq, aResp ); |
|
2912 break; |
|
2913 } |
|
2914 default: |
|
2915 { |
|
2916 CStifTFwIfProt* resp = NULL; |
|
2917 TRAPD( err, |
|
2918 resp = CStifTFwIfProt::NewL(); |
|
2919 resp->CreateL(); |
|
2920 ); |
|
2921 if( err != KErrNone ) |
|
2922 { |
|
2923 delete resp; |
|
2924 return err; |
|
2925 } |
|
2926 resp->SetMsgType( CStifTFwIfProt::EMsgResponse ); |
|
2927 resp->SetSrcId( aReq.DstId() ); |
|
2928 resp->SetDstId( aReq.SrcId() ); |
|
2929 resp->SetRespType( CStifTFwIfProt::EMsgRemote ); |
|
2930 // Command type must be set separately, |
|
2931 // because it is unspecified in this case |
|
2932 resp->iCmdType = aReq.iCmdType; |
|
2933 resp->Append( aReq.iCmdDes ); |
|
2934 |
|
2935 ret = RemotePopup( aContainer, aReq.Message(), resp ); |
|
2936 |
|
2937 if( ret != KErrNone ) |
|
2938 { |
|
2939 delete resp; |
|
2940 } |
|
2941 } |
|
2942 break; |
|
2943 } |
|
2944 |
|
2945 return ret; |
|
2946 |
|
2947 } |
|
2948 |
|
2949 /* |
|
2950 ------------------------------------------------------------------------------- |
|
2951 |
|
2952 Class: CUIStore |
|
2953 |
|
2954 Method: AtsRemoteRun |
|
2955 |
|
2956 Description: Remote run message |
|
2957 |
|
2958 Parameters: const TDesC& aMessage: in: |
|
2959 |
|
2960 Return Values: KErrNotSupported |
|
2961 |
|
2962 Errors/Exceptions: None |
|
2963 |
|
2964 Status: Draft |
|
2965 |
|
2966 ------------------------------------------------------------------------------- |
|
2967 */ |
|
2968 TInt CUIStore::MsgRemoteRun( CUIEngineContainer* aContainer, |
|
2969 CStifTFwIfProt& aReq, |
|
2970 CStifTFwIfProt& /* aResp */) |
|
2971 { |
|
2972 |
|
2973 TInt ret = KErrNone; |
|
2974 TUint16 testid = 0; |
|
2975 |
|
2976 if( ( aReq.DstDevId() == 0 ) || |
|
2977 ( aReq.DstTestId() != 0 ) ) |
|
2978 { |
|
2979 // Protocol violation |
|
2980 __TRACE( KError, ( _L( "AtsReceive: remote run for illegal dstid received") ) ); |
|
2981 return KErrGeneral; |
|
2982 } |
|
2983 |
|
2984 if ( aReq.DstDevId() != DevId() ) |
|
2985 { |
|
2986 // Not our protocol message |
|
2987 __TRACE( KError, ( _L( "AtsReceive: remote run for illegal dstdevid received") ) ); |
|
2988 return KErrNotFound; |
|
2989 } |
|
2990 |
|
2991 |
|
2992 if( aReq.iModule.Length() == 0 ) |
|
2993 { |
|
2994 __TRACE( KError, ( _L("No mandatory test module name given as run parameter") ) ); |
|
2995 ret = KErrNotFound; |
|
2996 } |
|
2997 else if( aReq.iTestCaseNumber < 0 ) |
|
2998 { |
|
2999 __TRACE( KError, ( _L("No mandatory test case number given as run parameter") ) ); |
|
3000 ret = KErrNotFound; |
|
3001 } |
|
3002 |
|
3003 testid = 1; |
|
3004 CStifTFwIfProt* resp = NULL; |
|
3005 TRAPD( err, |
|
3006 resp = CStifTFwIfProt::NewL(); |
|
3007 resp->CreateL(); |
|
3008 ); |
|
3009 if( err != KErrNone ) |
|
3010 { |
|
3011 delete resp; |
|
3012 return err; |
|
3013 } |
|
3014 |
|
3015 CStifTFwIfProt* resp2 = NULL; |
|
3016 TRAP( err, |
|
3017 resp2 = CStifTFwIfProt::NewL(); |
|
3018 resp2->CreateL(); |
|
3019 ); |
|
3020 if( err != KErrNone ) |
|
3021 { |
|
3022 delete resp2; |
|
3023 return err; |
|
3024 } |
|
3025 |
|
3026 resp->SetMsgType( CStifTFwIfProt::EMsgResponse ); |
|
3027 resp->SetSrcId( SETID( (TInt32)DevId(), testid ) ); |
|
3028 resp->SetDstId( aReq.SrcId() ); |
|
3029 resp->SetRespType( CStifTFwIfProt::EMsgRemote ); |
|
3030 resp->SetCmdType( CStifTFwIfProt::ECmdRun ); |
|
3031 |
|
3032 resp2->SetMsgType( CStifTFwIfProt::EMsgResponse ); |
|
3033 resp2->SetSrcId( SETID( (TInt32)DevId(), testid ) ); |
|
3034 resp2->SetDstId( aReq.SrcId() ); |
|
3035 resp2->SetRespType( CStifTFwIfProt::EMsgRemote ); |
|
3036 resp2->SetCmdType( CStifTFwIfProt::ECmdRun ); |
|
3037 |
|
3038 // Remote run started popup call |
|
3039 ret = RemotePopup( aContainer, aReq.Message(), resp, EPopupPriorityHighest ); |
|
3040 if( ret != KErrNone ) |
|
3041 { |
|
3042 delete resp; |
|
3043 } |
|
3044 |
|
3045 // Remote run result popup call |
|
3046 ret = RemotePopup( aContainer, aReq.Message(), resp2 ); |
|
3047 if( ret != KErrNone ) |
|
3048 { |
|
3049 delete resp2; |
|
3050 } |
|
3051 |
|
3052 return ret; |
|
3053 } |
|
3054 |
|
3055 /* |
|
3056 ------------------------------------------------------------------------------- |
|
3057 |
|
3058 Class: CUIStore |
|
3059 |
|
3060 Method: MsgRemoteTestCtl |
|
3061 |
|
3062 Description: Remote test control message |
|
3063 |
|
3064 Parameters: const TDesC& aMessage: in: |
|
3065 |
|
3066 Return Values: KErrNotSupported |
|
3067 |
|
3068 Errors/Exceptions: None |
|
3069 |
|
3070 Status: Draft |
|
3071 |
|
3072 ------------------------------------------------------------------------------- |
|
3073 */ |
|
3074 TInt CUIStore::MsgRemoteTestCtl( CUIEngineContainer* aContainer, |
|
3075 CStifTFwIfProt& aReq, |
|
3076 CStifTFwIfProt& /*aResp*/ ) |
|
3077 { |
|
3078 |
|
3079 TInt ret = KErrNone; |
|
3080 |
|
3081 if( ( aReq.DstDevId() == 0 ) || |
|
3082 ( aReq.DstTestId() == 0 ) ) |
|
3083 { |
|
3084 // Protocol violation |
|
3085 __TRACE( KError, ( _L( "AtsReceive: remote test control for illegal dstid received") ) ); |
|
3086 return KErrGeneral; |
|
3087 } |
|
3088 |
|
3089 if ( aReq.DstDevId() != DevId() ) |
|
3090 { |
|
3091 // Not our protocol message |
|
3092 __TRACE( KError, ( _L( "AtsReceive: remote test control for illegal dstdevid received") ) ); |
|
3093 return KErrNotFound; |
|
3094 } |
|
3095 |
|
3096 CStifTFwIfProt* resp = NULL; |
|
3097 TRAPD( err, |
|
3098 resp = CStifTFwIfProt::NewL(); |
|
3099 resp->CreateL(); |
|
3100 ); |
|
3101 if( err != KErrNone ) |
|
3102 { |
|
3103 delete resp; |
|
3104 return err; |
|
3105 } |
|
3106 |
|
3107 resp->SetMsgType( CStifTFwIfProt::EMsgResponse ); |
|
3108 resp->SetSrcId( aReq.DstId() ); |
|
3109 resp->SetDstId( aReq.SrcId() ); |
|
3110 resp->SetRespType( CStifTFwIfProt::EMsgRemote ); |
|
3111 resp->SetCmdType( aReq.iCmdType ); |
|
3112 |
|
3113 ret = RemotePopup( aContainer, aReq.Message(), resp ); |
|
3114 |
|
3115 if( ret != KErrNone ) |
|
3116 { |
|
3117 delete resp; |
|
3118 } |
|
3119 |
|
3120 return ret; |
|
3121 |
|
3122 } |
|
3123 |
|
3124 /* |
|
3125 ------------------------------------------------------------------------------- |
|
3126 |
|
3127 Class: CUIStore |
|
3128 |
|
3129 Method: MsgRemoteEventCtl |
|
3130 |
|
3131 Description: Remote run message |
|
3132 |
|
3133 Parameters: const TDesC& aMessage: in: |
|
3134 |
|
3135 Return Values: KErrNotSupported |
|
3136 |
|
3137 Errors/Exceptions: None |
|
3138 |
|
3139 Status: Draft |
|
3140 |
|
3141 ------------------------------------------------------------------------------- |
|
3142 */ |
|
3143 TInt CUIStore::MsgRemoteEventCtl( CUIEngineContainer* aContainer, |
|
3144 CStifTFwIfProt& aReq, |
|
3145 CStifTFwIfProt& aResp ) |
|
3146 { |
|
3147 |
|
3148 if( ( aReq.DstDevId() == 0 ) || |
|
3149 ( aReq.DstTestId() != 0 ) ) |
|
3150 { |
|
3151 // Protocol violation |
|
3152 __TRACE( KError, ( _L( "AtsReceive: remote event control for illegal dstid received") ) ); |
|
3153 return KErrGeneral; |
|
3154 } |
|
3155 |
|
3156 if ( aReq.DstDevId() != DevId() ) |
|
3157 { |
|
3158 // Not our protocol message |
|
3159 __TRACE( KError, ( _L( "AtsReceive: remote event control for illegal dstdevid received") ) ); |
|
3160 return KErrNotFound; |
|
3161 } |
|
3162 |
|
3163 if( aReq.iEventName.Length() == 0 ) |
|
3164 { |
|
3165 __TRACE( KError, ( _L("No event name given") ) ); |
|
3166 return KErrNotFound; |
|
3167 } |
|
3168 |
|
3169 TInt ret = KErrNone; |
|
3170 |
|
3171 switch( aReq.iCmdType ) |
|
3172 { |
|
3173 case CStifTFwIfProt::ECmdRequest: |
|
3174 { |
|
3175 // Send event active information |
|
3176 CStifTFwIfProt* resp = NULL; |
|
3177 TRAP( ret, |
|
3178 resp = CStifTFwIfProt::NewL(); |
|
3179 resp->CreateL(); ); |
|
3180 if( ret != KErrNone ) |
|
3181 { |
|
3182 delete resp; |
|
3183 return ret; |
|
3184 } |
|
3185 |
|
3186 resp->SetMsgType( CStifTFwIfProt::EMsgResponse ); |
|
3187 resp->SetSrcId( aReq.DstId() ); |
|
3188 resp->SetDstId( aReq.SrcId() ); |
|
3189 resp->SetRespType( CStifTFwIfProt::EMsgRemote ); |
|
3190 resp->SetCmdType( CStifTFwIfProt::ECmdRequest ); |
|
3191 resp->Append( CStifTFwIfProt::EventStatus, |
|
3192 CStifTFwIfProt::EEventSet ); |
|
3193 resp->Append( aReq.iEventName ); |
|
3194 ret = RemotePopup( aContainer, aReq.Message(), resp, EPopupPriorityNormal ); |
|
3195 |
|
3196 if( ret != KErrNone ) |
|
3197 { |
|
3198 delete resp; |
|
3199 } |
|
3200 |
|
3201 aResp.AppendId( aReq.DstId() ); |
|
3202 aResp.AppendId( aReq.SrcId() ); |
|
3203 aResp.Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ); |
|
3204 aResp.Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRequest ); |
|
3205 if( ret == KErrNone ) |
|
3206 { |
|
3207 aResp.Append( CStifTFwIfProt::EventStatus, |
|
3208 CStifTFwIfProt::EEventActive ); |
|
3209 aResp.Append( aReq.iEventName ); |
|
3210 } |
|
3211 else |
|
3212 { |
|
3213 aResp.Append( CStifTFwIfProt::EventStatus, |
|
3214 CStifTFwIfProt::EEventError ); |
|
3215 aResp.Append( aReq.iEventName ); |
|
3216 aResp.Append( CStifTFwIfProt::EventStatusParams, |
|
3217 CStifTFwIfProt::EEventResult, |
|
3218 ret ); |
|
3219 } |
|
3220 |
|
3221 ret = aContainer->RemoteReceive( aResp.Message() ); |
|
3222 ret = KErrNone; |
|
3223 } |
|
3224 break; |
|
3225 case CStifTFwIfProt::ECmdRelease: |
|
3226 { |
|
3227 // Check and delete all pending event popup windows for test case |
|
3228 TInt count = iPopups.Count(); |
|
3229 for( TInt i = 0; i<count; i++ ) |
|
3230 { |
|
3231 if( ( iPopups[i]->Container() == aContainer ) && |
|
3232 iPopups[i]->IsEventPopup() ) |
|
3233 { |
|
3234 delete iPopups[i]; |
|
3235 iPopups.Remove( i ); |
|
3236 } |
|
3237 } |
|
3238 |
|
3239 aResp.AppendId( aReq.DstId() ); |
|
3240 aResp.AppendId( aReq.SrcId() ); |
|
3241 aResp.Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ); |
|
3242 aResp.Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRelease ); |
|
3243 aResp.Append( aReq.iEventName ); |
|
3244 |
|
3245 ret = aContainer->RemoteReceive( aResp.Message() ); |
|
3246 ret = KErrNone; |
|
3247 |
|
3248 } |
|
3249 break; |
|
3250 default: |
|
3251 return KErrNotSupported; |
|
3252 } |
|
3253 |
|
3254 return ret; |
|
3255 |
|
3256 } |
|
3257 |
|
3258 /* |
|
3259 ------------------------------------------------------------------------------- |
|
3260 |
|
3261 Class: CUIStore |
|
3262 |
|
3263 Method: MsgRemoteSendReceive |
|
3264 |
|
3265 Description: Asynchronous remote sendreceive message |
|
3266 |
|
3267 Parameters: CUIEngineContainer* aContainer: in: |
|
3268 CStifTFwIfProt& aReq: in |
|
3269 CStifTFwIfProt& aResp: in |
|
3270 |
|
3271 Return Values: KErrNotSupported |
|
3272 |
|
3273 Errors/Exceptions: None |
|
3274 |
|
3275 Status: Draft |
|
3276 |
|
3277 ------------------------------------------------------------------------------- |
|
3278 */ |
|
3279 TInt CUIStore::MsgRemoteSendReceive( CUIEngineContainer* aContainer, |
|
3280 CStifTFwIfProt& aReq, |
|
3281 CStifTFwIfProt& aResp ) |
|
3282 { |
|
3283 |
|
3284 TInt ret = KErrNone; |
|
3285 // TUint16 testid = 0; |
|
3286 |
|
3287 if( ( aReq.DstDevId() == 0 ) || |
|
3288 ( aReq.DstTestId() != 0 ) ) |
|
3289 { |
|
3290 // Protocol violation |
|
3291 __TRACE( KError, ( _L( "AtsReceive: remote run for illegal dstid received") ) ); |
|
3292 return KErrGeneral; |
|
3293 } |
|
3294 |
|
3295 if ( aReq.DstDevId() != DevId() ) |
|
3296 { |
|
3297 // Not our protocol message |
|
3298 __TRACE( KError, ( _L( "AtsReceive: remote run for illegal dstdevid received") ) ); |
|
3299 return KErrNotFound; |
|
3300 } |
|
3301 |
|
3302 // testid = 1; |
|
3303 CStifTFwIfProt* resp = NULL; |
|
3304 TRAPD( err, |
|
3305 resp = CStifTFwIfProt::NewL(); |
|
3306 resp->CreateL(); |
|
3307 ); |
|
3308 if( err != KErrNone ) |
|
3309 { |
|
3310 delete resp; |
|
3311 return err; |
|
3312 } |
|
3313 |
|
3314 resp->SetMsgType( CStifTFwIfProt::EMsgResponse ); |
|
3315 //resp->SetSrcId( SETID( DevId(), testid ) ); |
|
3316 resp->SetSrcId( aReq.DstId() ); |
|
3317 resp->SetDstId( aReq.SrcId() ); |
|
3318 resp->SetRespType( CStifTFwIfProt::EMsgRemote ); |
|
3319 resp->SetCmdType( CStifTFwIfProt::ECmdSendReceive ); |
|
3320 |
|
3321 ret = RemotePopup( aContainer, aReq.Message(), resp ); |
|
3322 if( ret != KErrNone ) |
|
3323 { |
|
3324 delete resp; |
|
3325 } |
|
3326 |
|
3327 aResp.AppendId( aReq.DstId() ); |
|
3328 aResp.AppendId( aReq.SrcId() ); |
|
3329 aResp.Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ); |
|
3330 aResp.Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdSendReceive ); |
|
3331 if( ret != KErrNone ) |
|
3332 { |
|
3333 aResp.Append( CStifTFwIfProt::RunStatus, |
|
3334 CStifTFwIfProt::ERunError ); |
|
3335 aResp.Append( CStifTFwIfProt::RunStatusParams, |
|
3336 CStifTFwIfProt::ERunResult, ret ); |
|
3337 } |
|
3338 else |
|
3339 { |
|
3340 aResp.Append( CStifTFwIfProt::RunStatus, |
|
3341 CStifTFwIfProt::ERunStarted ); |
|
3342 } |
|
3343 |
|
3344 // Send response |
|
3345 aContainer->RemoteReceive( aResp.Message() ); |
|
3346 |
|
3347 // Response is created, return success |
|
3348 ret = KErrNone; |
|
3349 |
|
3350 return ret; |
|
3351 |
|
3352 } |
|
3353 |
|
3354 /* |
|
3355 ------------------------------------------------------------------------------- |
|
3356 |
|
3357 Class: CUIStore |
|
3358 |
|
3359 Method: GoingToReboot |
|
3360 |
|
3361 Description: Reboot indication handling. |
|
3362 |
|
3363 Parameters: CUIEngineContainer* aContainer: in: Container |
|
3364 |
|
3365 Return Values: None |
|
3366 |
|
3367 Errors/Exceptions: None |
|
3368 |
|
3369 Status: Draft |
|
3370 |
|
3371 ------------------------------------------------------------------------------- |
|
3372 */ |
|
3373 TInt CUIStore::GoingToReboot( CUIEngineContainer* /* aContainer */, |
|
3374 TRequestStatus& aStatus ) |
|
3375 { |
|
3376 |
|
3377 _LIT( KDateString,"%H%T%S.%C" ); |
|
3378 |
|
3379 const TInt KTimeFieldLength = 30; |
|
3380 TBuf<KTimeFieldLength> time; |
|
3381 |
|
3382 // Store info |
|
3383 CStifLogger* logger = CStifLogger::NewL( KUIStoreDefaultDir, |
|
3384 KUIStoreDefaultRebootFile, |
|
3385 CStifLogger::EData, |
|
3386 CStifLogger::EFile, |
|
3387 ETrue, |
|
3388 EFalse, |
|
3389 EFalse, |
|
3390 EFalse, |
|
3391 EFalse, |
|
3392 ETrue ); |
|
3393 |
|
3394 CleanupStack::PushL( logger ); |
|
3395 TInt count = iStartedTestCases.Count(); |
|
3396 for( TInt index=0; index<count; index++ ) |
|
3397 { |
|
3398 logger->Log( _L("%S\r\n"), &KUIStoreStartTest ); |
|
3399 |
|
3400 // First test case info |
|
3401 logger->Log( _L("%S %S\r\n"), &KUIStoreCaseModuleName, |
|
3402 &iStartedTestCases[index]->TestInfo().ModuleName() ); |
|
3403 logger->Log( _L("%S %S\r\n"), &KUIStoreTestCaseTitle, |
|
3404 &iStartedTestCases[index]->TestInfo().TestCaseTitle() ); |
|
3405 if( iStartedTestCases[index]->TestInfo().TestCaseFile().Length() > 0 ) |
|
3406 { |
|
3407 logger->Log( _L("%S %S\r\n"), &KUIStoreTestCaseFile, |
|
3408 &iStartedTestCases[index]->TestInfo().TestCaseFile() ); |
|
3409 } |
|
3410 logger->Log( _L("%S %d\r\n"), &KUIStoreTestCaseNum, |
|
3411 iStartedTestCases[index]->TestInfo().TestCaseNum() ); |
|
3412 logger->Log( _L("%S %d\r\n"), &KUIStoreCasePriority, |
|
3413 iStartedTestCases[index]->TestInfo().Priority() ); |
|
3414 //@js<--remove--> logger->Log( _L("%S %d %d\r\n"), &KUIStoreCaseTimeout, |
|
3415 //@js<--remove--> iStartedTestCases[index]->TestInfo().Timeout().Int64().Low(), |
|
3416 //@js<--remove--> iStartedTestCases[index]->TestInfo().Timeout().Int64().High() ); |
|
3417 logger->Log( _L("%S %d %d\r\n"), &KUIStoreCaseTimeout, |
|
3418 I64LOW(iStartedTestCases[index]->TestInfo().Timeout().Int64()), |
|
3419 I64HIGH(iStartedTestCases[index]->TestInfo().Timeout().Int64())); |
|
3420 |
|
3421 logger->Log( _L("%S %d\r\n"), &KUIStoreCaseExpectedResult, |
|
3422 iStartedTestCases[index]->TestInfo().ExpectedResult() ); |
|
3423 |
|
3424 logger->Log( _L("%S %d\r\n"), &KUIStoreCaseStatus, |
|
3425 iStartedTestCases[index]->Status() ); |
|
3426 |
|
3427 logger->Log( _L("%S %d %d\r\n"), &KUIStoreCaseExecutionResult, |
|
3428 iStartedTestCases[index]->Result().iCaseExecutionResultType, |
|
3429 iStartedTestCases[index]->Result().iCaseExecutionResultCode ); |
|
3430 logger->Log( _L("%S %d %S\r\n"), &KUIStoreCaseResult, |
|
3431 iStartedTestCases[index]->Result().iTestResult.iResult, |
|
3432 &iStartedTestCases[index]->Result().iTestResult.iResultDes ); |
|
3433 |
|
3434 // Start time |
|
3435 iStartedTestCases[index]->Result().iStartTime.FormatL( |
|
3436 time, KDateString ); |
|
3437 logger->Log( _L("%S %S\r\n"), &KUIStoreCaseStartTime, &time ); |
|
3438 |
|
3439 // Start time |
|
3440 iStartedTestCases[index]->Result().iEndTime.FormatL( |
|
3441 time, KDateString ); |
|
3442 logger->Log( _L("%S %S\r\n"), &KUIStoreCaseEndTime, &time ); |
|
3443 |
|
3444 logger->Log( _L("%S\r\n\r\n"), &KUIStoreStartTestEnd ); |
|
3445 } |
|
3446 |
|
3447 CleanupStack::PopAndDestroy( logger ); |
|
3448 |
|
3449 // Show popup |
|
3450 TKeyCode key; |
|
3451 iUIStoreIf->PopupMsg( _L("GoingToReboot"), |
|
3452 _L("Press any key to continue"), |
|
3453 KRebootPopupTimeout, key, aStatus ); |
|
3454 |
|
3455 return KErrNone; |
|
3456 |
|
3457 } |
|
3458 |
|
3459 /* |
|
3460 ------------------------------------------------------------------------------- |
|
3461 |
|
3462 Class: CUIStore |
|
3463 |
|
3464 Method: LoadExecutedTestCasesL |
|
3465 |
|
3466 Description: Load all executed testcases saved before reboot. |
|
3467 |
|
3468 Parameters: None |
|
3469 |
|
3470 Return Values: None |
|
3471 |
|
3472 Errors/Exceptions: Leaves on error |
|
3473 |
|
3474 Status: Draft |
|
3475 |
|
3476 ------------------------------------------------------------------------------- |
|
3477 */ |
|
3478 void CUIStore::LoadExecutedTestCasesL() |
|
3479 { |
|
3480 TPtrC tmp; |
|
3481 TInt num = 0; |
|
3482 TInt high = 0; |
|
3483 TInt64 interval; |
|
3484 TFullTestResult result; |
|
3485 TInt status = 0; |
|
3486 CStifItemParser* item = NULL; |
|
3487 TInt ret = KErrNone; |
|
3488 |
|
3489 CStifParser* parser = NULL; |
|
3490 TRAP( ret, |
|
3491 parser = CStifParser::NewL( KUIStoreDefaultDir, |
|
3492 KUIStoreDefaultRebootFile ); |
|
3493 ); |
|
3494 if( ret != KErrNone ) |
|
3495 { |
|
3496 // reboot file not found |
|
3497 return; |
|
3498 } |
|
3499 CleanupStack::PushL( parser ); |
|
3500 |
|
3501 __TRACE( KInit, ( _L( "Reboot file is found(%S%S). Reboot testing ongoing..." ), &KUIStoreDefaultDir, &KUIStoreDefaultRebootFile ) ); |
|
3502 |
|
3503 CTestInfo* testInfo = NULL; |
|
3504 |
|
3505 CStifSectionParser* section = |
|
3506 parser->SectionL( KUIStoreStartTest, KUIStoreStartTestEnd ); |
|
3507 |
|
3508 while( section ) |
|
3509 { |
|
3510 CleanupStack::PushL( section ); |
|
3511 |
|
3512 testInfo = CTestInfo::NewL(); |
|
3513 CleanupStack::PushL( testInfo ); |
|
3514 |
|
3515 // Get module name |
|
3516 // Mandatory, leave if not found |
|
3517 User::LeaveIfError( |
|
3518 section->GetLine( KUIStoreCaseModuleName, tmp, ENoTag ) ); |
|
3519 testInfo->SetModuleName( tmp ); |
|
3520 |
|
3521 // Get test case title |
|
3522 // Mandatory, leave if not found |
|
3523 User::LeaveIfError( |
|
3524 section->GetLine( KUIStoreTestCaseTitle, tmp, ENoTag ) ); |
|
3525 testInfo->SetTestCaseTitle( tmp ); |
|
3526 |
|
3527 // Get test case file |
|
3528 num = section->GetLine( KUIStoreTestCaseFile, tmp, ENoTag ); |
|
3529 if( ( num == KErrNone ) && |
|
3530 ( tmp.Length() > 0 ) ) |
|
3531 { |
|
3532 // Optional |
|
3533 testInfo->SetTestCaseFile( tmp ); |
|
3534 } |
|
3535 else |
|
3536 { |
|
3537 testInfo->SetTestCaseFile( KNullDesC ); |
|
3538 } |
|
3539 |
|
3540 // Get test case number |
|
3541 item = section->GetItemLineL( KUIStoreTestCaseNum ); |
|
3542 CleanupStack::PushL( item ); |
|
3543 // Mandatory, leave if not found |
|
3544 User::LeaveIfError( item->GetInt( KUIStoreTestCaseNum, num )); |
|
3545 testInfo->SetTestCaseNumber( num ); |
|
3546 CleanupStack::PopAndDestroy( item ); |
|
3547 |
|
3548 // Get test case priority |
|
3549 item = section->GetItemLineL( KUIStoreCasePriority ); |
|
3550 CleanupStack::PushL( item ); |
|
3551 // Mandatory, leave if not found |
|
3552 User::LeaveIfError( item->GetInt( KUIStoreCasePriority, num )); |
|
3553 testInfo->SetPriority( num ); |
|
3554 CleanupStack::PopAndDestroy( item ); |
|
3555 |
|
3556 // Get test case timeout |
|
3557 item = section->GetItemLineL( KUIStoreCaseTimeout ); |
|
3558 CleanupStack::PushL( item ); |
|
3559 // Mandatory, leave if not found |
|
3560 User::LeaveIfError( item->GetInt( KUIStoreCaseTimeout, num )); |
|
3561 User::LeaveIfError( item->GetNextInt( high )); |
|
3562 //interval.Set( high, num ); |
|
3563 interval = MAKE_TINT64( high, num ); |
|
3564 TTimeIntervalMicroSeconds timeout( interval ); |
|
3565 testInfo->SetTimeout( timeout ); |
|
3566 CleanupStack::PopAndDestroy( item ); |
|
3567 |
|
3568 // Get test case status |
|
3569 item = section->GetItemLineL( KUIStoreCaseStatus ); |
|
3570 CleanupStack::PushL( item ); |
|
3571 // Mandatory, leave if not found |
|
3572 User::LeaveIfError( item->GetInt( KUIStoreCaseStatus, status )); |
|
3573 CleanupStack::PopAndDestroy( item ); |
|
3574 |
|
3575 // Get test case execution result |
|
3576 item = section->GetItemLineL( KUIStoreCaseExecutionResult ); |
|
3577 CleanupStack::PushL( item ); |
|
3578 // Mandatory, leave if not found |
|
3579 User::LeaveIfError( item->GetInt( KUIStoreCaseExecutionResult, num )); |
|
3580 result.iCaseExecutionResultType = ( TFullTestResult::TCaseExecutionResult) num; |
|
3581 // Mandatory, leave if not found |
|
3582 User::LeaveIfError( item->GetNextInt( result.iCaseExecutionResultCode )); |
|
3583 CleanupStack::PopAndDestroy( item ); |
|
3584 |
|
3585 // Get test case result |
|
3586 item = section->GetItemLineL( KUIStoreCaseResult ); |
|
3587 CleanupStack::PushL( item ); |
|
3588 // Mandatory, leave if not found |
|
3589 User::LeaveIfError( item->GetInt( KUIStoreCaseResult, |
|
3590 result.iTestResult.iResult )); |
|
3591 // Not mandatory |
|
3592 TBool first = ETrue; |
|
3593 result.iTestResult.iResultDes.Zero(); |
|
3594 ret = item->GetNextString( tmp ); |
|
3595 while( ret == KErrNone ) |
|
3596 { |
|
3597 if( result.iTestResult.iResultDes.Length() + tmp.Length() + 1 > result.iTestResult.iResultDes.MaxLength() ) |
|
3598 { |
|
3599 User::Leave( KErrGeneral ); |
|
3600 } |
|
3601 if(!first) |
|
3602 result.iTestResult.iResultDes.Append(_L(" ")); |
|
3603 result.iTestResult.iResultDes.Append( tmp ); |
|
3604 first = EFalse; |
|
3605 ret = item->GetNextString( tmp ); |
|
3606 } |
|
3607 /* |
|
3608 ret = item->GetNextString( tmp ); |
|
3609 if( ret == KErrNone ) |
|
3610 { |
|
3611 if( tmp.Length() > result.iTestResult.iResultDes.MaxLength() ) |
|
3612 { |
|
3613 User::Leave( KErrGeneral ); |
|
3614 } |
|
3615 result.iTestResult.iResultDes.Copy( tmp ); |
|
3616 } |
|
3617 */ |
|
3618 CleanupStack::PopAndDestroy( item ); |
|
3619 |
|
3620 // Get test start time |
|
3621 item = section->GetItemLineL( KUIStoreCaseStartTime ); |
|
3622 CleanupStack::PushL( item ); |
|
3623 // Mandatory, leave if not found |
|
3624 User::LeaveIfError( item->GetString( KUIStoreCaseStartTime, tmp )); |
|
3625 result.iStartTime.Set( tmp ); |
|
3626 CleanupStack::PopAndDestroy( item ); |
|
3627 |
|
3628 // Get test end time |
|
3629 item = section->GetItemLineL( KUIStoreCaseEndTime ); |
|
3630 CleanupStack::PushL( item ); |
|
3631 // Mandatory, leave if not found |
|
3632 User::LeaveIfError( item->GetString( KUIStoreCaseEndTime, tmp )); |
|
3633 result.iEndTime.Set( tmp ); |
|
3634 CleanupStack::PopAndDestroy( item ); |
|
3635 |
|
3636 if( status != CUIStoreIf::EStatusRunning ) |
|
3637 { |
|
3638 // Add executed test cases to list |
|
3639 CStartedTestCase* startedCase = |
|
3640 new( ELeave )CStartedTestCase( testInfo, result, status ); |
|
3641 User::LeaveIfError( iStartedTestCases.Append( startedCase ) ); |
|
3642 CleanupStack::Pop( testInfo ); |
|
3643 |
|
3644 // Fill data with test case info and send to test engine |
|
3645 TTestInfo *info = new (ELeave) TTestInfo; |
|
3646 CleanupStack::PushL(info); |
|
3647 info->iModuleName.Copy(testInfo->ModuleName()); |
|
3648 info->iConfig.Copy(testInfo->TestCaseFile()); |
|
3649 info->iTestCaseInfo.iCaseNumber = testInfo->TestCaseNum(); |
|
3650 info->iTestCaseInfo.iTitle.Copy(testInfo->TestCaseTitle()); |
|
3651 info->iTestCaseInfo.iTimeout = testInfo->Timeout(); |
|
3652 info->iTestCaseInfo.iPriority = testInfo->Priority(); |
|
3653 |
|
3654 iUIEngine->TestEngine().AddTestCaseResultToTestReport(*info, result, KErrNone); |
|
3655 CleanupStack::PopAndDestroy(info); |
|
3656 } |
|
3657 else |
|
3658 { |
|
3659 // Restart testcase that was running when reset was done |
|
3660 CUIEngineContainer* container = NULL; |
|
3661 User::LeaveIfError( |
|
3662 iUIEngine->StartTestCase( container, *testInfo ) ); |
|
3663 |
|
3664 CStartedTestCase* testCase = NULL; |
|
3665 TRAPD( retVal, |
|
3666 testCase = CStartedTestCase::NewL( *testInfo, *container ); |
|
3667 ); |
|
3668 if( retVal != KErrNone ) |
|
3669 { |
|
3670 iUIEngine->AbortStartedTestCase( container ); |
|
3671 User::Leave( retVal ); |
|
3672 } |
|
3673 |
|
3674 retVal = iStartedTestCases.Append( testCase ); |
|
3675 if( retVal != KErrNone ) |
|
3676 { |
|
3677 iUIEngine->AbortStartedTestCase( container ); |
|
3678 delete testCase; |
|
3679 User::Leave( retVal ); |
|
3680 } |
|
3681 |
|
3682 CleanupStack::PopAndDestroy( testInfo ); |
|
3683 |
|
3684 } |
|
3685 |
|
3686 CleanupStack::PopAndDestroy( section ); |
|
3687 section = |
|
3688 parser->NextSectionL( KUIStoreStartTest, KUIStoreStartTestEnd ); |
|
3689 } |
|
3690 |
|
3691 CleanupStack::PopAndDestroy( parser ); |
|
3692 |
|
3693 // Delete file |
|
3694 RFs rf; |
|
3695 TInt retVal = rf.Connect(); |
|
3696 if( retVal != KErrNone ) |
|
3697 { |
|
3698 User::Leave( retVal ); |
|
3699 } |
|
3700 |
|
3701 TFileName file( KUIStoreDefaultDir ); |
|
3702 file.Append( KUIStoreDefaultRebootFile ); |
|
3703 rf.Delete( file ); |
|
3704 rf.Close(); |
|
3705 |
|
3706 return; |
|
3707 } |
|
3708 /* |
|
3709 ------------------------------------------------------------------------------- |
|
3710 |
|
3711 Class: CUIStore |
|
3712 |
|
3713 Method: FindByContainer |
|
3714 |
|
3715 Description: Find test case with UIEngine Container pointer. |
|
3716 |
|
3717 Parameters: CUIEngineContainer* const aContainer: in: Execution container |
|
3718 CStartedTestCase*& aTestCase: out: Testcase info |
|
3719 |
|
3720 Return Values: Symbian OS error code |
|
3721 |
|
3722 Errors/Exceptions: None |
|
3723 |
|
3724 Status: Draft |
|
3725 |
|
3726 ------------------------------------------------------------------------------- |
|
3727 */ |
|
3728 TInt CUIStore::FindByContainer( CUIEngineContainer* const aContainer, |
|
3729 CStartedTestCase*& aTestCase ) |
|
3730 { |
|
3731 |
|
3732 TInt count = iStartedTestCases.Count(); |
|
3733 TInt index = 0; |
|
3734 for( ; index < count; index++ ) |
|
3735 { |
|
3736 if( ( iStartedTestCases[index]->Status() & |
|
3737 CUIStoreIf::EStatusRunning ) && |
|
3738 ( &iStartedTestCases[index]->UIEngineContainer() == |
|
3739 aContainer ) ) |
|
3740 { |
|
3741 aTestCase = iStartedTestCases[index]; |
|
3742 return KErrNone; |
|
3743 } |
|
3744 } |
|
3745 |
|
3746 return KErrNotFound; |
|
3747 |
|
3748 } |
|
3749 |
|
3750 /* |
|
3751 ------------------------------------------------------------------------------- |
|
3752 |
|
3753 Class: CUIStore |
|
3754 |
|
3755 Method: UpdateCases |
|
3756 |
|
3757 Description: Refreshs iTestCases array ie. fetches test cases from |
|
3758 test framework |
|
3759 |
|
3760 Parameters: None |
|
3761 |
|
3762 Return Values: None |
|
3763 |
|
3764 Errors/Exceptions: None |
|
3765 |
|
3766 Status: Draft |
|
3767 |
|
3768 ------------------------------------------------------------------------------- |
|
3769 */ |
|
3770 TInt CUIStore::UpdateCases() |
|
3771 { |
|
3772 |
|
3773 if( iUpdateNeeded ) |
|
3774 { |
|
3775 TInt handle = iUIStoreIf->PopupMsg( |
|
3776 _L("Updating"), _L("Test cases"), 60 ); |
|
3777 iTestCases.ResetAndDestroy(); |
|
3778 TRAPD( ret, |
|
3779 ret = iUIEngine->GetTestCasesL( iTestCases ); |
|
3780 ); |
|
3781 iUpdateNeeded = EFalse; |
|
3782 // Close popup |
|
3783 iUIStoreIf->Close( handle ); |
|
3784 if( iTestCases.Count() == 0 ) |
|
3785 { |
|
3786 iUIStoreIf->PopupMsg( _L("No test cases found"), |
|
3787 _L("e.g. check TestEngine log"), |
|
3788 3 ); |
|
3789 } |
|
3790 return ret; |
|
3791 } |
|
3792 |
|
3793 return KErrNone; |
|
3794 |
|
3795 } |
|
3796 |
|
3797 /* |
|
3798 ------------------------------------------------------------------------------- |
|
3799 |
|
3800 Class: CUIStore |
|
3801 |
|
3802 Method: CheckIniL |
|
3803 |
|
3804 Description: Check ini file |
|
3805 |
|
3806 Parameters: None |
|
3807 |
|
3808 Return Values: None |
|
3809 |
|
3810 Errors/Exceptions: None |
|
3811 |
|
3812 Status: Draft |
|
3813 |
|
3814 ------------------------------------------------------------------------------- |
|
3815 */ |
|
3816 void CUIStore::CheckIniL( TFileName& aIni ) |
|
3817 { |
|
3818 |
|
3819 RFs fs; |
|
3820 User::LeaveIfError( fs.Connect() ); |
|
3821 RFile file; |
|
3822 TInt err = KErrNone; |
|
3823 TErrorNotification error; |
|
3824 error.iModule.Copy( KUIStore ); |
|
3825 |
|
3826 TStifUtil::CorrectFilePathL( aIni ); |
|
3827 |
|
3828 if ( aIni.Length() != 0 ) |
|
3829 { |
|
3830 err = file.Open ( fs, aIni, EFileRead ); |
|
3831 |
|
3832 if ( err == KErrNone ) |
|
3833 { |
|
3834 // Use the file given as command line parameter |
|
3835 iUIStoreIf->PopupMsg( _L("Using given ini-file"), |
|
3836 KNullDesC, 0 ); |
|
3837 file.Close(); |
|
3838 fs.Close(); |
|
3839 return; |
|
3840 } |
|
3841 else |
|
3842 { |
|
3843 error.iText.Copy( _L("Can't open given ini-file") ); |
|
3844 iUIStoreIf->Error( error ); |
|
3845 aIni.Zero(); |
|
3846 } |
|
3847 } |
|
3848 |
|
3849 // Try to locate default ini file from every drive |
|
3850 TDriveList drivelist; |
|
3851 User::LeaveIfError( fs.DriveList(drivelist) ); |
|
3852 // A TDriveList (the list of available drives), is an array of |
|
3853 // 26 bytes. Each byte with a non zero value signifies that the |
|
3854 // corresponding drive is available. |
|
3855 |
|
3856 TInt driveNumber; |
|
3857 TChar driveLetter; |
|
3858 |
|
3859 for( driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++ ) |
|
3860 { |
|
3861 if( !drivelist[driveNumber] ) |
|
3862 { |
|
3863 // If drive-list entry is zero, drive is not available |
|
3864 continue; |
|
3865 } |
|
3866 User::LeaveIfError( |
|
3867 fs.DriveToChar( driveNumber, driveLetter )); |
|
3868 |
|
3869 aIni.Zero(); |
|
3870 aIni.Append( driveLetter ); |
|
3871 aIni.Append( _L(":") ); |
|
3872 aIni.Append( KDefaultIni ); |
|
3873 |
|
3874 // Try to open |
|
3875 err = file.Open ( fs, aIni, EFileRead ); |
|
3876 |
|
3877 if ( err == KErrNone ) |
|
3878 { |
|
3879 // Use default file |
|
3880 file.Close(); |
|
3881 TFileName info( _L("Using default ini-file ") ); |
|
3882 if( info.MaxLength()-info.Length() > aIni.Length() ) |
|
3883 { |
|
3884 // Show also filename if fits to descriptor |
|
3885 info.Append( aIni ); |
|
3886 } |
|
3887 iUIStoreIf->PopupMsg( info, KNullDesC, 0 ); |
|
3888 break; |
|
3889 } |
|
3890 } |
|
3891 if( err != KErrNone ) |
|
3892 { |
|
3893 iUIStoreIf->PopupMsg( _L("Starting without ini-file"), |
|
3894 KNullDesC, 0); |
|
3895 aIni.Zero(); |
|
3896 } |
|
3897 |
|
3898 fs.Close(); |
|
3899 |
|
3900 } |
|
3901 |
|
3902 /* |
|
3903 ------------------------------------------------------------------------------- |
|
3904 |
|
3905 Class: CUIStore |
|
3906 |
|
3907 Method: ParseTestSetName |
|
3908 |
|
3909 Description: Parses test set name from test set filename. |
|
3910 |
|
3911 Parameters: const TDesC& aSetFileName: in: Test set filename |
|
3912 TPtrC& aSetName: out: testset name |
|
3913 TFileName& aFileName: in: filenamebuffer |
|
3914 |
|
3915 Return Values: Symbian OS error code |
|
3916 |
|
3917 Errors/Exceptions: None |
|
3918 |
|
3919 Status: Draft |
|
3920 |
|
3921 ------------------------------------------------------------------------------- |
|
3922 */ |
|
3923 TInt CUIStore::ParseTestSetName( const TDesC& aSetFileName, |
|
3924 TPtrC& aSetName, |
|
3925 TFileName& aFileName ) |
|
3926 { |
|
3927 if( aSetFileName.Length() > KMaxFileName ) |
|
3928 { |
|
3929 return KErrArgument; |
|
3930 } |
|
3931 |
|
3932 aFileName.Copy( aSetFileName ); |
|
3933 TParsePtr p( aFileName ); |
|
3934 aSetName.Set( p.NameAndExt() ); // gives test set name without path |
|
3935 |
|
3936 if( aSetName.Length() > KMaxName ) |
|
3937 { |
|
3938 return KErrArgument; |
|
3939 } |
|
3940 |
|
3941 return KErrNone; |
|
3942 |
|
3943 } |
|
3944 |
|
3945 /* |
|
3946 ------------------------------------------------------------------------------- |
|
3947 |
|
3948 Class: CUIStore |
|
3949 |
|
3950 Method: RemotePopup |
|
3951 |
|
3952 Description: Do remote message popup |
|
3953 |
|
3954 Parameters: const TDesC& aReq: in: request |
|
3955 |
|
3956 Return Values: Symbian OS error code |
|
3957 |
|
3958 Errors/Exceptions: None |
|
3959 |
|
3960 Status: Draft |
|
3961 |
|
3962 ------------------------------------------------------------------------------- |
|
3963 */ |
|
3964 TInt CUIStore::RemotePopup( CUIEngineContainer* aContainer, |
|
3965 const TDesC& aMsg, |
|
3966 CStifTFwIfProt* aResp, |
|
3967 TPopupPriority aPopupPriority ) |
|
3968 { |
|
3969 TInt ret = KErrNone; |
|
3970 |
|
3971 CUIStorePopup* popup = NULL; |
|
3972 TRAP( ret, popup = CUIStorePopup::NewL( this, aContainer, aResp, aPopupPriority, aMsg ); ); |
|
3973 if( ret != KErrNone ) |
|
3974 { |
|
3975 return ret; |
|
3976 } |
|
3977 ret = iPopups.Append( popup ); |
|
3978 if( ret != KErrNone ) |
|
3979 { |
|
3980 delete popup; |
|
3981 return ret; |
|
3982 } |
|
3983 |
|
3984 // We'll put new popup to the top if there are no popups active or if |
|
3985 // currently active popup has lower priority than the new one |
|
3986 if( !iPopupActive || iActivePopupPriority > popup->GetPriority() ) |
|
3987 { |
|
3988 SetRemotePopupFromQueue(); |
|
3989 } |
|
3990 |
|
3991 return ret; |
|
3992 } |
|
3993 |
|
3994 /* |
|
3995 ------------------------------------------------------------------------------- |
|
3996 |
|
3997 Class: CUIStore |
|
3998 |
|
3999 Method: SetRemotePopupFromQueue |
|
4000 |
|
4001 Description: Prints the highest priority popup to the UI from the popup |
|
4002 queue |
|
4003 |
|
4004 Parameters: None |
|
4005 |
|
4006 Return Values: None |
|
4007 |
|
4008 Errors/Exceptions: None |
|
4009 |
|
4010 Status: Draft @js |
|
4011 |
|
4012 ------------------------------------------------------------------------------- |
|
4013 */ |
|
4014 |
|
4015 void CUIStore::SetRemotePopupFromQueue() |
|
4016 { |
|
4017 CUIStorePopup* popup = NULL; |
|
4018 |
|
4019 if(iPopups.Count() > 0 ) |
|
4020 { |
|
4021 TInt highest = 0; |
|
4022 |
|
4023 // Let's get the highest priority popup and print it to the UI |
|
4024 for( TInt x=0; x<iPopups.Count(); x++) |
|
4025 { |
|
4026 if( iPopups[x]->GetPriority() < iPopups[highest]->GetPriority() ) |
|
4027 { |
|
4028 highest = x; |
|
4029 } |
|
4030 } |
|
4031 |
|
4032 popup = iPopups[highest]; |
|
4033 |
|
4034 if( popup == NULL ) |
|
4035 { |
|
4036 // Some weird error |
|
4037 iPopupActive = EFalse; |
|
4038 return; |
|
4039 } |
|
4040 |
|
4041 // Change the active popup priority |
|
4042 iActivePopupPriority = popup->GetPriority(); |
|
4043 |
|
4044 // Create proper popup |
|
4045 if( popup->GetPriority() == EPopupPriorityHighest ) |
|
4046 { |
|
4047 popup->Start( popup->GetMessage().Right( popup->GetMessage().Length() - KRcpHeaderLen ), |
|
4048 _L("Press any key to send 'remote run started' message")); |
|
4049 } |
|
4050 else if( popup->GetPriority() == EPopupPriorityNormal ) |
|
4051 { |
|
4052 popup->Start( popup->GetMessage().Right( popup->GetMessage().Length() - KRcpHeaderLen ), |
|
4053 _L("Press any key to set event") ); |
|
4054 } |
|
4055 else if( popup->GetPriority() == EPopupPriorityLow ) |
|
4056 { |
|
4057 popup->Start( popup->GetMessage().Right( popup->GetMessage().Length() - KRcpHeaderLen ), |
|
4058 _L("Press 1-9 to return negative error value, a to switch to another remote run result popup, or any other key to return 0") ); |
|
4059 } |
|
4060 |
|
4061 iPopupActive = ETrue; |
|
4062 } |
|
4063 } |
|
4064 /* |
|
4065 ------------------------------------------------------------------------------- |
|
4066 |
|
4067 Class: CUIStore |
|
4068 |
|
4069 Method: ShuffleRemoteRunResultPopups |
|
4070 |
|
4071 Description: Shuffle remote run result popups |
|
4072 |
|
4073 Parameters: CUIStorePopup* aPopup (currently active popup) |
|
4074 |
|
4075 Return Values: None |
|
4076 |
|
4077 Errors/Exceptions: None |
|
4078 |
|
4079 Status: Draft @js |
|
4080 |
|
4081 ------------------------------------------------------------------------------- |
|
4082 */ |
|
4083 void CUIStore::ShuffleRemoteRunResultPopups( CUIStorePopup* aPopup ) |
|
4084 { |
|
4085 TInt nextPopupId = -1; |
|
4086 |
|
4087 for( TInt x=0; x<iPopups.Count(); x++) |
|
4088 { |
|
4089 // Lets find the next remote run result priority popup |
|
4090 if( iPopups[x]->GetPriority() == EPopupPriorityLow && iPopups[x] != aPopup ) |
|
4091 { |
|
4092 nextPopupId = x; |
|
4093 break; |
|
4094 } |
|
4095 } |
|
4096 |
|
4097 if( nextPopupId == -1 ) |
|
4098 { |
|
4099 // We'll print error message popup, because there weren't any other remote run |
|
4100 // result popups active |
|
4101 |
|
4102 iUIStoreIf->PopupMsg( |
|
4103 _L("Error! There weren't any other remote run result popups active."), |
|
4104 _L(""), |
|
4105 5 ); |
|
4106 User::After( 5000000 ); |
|
4107 iPopups.Append( aPopup ); |
|
4108 SetRemotePopupFromQueue(); |
|
4109 return; |
|
4110 } |
|
4111 |
|
4112 // We'll add the popup to the end of the array |
|
4113 TInt ret = iPopups.Append( aPopup ); |
|
4114 |
|
4115 if( ret != KErrNone ) |
|
4116 { |
|
4117 delete aPopup; |
|
4118 return; |
|
4119 } |
|
4120 |
|
4121 // Print the next popup from queue |
|
4122 SetRemotePopupFromQueue(); |
|
4123 } |
|
4124 |
|
4125 /* |
|
4126 ------------------------------------------------------------------------------- |
|
4127 |
|
4128 Class: CUIStore |
|
4129 |
|
4130 Method: RemotePopup |
|
4131 |
|
4132 Description: Do remote message popup |
|
4133 |
|
4134 Parameters: const TDesC& aReq: in: request |
|
4135 |
|
4136 Return Values: Symbian OS error code |
|
4137 |
|
4138 Errors/Exceptions: None |
|
4139 |
|
4140 Status: Draft |
|
4141 |
|
4142 ------------------------------------------------------------------------------- |
|
4143 */ |
|
4144 TInt CUIStore::RemotePopupComplete( CUIStorePopup* aPopup, |
|
4145 TInt aError, |
|
4146 CUIEngineContainer* aContainer, |
|
4147 CStifTFwIfProt* aResp, |
|
4148 TKeyCode aKeyCode ) |
|
4149 { |
|
4150 |
|
4151 TInt ret = KErrNone; |
|
4152 TInt index = iPopups.Find( aPopup ); |
|
4153 if( index < 0 ) |
|
4154 { |
|
4155 User::Panic( KUIStore, KErrGeneral ); |
|
4156 } |
|
4157 iPopups.Remove( index ); |
|
4158 |
|
4159 iPopupActive = EFalse; |
|
4160 iActivePopupPriority = EPopupPriorityLow; |
|
4161 |
|
4162 if( aError != KErrNone ) |
|
4163 { |
|
4164 ret = aError; |
|
4165 } |
|
4166 else |
|
4167 { |
|
4168 TChar c( aKeyCode ); |
|
4169 if( c.IsDigit() ) |
|
4170 { |
|
4171 // Solve return value |
|
4172 ret = -( aKeyCode - '0' ); |
|
4173 } |
|
4174 else |
|
4175 { |
|
4176 ret = KErrNone; |
|
4177 } |
|
4178 } |
|
4179 // If aResp is given, send it |
|
4180 if( aResp ) |
|
4181 { |
|
4182 switch( aResp->iCmdType ) |
|
4183 { |
|
4184 case CStifTFwIfProt::ECmdRun: |
|
4185 { |
|
4186 TChar response( aKeyCode ); |
|
4187 RDebug::Print(_L("CUIStore::RemotePopupComplete: user pressed key %c"), (char)response); |
|
4188 |
|
4189 if( aPopup->GetPriority() == EPopupPriorityHighest ) |
|
4190 { |
|
4191 // User has given response to remote run started- popup |
|
4192 aResp->Append( CStifTFwIfProt::RunStatus, |
|
4193 CStifTFwIfProt::ERunStarted ); |
|
4194 } |
|
4195 else if( aPopup->GetPriority() == EPopupPriorityLow && response=='a' ) |
|
4196 { |
|
4197 // User wants to change current remote run result popup to other |
|
4198 // remote run result popup. |
|
4199 |
|
4200 ShuffleRemoteRunResultPopups( aPopup ); |
|
4201 return KErrNone; |
|
4202 } |
|
4203 else |
|
4204 { |
|
4205 // The test case result was given |
|
4206 aResp->Append( CStifTFwIfProt::RunStatus, |
|
4207 CStifTFwIfProt::ERunReady ); |
|
4208 if( ret != KErrNone ) |
|
4209 { |
|
4210 aResp->Append( CStifTFwIfProt::RunStatusParams, |
|
4211 CStifTFwIfProt::ERunResult, ret ); |
|
4212 } |
|
4213 } |
|
4214 break; |
|
4215 } |
|
4216 case CStifTFwIfProt::ECmdSendReceive: |
|
4217 { |
|
4218 aResp->Append( CStifTFwIfProt::RunStatus, |
|
4219 CStifTFwIfProt::ERunReady ); |
|
4220 if( ret != KErrNone ) |
|
4221 { |
|
4222 aResp->Append( CStifTFwIfProt::RunStatusParams, |
|
4223 CStifTFwIfProt::ERunResult, ret ); |
|
4224 } |
|
4225 break; |
|
4226 } |
|
4227 case CStifTFwIfProt::ECmdPause: |
|
4228 case CStifTFwIfProt::ECmdResume: |
|
4229 case CStifTFwIfProt::ECmdCancel: |
|
4230 case CStifTFwIfProt::ECmdRequest: |
|
4231 case CStifTFwIfProt::ECmdRelease: |
|
4232 default: |
|
4233 if( ret != KErrNone ) |
|
4234 { |
|
4235 aResp->Append( CStifTFwIfProt::RespParam, |
|
4236 CStifTFwIfProt::ERespResult, |
|
4237 ret ); |
|
4238 } |
|
4239 break; |
|
4240 } |
|
4241 |
|
4242 ret = aContainer->RemoteReceive( aResp->Message() ); |
|
4243 } |
|
4244 |
|
4245 delete aPopup; |
|
4246 |
|
4247 SetRemotePopupFromQueue(); |
|
4248 |
|
4249 return ret; |
|
4250 |
|
4251 } |
|
4252 |
|
4253 /* |
|
4254 ------------------------------------------------------------------------------- |
|
4255 |
|
4256 Class: CUIStore |
|
4257 |
|
4258 Method: ReadFiltersL |
|
4259 |
|
4260 Description: Reads filters from test framework initialization file. |
|
4261 |
|
4262 Parameters: RPointerArray<TDesC>& aFilters: array to be filled |
|
4263 |
|
4264 Return Values: None |
|
4265 |
|
4266 Errors/Exceptions: |
|
4267 |
|
4268 Status: Draft |
|
4269 |
|
4270 ------------------------------------------------------------------------------- |
|
4271 */ |
|
4272 EXPORT_C void CUIStore::ReadFiltersL(RPointerArray<TDesC>& aFilters) |
|
4273 { |
|
4274 // Clean array |
|
4275 aFilters.ResetAndDestroy(); |
|
4276 |
|
4277 // Locate file |
|
4278 _LIT(KFilterSectionStart, "[Filters]"); |
|
4279 _LIT(KFilterSectionEnd, "[End_Filters]"); |
|
4280 _LIT(KFilterDefinition, "filter="); |
|
4281 |
|
4282 // Parse initialization file |
|
4283 TInt err = KErrNone; |
|
4284 CStifParser* parser; |
|
4285 |
|
4286 RDebug::Print(_L("STIF: Try to read filters from [%S]"), &iTestFrameworkIni); |
|
4287 parser = CStifParser::NewL(KNullDesC, iTestFrameworkIni); |
|
4288 CleanupStack::PushL(parser); |
|
4289 |
|
4290 // Parser created (file exists), create section parser |
|
4291 CStifSectionParser* section; |
|
4292 section = parser->SectionL(KFilterSectionStart, KFilterSectionEnd); |
|
4293 if(section) |
|
4294 { |
|
4295 CleanupStack::PushL(section); |
|
4296 |
|
4297 // Get item lines |
|
4298 CStifItemParser* item = section->GetItemLineL(KFilterDefinition, ENoTag); |
|
4299 |
|
4300 TPtrC ptr; |
|
4301 |
|
4302 while(item) |
|
4303 { |
|
4304 CleanupStack::PushL(item); |
|
4305 |
|
4306 // Read filter value |
|
4307 err = item->GetString(KNullDesC, ptr); |
|
4308 if(err == KErrNone) |
|
4309 { |
|
4310 HBufC* filter = ptr.AllocLC(); |
|
4311 User::LeaveIfError(aFilters.Append(filter)); |
|
4312 CleanupStack::Pop(); |
|
4313 } |
|
4314 |
|
4315 CleanupStack::PopAndDestroy(item); |
|
4316 item = NULL; |
|
4317 item = section->GetNextItemLineL(KFilterDefinition, ENoTag); |
|
4318 } |
|
4319 |
|
4320 CleanupStack::PopAndDestroy(section); |
|
4321 } |
|
4322 |
|
4323 // Clean |
|
4324 CleanupStack::PopAndDestroy(parser); |
|
4325 |
|
4326 // If there are some filters added, first filter has to be "No filter" |
|
4327 if(aFilters.Count() > 0) |
|
4328 { |
|
4329 RDebug::Print(_L("STIF: Filters loaded")); |
|
4330 _LIT(KNoFilter, "No filter"); |
|
4331 HBufC* name = KNoFilter().AllocLC(); |
|
4332 User::LeaveIfError(aFilters.Insert(name, 0)); |
|
4333 CleanupStack::Pop(name); |
|
4334 } |
|
4335 } |
|
4336 |
|
4337 /* |
|
4338 ------------------------------------------------------------------------------- |
|
4339 |
|
4340 DESCRIPTION |
|
4341 |
|
4342 This module contains implementation of CUIStoreIf class member functions. |
|
4343 |
|
4344 ------------------------------------------------------------------------------- |
|
4345 */ |
|
4346 |
|
4347 // ================= MEMBER FUNCTIONS ========================================= |
|
4348 |
|
4349 /* |
|
4350 ------------------------------------------------------------------------------- |
|
4351 |
|
4352 Class: CUIStoreIf |
|
4353 |
|
4354 Method: ConstructL |
|
4355 |
|
4356 Description: Second phase constructor. |
|
4357 |
|
4358 Parameters: None |
|
4359 |
|
4360 Return Values: None |
|
4361 |
|
4362 Errors/Exceptions: Leaves if.. |
|
4363 |
|
4364 Status: Draft |
|
4365 |
|
4366 ------------------------------------------------------------------------------- |
|
4367 */ |
|
4368 EXPORT_C void CUIStoreIf::ConstructL( ) |
|
4369 { |
|
4370 |
|
4371 iUIStore = CUIStore::NewL( this ); |
|
4372 |
|
4373 } |
|
4374 |
|
4375 |
|
4376 /* |
|
4377 ------------------------------------------------------------------------------- |
|
4378 |
|
4379 Class: CUIStoreIf |
|
4380 |
|
4381 Method: CUIStoreIf |
|
4382 |
|
4383 Description: Constructor. |
|
4384 |
|
4385 Parameters: None |
|
4386 |
|
4387 Return Values: None |
|
4388 |
|
4389 Errors/Exceptions: None |
|
4390 |
|
4391 Status: Draft |
|
4392 |
|
4393 ------------------------------------------------------------------------------- |
|
4394 */ |
|
4395 EXPORT_C CUIStoreIf::CUIStoreIf( ) |
|
4396 { |
|
4397 } |
|
4398 |
|
4399 |
|
4400 /* |
|
4401 ------------------------------------------------------------------------------- |
|
4402 |
|
4403 Class: CUIStoreIf |
|
4404 |
|
4405 Method: ~CUIStoreIf |
|
4406 |
|
4407 Description: Destructor |
|
4408 |
|
4409 Parameters: None |
|
4410 |
|
4411 Return Values: None |
|
4412 |
|
4413 Errors/Exceptions: None |
|
4414 |
|
4415 Status: Draft |
|
4416 |
|
4417 ------------------------------------------------------------------------------- |
|
4418 */ |
|
4419 EXPORT_C CUIStoreIf::~CUIStoreIf() |
|
4420 { |
|
4421 |
|
4422 delete iUIStore; |
|
4423 iUIStore = NULL; |
|
4424 |
|
4425 } |
|
4426 |
|
4427 |
|
4428 /* |
|
4429 ------------------------------------------------------------------------------- |
|
4430 |
|
4431 Class: CUIStoreIf |
|
4432 |
|
4433 Method: UIStore |
|
4434 |
|
4435 Description: Returns reference to CUIStore object, which handles test |
|
4436 cases and test modules. |
|
4437 |
|
4438 Parameters: None |
|
4439 |
|
4440 Return Values: CUIStore reference |
|
4441 |
|
4442 Errors/Exceptions: None |
|
4443 |
|
4444 Status: Draft |
|
4445 |
|
4446 ------------------------------------------------------------------------------- |
|
4447 */ |
|
4448 EXPORT_C CUIStore& CUIStoreIf::UIStore() |
|
4449 { |
|
4450 |
|
4451 __ASSERT_ALWAYS( iUIStore, User::Panic( KUIStoreIf, KErrNotFound ) ); |
|
4452 |
|
4453 return *iUIStore; |
|
4454 |
|
4455 } |
|
4456 |
|
4457 /* |
|
4458 ------------------------------------------------------------------------------- |
|
4459 |
|
4460 DESCRIPTION |
|
4461 |
|
4462 This module contains implementation of CTestSetInfo class member functions. |
|
4463 |
|
4464 ------------------------------------------------------------------------------- |
|
4465 */ |
|
4466 |
|
4467 // ================= MEMBER FUNCTIONS ========================================= |
|
4468 |
|
4469 /* |
|
4470 ------------------------------------------------------------------------------- |
|
4471 |
|
4472 Class: CTestSetInfo |
|
4473 |
|
4474 Method: NewL |
|
4475 |
|
4476 Description: Construct the CTestSetInfo class |
|
4477 |
|
4478 Parameters: None |
|
4479 |
|
4480 Return Values: CTestSetInfo* New object |
|
4481 |
|
4482 Errors/Exceptions: Leaves if memory allocation fails or |
|
4483 ConstructL leaves. |
|
4484 |
|
4485 Status: Draft |
|
4486 |
|
4487 ------------------------------------------------------------------------------- |
|
4488 */ |
|
4489 CTestSetInfo* CTestSetInfo::NewL( const TDesC& aName ) |
|
4490 { |
|
4491 |
|
4492 CTestSetInfo* self = new ( ELeave ) CTestSetInfo(); |
|
4493 CleanupStack::PushL( self ); |
|
4494 self->ConstructL( aName ); |
|
4495 CleanupStack::Pop( self ); |
|
4496 |
|
4497 return self; |
|
4498 |
|
4499 } |
|
4500 |
|
4501 /* |
|
4502 ------------------------------------------------------------------------------- |
|
4503 |
|
4504 Class: CTestSetInfo |
|
4505 |
|
4506 Method: ConstructL |
|
4507 |
|
4508 Description: Second phase constructor. |
|
4509 |
|
4510 Parameters: None |
|
4511 |
|
4512 Return Values: None |
|
4513 |
|
4514 Errors/Exceptions: Leaves if.. |
|
4515 |
|
4516 Status: Draft |
|
4517 |
|
4518 ------------------------------------------------------------------------------- |
|
4519 */ |
|
4520 void CTestSetInfo::ConstructL( const TDesC& aName ) |
|
4521 { |
|
4522 |
|
4523 iName = aName.AllocL(); |
|
4524 |
|
4525 } |
|
4526 |
|
4527 |
|
4528 /* |
|
4529 ------------------------------------------------------------------------------- |
|
4530 |
|
4531 Class: CTestSetInfo |
|
4532 |
|
4533 Method: CTestSetInfo |
|
4534 |
|
4535 Description: Constructor. |
|
4536 |
|
4537 Parameters: None |
|
4538 |
|
4539 Return Values: None |
|
4540 |
|
4541 Errors/Exceptions: None |
|
4542 |
|
4543 Status: Draft |
|
4544 |
|
4545 ------------------------------------------------------------------------------- |
|
4546 */ |
|
4547 CTestSetInfo::CTestSetInfo() |
|
4548 { |
|
4549 iLastStartedCaseIndex = 0; |
|
4550 } |
|
4551 |
|
4552 |
|
4553 /* |
|
4554 ------------------------------------------------------------------------------- |
|
4555 |
|
4556 Class: CTestSetInfo |
|
4557 |
|
4558 Method: ~CTestSetInfo |
|
4559 |
|
4560 Description: Destructor |
|
4561 |
|
4562 Parameters: None |
|
4563 |
|
4564 Return Values: None |
|
4565 |
|
4566 Errors/Exceptions: None |
|
4567 |
|
4568 Status: Draft |
|
4569 |
|
4570 ------------------------------------------------------------------------------- |
|
4571 */ |
|
4572 CTestSetInfo::~CTestSetInfo() |
|
4573 { |
|
4574 |
|
4575 iTestCases.ResetAndDestroy(); |
|
4576 iTestCaseRefs.Reset(); |
|
4577 iTestCases.Close(); |
|
4578 iTestCaseRefs.Close(); |
|
4579 |
|
4580 delete iName; |
|
4581 iName = NULL; |
|
4582 |
|
4583 } |
|
4584 /* |
|
4585 ------------------------------------------------------------------------------- |
|
4586 |
|
4587 Class: CTestSetInfo |
|
4588 |
|
4589 Method: AddTestCase |
|
4590 |
|
4591 Description: Add test case to test set. |
|
4592 |
|
4593 Parameters: const CTestInfo& aTestInfo: in: test info |
|
4594 |
|
4595 Return Values: Symbian OS error code |
|
4596 |
|
4597 Errors/Exceptions: None |
|
4598 |
|
4599 Status: Draft |
|
4600 |
|
4601 ------------------------------------------------------------------------------- |
|
4602 */ |
|
4603 TInt CTestSetInfo::AddTestCase( const CTestInfo& aTestInfo ) |
|
4604 { |
|
4605 |
|
4606 CTestInfo* testInfo = NULL; |
|
4607 |
|
4608 TRAPD( err, |
|
4609 testInfo = CTestInfo::NewL(); |
|
4610 testInfo->CopyL( aTestInfo ); |
|
4611 ); |
|
4612 if( err != KErrNone ) |
|
4613 { |
|
4614 return err; |
|
4615 } |
|
4616 |
|
4617 if( iTestCaseRefs.Append( *testInfo ) != KErrNone ) |
|
4618 { |
|
4619 delete testInfo; |
|
4620 return KErrNoMemory; |
|
4621 } |
|
4622 if( iTestCases.Append( testInfo ) != KErrNone ) |
|
4623 { |
|
4624 iTestCaseRefs.Remove( iTestCaseRefs.Count()-1 ); |
|
4625 delete testInfo; |
|
4626 return KErrNoMemory; |
|
4627 } |
|
4628 |
|
4629 return KErrNone; |
|
4630 |
|
4631 } |
|
4632 |
|
4633 /* |
|
4634 ------------------------------------------------------------------------------- |
|
4635 |
|
4636 Class: CTestSetInfo |
|
4637 |
|
4638 Method: InsertTestCase |
|
4639 |
|
4640 Description: Insert test case to test set. |
|
4641 |
|
4642 Parameters: const CTestInfo& aTestInfo: in: test info |
|
4643 TInt aPos: in: position to add |
|
4644 |
|
4645 Return Values: Symbian OS error code |
|
4646 |
|
4647 Errors/Exceptions: None |
|
4648 |
|
4649 Status: Draft |
|
4650 |
|
4651 ------------------------------------------------------------------------------- |
|
4652 */ |
|
4653 TInt CTestSetInfo::InsertTestCase( const CTestInfo& aTestInfo, TInt aPos ) |
|
4654 { |
|
4655 |
|
4656 if( ( aPos < 0 ) || |
|
4657 ( aPos >= iTestCases.Count() ) ) |
|
4658 { |
|
4659 return KErrArgument; |
|
4660 } |
|
4661 |
|
4662 CTestInfo* testInfo = NULL; |
|
4663 |
|
4664 TRAPD( err, |
|
4665 testInfo = CTestInfo::NewL(); |
|
4666 testInfo->CopyL( aTestInfo ); |
|
4667 ); |
|
4668 if( err != KErrNone ) |
|
4669 { |
|
4670 return err; |
|
4671 } |
|
4672 |
|
4673 if( iTestCaseRefs.Insert( *testInfo, aPos ) != KErrNone ) |
|
4674 { |
|
4675 delete testInfo; |
|
4676 return KErrNoMemory; |
|
4677 } |
|
4678 if( iTestCases.Insert( testInfo, aPos ) != KErrNone ) |
|
4679 { |
|
4680 iTestCaseRefs.Remove( aPos ); |
|
4681 delete testInfo; |
|
4682 return KErrNoMemory; |
|
4683 } |
|
4684 |
|
4685 return err; |
|
4686 |
|
4687 } |
|
4688 |
|
4689 /* |
|
4690 ------------------------------------------------------------------------------- |
|
4691 |
|
4692 Class: CTestSetInfo |
|
4693 |
|
4694 Method: RemoveTestCase |
|
4695 |
|
4696 Description: Remove test case from test set. |
|
4697 |
|
4698 Parameters: const CTestInfo& aTestInfo: in: test info |
|
4699 |
|
4700 Return Values: Symbian OS error code |
|
4701 |
|
4702 Errors/Exceptions: None |
|
4703 |
|
4704 Status: Draft |
|
4705 |
|
4706 ------------------------------------------------------------------------------- |
|
4707 */ |
|
4708 TInt CTestSetInfo::RemoveTestCase( const CTestInfo& aTestInfo ) |
|
4709 { |
|
4710 |
|
4711 TInt count = iTestCases.Count(); |
|
4712 for( TInt i=0; i<count; i++ ) |
|
4713 { |
|
4714 if( aTestInfo == *iTestCases[i] ) |
|
4715 { |
|
4716 CTestInfo* testInfo = iTestCases[i]; |
|
4717 iTestCases.Remove( i ); |
|
4718 iTestCaseRefs.Remove( i ); |
|
4719 delete testInfo; |
|
4720 return KErrNone; |
|
4721 } |
|
4722 } |
|
4723 |
|
4724 return KErrNotFound; |
|
4725 |
|
4726 } |
|
4727 |
|
4728 /* |
|
4729 ------------------------------------------------------------------------------- |
|
4730 |
|
4731 Class: CTestSetInfo |
|
4732 |
|
4733 Method: CopyL |
|
4734 |
|
4735 Description: Remove test case from test set. |
|
4736 |
|
4737 Parameters: const CTestInfo& aTestInfo: in: test info |
|
4738 |
|
4739 Return Values: Symbian OS error code |
|
4740 |
|
4741 Errors/Exceptions: None |
|
4742 |
|
4743 Status: Draft |
|
4744 |
|
4745 ------------------------------------------------------------------------------- |
|
4746 */ |
|
4747 void CTestSetInfo::CopyL( const CTestSetInfo& aTestSetInfo ) |
|
4748 { |
|
4749 |
|
4750 iTestCaseRefs.Reset(); |
|
4751 iTestCases.ResetAndDestroy(); |
|
4752 |
|
4753 TInt count = aTestSetInfo.TestCases().Count(); |
|
4754 for( TInt i=0; i<count; i++ ) |
|
4755 { |
|
4756 User::LeaveIfError( AddTestCase( aTestSetInfo.TestCases()[i] ) ); |
|
4757 } |
|
4758 |
|
4759 delete iName; |
|
4760 iName = 0; |
|
4761 iName = aTestSetInfo.Name().AllocL(); |
|
4762 |
|
4763 iLastStartedCaseIndex = aTestSetInfo.iLastStartedCaseIndex; |
|
4764 |
|
4765 } |
|
4766 |
|
4767 /* |
|
4768 ------------------------------------------------------------------------------- |
|
4769 |
|
4770 Class: CTestSetInfo |
|
4771 |
|
4772 Method: SetLastStartedCaseIndex |
|
4773 |
|
4774 Description: Sets the info which test case has been started lately. |
|
4775 |
|
4776 Parameters: TInt aCaseStarted: index of started test case |
|
4777 |
|
4778 Return Values: None |
|
4779 |
|
4780 Errors/Exceptions: None |
|
4781 |
|
4782 Status: Approved |
|
4783 |
|
4784 ------------------------------------------------------------------------------- |
|
4785 */ |
|
4786 void CTestSetInfo::SetLastStartedCaseIndex(TUint aLastStartedCaseIndex) |
|
4787 { |
|
4788 iLastStartedCaseIndex = aLastStartedCaseIndex; |
|
4789 } |
|
4790 |
|
4791 /* |
|
4792 ------------------------------------------------------------------------------- |
|
4793 |
|
4794 Class: CTestSetInfo |
|
4795 |
|
4796 Method: GetLastStartedCaseIndex |
|
4797 |
|
4798 Description: Gets the info which test case has been started lately. |
|
4799 |
|
4800 Parameters: None |
|
4801 |
|
4802 Return Values: TInt: index of lately started test case |
|
4803 |
|
4804 Errors/Exceptions: None |
|
4805 |
|
4806 Status: Approved |
|
4807 |
|
4808 ------------------------------------------------------------------------------- |
|
4809 */ |
|
4810 TUint CTestSetInfo::GetLastStartedCaseIndex(void) |
|
4811 { |
|
4812 return iLastStartedCaseIndex; |
|
4813 } |
|
4814 |
|
4815 /* |
|
4816 ------------------------------------------------------------------------------- |
|
4817 |
|
4818 Class: CTestSetInfo |
|
4819 |
|
4820 Method: RenameTestSet |
|
4821 |
|
4822 Description: rename test set |
|
4823 |
|
4824 Parameters: aTestSetName : new TestSetName |
|
4825 |
|
4826 Return Values: TInt: KErrNone if success. |
|
4827 |
|
4828 Errors/Exceptions: None |
|
4829 |
|
4830 Status: Approved |
|
4831 |
|
4832 ------------------------------------------------------------------------------- |
|
4833 */ |
|
4834 void CTestSetInfo::RenameTestSet(const TDesC& aTestSetName) |
|
4835 { |
|
4836 delete iName; |
|
4837 iName=NULL; |
|
4838 iName=aTestSetName.AllocL(); |
|
4839 } |
|
4840 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
4841 |
|
4842 // End of File |
|