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 file contains TestScripter implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <StifTestEventInterface.h> |
|
20 #include <StifLogger.h> |
|
21 #include "TestScripter.h" |
|
22 #include "TestKeywords.h" |
|
23 #include "Logging.h" |
|
24 #include "TestEngineClient.h" |
|
25 #include "SettingServerClient.h" |
|
26 |
|
27 #include <stifinternal/UiEnvProxy.h> |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 // None |
|
31 |
|
32 // EXTERNAL FUNCTION PROTOTYPES |
|
33 // None |
|
34 |
|
35 // CONSTANTS |
|
36 // None |
|
37 |
|
38 // MACROS |
|
39 #ifdef LOGGER |
|
40 #undef LOGGER |
|
41 #endif |
|
42 #define LOGGER iLog |
|
43 |
|
44 // LOCAL CONSTANTS AND MACROS |
|
45 // None |
|
46 |
|
47 // MODULE DATA STRUCTURES |
|
48 // None |
|
49 |
|
50 // LOCAL FUNCTION PROTOTYPES |
|
51 // None |
|
52 |
|
53 // FORWARD DECLARATIONS |
|
54 // None |
|
55 |
|
56 // ==================== LOCAL FUNCTIONS ======================================= |
|
57 |
|
58 /* |
|
59 ------------------------------------------------------------------------------- |
|
60 |
|
61 Class: - |
|
62 |
|
63 Method: CallBack |
|
64 |
|
65 Description: (Function pointer) Called from CScriptBase class. Generic |
|
66 method for call back operations from Test Script Class to |
|
67 TestScripter. |
|
68 |
|
69 Parameters: CTestScripter* aTestScripter: in: Pointer to TestScripter |
|
70 TStifTSCallBackType aCallType: in: Call back type |
|
71 const TDesC& aLine: in Script line |
|
72 |
|
73 Return Values: TInt: Symbian error code |
|
74 |
|
75 Errors/Exceptions: None |
|
76 |
|
77 Status: Draft |
|
78 |
|
79 ------------------------------------------------------------------------------- |
|
80 */ |
|
81 TInt CallBack( CTestScripter* aTestScripter, |
|
82 TStifTSCallBackType aCallType, |
|
83 const TDesC& aLine ) |
|
84 { |
|
85 TInt ret( 0 ); |
|
86 switch( aCallType ) |
|
87 { |
|
88 case EStifTSCallClass: |
|
89 { |
|
90 ret = aTestScripter->CallTestClass( aLine ); |
|
91 break; |
|
92 } |
|
93 case EStifTSGetObject: |
|
94 { |
|
95 ret = aTestScripter->GetTestScriptObject( aLine ); |
|
96 break; |
|
97 } |
|
98 default: |
|
99 { |
|
100 ret = KErrArgument; |
|
101 break; |
|
102 } |
|
103 } |
|
104 |
|
105 return ret; |
|
106 |
|
107 } |
|
108 |
|
109 /* |
|
110 ------------------------------------------------------------------------------- |
|
111 |
|
112 DESCRIPTION |
|
113 |
|
114 This module contains the implementation of CTestScripter class |
|
115 member functions. |
|
116 |
|
117 ------------------------------------------------------------------------------- |
|
118 */ |
|
119 |
|
120 // ================= MEMBER FUNCTIONS ========================================= |
|
121 |
|
122 /* |
|
123 ------------------------------------------------------------------------------- |
|
124 |
|
125 Class: CTestScripter |
|
126 |
|
127 Method: CTestScripter |
|
128 |
|
129 Description: Default constructor |
|
130 |
|
131 C++ default constructor can NOT contain any code, that |
|
132 might leave. |
|
133 |
|
134 Parameters: None |
|
135 |
|
136 Return Values: None |
|
137 |
|
138 Errors/Exceptions: None |
|
139 |
|
140 Status: Draft |
|
141 |
|
142 ------------------------------------------------------------------------------- |
|
143 */ |
|
144 CTestScripter::CTestScripter() |
|
145 { |
|
146 |
|
147 } |
|
148 |
|
149 /* |
|
150 ------------------------------------------------------------------------------- |
|
151 |
|
152 Class: CTestScripter |
|
153 |
|
154 Method: ConstructL |
|
155 |
|
156 Description: Symbian OS second phase constructor |
|
157 |
|
158 Symbian OS default constructor can leave. |
|
159 |
|
160 Parameters: None |
|
161 |
|
162 Return Values: None |
|
163 |
|
164 Errors/Exceptions: None. |
|
165 |
|
166 Status: Draft |
|
167 |
|
168 ------------------------------------------------------------------------------- |
|
169 */ |
|
170 void CTestScripter::ConstructL() |
|
171 { |
|
172 __TRACE( KPrint, ( _L("New TestScripter") ) ); |
|
173 iStdLog = CStifLogger::NewL( KTestScripterLogDir, |
|
174 KTestScripterLogFile ); |
|
175 iLog = iStdLog; |
|
176 |
|
177 iOOMIgnoreFailure = EFalse; // OFF for default |
|
178 |
|
179 iCheckHeapBalance = EFalse; // No checking heap balance by default |
|
180 |
|
181 //Read logger settings to check whether test case name is to be |
|
182 //appended to log file name. |
|
183 RSettingServer settingServer; |
|
184 TInt ret = settingServer.Connect(); |
|
185 if(ret != KErrNone) |
|
186 { |
|
187 User::Leave(ret); |
|
188 } |
|
189 // Struct to StifLogger settigs. |
|
190 TLoggerSettings loggerSettings; |
|
191 // Parse StifLogger defaults from STIF initialization file. |
|
192 ret = settingServer.GetLoggerSettings(loggerSettings); |
|
193 if(ret != KErrNone) |
|
194 { |
|
195 User::Leave(ret); |
|
196 } |
|
197 // Close Setting server session |
|
198 settingServer.Close(); |
|
199 iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle; |
|
200 |
|
201 // Initialize parser variables |
|
202 iCurrentParser = NULL; |
|
203 iCurrentParserReadFirstLine = EFalse; |
|
204 } |
|
205 |
|
206 /* |
|
207 ------------------------------------------------------------------------------- |
|
208 |
|
209 Class: CTestScripter |
|
210 |
|
211 Method: NewL |
|
212 |
|
213 Description: Two-phased constructor. |
|
214 |
|
215 Parameters: None |
|
216 |
|
217 Return Values: CTestScripter*: new object |
|
218 |
|
219 Errors/Exceptions: Leaves if new or ConstructL leaves. |
|
220 |
|
221 Status: Draft |
|
222 |
|
223 ------------------------------------------------------------------------------- |
|
224 */ |
|
225 CTestScripter* CTestScripter::NewL() |
|
226 { |
|
227 |
|
228 CTestScripter* self = new (ELeave) CTestScripter(); |
|
229 |
|
230 CleanupStack::PushL( self ); |
|
231 self->ConstructL(); |
|
232 CleanupStack::Pop(); |
|
233 |
|
234 return self; |
|
235 |
|
236 } |
|
237 |
|
238 /* |
|
239 ------------------------------------------------------------------------------- |
|
240 |
|
241 Class: CTestScripter |
|
242 |
|
243 Method: ~CTestScripter |
|
244 |
|
245 Description: Destructor |
|
246 |
|
247 Parameters: None |
|
248 |
|
249 Return Values: None |
|
250 |
|
251 Errors/Exceptions: None |
|
252 |
|
253 Status: Draft |
|
254 |
|
255 ------------------------------------------------------------------------------- |
|
256 */ |
|
257 CTestScripter::~CTestScripter() |
|
258 { |
|
259 iTestObjects.ResetAndDestroy(); |
|
260 iTestModules.ResetAndDestroy(); |
|
261 iDefinedIni.ResetAndDestroy(); |
|
262 iDefinedRuntime.ResetAndDestroy(); |
|
263 iDefinedLocal.ResetAndDestroy(); |
|
264 iParserStack.ResetAndDestroy(); |
|
265 iTestObjects.Close(); |
|
266 iTestModules.Close(); |
|
267 iDefinedIni.Close(); |
|
268 iDefinedRuntime.Close(); |
|
269 iDefinedLocal.Close(); |
|
270 iParserStack.Close(); |
|
271 |
|
272 iCurrentParser = NULL; |
|
273 delete iSectionParser; |
|
274 delete iTestRunner; |
|
275 |
|
276 iLog = NULL; |
|
277 delete iStdLog; |
|
278 iStdLog = NULL; |
|
279 delete iTCLog; |
|
280 iTCLog = NULL; |
|
281 } |
|
282 |
|
283 /* |
|
284 ------------------------------------------------------------------------------- |
|
285 |
|
286 Class: CTestScripter |
|
287 |
|
288 Method: InitL |
|
289 |
|
290 Description: InitL is used to initialize the Test Module. |
|
291 |
|
292 Parameters: const TFileName& aIniFile: in: Initialization file |
|
293 TBool aFirstTime: in: First time flag |
|
294 |
|
295 Return Values: Symbian OS error code |
|
296 |
|
297 Errors/Exceptions: Leaves if ReadInitializationL leaves |
|
298 |
|
299 Status: Draft |
|
300 |
|
301 ------------------------------------------------------------------------------- |
|
302 */ |
|
303 TInt CTestScripter::InitL( TFileName& aIniFile, |
|
304 TBool /*aFirstTime*/ ) |
|
305 { |
|
306 |
|
307 __TRACEFUNC(); |
|
308 |
|
309 if( aIniFile.Length() > 0 ) |
|
310 { |
|
311 // Read initialization from test case file |
|
312 ReadInitializationL( aIniFile, iDefinedIni ); |
|
313 } |
|
314 |
|
315 return KErrNone; |
|
316 |
|
317 } |
|
318 |
|
319 /* |
|
320 ------------------------------------------------------------------------------- |
|
321 |
|
322 Class: CTestScripter |
|
323 |
|
324 Method: GetTestCases |
|
325 |
|
326 Description: GetTestCases is used to inquired test cases |
|
327 |
|
328 Parameters: const TFileName& aConfigFile: in: Test case file |
|
329 RPointerArray<RTestEngine::TTestCaseInfo>& aTestCases: out: |
|
330 Array of TestCases |
|
331 |
|
332 Return Values: KErrNone: Success |
|
333 Symbian OS error code |
|
334 |
|
335 Errors/Exceptions: Leaves if CStifParser::SectionL leaves |
|
336 Leaves if CStifParser::NextSectionL leaves |
|
337 Leaves if memory allocation fails |
|
338 |
|
339 Status: Draft |
|
340 |
|
341 ------------------------------------------------------------------------------- |
|
342 */ |
|
343 TInt CTestScripter::GetTestCasesL( const TFileName& aConfigFile, |
|
344 RPointerArray<TTestCaseInfo>& aTestCases ) |
|
345 { |
|
346 __TRACEFUNC(); |
|
347 |
|
348 if( aConfigFile.Length() == 0 ) |
|
349 { |
|
350 __TRACE( KError, (_L("No test case script file given") ) ); |
|
351 __RDEBUG( (_L("No test case script file given") ) ); |
|
352 return KErrNotFound; |
|
353 } |
|
354 |
|
355 CStifParser* parser = NULL; |
|
356 |
|
357 // Open test case file |
|
358 TRAPD( err, |
|
359 parser = CStifParser::NewL( _L(""), |
|
360 aConfigFile, |
|
361 CStifParser::ECStyleComments ) ); |
|
362 if( err != KErrNone ) |
|
363 { |
|
364 __TRACE( KError, (_L("Given test case script file [%S] not found"), |
|
365 &aConfigFile ) ); |
|
366 __RDEBUG( (_L("Given test case script file [%S] not found"), |
|
367 &aConfigFile ) ); |
|
368 return err; |
|
369 } |
|
370 |
|
371 CleanupStack::PushL( parser ); |
|
372 CStifSectionParser* section; |
|
373 TPtrC tmp; |
|
374 TInt index = 0; |
|
375 TInt ret = KErrNone; |
|
376 |
|
377 // Find first section |
|
378 section = parser->SectionL( KTestStartTag, KTestEndTag ); |
|
379 if( section == NULL ) |
|
380 { |
|
381 ret = KErrNotFound; |
|
382 } |
|
383 else |
|
384 { |
|
385 // Parse all sections |
|
386 while( section ) |
|
387 { |
|
388 CleanupStack::PushL( section ); |
|
389 |
|
390 // Get title line |
|
391 if( section->GetLine( TTestKeywords::Keyword( TTestKeywords::ETitle ), |
|
392 tmp, ENoTag ) != KErrNone ) |
|
393 { |
|
394 __TRACE( KError, (_L("Title not given for test case"))); |
|
395 User::Leave( KErrNotFound ); |
|
396 } |
|
397 else |
|
398 { |
|
399 if( tmp.Length() > KMaxName ) |
|
400 { |
|
401 tmp.Set( tmp.Left( KMaxName ) ); |
|
402 } |
|
403 TTestCaseInfo* tc = new ( ELeave ) TTestCaseInfo(); |
|
404 CleanupStack::PushL( tc ); |
|
405 __TRACE( KVerbose, (_L("TestCase: %S"), &tmp)); |
|
406 tc->iTitle.Copy( tmp ); |
|
407 tc->iCaseNumber = ++index; |
|
408 |
|
409 // Get timeout if defined |
|
410 CStifItemParser* item = section->GetItemLineL( |
|
411 TTestKeywords::Keyword( TTestKeywords::ETimeout ) ); |
|
412 if( item ) |
|
413 { |
|
414 TInt timeout; // In milliseconds |
|
415 ret = item->GetInt( |
|
416 TTestKeywords::Keyword( TTestKeywords::ETimeout ), |
|
417 timeout ); |
|
418 if( ret != KErrNone ) |
|
419 { |
|
420 __TRACE( KError, (_L("Illegal timeout"))); |
|
421 User::Leave( ret ); |
|
422 } |
|
423 |
|
424 // Type cast timeout to TInt64 |
|
425 tc->iTimeout = TInt64( timeout ) * 1000; |
|
426 __TRACE( KMessage, (_L("Timeout: %i"), tc->iTimeout.Int64() )); |
|
427 } |
|
428 |
|
429 // Get priority if defined |
|
430 item = section->GetItemLineL( |
|
431 TTestKeywords::Keyword( TTestKeywords::EPriority ) ); |
|
432 if( item ) |
|
433 { |
|
434 // First try to interpret as integer |
|
435 ret = item->GetInt( |
|
436 TTestKeywords::Keyword( TTestKeywords::EPriority ), |
|
437 tc->iPriority ); |
|
438 if( ret != KErrNone ) |
|
439 { |
|
440 TPtrC priority; |
|
441 // If priority was not given as integer, it must be |
|
442 // one of the predefined values |
|
443 ret = item->GetString( |
|
444 TTestKeywords::Keyword( TTestKeywords::EPriority ), |
|
445 priority ); |
|
446 if( ret != KErrNone ) |
|
447 { |
|
448 __TRACE( KError, (_L("Illegal priority"))); |
|
449 User::Leave( ret ); |
|
450 } |
|
451 switch( TTestKeywords::Parse( priority, |
|
452 TTestKeywords::Priority ) ) |
|
453 { |
|
454 case TTestKeywords::EPriHigh: |
|
455 tc->iPriority = TTestCaseInfo::EPriorityHigh; |
|
456 break; |
|
457 case TTestKeywords::EPriNormal: |
|
458 tc->iPriority = TTestCaseInfo::EPriorityNormal; |
|
459 break; |
|
460 case TTestKeywords::EPriLow: |
|
461 tc->iPriority = TTestCaseInfo::EPriorityLow; |
|
462 break; |
|
463 default: |
|
464 __TRACE( KError, (_L("Illegal priority"))); |
|
465 User::Leave( KErrArgument ); |
|
466 } |
|
467 } |
|
468 __TRACE( KMessage, (_L("Priority: %i"), tc->iPriority )); |
|
469 } |
|
470 |
|
471 aTestCases.Append(tc); |
|
472 CleanupStack::Pop( tc ); |
|
473 } |
|
474 CleanupStack::PopAndDestroy( section ); |
|
475 section = parser->NextSectionL( KTestStartTag, KTestEndTag ); |
|
476 } |
|
477 } |
|
478 |
|
479 CleanupStack::PopAndDestroy( parser ); |
|
480 |
|
481 __TRACE( KPrint, ( _L( "Configfile '%S', testcases %d" ), |
|
482 &aConfigFile, index )); |
|
483 |
|
484 return ret; |
|
485 |
|
486 } |
|
487 |
|
488 /* |
|
489 ------------------------------------------------------------------------------- |
|
490 |
|
491 Class: CTestScripter |
|
492 |
|
493 Method: GetConstantValue |
|
494 |
|
495 Description: Internal fuction to get const value defined in |
|
496 [Define]...[Enddefine] section of script file |
|
497 |
|
498 GetConstantValue gets const value defined in [Define]...[Enddefine] |
|
499 section of script file |
|
500 |
|
501 Parameters: const TDesC& aName: in: constant name |
|
502 TDes& avalue: out: constant value |
|
503 |
|
504 Return Values: KErrNone: Value is returned succesfully. |
|
505 KErrNotFound: Constant was not found |
|
506 Any other SymbianOS error |
|
507 |
|
508 ------------------------------------------------------------------------------- |
|
509 */ |
|
510 EXPORT_C TInt CTestScripter::GetConstantValue( const TDesC& aName, TDes& aValue ) |
|
511 { |
|
512 |
|
513 __TRACEFUNC(); |
|
514 |
|
515 TInt count = iDefinedLocal.Count(); |
|
516 for(TInt i = 0; i < count; i++) |
|
517 { |
|
518 if(iDefinedLocal[i]->Name() == aName) |
|
519 { |
|
520 aValue.Copy(iDefinedLocal[i]->Value()); |
|
521 return KErrNone; |
|
522 } |
|
523 } |
|
524 |
|
525 count = iDefinedIni.Count(); |
|
526 for( TInt i = 0; i < count; i++ ) |
|
527 { |
|
528 if( iDefinedIni[i]->Name() == aName ) |
|
529 { |
|
530 aValue.Copy( iDefinedIni[i]->Value() ); |
|
531 return KErrNone; |
|
532 } |
|
533 } |
|
534 |
|
535 count = iDefinedRuntime.Count(); |
|
536 for( TInt i = 0; i < count; i++ ) |
|
537 { |
|
538 if( iDefinedRuntime[i]->Name() == aName ) |
|
539 { |
|
540 aValue.Copy( iDefinedRuntime[i]->Value() ); |
|
541 return KErrNone; |
|
542 } |
|
543 } |
|
544 return KErrNotFound; |
|
545 } |
|
546 |
|
547 |
|
548 /* |
|
549 ------------------------------------------------------------------------------- |
|
550 |
|
551 Class: CTestScripter |
|
552 |
|
553 Method: RunTestCaseL |
|
554 |
|
555 Description: Run a specified testcase. |
|
556 |
|
557 RunTestCaseL is used to run an individual test case. |
|
558 |
|
559 Parameters: const TInt aCaseNumber: in: Testcase number |
|
560 const TFileName& aConfig: in: Test case file |
|
561 TTestResult& aResult: out: test case result |
|
562 |
|
563 Return Values: KErrNone: Test case started succesfully. |
|
564 KErrNotFound: Testcase not found |
|
565 KErrUnknown: Unknown TestScripter error |
|
566 Any other SymbianOS error |
|
567 |
|
568 Errors/Exceptions: Leaves if GetTestCaseL leaves |
|
569 Leaves if RunTestL leaves |
|
570 Leaves if memory allocation fails |
|
571 |
|
572 Status: Draft |
|
573 |
|
574 ------------------------------------------------------------------------------- |
|
575 */ |
|
576 TInt CTestScripter::RunTestCaseL( const TInt aCaseNumber, |
|
577 const TFileName& aConfig, |
|
578 TTestResult& aResult ) |
|
579 { |
|
580 |
|
581 // Heap is checked by test server |
|
582 //__UHEAP_MARK; |
|
583 |
|
584 __TRACEFUNC(); |
|
585 |
|
586 //Open new log file with test case title in file name |
|
587 if(iAddTestCaseTitleToLogName) |
|
588 { |
|
589 //Delete test case logger if exists |
|
590 if(iTCLog) |
|
591 { |
|
592 delete iTCLog; |
|
593 iTCLog = NULL; |
|
594 } |
|
595 |
|
596 TFileName logFileName; |
|
597 TName title; |
|
598 TestModuleIf().GetTestCaseTitleL(title); |
|
599 |
|
600 logFileName.Format(KTestScripterLogFileWithTitle, &title); |
|
601 iTCLog = CStifLogger::NewL(KTestScripterLogDir, logFileName); |
|
602 iLog = iTCLog; |
|
603 } |
|
604 |
|
605 __TRACE( KMessage, (_L("\n\n***Testcase started***"))); |
|
606 |
|
607 // Remove locally defined variables |
|
608 iDefinedLocal.ResetAndDestroy(); |
|
609 // Remove existing function parsers (there shouldn't be any) |
|
610 iParserStack.ResetAndDestroy(); |
|
611 |
|
612 // Keep file name of config file |
|
613 iConfig = aConfig; |
|
614 |
|
615 // Read initialization from test case file |
|
616 ReadInitializationL( aConfig, iDefinedRuntime ); |
|
617 |
|
618 // Get case from test case file |
|
619 iSectionParser = GetTestCaseL( aCaseNumber, aConfig ); |
|
620 iCurrentParser = iSectionParser; |
|
621 iCurrentParserReadFirstLine = EFalse; |
|
622 |
|
623 // Check parsing result |
|
624 if( iSectionParser == NULL ) |
|
625 { |
|
626 __TRACE( KError, (_L("***Parsing testcase failed***\n\n"))); |
|
627 // Delete runtime defines |
|
628 iDefinedRuntime.ResetAndDestroy(); |
|
629 //__UHEAP_MARKEND; |
|
630 return KErrNotFound; |
|
631 } |
|
632 |
|
633 // When option is set in cfg file, on EKA2 env memory leaking is enabled |
|
634 TInt memCellsBef = 0; //memory in current thread allocated before the test case is run |
|
635 TInt memCellsAft = 0; //memory in current thread allocated after the test case has run |
|
636 |
|
637 memCellsBef = User::Heap().Count(); |
|
638 __TRACE(KMessage, (_L("Allocated memory cells before the test case: %d"), memCellsBef)); |
|
639 |
|
640 CActiveScheduler* activeScheduler = |
|
641 new ( ELeave ) CActiveScheduler(); |
|
642 CleanupStack::PushL( activeScheduler ); |
|
643 |
|
644 if ( CActiveScheduler::Current() == NULL ) |
|
645 { |
|
646 CActiveScheduler::Install( activeScheduler ); |
|
647 } |
|
648 |
|
649 // Run the given testcase described in iSectionParser section |
|
650 RunTestL(); |
|
651 |
|
652 iTestObjects.ResetAndDestroy(); |
|
653 iTestModules.ResetAndDestroy(); |
|
654 |
|
655 // TestScripter must stop Active Scheduler after test |
|
656 // object is destroyed. Otherwise if unexpected error occurs |
|
657 // handling is erronous. |
|
658 CleanupStack::PopAndDestroy( activeScheduler ); |
|
659 |
|
660 // Check for memory leak. |
|
661 // It is reported in log always, but result of test case is changed only |
|
662 // when option in cfg file is enabled. |
|
663 memCellsAft = User::Heap().Count(); |
|
664 __TRACE(KMessage, (_L("Allocated memory cells after the test case: %d"), memCellsAft)); |
|
665 |
|
666 // if there is a difference report memory leak |
|
667 if(memCellsAft != memCellsBef) |
|
668 { |
|
669 __TRACE(KError, (_L("Memory leak, %d cell(s) is missing"), memCellsAft - memCellsBef)); |
|
670 if(iCheckHeapBalance) |
|
671 { |
|
672 // Memory leaks detection is disabled for UI components testing |
|
673 if ( !( TestModuleIf().UITesting() ) ) |
|
674 { |
|
675 UpdateTestCaseResult(KErrGeneral, _L("Memory leak has occured")); |
|
676 } |
|
677 } |
|
678 } |
|
679 |
|
680 // Delete parser and set current parser to NULL |
|
681 iCurrentParser = NULL; |
|
682 delete iSectionParser; |
|
683 iSectionParser = NULL; |
|
684 |
|
685 // Erase config file name |
|
686 iConfig = KNullDesC; |
|
687 |
|
688 // Return result |
|
689 aResult = iResult; |
|
690 |
|
691 if( iResult.iResult == KErrNone ) |
|
692 { |
|
693 __TRACE( KPrint, (_L("***Testcase PASSED***\n\n"))); |
|
694 TestModuleIf().Printf( KPrintPriNorm, _L("TestScripter"), |
|
695 _L("***Testcase PASSED***\n\n")); |
|
696 } |
|
697 else |
|
698 { |
|
699 __TRACE( KPrint, (_L("***Testcase FAILED***\n\n"))); |
|
700 TestModuleIf().Printf( KPrintPriNorm, _L("TestScripter"), |
|
701 _L("***Testcase FAILED***\n\n")); |
|
702 } |
|
703 User::After(300000); |
|
704 // Delete runtime defines |
|
705 iDefinedRuntime.ResetAndDestroy(); |
|
706 |
|
707 //__UHEAP_MARKEND; |
|
708 |
|
709 //If log was replaced then restore it |
|
710 if(iAddTestCaseTitleToLogName) |
|
711 { |
|
712 iLog = iStdLog; |
|
713 delete iTCLog; |
|
714 iTCLog = NULL; |
|
715 } |
|
716 |
|
717 return KErrNone; |
|
718 |
|
719 } |
|
720 |
|
721 /* |
|
722 ------------------------------------------------------------------------------- |
|
723 |
|
724 Class: CTestScripter |
|
725 |
|
726 Method: ReadInitializationL |
|
727 |
|
728 Description: Read initialization from file. |
|
729 |
|
730 Parameters: const TDesC& aIniFile: in: File that contains initialization |
|
731 |
|
732 Return Values: None |
|
733 |
|
734 Errors/Exceptions: None |
|
735 |
|
736 Status: Draft |
|
737 |
|
738 ------------------------------------------------------------------------------- |
|
739 */ |
|
740 void CTestScripter::ReadInitializationL( |
|
741 const TDesC& aIniFile, |
|
742 RPointerArray<CDefinedValue>& aDefines ) |
|
743 { |
|
744 |
|
745 CStifParser* parser = NULL; |
|
746 |
|
747 // Open file |
|
748 TRAPD( err, |
|
749 parser = CStifParser::NewL( _L(""), |
|
750 aIniFile, |
|
751 CStifParser::ECStyleComments ) ); |
|
752 if( ( err == KErrNone ) && parser ) |
|
753 { |
|
754 CleanupStack::PushL( parser ); |
|
755 __TRACE( KMessage, (_L("Read initialization from [%S]"), |
|
756 &aIniFile ) ); |
|
757 |
|
758 CStifSectionParser* section = parser->SectionL( KDefineStartTag, |
|
759 KDefineEndTag ); |
|
760 while(section) |
|
761 { |
|
762 CleanupStack::PushL( section ); |
|
763 __TRACE( KMessage, (_L("Read defines")) ); |
|
764 |
|
765 TPtrC name; |
|
766 TPtrC value; |
|
767 CStifItemParser* item = section->GetItemLineL( _L("") ); |
|
768 while( item ) |
|
769 { |
|
770 CleanupStack::PushL( item ); |
|
771 |
|
772 if( item->GetString( _L(""), name ) != KErrNone ) |
|
773 { |
|
774 __TRACE( KError, (_L("No define name given")) ); |
|
775 User::Leave( KErrGeneral ); |
|
776 } |
|
777 if( item->Remainder( value ) != KErrNone ) |
|
778 { |
|
779 __TRACE( KError, (_L("No define value given")) ); |
|
780 User::Leave( KErrGeneral ); |
|
781 } |
|
782 TInt count = aDefines.Count(); |
|
783 TInt i = 0; |
|
784 for( ; i < count; i++ ) |
|
785 { |
|
786 if( aDefines[i]->Name() == name ) |
|
787 { |
|
788 // Update existing |
|
789 aDefines[i]->SetValueL( value ); |
|
790 __TRACE(KMessage, (_L("Update define [%S]: [%S]"), &name, &value)); |
|
791 break; |
|
792 } |
|
793 } |
|
794 if( i == count) |
|
795 { |
|
796 // New define, store it |
|
797 CDefinedValue* define = CDefinedValue::NewL( name, value ); |
|
798 CleanupStack::PushL( define ); |
|
799 User::LeaveIfError( aDefines.Append( define ) ); |
|
800 CleanupStack::Pop( define ); |
|
801 } |
|
802 |
|
803 CleanupStack::PopAndDestroy( item ); |
|
804 item = section->GetNextItemLineL(); |
|
805 } |
|
806 CleanupStack::PopAndDestroy( section ); |
|
807 section = parser->NextSectionL(KDefineStartTag, KDefineEndTag); |
|
808 } |
|
809 |
|
810 //Read StifSettings section and find value for CheckHeapBalance. |
|
811 //(In cfg file in settings section User may also set CapsModifier |
|
812 // option. This is handled in TestServerClient.cpp in |
|
813 // RTestServer::GetCapsModifier method). |
|
814 section = parser->SectionL(KStifSettingsStartTag, KStifSettingsEndTag); |
|
815 |
|
816 if(section) |
|
817 { |
|
818 CleanupStack::PushL(section); |
|
819 __TRACE(KMessage, (_L("Read stif settings"))); |
|
820 |
|
821 TPtrC value; |
|
822 CStifItemParser* item = section->GetItemLineL(_L("")); |
|
823 while(item) |
|
824 { |
|
825 CleanupStack::PushL(item); |
|
826 __TRACE( KMessage, (_L("Got settings line"))); |
|
827 |
|
828 if(item->GetString(_L("CheckHeapBalance="), value) == KErrNone) |
|
829 { |
|
830 __TRACE(KMessage, (_L("Got CheckHeapBalance item, value=%S"), &value)); |
|
831 if(value.Compare(_L("off")) == 0) |
|
832 { |
|
833 iCheckHeapBalance = EFalse; |
|
834 } |
|
835 else if(value.Compare(_L("on")) == 0) |
|
836 { |
|
837 iCheckHeapBalance = ETrue; |
|
838 } |
|
839 else |
|
840 { |
|
841 __TRACE(KError, (_L("Value '%S' for CheckHeapBalance setting is not supported. Aborting"), &value)); |
|
842 User::Leave(KErrNotSupported); |
|
843 } |
|
844 } |
|
845 CleanupStack::PopAndDestroy(item); |
|
846 item = section->GetNextItemLineL(); |
|
847 } |
|
848 CleanupStack::PopAndDestroy(section); |
|
849 } |
|
850 |
|
851 CleanupStack::PopAndDestroy( parser ); |
|
852 } |
|
853 } |
|
854 |
|
855 |
|
856 /* |
|
857 ------------------------------------------------------------------------------- |
|
858 |
|
859 Class: CTestScripter |
|
860 |
|
861 Method: GetTestCaseL |
|
862 |
|
863 Description: Get specified test case section from configfile. |
|
864 |
|
865 Parameters: const TInt aCaseNumber: in: Test case number |
|
866 const TFileName& aConfig: in: Configfile name |
|
867 |
|
868 Return Values: CStifSectionParser*: pointer to test case section |
|
869 |
|
870 Errors/Exceptions: Leaves if CStifParser::NewL leaves |
|
871 Leaves if CStifParser::SectionL leaves |
|
872 Leaves if memory allocation fails |
|
873 |
|
874 |
|
875 Status: Draft |
|
876 |
|
877 ------------------------------------------------------------------------------- |
|
878 */ |
|
879 CStifSectionParser* CTestScripter::GetTestCaseL( const TInt aCaseNumber, |
|
880 const TFileName& aConfig ) |
|
881 { |
|
882 __TRACEFUNC(); |
|
883 CStifParser* parser = NULL; |
|
884 |
|
885 TRAPD( err, |
|
886 parser = CStifParser::NewL( _L(""), |
|
887 aConfig, |
|
888 CStifParser::ECStyleComments ); ); |
|
889 if( err != KErrNone ) |
|
890 { |
|
891 __TRACE( KError, (_L("Test case file [%S] not found"), &aConfig )); |
|
892 User::Leave( err ); |
|
893 } |
|
894 CleanupStack::PushL( parser ); |
|
895 |
|
896 CStifSectionParser* section = NULL; |
|
897 TRAP( err, |
|
898 section =parser->SectionL( KTestStartTag, KTestEndTag, aCaseNumber );); |
|
899 if( err != KErrNone ) |
|
900 { |
|
901 __TRACE( KError, |
|
902 (_L("Section [%S/%d] not found"), &aConfig, aCaseNumber )); |
|
903 User::Leave( err ); |
|
904 } |
|
905 |
|
906 CleanupStack::PopAndDestroy( parser ); |
|
907 return section; |
|
908 |
|
909 } |
|
910 |
|
911 /* |
|
912 ------------------------------------------------------------------------------- |
|
913 |
|
914 Class: CTestScripter |
|
915 |
|
916 Method: GetSubL |
|
917 |
|
918 Description: Get specified function (sub) from stored config file. |
|
919 |
|
920 Parameters: const TDesC& aSubName: in: function name |
|
921 |
|
922 Return Values: CStifSectionParser*: pointer to test function section |
|
923 |
|
924 Errors/Exceptions: Leaves if CStifParser::NewL leaves |
|
925 Leaves if CStifParser::SectionL leaves |
|
926 Leaves if memory allocation fails |
|
927 |
|
928 Status: Draft |
|
929 |
|
930 ------------------------------------------------------------------------------- |
|
931 */ |
|
932 CStifSectionParser* CTestScripter::GetSubL(const TDesC& aSubName) |
|
933 { |
|
934 __TRACE(KMessage, (_L("Searching sub [%S]."), &aSubName)); |
|
935 // Check if config file is set |
|
936 if(iConfig.Length() == 0) |
|
937 { |
|
938 __TRACE(KError, (_L("Searching sub [%S]. Config file is not set."), &aSubName)); |
|
939 User::Leave(KErrBadName); |
|
940 } |
|
941 |
|
942 // Create parser |
|
943 CStifParser* parser = NULL; |
|
944 CStifSectionParser* section = NULL; |
|
945 |
|
946 TRAPD(err, |
|
947 parser = CStifParser::NewL(_L(""), iConfig, CStifParser::ECStyleComments); |
|
948 ); |
|
949 if(err != KErrNone) |
|
950 { |
|
951 __TRACE(KError, (_L("Searching sub [%S]. Error [%d] when loading config file [%S]."), &aSubName, err, &iConfig)); |
|
952 User::Leave(err); |
|
953 } |
|
954 CleanupStack::PushL(parser); |
|
955 |
|
956 // Set section tags |
|
957 _LIT(KEndSubTag, "[EndSub]"); |
|
958 TName startSubTag; |
|
959 startSubTag.Copy(_L("[Sub ")); |
|
960 startSubTag.Append(aSubName); |
|
961 startSubTag.Append(_L("]")); |
|
962 |
|
963 // Load section |
|
964 TRAP(err, |
|
965 section = parser->SectionL(startSubTag, KEndSubTag, 1); |
|
966 ); |
|
967 if(err != KErrNone) |
|
968 { |
|
969 __TRACE(KError, (_L("Searching sub [%S]. Searching section %S%S ended with error [%d]."), &aSubName, &startSubTag, &KEndSubTag, err)); |
|
970 User::Leave(err); |
|
971 } |
|
972 if(!section) |
|
973 { |
|
974 __TRACE(KError, (_L("Searching sub [%S]. Section %S%S not found."), &aSubName, &startSubTag, &KEndSubTag)); |
|
975 User::Leave(err); |
|
976 } |
|
977 else |
|
978 { |
|
979 __TRACE(KMessage, (_L("Searching sub [%S]. Section %S%S found."), &aSubName, &startSubTag, &KEndSubTag)); |
|
980 } |
|
981 |
|
982 CleanupStack::PopAndDestroy(parser); |
|
983 return section; |
|
984 } |
|
985 |
|
986 /* |
|
987 ------------------------------------------------------------------------------- |
|
988 |
|
989 Class: CTestScripter |
|
990 |
|
991 Method: RunTestL |
|
992 |
|
993 Description: Run a testcase specified by iSectionParser. |
|
994 |
|
995 Parameters: None |
|
996 |
|
997 Return Values: None. |
|
998 |
|
999 Errors/Exceptions: Leaves if CSectionParser::GetItemLineL leaves |
|
1000 Leaves if CTestRunner::NewL leaves |
|
1001 Leaves if memory allocation fails |
|
1002 |
|
1003 Status: Draft |
|
1004 |
|
1005 ------------------------------------------------------------------------------- |
|
1006 */ |
|
1007 void CTestScripter::RunTestL() |
|
1008 { |
|
1009 __TRACEFUNC(); |
|
1010 iResult.iResult = KErrNone; |
|
1011 iResult.iResultDes.Zero(); |
|
1012 |
|
1013 // "title" keyword must be in the first line |
|
1014 TPtrC title; |
|
1015 if( iCurrentParser->GetLine( |
|
1016 TTestKeywords::Keyword( TTestKeywords::ETitle ), title, ENoTag ) |
|
1017 != KErrNone ) |
|
1018 { |
|
1019 __TRACE( KError, (_L("title not found from section"))); |
|
1020 User::Leave( KErrNotFound ); |
|
1021 } |
|
1022 iCurrentParserReadFirstLine = ETrue; |
|
1023 |
|
1024 __TRACE( KMessage, (_L("RunTest: %S"), &title )); |
|
1025 |
|
1026 iTestRunner = CTestRunner::NewL( this ); |
|
1027 |
|
1028 TestModuleIf().Printf( KPrintPriNorm, _L("RunTest"), _L("%S"), &title ); |
|
1029 |
|
1030 // Rest of the job is done by test runner |
|
1031 iTestRunner->SetRunnerActive(); |
|
1032 |
|
1033 // Start activeScheduler looping testcase lines |
|
1034 __TRACE( KMessage, (_L("Start CActiveScheduler"))); |
|
1035 CActiveScheduler::Current()->Start(); |
|
1036 |
|
1037 delete iTestRunner; |
|
1038 iTestRunner = NULL; |
|
1039 __TRACE( KMessage, ( _L("RunTestL: Done"))); |
|
1040 |
|
1041 // Destroy locally defined variables |
|
1042 iDefinedLocal.ResetAndDestroy(); |
|
1043 // Destroy function parsers (there shouldn't be any) |
|
1044 iParserStack.ResetAndDestroy(); |
|
1045 } |
|
1046 |
|
1047 /* |
|
1048 ------------------------------------------------------------------------------- |
|
1049 |
|
1050 Class: CTestScripter |
|
1051 |
|
1052 Method: GetTestModuleL |
|
1053 |
|
1054 Description: Load testmodule if not already loaded, otherwise return |
|
1055 description of the loaded testmodule. |
|
1056 |
|
1057 Parameters: TDesC& aModule: in: module name |
|
1058 TDesC& aIniFile: in: ini file name |
|
1059 |
|
1060 Return Values: CTCTestModule*: pointer to testmodules description |
|
1061 |
|
1062 Errors/Exceptions: Leaves if CTCTestModule::NewL leaves |
|
1063 Leaves if RPointerArray::Append fails |
|
1064 |
|
1065 Status: Draft |
|
1066 |
|
1067 ------------------------------------------------------------------------------- |
|
1068 */ |
|
1069 TTestModule* CTestScripter::LoadTestModuleL( TDesC& aModule ) |
|
1070 { |
|
1071 __TRACEFUNC(); |
|
1072 TInt count = iTestModules.Count(); |
|
1073 for( TInt i=0; i < count; i++ ) |
|
1074 { |
|
1075 if( iTestModules[i]->ModuleName() == aModule ) |
|
1076 { |
|
1077 // Found test module, return description |
|
1078 __TRACE( KMessage, |
|
1079 (_L("GetTestModuleL: Use already loaded TestModule (%S)"), |
|
1080 &aModule )); |
|
1081 return iTestModules[i]; |
|
1082 } |
|
1083 } |
|
1084 |
|
1085 __TRACE( KMessage, (_L("GetTestModuleL: Load new TestModule (%S)"), |
|
1086 &aModule )); |
|
1087 TTestModule* module = new (ELeave) TTestModule(); |
|
1088 CleanupStack::PushL( module ); |
|
1089 module->ModuleName() = aModule; |
|
1090 User::LeaveIfError( iTestModules.Append( module ) ); |
|
1091 CleanupStack::Pop( module ); |
|
1092 |
|
1093 TInt ret = module->iLibrary.Load ( aModule ); |
|
1094 |
|
1095 if( ret != KErrNone ) |
|
1096 { |
|
1097 __TRACE( KMessage, (_L("GetTestModuleL: %S loading failed"), |
|
1098 &aModule )); |
|
1099 TestModuleIf().Printf( KMessage, _L("Load dll"), _L("%S failed"), |
|
1100 &aModule ); |
|
1101 |
|
1102 User::Leave( ret ); |
|
1103 } |
|
1104 |
|
1105 // Get pointer to first exported function |
|
1106 module->iLibEntry = (CInterfaceFactory) module->iLibrary.Lookup(1); |
|
1107 return module; |
|
1108 |
|
1109 } |
|
1110 |
|
1111 /* |
|
1112 ------------------------------------------------------------------------------- |
|
1113 |
|
1114 Class: CTestScripter |
|
1115 |
|
1116 Method: CreateObjectL |
|
1117 |
|
1118 Description: Load testmodule if not already loaded, otherwise return |
|
1119 description of the loaded testmodule. |
|
1120 |
|
1121 Parameters: TDesC& aModule: in: module name |
|
1122 TDesC& aObjectId: in: object id name |
|
1123 |
|
1124 Return Values: None |
|
1125 |
|
1126 Errors/Exceptions: Leaves on error |
|
1127 |
|
1128 Status: Draft |
|
1129 |
|
1130 ------------------------------------------------------------------------------- |
|
1131 */ |
|
1132 void CTestScripter::CreateObjectL( TDesC& aModule, TDesC& aObjectId ) |
|
1133 { |
|
1134 __TRACEFUNC(); |
|
1135 |
|
1136 // Load module and get pointer |
|
1137 TTestModule* module = LoadTestModuleL( aModule ); |
|
1138 TTestObject* object = new (ELeave) TTestObject(); |
|
1139 CleanupStack::PushL( object ); |
|
1140 object->ObjectId() = aObjectId; |
|
1141 User::LeaveIfError( iTestObjects.Append( object ) ); |
|
1142 CleanupStack::Pop( object ); |
|
1143 |
|
1144 // Create object |
|
1145 object->iScript = module->iLibEntry( TestModuleIf() ); |
|
1146 //User::LeaveIfNull ( object->iScript ); |
|
1147 if( object->iScript == NULL ) |
|
1148 { |
|
1149 User::Leave( KErrGeneral ); |
|
1150 } |
|
1151 |
|
1152 // Create continue callback |
|
1153 object->iContinue = CTestContinue::NewL( this, object ); |
|
1154 |
|
1155 // Create function pointer operation to possible |
|
1156 object->iScript->SetScripter( &CallBack, this ); |
|
1157 |
|
1158 } |
|
1159 |
|
1160 /* |
|
1161 ------------------------------------------------------------------------------- |
|
1162 |
|
1163 Class: CTestScripter |
|
1164 |
|
1165 Method: CreateKernelObjectL |
|
1166 |
|
1167 Description: Load testdriver if not already loaded, otherwise return |
|
1168 description of the loaded testdriver. |
|
1169 |
|
1170 Parameters: TDesC& aDriver: in: driver name |
|
1171 TDesC& aObjectId: in: object id name |
|
1172 |
|
1173 Return Values: None |
|
1174 |
|
1175 Errors/Exceptions: Leaves on error |
|
1176 |
|
1177 Status: Draft |
|
1178 |
|
1179 ------------------------------------------------------------------------------- |
|
1180 */ |
|
1181 void CTestScripter::CreateKernelObjectL( TDesC& aDriver, TDesC& aObjectId ) |
|
1182 { |
|
1183 |
|
1184 __TRACEFUNC(); |
|
1185 |
|
1186 if( ( aDriver.Length() > KMaxName ) || |
|
1187 ( aObjectId.Length() > KMaxName ) ) |
|
1188 { |
|
1189 __TRACE( KError, (_L("CreateKernelObjectL: Max lenght exceeded") ) ); |
|
1190 User::Leave( KErrArgument ); |
|
1191 } |
|
1192 TInt ret = User::LoadLogicalDevice( aDriver ); |
|
1193 if( ( ret != KErrNone ) && ( ret != KErrAlreadyExists ) ) |
|
1194 { |
|
1195 __TRACE( KError, |
|
1196 (_L("CreateKernelObjectL: User::LoadLogicalDevice failed %d"), |
|
1197 ret ) ); |
|
1198 User::Leave( ret ); |
|
1199 } |
|
1200 |
|
1201 TTestObjectKernel* object = new (ELeave) TTestObjectKernel(); |
|
1202 CleanupStack::PushL( object ); |
|
1203 object->ObjectId() = aObjectId; |
|
1204 object->LddName().Copy( aDriver ); |
|
1205 ret = object->KernelTestClass().Open( |
|
1206 object->KernelTestClass().VersionRequired(), |
|
1207 aDriver ); |
|
1208 if( ret != KErrNone ) |
|
1209 { |
|
1210 __TRACE( KError, |
|
1211 (_L("CreateKernelObjectL: KernelTestClass().Open failed %d"), |
|
1212 ret ) ); |
|
1213 User::Leave( ret ); |
|
1214 } |
|
1215 |
|
1216 User::LeaveIfError( iTestObjects.Append( object ) ); |
|
1217 CleanupStack::Pop( object ); |
|
1218 |
|
1219 } |
|
1220 |
|
1221 /* |
|
1222 ------------------------------------------------------------------------------- |
|
1223 |
|
1224 Class: CTestScripter |
|
1225 |
|
1226 Method: GetTestModuleL |
|
1227 |
|
1228 Description: Load testmodule if not already loaded, otherwise return |
|
1229 description of the loaded testmodule. |
|
1230 |
|
1231 Parameters: TDesC& aModule: in: module name |
|
1232 TDesC& aIniFile: in: ini file name |
|
1233 |
|
1234 Return Values: CTCTestModule*: pointer to testmodules description |
|
1235 |
|
1236 Errors/Exceptions: Leaves if CTCTestModule::NewL leaves |
|
1237 Leaves if RPointerArray::Append fails |
|
1238 |
|
1239 Status: Draft |
|
1240 |
|
1241 ------------------------------------------------------------------------------- |
|
1242 */ |
|
1243 TInt CTestScripter::DeleteObjectL( TDesC& aObjectId ) |
|
1244 { |
|
1245 __TRACEFUNC(); |
|
1246 |
|
1247 TInt count = iTestObjects.Count(); |
|
1248 for( TInt i=0; i < count; i++ ) |
|
1249 { |
|
1250 if( iTestObjects[i]->ObjectId() == aObjectId ) |
|
1251 { |
|
1252 TTestObjectBase* object = iTestObjects[i]; |
|
1253 iTestObjects.Remove( i ); |
|
1254 delete object; |
|
1255 return KErrNone; |
|
1256 } |
|
1257 } |
|
1258 |
|
1259 return KErrNone; |
|
1260 } |
|
1261 |
|
1262 /* |
|
1263 ------------------------------------------------------------------------------- |
|
1264 |
|
1265 Class: CTestScripter |
|
1266 |
|
1267 Method: GetTest |
|
1268 |
|
1269 Description: Get test case from testcase array. |
|
1270 |
|
1271 Parameters: TDesC& aTestId: in: TestId for testcase |
|
1272 |
|
1273 Return Values: CTCTestCase*: running/runned testcase |
|
1274 NULL: Testcase with aTestId not running/runned |
|
1275 |
|
1276 Errors/Exceptions: None |
|
1277 |
|
1278 Status: Draft |
|
1279 |
|
1280 ------------------------------------------------------------------------------- |
|
1281 */ |
|
1282 TTestObjectBase* CTestScripter::GetObject( const TDesC& aObjectId ) |
|
1283 { |
|
1284 __TRACEFUNC(); |
|
1285 |
|
1286 TInt count = iTestObjects.Count(); |
|
1287 for( TInt i=0; i < count; i++ ) |
|
1288 { |
|
1289 if( iTestObjects[i]->ObjectId() == aObjectId ) |
|
1290 { |
|
1291 // Found testcase with specified TestId |
|
1292 return iTestObjects[i]; |
|
1293 } |
|
1294 } |
|
1295 // Object with iTestObjects not found |
|
1296 return NULL; |
|
1297 |
|
1298 } |
|
1299 |
|
1300 /* |
|
1301 ------------------------------------------------------------------------------- |
|
1302 |
|
1303 Class: CTestScripter |
|
1304 |
|
1305 Method: CallTestClass |
|
1306 |
|
1307 Description: For sub classing operations. |
|
1308 |
|
1309 Parameters: const TDesC& aLine: in: script line |
|
1310 |
|
1311 Return Values: TInt: Symbian error code |
|
1312 |
|
1313 Errors/Exceptions: None |
|
1314 |
|
1315 Status: Draft |
|
1316 |
|
1317 ------------------------------------------------------------------------------- |
|
1318 */ |
|
1319 TInt CTestScripter::CallTestClass( const TDesC& aLine ) |
|
1320 { |
|
1321 CStifItemParser* item = CStifItemParser::NewL( aLine, 0, aLine.Length() ); |
|
1322 CleanupStack::PushL( item ); |
|
1323 |
|
1324 TPtrC objectName; |
|
1325 TInt ret( KErrNone ); |
|
1326 ret = item->GetString( _L( "" ), objectName ); |
|
1327 if( ret != KErrNone ) |
|
1328 { |
|
1329 CleanupStack::PopAndDestroy( item); |
|
1330 return ret; |
|
1331 } |
|
1332 |
|
1333 TTestObjectBase* obj = GetObject( objectName ); |
|
1334 if( obj == NULL ) |
|
1335 { |
|
1336 CleanupStack::PopAndDestroy(item ); |
|
1337 return KErrNotFound; |
|
1338 } |
|
1339 |
|
1340 TRAPD( commandResult, commandResult = obj->RunMethodL( *item ) ); |
|
1341 |
|
1342 CleanupStack::PopAndDestroy(item ); |
|
1343 |
|
1344 return commandResult; |
|
1345 |
|
1346 } |
|
1347 |
|
1348 /* |
|
1349 ------------------------------------------------------------------------------- |
|
1350 |
|
1351 Class: CTestScripter |
|
1352 |
|
1353 Method: GetTestScriptObject |
|
1354 |
|
1355 Description: Get object address. |
|
1356 |
|
1357 Parameters: const TDesC& aObjectName: in: object name |
|
1358 |
|
1359 Return Values: TInt: Symbian error code |
|
1360 |
|
1361 Errors/Exceptions: None |
|
1362 |
|
1363 Status: Draft |
|
1364 |
|
1365 ------------------------------------------------------------------------------- |
|
1366 */ |
|
1367 TInt CTestScripter::GetTestScriptObject( const TDesC& aObjectName ) |
|
1368 { |
|
1369 |
|
1370 TTestObjectBase* objBase = GetObject( aObjectName ); |
|
1371 if( ( objBase == NULL ) || |
|
1372 ( objBase->ObjectType() != TTestObjectBase::EObjectNormal ) ) |
|
1373 { |
|
1374 return KErrNotFound; |
|
1375 } |
|
1376 |
|
1377 TTestObject* object = ( TTestObject* )objBase; |
|
1378 |
|
1379 return (TInt) object->iScript; |
|
1380 |
|
1381 } |
|
1382 |
|
1383 /* |
|
1384 ------------------------------------------------------------------------------- |
|
1385 |
|
1386 Class: CTestScripter |
|
1387 |
|
1388 Method: UpdateTestCaseResult |
|
1389 |
|
1390 Description: Updates result of test case. If there is already some |
|
1391 description stored, it is put in the [] brackets. |
|
1392 |
|
1393 Parameters: const TInt aResult: in: error code |
|
1394 const TDesC& aDescr: in: description |
|
1395 |
|
1396 Return Values: None |
|
1397 |
|
1398 Errors/Exceptions: None |
|
1399 |
|
1400 Status: Draft |
|
1401 |
|
1402 ------------------------------------------------------------------------------- |
|
1403 */ |
|
1404 void CTestScripter::UpdateTestCaseResult(const TInt aResult, const TDesC& aDescr) |
|
1405 { |
|
1406 // Create buffer |
|
1407 RBuf buf; |
|
1408 |
|
1409 TInt ret = buf.Create(iResult.iResultDes.Length() + aDescr.Length() + 5); |
|
1410 if(ret != KErrNone) |
|
1411 { |
|
1412 __TRACE(KError, (_L("UpdateResultDescription: descriptor creation failed [%d]"), ret)); |
|
1413 return; |
|
1414 } |
|
1415 CleanupClosePushL(buf); |
|
1416 |
|
1417 // Update result |
|
1418 iResult.iResult = aResult; |
|
1419 if(iResult.iResultDes.Length() > 0) |
|
1420 { |
|
1421 buf.Format(_L("%S [%S]"), &aDescr, &iResult.iResultDes); |
|
1422 } |
|
1423 else |
|
1424 { |
|
1425 buf.Copy(aDescr); |
|
1426 } |
|
1427 |
|
1428 SetResultDescription(buf); |
|
1429 |
|
1430 // Close buffer |
|
1431 CleanupStack::PopAndDestroy(&buf); |
|
1432 } |
|
1433 |
|
1434 /* |
|
1435 ------------------------------------------------------------------------------- |
|
1436 |
|
1437 Class: CTestScripter |
|
1438 |
|
1439 Method: SetResultDescription |
|
1440 |
|
1441 Description: Sets result description of test case. |
|
1442 |
|
1443 Parameters: const TDesC& aDescr: in: new description |
|
1444 |
|
1445 Return Values: None |
|
1446 |
|
1447 Errors/Exceptions: None |
|
1448 |
|
1449 Status: Draft |
|
1450 |
|
1451 ------------------------------------------------------------------------------- |
|
1452 */ |
|
1453 EXPORT_C void CTestScripter::SetResultDescription(const TDesC& aDescr) |
|
1454 { |
|
1455 if(aDescr.Length() > KStifMaxResultDes) |
|
1456 { |
|
1457 iResult.iResultDes.Copy(aDescr.Mid(0, KStifMaxResultDes)); |
|
1458 } |
|
1459 else |
|
1460 { |
|
1461 iResult.iResultDes.Copy(aDescr); |
|
1462 } |
|
1463 } |
|
1464 |
|
1465 /* |
|
1466 ------------------------------------------------------------------------------- |
|
1467 |
|
1468 Class: CTestScripter |
|
1469 |
|
1470 Method: SetLocalValue |
|
1471 |
|
1472 Description: Internal fuction to set value of local variable defined in script |
|
1473 |
|
1474 Parameters: const TDesC& aName: in: local variable name |
|
1475 const TDesC& avalue: in: local variable value |
|
1476 |
|
1477 Return Values: KErrNone: Value is returned succesfully. |
|
1478 KErrNotFound: Variable was not found |
|
1479 Any other SymbianOS error |
|
1480 |
|
1481 ------------------------------------------------------------------------------- |
|
1482 */ |
|
1483 EXPORT_C TInt CTestScripter::SetLocalValue(const TDesC& aName, const TDesC& aValue) |
|
1484 { |
|
1485 __TRACEFUNC(); |
|
1486 |
|
1487 TInt count = iDefinedLocal.Count(); |
|
1488 for(TInt i = 0; i < count; i++) |
|
1489 { |
|
1490 if(iDefinedLocal[i]->Name() == aName) |
|
1491 { |
|
1492 iDefinedLocal[i]->SetValueL(const_cast<TDesC&>(aValue)); |
|
1493 return KErrNone; |
|
1494 } |
|
1495 } |
|
1496 |
|
1497 return KErrNotFound; |
|
1498 } |
|
1499 |
|
1500 /* |
|
1501 ------------------------------------------------------------------------------- |
|
1502 |
|
1503 Class: CTestScripter |
|
1504 |
|
1505 Method: GetLocalValue |
|
1506 |
|
1507 Description: Internal fuction to get value of local variable |
|
1508 |
|
1509 Parameters: const TDesC& aName: in: local variable name |
|
1510 const TDesC& avalue: in: local variable value |
|
1511 |
|
1512 Return Values: KErrNone: Value is returned succesfully. |
|
1513 KErrNotFound: Variable was not found |
|
1514 Any other SymbianOS error |
|
1515 |
|
1516 ------------------------------------------------------------------------------- |
|
1517 */ |
|
1518 EXPORT_C TInt CTestScripter::GetLocalValue(const TDesC& aName, TDes& aValue) |
|
1519 { |
|
1520 __TRACEFUNC(); |
|
1521 |
|
1522 TInt count = iDefinedLocal.Count(); |
|
1523 for(TInt i = 0; i < count; i++) |
|
1524 { |
|
1525 if(iDefinedLocal[i]->Name() == aName) |
|
1526 { |
|
1527 aValue.Copy(iDefinedLocal[i]->Value()); |
|
1528 return KErrNone; |
|
1529 } |
|
1530 } |
|
1531 |
|
1532 return KErrNotFound; |
|
1533 } |
|
1534 |
|
1535 /* |
|
1536 ------------------------------------------------------------------------------- |
|
1537 |
|
1538 DESCRIPTION |
|
1539 |
|
1540 This module contains the implementation of CTestRunner class |
|
1541 member functions. CTestRunner is used to execute TestScripter testcase by |
|
1542 CTestScripter. |
|
1543 |
|
1544 ------------------------------------------------------------------------------- |
|
1545 */ |
|
1546 // MACROS |
|
1547 #ifdef LOGGER |
|
1548 #undef LOGGER |
|
1549 #endif |
|
1550 #define LOGGER iTestScripter->iLog |
|
1551 |
|
1552 // ================= MEMBER FUNCTIONS ========================================= |
|
1553 |
|
1554 /* |
|
1555 ------------------------------------------------------------------------------- |
|
1556 |
|
1557 Class: CTestRunner |
|
1558 |
|
1559 Method: CTestRunner |
|
1560 |
|
1561 Description: Default constructor |
|
1562 |
|
1563 C++ default constructor can NOT contain any code, that |
|
1564 might leave. |
|
1565 |
|
1566 Parameters: CTestScripter* aTestScripter: in: Backpointer to CTestScripter |
|
1567 |
|
1568 Return Values: None |
|
1569 |
|
1570 Errors/Exceptions: None |
|
1571 |
|
1572 Status: Draft |
|
1573 |
|
1574 ------------------------------------------------------------------------------- |
|
1575 */ |
|
1576 CTestRunner::CTestRunner( CTestScripter* aTestScripter ): |
|
1577 CActive( CActive::EPriorityHigh ), // Executed with highest priority |
|
1578 iState( ERunnerIdle ), |
|
1579 iTestScripter( aTestScripter ), |
|
1580 iRemainingTimeValue( 0 ) |
|
1581 { |
|
1582 CActiveScheduler::Add( this ); |
|
1583 __TRACEFUNC(); |
|
1584 |
|
1585 } |
|
1586 |
|
1587 /* |
|
1588 ------------------------------------------------------------------------------- |
|
1589 |
|
1590 Class: CTestRunner |
|
1591 |
|
1592 Method: ConstructL |
|
1593 |
|
1594 Description: Symbian OS second phase constructor |
|
1595 |
|
1596 Symbian OS default constructor can leave. |
|
1597 |
|
1598 Parameters: None |
|
1599 |
|
1600 Return Values: None |
|
1601 |
|
1602 Errors/Exceptions: None |
|
1603 |
|
1604 Status: Draft |
|
1605 |
|
1606 ------------------------------------------------------------------------------- |
|
1607 */ |
|
1608 void CTestRunner::ConstructL() |
|
1609 { |
|
1610 |
|
1611 iPauseTimer.CreateLocal(); |
|
1612 |
|
1613 // Initiaze all OOM related variables to default. |
|
1614 OOMHeapToNormal(); |
|
1615 |
|
1616 } |
|
1617 |
|
1618 /* |
|
1619 ------------------------------------------------------------------------------- |
|
1620 |
|
1621 Class: CTestRunner |
|
1622 |
|
1623 Method: NewL |
|
1624 |
|
1625 Description: Two-phased constructor. |
|
1626 |
|
1627 Parameters: CTestScripter* aTestScripter: in: Backpointer to CTestScripter |
|
1628 |
|
1629 Return Values: CTestRunner*: new object |
|
1630 |
|
1631 Errors/Exceptions: Leaves if new or ConstructL leaves |
|
1632 |
|
1633 Status: Draft |
|
1634 |
|
1635 ------------------------------------------------------------------------------- |
|
1636 */ |
|
1637 |
|
1638 CTestRunner* CTestRunner::NewL( CTestScripter* aTestScripter ) |
|
1639 { |
|
1640 CTestRunner* self = new (ELeave) CTestRunner( aTestScripter ); |
|
1641 |
|
1642 CleanupStack::PushL( self ); |
|
1643 self->ConstructL(); |
|
1644 CleanupStack::Pop(); |
|
1645 |
|
1646 return self; |
|
1647 } |
|
1648 |
|
1649 /* |
|
1650 ------------------------------------------------------------------------------- |
|
1651 |
|
1652 Class: CTestRunner |
|
1653 |
|
1654 Method: ~CTestRunner |
|
1655 |
|
1656 Description: Destructor |
|
1657 |
|
1658 Parameters: None |
|
1659 |
|
1660 Return Values: None |
|
1661 |
|
1662 Errors/Exceptions: None |
|
1663 |
|
1664 Status: Approved |
|
1665 |
|
1666 ------------------------------------------------------------------------------- |
|
1667 */ |
|
1668 |
|
1669 CTestRunner::~CTestRunner() |
|
1670 { |
|
1671 __TRACEFUNC(); |
|
1672 Cancel(); |
|
1673 |
|
1674 iPauseTimer.Close(); |
|
1675 |
|
1676 delete iLine; |
|
1677 iLine = NULL; |
|
1678 |
|
1679 TInt count = iEventArray.Count(); |
|
1680 TEventIf event( TEventIf::ERelEvent ); |
|
1681 for( TInt i = 0; i < count; i++ ) |
|
1682 { |
|
1683 HBufC* tmp = iEventArray[0]; |
|
1684 event.SetName( iEventArray[0]->Des() ); |
|
1685 iEventArray.Remove(0); |
|
1686 if( iTestScripter != NULL ) |
|
1687 { |
|
1688 iTestScripter->TestModuleIf().Event( event ); |
|
1689 } |
|
1690 delete tmp; |
|
1691 } |
|
1692 |
|
1693 iTestCaseResults.Reset(); |
|
1694 iEventArray.ResetAndDestroy(); |
|
1695 iTestCaseResults.Close(); |
|
1696 iEventArray.Close(); |
|
1697 |
|
1698 // Reset test case allow result to CTestModuleIf side too. This is |
|
1699 // used in TAL-TA5L macro handling. |
|
1700 if( iTestScripter != NULL ) |
|
1701 { |
|
1702 User::LeaveIfError( |
|
1703 iTestScripter->TestModuleIf().ResetAllowResult() ); |
|
1704 } |
|
1705 |
|
1706 // Stop all remaining interference object |
|
1707 TInt count_inter = iTestInterferenceArray.Count(); |
|
1708 for( TInt a = 0; a < count_inter; a++ ) |
|
1709 { |
|
1710 if( iTestInterferenceArray[a] != NULL ) |
|
1711 { |
|
1712 iTestInterferenceArray[a]->iInterference->Stop(); |
|
1713 } |
|
1714 } |
|
1715 iTestInterferenceArray.ResetAndDestroy(); |
|
1716 iTestInterferenceArray.Close(); |
|
1717 |
|
1718 // Stop all remaining measurement modules |
|
1719 const TInt count_meas = iTestMeasurementArray.Count(); |
|
1720 for( TInt b = 0; b < count_meas; b++ ) |
|
1721 { |
|
1722 if( iTestMeasurementArray[b] != NULL ) |
|
1723 { |
|
1724 iTestMeasurementArray[b]->iMeasurement->Stop(); |
|
1725 } |
|
1726 } |
|
1727 iTestMeasurementArray.ResetAndDestroy(); |
|
1728 iTestMeasurementArray.Close(); |
|
1729 |
|
1730 } |
|
1731 |
|
1732 /* |
|
1733 ------------------------------------------------------------------------------- |
|
1734 |
|
1735 Class: CTestRunner |
|
1736 |
|
1737 Method: RunL |
|
1738 |
|
1739 Description: Derived from CActive, handles testcase execution. |
|
1740 |
|
1741 Parameters: None. |
|
1742 |
|
1743 Return Values: None. |
|
1744 |
|
1745 Errors/Exceptions: Leaves on error situations. |
|
1746 |
|
1747 Status: Draft |
|
1748 |
|
1749 ------------------------------------------------------------------------------- |
|
1750 */ |
|
1751 void CTestRunner::RunL() |
|
1752 { |
|
1753 __TRACEFUNC(); |
|
1754 __TRACE( KMessage, (_L("CTestRunner::RunL: [%d] "), iStatus.Int() )); |
|
1755 |
|
1756 // Check if we need to Pause test case again |
|
1757 if( iStatus == KErrNone && iRemainingTimeValue > 0 ) |
|
1758 { |
|
1759 // Maximum time for one RTimer::After request |
|
1760 TInt maximumTime = KMaxTInt / 1000; |
|
1761 |
|
1762 __TRACE( KMessage, (_L("CTestRunner::RunL: Going to reissue After request ") ) ); |
|
1763 __TRACE( KMessage, (_L("CTestRunner::RunL: iRemainingTimeValue = %d"), iRemainingTimeValue ) ); |
|
1764 |
|
1765 if( iRemainingTimeValue < maximumTime ) |
|
1766 { |
|
1767 iPauseTimer.After( iStatus, ( iRemainingTimeValue * 1000 ) ); |
|
1768 iRemainingTimeValue = 0; |
|
1769 } |
|
1770 else |
|
1771 { |
|
1772 iRemainingTimeValue -= maximumTime; |
|
1773 iPauseTimer.After( iStatus, ( maximumTime * 1000 ) ); |
|
1774 } |
|
1775 SetActive(); |
|
1776 } |
|
1777 else |
|
1778 { |
|
1779 TBool continueTask = EFalse; |
|
1780 |
|
1781 User::LeaveIfError( iStatus.Int() ); |
|
1782 |
|
1783 if( ( iTestScripter == NULL ) || |
|
1784 ( iTestScripter->iCurrentParser == NULL ) ) |
|
1785 { |
|
1786 __TRACE( KError, (_L("CTestRunner invalid arguments"))); |
|
1787 User::Leave( KErrGeneral ); |
|
1788 } |
|
1789 |
|
1790 iState = ERunnerIdle; |
|
1791 |
|
1792 // Get next execution line from configuration section |
|
1793 TPtrC line; |
|
1794 // If current parser already has read the first line, then read next line. |
|
1795 // Otherwise read the first line. |
|
1796 if(iTestScripter->iCurrentParserReadFirstLine && iTestScripter->iCurrentParser->GetNextLine(line) == KErrNone |
|
1797 || !iTestScripter->iCurrentParserReadFirstLine && iTestScripter->iCurrentParser->GetLine(KNullDesC, line) == KErrNone) |
|
1798 { |
|
1799 iTestScripter->iCurrentParserReadFirstLine = ETrue; |
|
1800 |
|
1801 // Got new execution line |
|
1802 __TRACE( KMessage, (_L("Executing line [%S]"), &line)); |
|
1803 |
|
1804 CStifItemParser* item = PreprocessLineL( line ); |
|
1805 |
|
1806 CleanupStack::PushL( item ); |
|
1807 |
|
1808 TPtrC keyword; |
|
1809 // Get first word from line, i.e. keyword |
|
1810 User::LeaveIfError( item->GetString( _L(""), keyword ) ); |
|
1811 |
|
1812 __TRACE( KMessage, (_L("CTestRunner execute %S"), &keyword )); |
|
1813 |
|
1814 // Execute script line |
|
1815 continueTask = ExecuteLineL( keyword, item ); |
|
1816 __TRACE( KMessage, (_L("CTestRunner %S executed"), &keyword )); |
|
1817 |
|
1818 if( continueTask ) |
|
1819 { |
|
1820 __TRACE( KMessage, (_L("RunL: continueTask"))); |
|
1821 // Set CTestRunner active again to perform |
|
1822 // next execution line |
|
1823 // from testcase section |
|
1824 SetRunnerActive(); |
|
1825 } |
|
1826 |
|
1827 CleanupStack::PopAndDestroy( item ); |
|
1828 } |
|
1829 else // Stop execution if end of test case |
|
1830 { |
|
1831 __TRACE( KMessage, (_L("Executing line: no more lines from this section"))); |
|
1832 // There is no more lines in current parser, but it needs to be |
|
1833 // checked if the parser is not taken for function (sub). |
|
1834 // If this is true, then we have to get back to the parser which |
|
1835 // has called the function. |
|
1836 TInt lastParserIndex = iTestScripter->iParserStack.Count() - 1; |
|
1837 if(lastParserIndex >= 0) |
|
1838 { |
|
1839 // Delete current (the last one) parser |
|
1840 delete iTestScripter->iParserStack[lastParserIndex]; |
|
1841 iTestScripter->iParserStack.Remove(lastParserIndex); |
|
1842 if(lastParserIndex >= 1) //There is some other parser on the stack |
|
1843 { |
|
1844 iTestScripter->iCurrentParser = iTestScripter->iParserStack[lastParserIndex - 1]; |
|
1845 } |
|
1846 else //The parser stack is empty |
|
1847 { |
|
1848 iTestScripter->iCurrentParser = iTestScripter->iSectionParser; |
|
1849 } |
|
1850 __TRACE(KMessage, (_L("Returning to calling parser stored on section stack"))); |
|
1851 |
|
1852 // Continue with the test case |
|
1853 __TRACE(KMessage, (_L("RunL: continueTask (end of Sub reached)"))); |
|
1854 SetRunnerActive(); |
|
1855 return; |
|
1856 } |
|
1857 // No more execution lines in testcase section |
|
1858 __TRACE( KMessage, |
|
1859 (_L("CTestRunner::RunL: Testcase script done") )); |
|
1860 iTestScripter->TestModuleIf().Printf( KPrintPriLow, |
|
1861 _L("RunL"), _L("Script done")); |
|
1862 |
|
1863 |
|
1864 __TRACE( KMessage, |
|
1865 (_L("RunL: All TestCases done, stop CActiveScheduler"))); |
|
1866 CActiveScheduler::Current()->Stop(); |
|
1867 // Now testcase section is executed, |
|
1868 // so CTestRunner has done its job and stops |
|
1869 } |
|
1870 } |
|
1871 } |
|
1872 |
|
1873 /* |
|
1874 ------------------------------------------------------------------------------- |
|
1875 |
|
1876 Class: CTestRunner |
|
1877 |
|
1878 Method: DoCancel |
|
1879 |
|
1880 Description: Derived from CActive handles the Cancel |
|
1881 |
|
1882 Parameters: None. |
|
1883 |
|
1884 Return Values: None. |
|
1885 |
|
1886 Errors/Exceptions: None. |
|
1887 |
|
1888 Status: Draft |
|
1889 |
|
1890 ------------------------------------------------------------------------------- |
|
1891 */ |
|
1892 void CTestRunner::DoCancel() |
|
1893 { |
|
1894 __TRACEFUNC(); |
|
1895 __TRACE( KMessage, (_L("CTestRunner::DoCancel"))); |
|
1896 iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), _L("DoCancel")); |
|
1897 |
|
1898 if( iState == ERunnerPaused ) |
|
1899 { |
|
1900 iPauseTimer.Cancel(); |
|
1901 } |
|
1902 |
|
1903 CActiveScheduler::Current()->Stop(); |
|
1904 |
|
1905 iState = ERunnerCancel; |
|
1906 |
|
1907 } |
|
1908 |
|
1909 /* |
|
1910 ------------------------------------------------------------------------------- |
|
1911 |
|
1912 Class: CTestRunner |
|
1913 |
|
1914 Method: RunError |
|
1915 |
|
1916 Description: Derived from CActive handles errors from active handler. |
|
1917 |
|
1918 Parameters: TInt aError: in: error from CActive |
|
1919 |
|
1920 Return Values: KErrNone: success |
|
1921 |
|
1922 Errors/Exceptions: None. |
|
1923 |
|
1924 Status: Draft |
|
1925 |
|
1926 ------------------------------------------------------------------------------- |
|
1927 */ |
|
1928 TInt CTestRunner::RunError( TInt aError ) |
|
1929 { |
|
1930 __TRACEFUNC(); |
|
1931 __TRACE( KMessage, (_L("CTestRunner::RunError %d"), aError)); |
|
1932 |
|
1933 if ( iRunErrorMessage.Length() != 0 ) |
|
1934 { |
|
1935 iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), |
|
1936 _L("RunError : %S"), &iRunErrorMessage ); |
|
1937 iRunErrorMessage = KNullDesC; |
|
1938 } |
|
1939 else |
|
1940 { |
|
1941 iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), |
|
1942 _L("RunError")); |
|
1943 } |
|
1944 |
|
1945 iState = ERunnerError; |
|
1946 |
|
1947 // Return error from here, if none given from execution |
|
1948 if( iTestScripter->iResult.iResult == KErrNone ) |
|
1949 { |
|
1950 iTestScripter->UpdateTestCaseResult(aError, _L("CTestRunner::RunError")); |
|
1951 } |
|
1952 |
|
1953 CActiveScheduler::Current()->Stop(); |
|
1954 |
|
1955 return KErrNone; |
|
1956 |
|
1957 } |
|
1958 |
|
1959 /* |
|
1960 ------------------------------------------------------------------------------- |
|
1961 |
|
1962 Class: CTestRunner |
|
1963 |
|
1964 Method: PreprocessLineL |
|
1965 |
|
1966 Description: Preprocesses script line |
|
1967 |
|
1968 Parameters: TPtrC& line: in: script line |
|
1969 CStifItemParser*& aItem: out: New CItemParser for script line. |
|
1970 |
|
1971 Return Values: HBufC* pointer if new memory that has been allocated |
|
1972 |
|
1973 Errors/Exceptions: Leaves on error situations. |
|
1974 |
|
1975 Status: Draft |
|
1976 |
|
1977 ------------------------------------------------------------------------------- |
|
1978 */ |
|
1979 CStifItemParser* CTestRunner::PreprocessLineL( TDesC& line ) |
|
1980 { |
|
1981 CStifItemParser* item = NULL; |
|
1982 TPtrC tmp; |
|
1983 TInt len = 0; |
|
1984 TInt ret = 0; |
|
1985 |
|
1986 // Decide how long buffer should be allocated |
|
1987 if( line.Length() < KMaxName/2 ) |
|
1988 { |
|
1989 len = KMaxName; |
|
1990 } |
|
1991 else |
|
1992 { |
|
1993 len = line.Length() + KMaxName; |
|
1994 } |
|
1995 delete iLine; |
|
1996 iLine = 0; |
|
1997 iLine = HBufC::NewL(len); |
|
1998 TPtr parsedLine(iLine->Des()); |
|
1999 len = 0; |
|
2000 |
|
2001 HBufC* sourceLine = line.AllocL(); |
|
2002 CleanupStack::PushL(sourceLine); |
|
2003 |
|
2004 //Check for local variable definitions |
|
2005 item = CStifItemParser::NewL(sourceLine->Des(), 0, sourceLine->Length()); |
|
2006 CleanupStack::PushL(item); |
|
2007 |
|
2008 ret = item->GetString(KNullDesC, tmp); |
|
2009 TBool isVarDefinition = (tmp == TTestKeywords::Keyword(TTestKeywords::EVar)); |
|
2010 |
|
2011 if(!isVarDefinition) |
|
2012 { |
|
2013 while( ret == KErrNone ) |
|
2014 { |
|
2015 len += CheckDefinedLocals(tmp); |
|
2016 if((parsedLine.Length() + tmp.Length() + 1) > parsedLine.MaxLength()) |
|
2017 { |
|
2018 // Allocate bigger buffer |
|
2019 HBufC* tmpBuf = HBufC::NewL(parsedLine.MaxLength() + KMaxName); |
|
2020 CleanupStack::PushL(tmpBuf); |
|
2021 TPtrC ptr(iLine->Des()); |
|
2022 parsedLine.Set(tmpBuf->Des()); |
|
2023 parsedLine.Copy(ptr); |
|
2024 delete iLine; |
|
2025 iLine = tmpBuf; |
|
2026 CleanupStack::Pop(tmpBuf); |
|
2027 } |
|
2028 parsedLine.Append(tmp); |
|
2029 ret = item->GetNextString(tmp); |
|
2030 if(ret == KErrNone) |
|
2031 { |
|
2032 // Add space only if we got new string |
|
2033 parsedLine.Append(_L(" ")); |
|
2034 } |
|
2035 } |
|
2036 CleanupStack::PopAndDestroy(item); |
|
2037 item = NULL; |
|
2038 CleanupStack::PopAndDestroy(sourceLine); |
|
2039 sourceLine = NULL; |
|
2040 |
|
2041 //Prepare data for checking for defines |
|
2042 sourceLine = parsedLine.AllocL(); |
|
2043 CleanupStack::PushL(sourceLine); |
|
2044 parsedLine.Zero(); |
|
2045 |
|
2046 item = CStifItemParser::NewL(sourceLine->Des(), 0, sourceLine->Length()); |
|
2047 CleanupStack::PushL(item); |
|
2048 |
|
2049 ret = item->GetString(KNullDesC, tmp); |
|
2050 } |
|
2051 |
|
2052 //Check for defines |
|
2053 while(ret == KErrNone) |
|
2054 { |
|
2055 if(!isVarDefinition) |
|
2056 { |
|
2057 len += CheckDefined(tmp); |
|
2058 } |
|
2059 |
|
2060 if((parsedLine.Length() + tmp.Length() + 1) > parsedLine.MaxLength()) |
|
2061 { |
|
2062 // Allocate bigger buffer |
|
2063 HBufC* tmpBuf = HBufC::NewL(parsedLine.MaxLength() + KMaxName); |
|
2064 CleanupStack::PushL(tmpBuf); |
|
2065 TPtrC ptr(iLine->Des()); |
|
2066 parsedLine.Set(tmpBuf->Des()); |
|
2067 parsedLine.Copy(ptr); |
|
2068 delete iLine; |
|
2069 iLine = tmpBuf; |
|
2070 CleanupStack::Pop(tmpBuf); |
|
2071 } |
|
2072 parsedLine.Append(tmp); |
|
2073 ret = item->GetNextString(tmp); |
|
2074 if( ret == KErrNone ) |
|
2075 { |
|
2076 // Add space only if we got new string |
|
2077 parsedLine.Append(_L(" ")); |
|
2078 } |
|
2079 } |
|
2080 |
|
2081 //Cleaning... |
|
2082 CleanupStack::PopAndDestroy(item); |
|
2083 item = NULL; |
|
2084 CleanupStack::PopAndDestroy(sourceLine); |
|
2085 sourceLine = NULL; |
|
2086 |
|
2087 __TRACE(KMessage, (_L("Preprocessed line [%S]"), &parsedLine)); |
|
2088 item = CStifItemParser::NewL( parsedLine, 0, parsedLine.Length() ); |
|
2089 |
|
2090 return item; |
|
2091 } |
|
2092 |
|
2093 /* |
|
2094 ------------------------------------------------------------------------------- |
|
2095 |
|
2096 Class: CTestRunner |
|
2097 |
|
2098 Method: CheckDefined |
|
2099 |
|
2100 Description: Check if aWord is some defined word |
|
2101 |
|
2102 Parameters: TPtrC& aWord: inout: Parsed word, defined or original returned |
|
2103 |
|
2104 Return Values: TInt: length diference between new and old word |
|
2105 |
|
2106 Errors/Exceptions: None. |
|
2107 |
|
2108 Status: Draft |
|
2109 |
|
2110 ------------------------------------------------------------------------------- |
|
2111 */ |
|
2112 TInt CTestRunner::CheckDefined( TPtrC& aWord ) |
|
2113 { |
|
2114 |
|
2115 TInt len = 0; |
|
2116 TInt i = 0; |
|
2117 |
|
2118 // KLoopCounter word changing to current loop count value. |
|
2119 if( aWord == KLoopCounter ) |
|
2120 { |
|
2121 iLoopCounterDes.Zero(); |
|
2122 iLoopCounterDes.AppendNum( iLoopCounter ); |
|
2123 len = iLoopCounterDes.Length() - aWord.Length(); |
|
2124 aWord.Set( iLoopCounterDes ); |
|
2125 return len; |
|
2126 } |
|
2127 |
|
2128 // First, check values defined in test case file |
|
2129 TInt count = iTestScripter->iDefinedRuntime.Count(); |
|
2130 for( i = 0; i < count; i++ ) |
|
2131 { |
|
2132 if( iTestScripter->iDefinedRuntime[i]->Name() == aWord ) |
|
2133 { |
|
2134 len = iTestScripter->iDefinedRuntime[i]->Value().Length() - aWord.Length(); |
|
2135 aWord.Set( iTestScripter->iDefinedRuntime[i]->Value() ); |
|
2136 return len; |
|
2137 } |
|
2138 } |
|
2139 |
|
2140 // Second, check values defined in test module initialization file |
|
2141 count = iTestScripter->iDefinedIni.Count(); |
|
2142 for( i = 0; i < count; i++ ) |
|
2143 { |
|
2144 if( iTestScripter->iDefinedIni[i]->Name() == aWord ) |
|
2145 { |
|
2146 len = iTestScripter->iDefinedIni[i]->Value().Length() - aWord.Length(); |
|
2147 aWord.Set( iTestScripter->iDefinedIni[i]->Value() ); |
|
2148 return len; |
|
2149 } |
|
2150 } |
|
2151 |
|
2152 return len; |
|
2153 } |
|
2154 |
|
2155 /* |
|
2156 ------------------------------------------------------------------------------- |
|
2157 |
|
2158 Class: CTestRunner |
|
2159 |
|
2160 Method: CheckDefinedLocals |
|
2161 |
|
2162 Description: Check if aWord is a local variable |
|
2163 |
|
2164 Parameters: TPtrC& aWord: inout: Parsed word, defined or original returned |
|
2165 |
|
2166 Return Values: TInt: length diference between new and old word |
|
2167 |
|
2168 Errors/Exceptions: None. |
|
2169 |
|
2170 Status: Draft |
|
2171 |
|
2172 ------------------------------------------------------------------------------- |
|
2173 */ |
|
2174 TInt CTestRunner::CheckDefinedLocals( TPtrC& aWord ) |
|
2175 { |
|
2176 |
|
2177 TInt len = 0; |
|
2178 TInt i = 0; |
|
2179 |
|
2180 TInt count = iTestScripter->iDefinedLocal.Count(); |
|
2181 for(i = 0; i < count; i++) |
|
2182 { |
|
2183 if(iTestScripter->iDefinedLocal[i]->Name() == aWord) |
|
2184 { |
|
2185 len = iTestScripter->iDefinedLocal[i]->Value().Length() - aWord.Length(); |
|
2186 aWord.Set(iTestScripter->iDefinedLocal[i]->Value()); |
|
2187 return len; |
|
2188 } |
|
2189 } |
|
2190 |
|
2191 return len; |
|
2192 } |
|
2193 |
|
2194 /* |
|
2195 ------------------------------------------------------------------------------- |
|
2196 |
|
2197 Class: CTestRunner |
|
2198 |
|
2199 Method: ExecuteLineL |
|
2200 |
|
2201 Description: Executes script line |
|
2202 |
|
2203 Parameters: TDesC& aKeyword: in: keyword string |
|
2204 CStifItemParser* aItem: in: script line |
|
2205 |
|
2206 Return Values: ETrue: continue script file execution |
|
2207 EFalse: stop script file execution |
|
2208 |
|
2209 Errors/Exceptions: Leaves on error situations. |
|
2210 |
|
2211 Status: Approved |
|
2212 |
|
2213 ------------------------------------------------------------------------------- |
|
2214 */ |
|
2215 TBool CTestRunner::ExecuteLineL( TDesC& aKeyword, |
|
2216 CStifItemParser* aItem ) |
|
2217 { |
|
2218 _LIT( KErrMsgDeleteNoParam, "Delete: Name of object is not defined" ); |
|
2219 _LIT( KErrMsgDeleteObjNotFound, "Delete: Can't delete object %S. Object does not exists." ); |
|
2220 _LIT( KErrMsgPauseTimeoutNotDefined, "Pause: No timeout value given or value has invalid format" ); |
|
2221 _LIT( KErrMsgPauseTimeoutNotPositive, "Pause: Timeout value can't be <0" ); |
|
2222 _LIT( KErrMsgCreateTestModeleNotDefined, "Create: Name of test module is not defined" ); |
|
2223 _LIT( KErrMsgCreateObjectIdNotDefined, "Create: Name of test module object is not defined" ); |
|
2224 _LIT( KErrMsgCreateKernelDriverNotDefined, "CreateKernel: Kernel driver name is not defined" ); |
|
2225 _LIT( KErrMsgCreateKernelObjectNameNotDefined, "CreateKernel: Kernel driver object name is not defined" ); |
|
2226 _LIT( KErrMsgCreateKernelFailed, "CreateKernel: Can't creeate kernel driver %S" ); |
|
2227 _LIT( KErrMsgWaitTestClassNameNotDefined, "WaitTestClass: Test class object name is not defined" ); |
|
2228 _LIT( KErrMsgWaitTestClassObjNotFound, "WaitTestClass: Test class object %S does not exists" ); |
|
2229 _LIT( KErrMsgLoopNested, "Loop: Nested loop are not supported" ); |
|
2230 _LIT( KErrMsgLoopNoParam, "Loop: No loop iterations count given or value has invalid format" ); |
|
2231 _LIT( KErrMsgLoopInvalidParam, "Loop: Loop count must be >0" ); |
|
2232 _LIT( KErrMsgLoopUnknownUnexpectedOption, "Loop: Unknown or unexpected loop option"); |
|
2233 _LIT( KErrMsgEndLoopNotOpened, "Endloop: Can't execute endloop. No opened loop exists" ); |
|
2234 _LIT( KErrMsgBringToForegroundNotSupported, "BringToForeground: BringToForeground is not supported in non s60 environment" ); |
|
2235 _LIT( KErrMsgSendToBackgroundNotSupported, "SendToBackground: SendToBackground is not supported in non s60 environment" ); |
|
2236 _LIT( KErrMsgPressKeyNotSupported, "PressKey: PressKey is not supported in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini" ); |
|
2237 _LIT( KErrMsgTypeTextNotSupported, "TypeText: TypeText is not supported in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini" ); |
|
2238 _LIT( KErrMsgSendPointerEventNotSupported, "SendPointerEvent: SendPointerEvent is not supported in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini" ); |
|
2239 _LIT( KErrVarNameError, "Variable: Could not get variable name"); |
|
2240 _LIT( KErrVarValueError, "Variable: Value too long"); |
|
2241 _LIT( KErrSubNameError, "Sub: Could not get name of Sub to be called"); |
|
2242 _LIT( KErrSubGetError, "Sub: Could not get Sub section"); |
|
2243 |
|
2244 iRunErrorMessage = KNullDesC; |
|
2245 TBool continueTask = ETrue; |
|
2246 |
|
2247 TInt key = TTestKeywords::Parse( aKeyword, TTestKeywords::Keyword ); |
|
2248 |
|
2249 switch( key ) |
|
2250 { |
|
2251 // Test case execution control cases |
|
2252 case TTestKeywords::ECreate: |
|
2253 case TTestKeywords::ECreateX: |
|
2254 { |
|
2255 TPtrC tmp; |
|
2256 TName module; |
|
2257 |
|
2258 // Testmodule name |
|
2259 TInt ret = aItem->GetNextString( tmp ); |
|
2260 if ( ret != KErrNone ) |
|
2261 { |
|
2262 iRunErrorMessage = KErrMsgCreateTestModeleNotDefined; |
|
2263 User::Leave( KErrArgument ); |
|
2264 } |
|
2265 TParse p; |
|
2266 p.Set( tmp, NULL, NULL ); |
|
2267 // Check if exists in module name |
|
2268 if( p.ExtPresent() ) |
|
2269 { |
|
2270 module.Copy( tmp ); |
|
2271 } |
|
2272 else |
|
2273 { |
|
2274 // No extension in module name, add it here |
|
2275 _LIT( KDllExtension, ".dll"); |
|
2276 module.Copy( tmp ); |
|
2277 module.Append( KDllExtension ); |
|
2278 } |
|
2279 |
|
2280 // objectid |
|
2281 ret = aItem->GetNextString( tmp ); |
|
2282 if ( ret != KErrNone ) |
|
2283 { |
|
2284 iRunErrorMessage = KErrMsgCreateObjectIdNotDefined; |
|
2285 User::Leave( KErrArgument ); |
|
2286 } |
|
2287 |
|
2288 __TRACE( KMessage, (_L("%S %S"), &aKeyword, &tmp)); |
|
2289 iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), |
|
2290 _L("%S %S"), &aKeyword, &tmp); |
|
2291 |
|
2292 iTestScripter->CreateObjectL( module, tmp ); |
|
2293 } |
|
2294 break; |
|
2295 case TTestKeywords::ECreateKernel: |
|
2296 { |
|
2297 TPtrC obj; |
|
2298 TPtrC driver; |
|
2299 |
|
2300 // Testdriver name |
|
2301 TInt ret = aItem->GetNextString( driver ); |
|
2302 if ( ret != KErrNone ) |
|
2303 { |
|
2304 iRunErrorMessage = KErrMsgCreateKernelDriverNotDefined; |
|
2305 User::Leave( ret ); |
|
2306 } |
|
2307 |
|
2308 // objectid |
|
2309 ret = aItem->GetNextString( obj ); |
|
2310 if ( ret != KErrNone ) |
|
2311 { |
|
2312 iRunErrorMessage = KErrMsgCreateKernelObjectNameNotDefined; |
|
2313 User::Leave( ret ); |
|
2314 } |
|
2315 |
|
2316 __TRACE( KMessage, (_L("%S %S"), &aKeyword, &obj)); |
|
2317 iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), |
|
2318 _L("%S %S"), &aKeyword, &obj); |
|
2319 TInt leaveErr = KErrNone; |
|
2320 TRAP( leaveErr, iTestScripter->CreateKernelObjectL( driver, obj )); |
|
2321 if ( leaveErr != KErrNone ) |
|
2322 { |
|
2323 iRunErrorMessage.Format( KErrMsgCreateKernelFailed, &driver ); |
|
2324 User::Leave( leaveErr ); |
|
2325 } |
|
2326 } |
|
2327 break; |
|
2328 case TTestKeywords::EDelete: |
|
2329 { |
|
2330 TPtrC tmp; |
|
2331 // objectid |
|
2332 TInt ret = aItem->GetNextString( tmp ); |
|
2333 if ( ret != KErrNone ) |
|
2334 { |
|
2335 iRunErrorMessage = KErrMsgDeleteNoParam; |
|
2336 User::Leave( ret ); |
|
2337 } |
|
2338 |
|
2339 __TRACE( KMessage, (_L("%S %S"), &aKeyword, &tmp)); |
|
2340 iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), |
|
2341 _L("%S %S"), &aKeyword, &tmp); |
|
2342 |
|
2343 ret = iTestScripter->DeleteObjectL( tmp ); |
|
2344 if ( ret != KErrNone ) |
|
2345 { |
|
2346 iRunErrorMessage.Format( KErrMsgDeleteObjNotFound, &tmp ); |
|
2347 User::Leave( ret ); |
|
2348 } |
|
2349 } |
|
2350 break; |
|
2351 case TTestKeywords::ERequest: |
|
2352 case TTestKeywords::EWait: |
|
2353 case TTestKeywords::ERelease: |
|
2354 case TTestKeywords::ESet: |
|
2355 case TTestKeywords::EUnset: |
|
2356 continueTask = ExecuteEventL( aKeyword, aItem ); |
|
2357 break; |
|
2358 case TTestKeywords::EPrint: |
|
2359 { |
|
2360 __TRACE( KMessage, (_L("%S"), &aKeyword)); |
|
2361 iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), |
|
2362 _L("%S"), &aKeyword ); |
|
2363 |
|
2364 RBuf buf; |
|
2365 buf.CreateL(1024); |
|
2366 CleanupClosePushL(buf); |
|
2367 |
|
2368 TPtrC tmp; |
|
2369 |
|
2370 while( aItem->GetNextString( tmp ) == KErrNone ) |
|
2371 { |
|
2372 if( buf.Length() + tmp.Length() >= buf.MaxLength() ) |
|
2373 { |
|
2374 buf.ReAllocL(buf.MaxLength() + tmp.Length() * 10); |
|
2375 } |
|
2376 buf.Append( tmp ); |
|
2377 buf.Append( _L(" ") ); |
|
2378 } |
|
2379 |
|
2380 iTestScripter->TestModuleIf().Printf( KPrintPriNorm, |
|
2381 _L("Test"), |
|
2382 _L("%S"), &buf); |
|
2383 RDebug::Print( _L("Print : Test : %S"), &buf ); |
|
2384 CleanupStack::PopAndDestroy(&buf); |
|
2385 } |
|
2386 break; |
|
2387 case TTestKeywords::EAllowNextResult: |
|
2388 { |
|
2389 AddTestCaseResultL( aItem ); |
|
2390 } |
|
2391 break; |
|
2392 case TTestKeywords::EWaitTestClass: |
|
2393 { |
|
2394 // Just stop script running, continue event is signaled |
|
2395 // from test class with specified object name |
|
2396 TPtrC objectName; |
|
2397 // Get Object name |
|
2398 TInt ret = aItem->GetNextString( objectName ); |
|
2399 if ( ret != KErrNone ) |
|
2400 { |
|
2401 iRunErrorMessage = KErrMsgWaitTestClassNameNotDefined; |
|
2402 User::Leave( ret ); |
|
2403 } |
|
2404 TTestObjectBase* obj = iTestScripter->GetObject ( objectName ); |
|
2405 //User::LeaveIfNull( obj ); |
|
2406 if( obj == NULL ) |
|
2407 { |
|
2408 iRunErrorMessage.Format( KErrMsgWaitTestClassObjNotFound, &objectName ); |
|
2409 User::Leave( KErrGeneral ); |
|
2410 } |
|
2411 continueTask = obj->Wait(); |
|
2412 |
|
2413 if( continueTask ) |
|
2414 { |
|
2415 // If OOM testing is ongoing ignore result check(given by user) |
|
2416 if( !iTestScripter->iOOMIgnoreFailure ) |
|
2417 { |
|
2418 if( iTestCaseResults.Count() == 0 ) |
|
2419 { |
|
2420 // KErrNone is the default result expected |
|
2421 // if nothing else is given |
|
2422 User::LeaveIfError( iTestCaseResults.Append( |
|
2423 KErrNone ) ); |
|
2424 } |
|
2425 |
|
2426 if( iTestCaseResults.Find( obj->iAsyncResult ) < 0 ) |
|
2427 { |
|
2428 __TRACE( KError, ( _L("Command for [%S] failed (%d)"), |
|
2429 &objectName, obj->iAsyncResult )); |
|
2430 iTestScripter->UpdateTestCaseResult(obj->iAsyncResult, _L("CTestRunner::ExecuteLineL: asynchronous method returned error")); |
|
2431 // Stops execution from CTestRunner::RunError |
|
2432 User::Leave( KErrGeneral ); |
|
2433 } |
|
2434 } |
|
2435 else |
|
2436 { |
|
2437 __TRACE( KMessage, ( |
|
2438 _L( "OOM test: 'oomignorefailure' is ON, test case result will reset" ) ) ); |
|
2439 } |
|
2440 |
|
2441 iTestCaseResults.Reset(); |
|
2442 // Reset test case allow result to CTestModuleIf side too. This is |
|
2443 // used in TAL-TA5L macro handling. |
|
2444 User::LeaveIfError( |
|
2445 iTestScripter->TestModuleIf().ResetAllowResult() ); |
|
2446 } |
|
2447 |
|
2448 } |
|
2449 break; |
|
2450 case TTestKeywords::EPause: |
|
2451 { |
|
2452 // Maximum time for one RTimer::After request |
|
2453 TInt maximumTime = KMaxTInt / 1000; |
|
2454 // Set iRemainingTimeValue to zero |
|
2455 iRemainingTimeValue = 0; |
|
2456 |
|
2457 TInt timeout; |
|
2458 // Read valid results to timeout |
|
2459 if( aItem->GetNextInt( timeout ) != KErrNone ) |
|
2460 { |
|
2461 __TRACE( KError, (_L("CTestRunner::ExecuteLineL: No timeout value given for pause"))); |
|
2462 iRunErrorMessage = KErrMsgPauseTimeoutNotDefined; |
|
2463 User::Leave( KErrArgument ); |
|
2464 } |
|
2465 |
|
2466 // Test case file parsing was success |
|
2467 |
|
2468 __TRACE( KMessage, (_L("CTestRunner::ExecuteLineL: Pause for %d milliseconds"), timeout)); |
|
2469 |
|
2470 if( timeout < 0 ) |
|
2471 { |
|
2472 __TRACE( KError, (_L("CTestRunner::ExecuteLineL: Given pause value < 0"))); |
|
2473 iRunErrorMessage = KErrMsgPauseTimeoutNotPositive; |
|
2474 User::Leave( KErrArgument ); |
|
2475 } |
|
2476 else |
|
2477 { |
|
2478 // Check is pause value suitable for RTimer::After |
|
2479 if( timeout < maximumTime ) |
|
2480 { |
|
2481 iPauseTimer.After( iStatus, ( timeout * 1000 ) ); |
|
2482 } |
|
2483 else |
|
2484 { |
|
2485 // Given pause value after multiplication with 1000 is |
|
2486 // larger than KMaxTInt, so we need to split it and |
|
2487 // re-request After with remaining value from RunL |
|
2488 |
|
2489 iRemainingTimeValue = timeout - maximumTime; |
|
2490 iPauseTimer.After( iStatus, maximumTime * 1000 ); |
|
2491 } |
|
2492 |
|
2493 SetActive(); |
|
2494 |
|
2495 // Stop execution after paused for given timeout |
|
2496 continueTask = EFalse; |
|
2497 } |
|
2498 } |
|
2499 break; |
|
2500 case TTestKeywords::ELoop: |
|
2501 { |
|
2502 if( iLoopTimes > 0 ) |
|
2503 { |
|
2504 __TRACE( KError, (_L("ExecuteLineL: Nested loop are not supported"))); |
|
2505 iRunErrorMessage = KErrMsgLoopNested; |
|
2506 User::Leave( KErrNotSupported ); |
|
2507 } |
|
2508 iLoopTimes = 0; |
|
2509 iLoopCounter = 0; |
|
2510 iTimedLoop = EFalse; |
|
2511 if( aItem->GetNextInt( iLoopTimes ) != KErrNone ) |
|
2512 { |
|
2513 __TRACE( KError, (_L("ExecuteLineL: No loop count value given for loop"))); |
|
2514 iRunErrorMessage = KErrMsgLoopNoParam; |
|
2515 User::Leave( KErrArgument ); |
|
2516 } |
|
2517 if( iLoopTimes < 1 ) |
|
2518 { |
|
2519 __TRACE( KError, (_L("ExecuteLineL: Loop count must be >0"))); |
|
2520 iRunErrorMessage = KErrMsgLoopInvalidParam; |
|
2521 User::Leave( KErrArgument ); |
|
2522 } |
|
2523 __TRACE( KMessage, (_L("ExecuteLineL: Loop for %d times" ), iLoopTimes ) ); |
|
2524 |
|
2525 //Check loop options |
|
2526 TPtrC option; |
|
2527 TInt ret = aItem->GetNextString(option); |
|
2528 if(ret == KErrNone) |
|
2529 { |
|
2530 if(option.Compare(_L("msec")) == 0) //time loop option |
|
2531 { |
|
2532 iTimedLoop = ETrue; |
|
2533 iStartTime.HomeTime(); |
|
2534 iExpectedLoopTime = TInt64(iLoopTimes) * TInt64(1000); //convert to micro seconds |
|
2535 __TRACE(KMessage, (_L("ExecuteLineL: Timed loop for %d msec" ), iLoopTimes)); |
|
2536 |
|
2537 ret = aItem->GetNextString(option); //Get next option |
|
2538 } |
|
2539 } |
|
2540 |
|
2541 if(ret == KErrNone) |
|
2542 { |
|
2543 __TRACE( KError, (_L("ExecuteLineL: Unknown or unexpected loop option [%S]"), &option)); |
|
2544 iRunErrorMessage = KErrMsgLoopUnknownUnexpectedOption; |
|
2545 User::Leave( KErrNotSupported ); |
|
2546 } |
|
2547 |
|
2548 iLoopStartPos = iTestScripter->iCurrentParser->GetPosition(); |
|
2549 } |
|
2550 break; |
|
2551 case TTestKeywords::EEndLoop: |
|
2552 { |
|
2553 if( iLoopTimes == 0 ) |
|
2554 { |
|
2555 __TRACE( KError, (_L("ExecuteLineL: Can't execute endloop. No opened loop exists"))); |
|
2556 iRunErrorMessage = KErrMsgEndLoopNotOpened; |
|
2557 User::Leave( KErrNotFound ); |
|
2558 } |
|
2559 iLoopCounter++; |
|
2560 __TRACE( KMessage, |
|
2561 (_L("ExecuteLineL: Loop executed for %d times" ), |
|
2562 iLoopCounter ) ); |
|
2563 |
|
2564 TTime currTime; |
|
2565 currTime.HomeTime(); |
|
2566 if(((!iTimedLoop) && (iLoopCounter < iLoopTimes)) //Normal loop |
|
2567 || |
|
2568 iTimedLoop && (currTime.MicroSecondsFrom(iStartTime) < iExpectedLoopTime)) //Timed loop |
|
2569 { |
|
2570 // Go to beginning of the loop |
|
2571 User::LeaveIfError( |
|
2572 iTestScripter->iCurrentParser->SetPosition( iLoopStartPos )); |
|
2573 } |
|
2574 else |
|
2575 { |
|
2576 // End looping |
|
2577 iLoopCounter = 0; |
|
2578 iLoopTimes = 0; |
|
2579 iLoopStartPos = 0; |
|
2580 } |
|
2581 } |
|
2582 break; |
|
2583 case TTestKeywords::ETimeout: |
|
2584 case TTestKeywords::EPriority: |
|
2585 // not used here |
|
2586 break; |
|
2587 case TTestKeywords::EOOMIgnoreFailure: |
|
2588 { |
|
2589 OOMIgnoreFailureL( aItem ); // Handle parsing |
|
2590 break; |
|
2591 } |
|
2592 case TTestKeywords::EOOMHeapFailNext: |
|
2593 { |
|
2594 OOMHeapFailNextL( aItem ); // Handle parsing |
|
2595 break; |
|
2596 } |
|
2597 case TTestKeywords::EOOMHeapSetFail: |
|
2598 { |
|
2599 OOMHeapSetFailL( aItem ); // Handle parsing |
|
2600 break; |
|
2601 } |
|
2602 case TTestKeywords::EOOMHeapToNormal: |
|
2603 { |
|
2604 // Initialize all OOM related variables back to default. |
|
2605 OOMHeapToNormal(); |
|
2606 __TRACE( KMessage, ( |
|
2607 _L( "'oomheaptonormal' called, OOM initialization or ending OOM test") ) ); |
|
2608 break; |
|
2609 } |
|
2610 case TTestKeywords::ETestInterference: |
|
2611 { |
|
2612 TestInterferenceL( aItem ); // Handle parsing |
|
2613 break; |
|
2614 } |
|
2615 case TTestKeywords::EMeasurement: |
|
2616 { |
|
2617 MeasurementL( aItem ); // Handle parsing |
|
2618 break; |
|
2619 } |
|
2620 case TTestKeywords::EAllowErrorCodes: |
|
2621 { |
|
2622 // Check is KErrNone already appended to iTestCaseResults array. |
|
2623 if( iTestCaseResults.Find( KErrNone ) < 0 ) |
|
2624 { |
|
2625 // 'allowerrorcodes' keyword sets KErrNone as a default |
|
2626 User::LeaveIfError( iTestCaseResults.Append( KErrNone ) ); |
|
2627 // Set test case allow result to CTestModuleIf side too. This |
|
2628 // is used in TAL-TA5L macro handling. |
|
2629 User::LeaveIfError( |
|
2630 iTestScripter->TestModuleIf().SetAllowResult( KErrNone ) ); |
|
2631 } |
|
2632 |
|
2633 // Set user given specific error code to be allowed. |
|
2634 AddTestCaseResultL( aItem ); |
|
2635 } |
|
2636 break; |
|
2637 |
|
2638 case TTestKeywords::EBringToForeground: |
|
2639 { |
|
2640 if ( iTestScripter->TestModuleIf().UITesting() == true ) |
|
2641 { |
|
2642 iTestScripter->TestModuleIf().GetUiEnvProxy()->BringToForeground(); |
|
2643 } |
|
2644 else |
|
2645 { |
|
2646 __TRACE( KError, (_L("ExecuteLineL: Can't execute bringtoforeground in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini"))); |
|
2647 iRunErrorMessage = KErrMsgBringToForegroundNotSupported; |
|
2648 User::Leave( KErrNotSupported ); |
|
2649 } |
|
2650 } |
|
2651 break; |
|
2652 case TTestKeywords::ESendToBackground: |
|
2653 { |
|
2654 if ( iTestScripter->TestModuleIf().UITesting() == true ) |
|
2655 { |
|
2656 iTestScripter->TestModuleIf().GetUiEnvProxy()->SendToBackground(); |
|
2657 } |
|
2658 else |
|
2659 { |
|
2660 __TRACE( KError, (_L("ExecuteLineL: Can't execute sendtobackground in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini"))); |
|
2661 iRunErrorMessage = KErrMsgSendToBackgroundNotSupported; |
|
2662 User::Leave( KErrNotSupported ); |
|
2663 } |
|
2664 } |
|
2665 break; |
|
2666 case TTestKeywords::EPressKey: |
|
2667 { |
|
2668 if ( iTestScripter->TestModuleIf().UITesting() == true ) |
|
2669 { |
|
2670 continueTask = PressKeyL( aItem ); |
|
2671 } |
|
2672 else |
|
2673 { |
|
2674 __TRACE( KError, (_L("ExecuteLineL: Can't execute presskey in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini"))); |
|
2675 iRunErrorMessage = KErrMsgPressKeyNotSupported; |
|
2676 User::Leave( KErrNotSupported ); |
|
2677 } |
|
2678 |
|
2679 // Check if it was global or local presskey |
|
2680 if ( !continueTask ) |
|
2681 { |
|
2682 // Stop execution after key is pressed and wait until it is handled |
|
2683 SetActive(); |
|
2684 } |
|
2685 } |
|
2686 break; |
|
2687 case TTestKeywords::ETypeText: |
|
2688 { |
|
2689 if ( iTestScripter->TestModuleIf().UITesting() == true ) |
|
2690 { |
|
2691 continueTask = TypeTextL( aItem ); |
|
2692 } |
|
2693 else |
|
2694 { |
|
2695 __TRACE( KError, (_L("ExecuteLineL: Can't execute typetext in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini"))); |
|
2696 iRunErrorMessage = KErrMsgTypeTextNotSupported; |
|
2697 User::Leave( KErrNotSupported ); |
|
2698 } |
|
2699 |
|
2700 // Check if it was global or local typetext |
|
2701 if ( !continueTask ) |
|
2702 { |
|
2703 // Stop execution after key is pressed and wait until it is handled |
|
2704 SetActive(); |
|
2705 } |
|
2706 } |
|
2707 break; |
|
2708 case TTestKeywords::EVar: |
|
2709 { |
|
2710 TName name; |
|
2711 TName buf; |
|
2712 TPtrC tmp; |
|
2713 |
|
2714 //Get variable name |
|
2715 if(aItem->GetNextString(tmp) == KErrNone) |
|
2716 { |
|
2717 name.Copy(tmp); |
|
2718 } |
|
2719 else |
|
2720 { |
|
2721 //Error when getting variable name |
|
2722 __TRACE(KError, (_L("ExecuteLineL: Could not read variable name"))); |
|
2723 iRunErrorMessage = KErrVarNameError; |
|
2724 User::Leave(KErrArgument); |
|
2725 } |
|
2726 |
|
2727 //Get value for variable |
|
2728 while(aItem->GetNextString(tmp) == KErrNone) |
|
2729 { |
|
2730 if(buf.Length() + tmp.Length() >= buf.MaxLength()) |
|
2731 { |
|
2732 //Error when getting variable name |
|
2733 __TRACE(KError, (_L("ExecuteLineL: Variable value too long"))); |
|
2734 iRunErrorMessage = KErrVarValueError; |
|
2735 User::Leave(KErrArgument); |
|
2736 } |
|
2737 buf.Append(tmp); |
|
2738 buf.Append(_L(" ")); |
|
2739 } |
|
2740 //Remove last space |
|
2741 if(buf.Length() > 0) |
|
2742 { |
|
2743 buf.SetLength(buf.Length() - 1); |
|
2744 } |
|
2745 |
|
2746 //Store local variable |
|
2747 TInt count = iTestScripter->iDefinedLocal.Count(); |
|
2748 TInt i; |
|
2749 for(i = 0; i < count; i++) |
|
2750 { |
|
2751 if(iTestScripter->iDefinedLocal[i]->Name() == name) |
|
2752 { |
|
2753 // Update existing |
|
2754 iTestScripter->iDefinedLocal[i]->SetValueL(buf); |
|
2755 __TRACE(KMessage, (_L("Update local variable [%S]: [%S]"), &name, &buf)); |
|
2756 break; |
|
2757 } |
|
2758 } |
|
2759 if(i == count) |
|
2760 { |
|
2761 // New define, store it |
|
2762 CDefinedValue* define = CDefinedValue::NewL(name, buf); |
|
2763 CleanupStack::PushL(define); |
|
2764 User::LeaveIfError(iTestScripter->iDefinedLocal.Append(define)); |
|
2765 CleanupStack::Pop(define); |
|
2766 __TRACE(KMessage, (_L("Add local variable [%S]: [%S]"), &name, &buf)); |
|
2767 } |
|
2768 } |
|
2769 break; |
|
2770 case TTestKeywords::ECallSub: |
|
2771 { |
|
2772 // Get sub name |
|
2773 TPtrC subName; |
|
2774 |
|
2775 //Get sub name |
|
2776 TInt err = aItem->GetNextString(subName); |
|
2777 if(err != KErrNone) |
|
2778 { |
|
2779 //Error when getting sub name |
|
2780 __TRACE(KError, (_L("ExecuteLineL: Could not read sub name [%d]"), err)); |
|
2781 iRunErrorMessage = KErrSubNameError; |
|
2782 User::Leave(KErrArgument); |
|
2783 } |
|
2784 |
|
2785 // Load section |
|
2786 CStifSectionParser* subSection = NULL; |
|
2787 TRAP(err, |
|
2788 subSection = iTestScripter->GetSubL(subName); |
|
2789 ); |
|
2790 if((err != KErrNone) || (!subSection)) |
|
2791 { |
|
2792 //Error when getting sub name |
|
2793 if(err == KErrNone) |
|
2794 { |
|
2795 err = KErrArgument; |
|
2796 } |
|
2797 __TRACE(KError, (_L("ExecuteLineL: Could not get section for sub [%d]"), err)); |
|
2798 iRunErrorMessage = KErrSubGetError; |
|
2799 User::Leave(err); |
|
2800 } |
|
2801 |
|
2802 // Handle new section parser |
|
2803 CleanupStack::PushL(subSection); |
|
2804 iTestScripter->iParserStack.AppendL(subSection); |
|
2805 __TRACE(KMessage, (_L("ExecuteLineL: Section for sub [%S] appended to section stack"), &subName)); |
|
2806 CleanupStack::Pop(subSection); |
|
2807 iTestScripter->iCurrentParser = subSection; |
|
2808 iTestScripter->iCurrentParserReadFirstLine = EFalse; //Change it to false, becaue subSection is a new parser and it has nothing read |
|
2809 } |
|
2810 break; |
|
2811 case TTestKeywords::ESetResultDescription: |
|
2812 { |
|
2813 __TRACE(KMessage, (_L("%S"), &aKeyword)); |
|
2814 iTestScripter->TestModuleIf().Printf(KPrintPriLow, _L("Runner"), _L("%S"), &aKeyword); |
|
2815 |
|
2816 TName buf; |
|
2817 TPtrC tmp; |
|
2818 |
|
2819 while(aItem->GetNextString(tmp) == KErrNone) |
|
2820 { |
|
2821 if(buf.Length() + tmp.Length() >= buf.MaxLength()) |
|
2822 { |
|
2823 break; |
|
2824 } |
|
2825 if(buf.Length() > 0) |
|
2826 { |
|
2827 buf.Append(_L(" ")); |
|
2828 } |
|
2829 buf.Append(tmp); |
|
2830 } |
|
2831 |
|
2832 iTestScripter->SetResultDescription(buf); |
|
2833 RDebug::Print( _L("SetDescription to [%S]"), &buf ); |
|
2834 } |
|
2835 break; |
|
2836 case TTestKeywords::ESendPointerEvent: |
|
2837 { |
|
2838 if ( iTestScripter->TestModuleIf().UITesting() == true ) |
|
2839 { |
|
2840 continueTask = SendPointerEventL( aItem ); |
|
2841 } |
|
2842 else |
|
2843 { |
|
2844 __TRACE( KError, (_L("ExecuteLineL: Can't execute sendpointerevent in non s60 environment. Check if .cfg file name contains ui_ prefix and UITestingSupport= YES entry is defined in TestFrameworkd.ini"))); |
|
2845 iRunErrorMessage = KErrMsgSendPointerEventNotSupported; |
|
2846 User::Leave( KErrNotSupported ); |
|
2847 } |
|
2848 |
|
2849 // Check if it was global or local sendpointerevent |
|
2850 if ( !continueTask ) |
|
2851 { |
|
2852 // Stop execution after pointer event is send and wait until it is handled |
|
2853 SetActive(); |
|
2854 } |
|
2855 } |
|
2856 break; |
|
2857 default: |
|
2858 { |
|
2859 continueTask = ExecuteCommandL( aKeyword, aItem ); |
|
2860 } |
|
2861 break; |
|
2862 } |
|
2863 |
|
2864 __TRACE( KMessage, (_L("ExecuteLineL: TestCase line executed"))); |
|
2865 |
|
2866 return continueTask; |
|
2867 } |
|
2868 |
|
2869 /* |
|
2870 ------------------------------------------------------------------------------- |
|
2871 |
|
2872 Class: CTestRunner |
|
2873 |
|
2874 Method: PressKeyL |
|
2875 |
|
2876 Description: Send key press event to AppUi |
|
2877 |
|
2878 Parameters: CStifItemParser* aItem: in: script line |
|
2879 |
|
2880 Return Values: None |
|
2881 |
|
2882 Errors/Exceptions: Leaves on error situations. |
|
2883 |
|
2884 Status: Draft |
|
2885 |
|
2886 ------------------------------------------------------------------------------- |
|
2887 */ |
|
2888 TBool CTestRunner::PressKeyL( CStifItemParser* aItem ) |
|
2889 { |
|
2890 _LIT( KErrMsgSendKeyEventInvalidParameterValue, "PressKey: Invalid parameter %s value " ); |
|
2891 _LIT( KErrMsgSendKeyEventInvalidParameter, "PressKey: Invalid parameter %s" ); |
|
2892 |
|
2893 _LIT( KKeyCodeParameter, "keycode=" ); |
|
2894 _LIT( KKeyScanCodeParameter, "keyscancode=" ); |
|
2895 _LIT( KModifierParameter, "modifier=" ); |
|
2896 _LIT( KRepeatsParameter, "repeats=" ); |
|
2897 |
|
2898 _LIT( KModeGlobal, "global" ); |
|
2899 _LIT( KModeLocal, "local" ); |
|
2900 |
|
2901 TBool globalMode = EFalse; |
|
2902 TUint keyCode = 0; |
|
2903 TInt keyScanCode = 0; |
|
2904 TUint keyModifiers = 0; |
|
2905 TInt keyRepeats = 0; |
|
2906 |
|
2907 TPtrC parameter; |
|
2908 |
|
2909 CUiEnvProxy* uiEnvProxy = iTestScripter->TestModuleIf().GetUiEnvProxy(); |
|
2910 |
|
2911 while( aItem->GetNextString( parameter ) == KErrNone ) |
|
2912 { |
|
2913 if ( parameter.Find( KKeyCodeParameter ) == 0 ) |
|
2914 { |
|
2915 TPtrC parameterValue = parameter.Right( parameter.Length() - KKeyCodeParameter().Length() ); |
|
2916 TLex parameterValueParser( parameterValue ); |
|
2917 if ( parameterValueParser.Val( keyCode ) != KErrNone ) |
|
2918 { |
|
2919 if ( uiEnvProxy->ParseKeyCode( parameterValue, keyCode ) != KErrNone ) |
|
2920 { |
|
2921 __TRACE( KError, (_L("SendKeyEvent: Invalid parameter value"))); |
|
2922 TBuf<128> errMsg; |
|
2923 errMsg.Format( KErrMsgSendKeyEventInvalidParameterValue, &KKeyCodeParameter() ); |
|
2924 iRunErrorMessage = errMsg; |
|
2925 User::Leave( KErrArgument ); |
|
2926 } |
|
2927 } |
|
2928 } |
|
2929 else if ( parameter.Find( KKeyScanCodeParameter ) == 0 ) |
|
2930 { |
|
2931 TPtrC parameterValue = parameter.Right( parameter.Length() - KKeyScanCodeParameter().Length() ); |
|
2932 TLex parameterValueParser( parameterValue ); |
|
2933 if ( parameterValueParser.Val( keyScanCode ) != KErrNone ) |
|
2934 { |
|
2935 if ( uiEnvProxy->ParseKeyScanCode( parameterValue, keyScanCode ) != KErrNone ) |
|
2936 { |
|
2937 __TRACE( KError, (_L("SendKeyEvent: Invalid parameter value"))); |
|
2938 TBuf<128> errMsg; |
|
2939 errMsg.Format( KErrMsgSendKeyEventInvalidParameterValue, &KKeyCodeParameter() ); |
|
2940 iRunErrorMessage = errMsg; |
|
2941 User::Leave( KErrArgument ); |
|
2942 } |
|
2943 } |
|
2944 } |
|
2945 else if ( parameter.Find( KModifierParameter ) == 0 ) |
|
2946 { |
|
2947 TPtrC parameterValue = parameter.Right( parameter.Length() - KModifierParameter().Length() ); |
|
2948 TLex parameterValueParser( parameterValue ); |
|
2949 if ( parameterValueParser.Val( keyModifiers ) != KErrNone ) |
|
2950 { |
|
2951 if ( uiEnvProxy->ParseModifier( parameterValue, keyModifiers ) != KErrNone ) |
|
2952 { |
|
2953 __TRACE( KError, (_L("SendKeyEvent: Invalid parameter value"))); |
|
2954 TBuf<128> errMsg; |
|
2955 errMsg.Format( KErrMsgSendKeyEventInvalidParameterValue, &KModifierParameter() ); |
|
2956 iRunErrorMessage = errMsg; |
|
2957 User::Leave( KErrArgument ); |
|
2958 } |
|
2959 } |
|
2960 } |
|
2961 else if ( parameter.Find( KRepeatsParameter ) == 0 ) |
|
2962 { |
|
2963 TPtrC parameterValue = parameter.Right( parameter.Length() - KRepeatsParameter().Length() ); |
|
2964 TLex parameterValueParser( parameterValue ); |
|
2965 if ( parameterValueParser.Val( keyRepeats ) != KErrNone ) |
|
2966 { |
|
2967 __TRACE( KError, (_L("SendKeyEvent: Invalid parameter value"))); |
|
2968 TBuf<128> errMsg; |
|
2969 errMsg.Format( KErrMsgSendKeyEventInvalidParameterValue, &KRepeatsParameter() ); |
|
2970 iRunErrorMessage = errMsg; |
|
2971 User::Leave( KErrArgument ); |
|
2972 } |
|
2973 } |
|
2974 else if ( parameter == KModeGlobal ) |
|
2975 { |
|
2976 globalMode = ETrue; |
|
2977 } |
|
2978 else if ( parameter == KModeLocal ) |
|
2979 { |
|
2980 globalMode = EFalse; |
|
2981 } |
|
2982 else if ( uiEnvProxy->ParseKeyCode( parameter, keyCode ) == KErrNone ) |
|
2983 { |
|
2984 } |
|
2985 else if ( parameter.Length() == 1 ) |
|
2986 { |
|
2987 keyCode = parameter[ 0 ]; |
|
2988 } |
|
2989 else |
|
2990 { |
|
2991 __TRACE( KError, (_L("PressKey: Invalid parameter"))); |
|
2992 TBuf<128> errMsg; |
|
2993 errMsg.Format( KErrMsgSendKeyEventInvalidParameter, ¶meter ); |
|
2994 iRunErrorMessage = errMsg; |
|
2995 User::Leave( KErrArgument ); |
|
2996 } |
|
2997 } |
|
2998 |
|
2999 if ( globalMode ) |
|
3000 { |
|
3001 uiEnvProxy->PressKeyL( keyCode, keyScanCode, keyModifiers, keyRepeats ); |
|
3002 } |
|
3003 else |
|
3004 { |
|
3005 uiEnvProxy->PressKeyL( &iStatus, keyCode, keyScanCode, keyModifiers, keyRepeats ); |
|
3006 } |
|
3007 |
|
3008 return globalMode; |
|
3009 } |
|
3010 |
|
3011 /* |
|
3012 ------------------------------------------------------------------------------- |
|
3013 |
|
3014 Class: CTestRunner |
|
3015 |
|
3016 Method: TypeTextL |
|
3017 |
|
3018 Description: Sends text to AppUi |
|
3019 |
|
3020 Parameters: CStifItemParser* aItem: in: script line |
|
3021 |
|
3022 Return Values: None |
|
3023 |
|
3024 Errors/Exceptions: Leaves on error situations. |
|
3025 |
|
3026 Status: Draft |
|
3027 |
|
3028 ------------------------------------------------------------------------------- |
|
3029 */ |
|
3030 TBool CTestRunner::TypeTextL( CStifItemParser* aItem ) |
|
3031 { |
|
3032 _LIT( KErrMsgTypeTextInvalidParameter, "TypeText: Invalid parameter %S" ); |
|
3033 _LIT( KErrMsgTypeTextNotEnoughParameters, "TypeText: Not enough parameters" ); |
|
3034 |
|
3035 TBool globalMode = EFalse; |
|
3036 |
|
3037 TPtrC command; |
|
3038 TPtrC text; |
|
3039 aItem->SetParsingType( CStifItemParser::EQuoteStyleParsing ); |
|
3040 |
|
3041 // Read first parameter |
|
3042 TInt ret = aItem->GetNextString( command ); |
|
3043 |
|
3044 if ( ret != KErrNone ) |
|
3045 { |
|
3046 __TRACE( KError, (_L("TypeText: Not enough parameters"))); |
|
3047 iRunErrorMessage = KErrMsgTypeTextNotEnoughParameters; |
|
3048 User::Leave( ret ); |
|
3049 } |
|
3050 |
|
3051 // Read second parameter |
|
3052 ret = aItem->GetNextString( text ); |
|
3053 |
|
3054 // Check if second can be read. if yes then check if first parameters is |
|
3055 // 'global' parameter |
|
3056 if ( ret != KErrNone ) |
|
3057 { |
|
3058 // normal type text |
|
3059 text.Set( command ); |
|
3060 iTestScripter->TestModuleIf().GetUiEnvProxy()->TypeTextL( &iStatus, text ); |
|
3061 globalMode = EFalse; |
|
3062 } |
|
3063 else if ( command == _L("global") ) |
|
3064 { |
|
3065 iTestScripter->TestModuleIf().GetUiEnvProxy()->TypeTextL( text ); |
|
3066 globalMode = ETrue; |
|
3067 } |
|
3068 else |
|
3069 { |
|
3070 __TRACE( KError, (_L("TypeText: Invalid parameter"))); |
|
3071 TBuf<128> errMsg; |
|
3072 errMsg.Format( KErrMsgTypeTextInvalidParameter, &command ); |
|
3073 iRunErrorMessage = errMsg; |
|
3074 User::Leave( KErrNotSupported ); |
|
3075 } |
|
3076 |
|
3077 return globalMode; |
|
3078 } |
|
3079 |
|
3080 /* |
|
3081 ------------------------------------------------------------------------------- |
|
3082 |
|
3083 Class: CTestRunner |
|
3084 |
|
3085 Method: SendPointerEventL |
|
3086 |
|
3087 Description: Send key press event to AppUi |
|
3088 |
|
3089 Parameters: CStifItemParser* aItem: in: script line |
|
3090 |
|
3091 Return Values: None |
|
3092 |
|
3093 Errors/Exceptions: Leaves on error situations. |
|
3094 |
|
3095 Status: Draft |
|
3096 |
|
3097 ------------------------------------------------------------------------------- |
|
3098 */ |
|
3099 TBool CTestRunner::SendPointerEventL( CStifItemParser* aItem ) |
|
3100 { |
|
3101 // Error messages |
|
3102 _LIT( KErrMsgNotEnoughParameters, "SendPointerEvent: Not enough parameters" ); |
|
3103 _LIT( KErrMsgPointerEventTypeNotDefined, "SendPointerEvent: Pointer event type not defined" ); |
|
3104 _LIT( KErrMsgInvalidUnknownPointerEventType, "SendPointerEvent: Invalid/Unknown pointer event type %S" ); |
|
3105 _LIT( KErrMsgPositionXNotDefined, "SendPointerEvent: x co-ordinate is not defined" ); |
|
3106 _LIT( KErrMsgPositionYNotDefined, "SendPointerEvent: y co-ordinate is not defined" ); |
|
3107 _LIT( KErrMsgPositionXInvalidValue, "SendPointerEvent: Invalid value of x co-ordinate" ); |
|
3108 _LIT( KErrMsgPositionYInvalidValue, "SendPointerEvent: Invalid value of y co-ordinate" ); |
|
3109 |
|
3110 // Parameters keywords |
|
3111 _LIT( KModeGlobal, "global" ); |
|
3112 _LIT( KModeLocal, "local" ); |
|
3113 |
|
3114 TBool globalMode = EFalse; |
|
3115 TUint eventType = 0; |
|
3116 TPoint position( 0, 0 ); |
|
3117 TPoint parentPosition( 0, 0 ); |
|
3118 |
|
3119 TPtrC parameter; |
|
3120 |
|
3121 CUiEnvProxy* uiEnvProxy = iTestScripter->TestModuleIf().GetUiEnvProxy(); |
|
3122 |
|
3123 // Get first parameter |
|
3124 if ( aItem->GetNextString( parameter ) != KErrNone ) |
|
3125 { |
|
3126 __TRACE( KError, (_L("SendPointerEvent: Not enough parameters"))); |
|
3127 iRunErrorMessage = KErrMsgNotEnoughParameters; |
|
3128 User::Leave( KErrArgument ); |
|
3129 } |
|
3130 else |
|
3131 { |
|
3132 TBool modeSelected = EFalse; |
|
3133 // Check if global/local mode is defined |
|
3134 if ( parameter == KModeLocal ) |
|
3135 { |
|
3136 globalMode = false; |
|
3137 modeSelected = ETrue; |
|
3138 } |
|
3139 else if ( parameter == KModeGlobal ) |
|
3140 { |
|
3141 globalMode = true; |
|
3142 modeSelected = ETrue; |
|
3143 } |
|
3144 |
|
3145 if ( modeSelected ) |
|
3146 { |
|
3147 // First parameter was mode so we need get next parameter which should |
|
3148 // contain event type |
|
3149 if ( aItem->GetNextString( parameter ) != KErrNone ) |
|
3150 { |
|
3151 __TRACE( KError, (_L("SendPointerEvent: Pointer event type not defined"))); |
|
3152 iRunErrorMessage = KErrMsgPointerEventTypeNotDefined; |
|
3153 User::Leave( KErrArgument ); |
|
3154 } |
|
3155 } |
|
3156 } |
|
3157 |
|
3158 // Parse event type |
|
3159 if ( uiEnvProxy->ParsePointerEventType( parameter, eventType ) != KErrNone ) |
|
3160 { |
|
3161 __TRACE( KError, (_L("PressKey: Invalid/Unknown pointer event type %S"), ¶meter )); |
|
3162 iRunErrorMessage.Format( KErrMsgInvalidUnknownPointerEventType, ¶meter ); |
|
3163 User::Leave( KErrArgument ); |
|
3164 } |
|
3165 |
|
3166 if ( aItem->GetNextString( parameter ) != KErrNone ) |
|
3167 { |
|
3168 __TRACE( KError, (_L("SendPointerEvent: x co-ordinate is not defined"))); |
|
3169 iRunErrorMessage = KErrMsgPositionXNotDefined; |
|
3170 User::Leave( KErrArgument ); |
|
3171 } |
|
3172 |
|
3173 TLex parameterParser( parameter ); |
|
3174 if ( parameterParser.Val( position.iX ) != KErrNone ) |
|
3175 { |
|
3176 __TRACE( KError, (_L("SendPointerEvent: Invalid value of x co-ordinate"))); |
|
3177 iRunErrorMessage = KErrMsgPositionXInvalidValue; |
|
3178 User::Leave( KErrArgument ); |
|
3179 } |
|
3180 |
|
3181 if ( aItem->GetNextString( parameter ) != KErrNone ) |
|
3182 { |
|
3183 __TRACE( KError, (_L("SendPointerEvent: y co-ordinate is not defined"))); |
|
3184 iRunErrorMessage = KErrMsgPositionYNotDefined; |
|
3185 User::Leave( KErrArgument ); |
|
3186 } |
|
3187 |
|
3188 parameterParser.Assign( parameter ); |
|
3189 if ( parameterParser.Val( position.iY ) != KErrNone ) |
|
3190 { |
|
3191 __TRACE( KError, (_L("SendPointerEvent: Invalid value of y co-ordinate"))); |
|
3192 iRunErrorMessage = KErrMsgPositionYInvalidValue; |
|
3193 User::Leave( KErrArgument ); |
|
3194 } |
|
3195 |
|
3196 // Send pointer event |
|
3197 if ( globalMode ) |
|
3198 { |
|
3199 uiEnvProxy->SendPointerEventL( eventType, position ); |
|
3200 } |
|
3201 else |
|
3202 { |
|
3203 uiEnvProxy->SendPointerEventL( &iStatus, eventType, position ); |
|
3204 } |
|
3205 |
|
3206 return globalMode; |
|
3207 } |
|
3208 |
|
3209 |
|
3210 /* |
|
3211 ------------------------------------------------------------------------------- |
|
3212 |
|
3213 Class: CTestRunner |
|
3214 |
|
3215 Method: ExecuteEventL |
|
3216 |
|
3217 Description: Executes event command script line |
|
3218 |
|
3219 Parameters: TDesC& aKeyword: in: keyword string |
|
3220 CStifItemParser* aItem: in: script line |
|
3221 |
|
3222 Return Values: ETrue: continue script file execution |
|
3223 EFalse: stop script file execution |
|
3224 |
|
3225 Errors/Exceptions: Leaves on error situations. |
|
3226 |
|
3227 Status: Draft |
|
3228 |
|
3229 ------------------------------------------------------------------------------- |
|
3230 */ |
|
3231 TBool CTestRunner::ExecuteEventL( TDesC& aKeyword, |
|
3232 CStifItemParser* aItem ) |
|
3233 { |
|
3234 _LIT( KErrMsgEventNameNotDefined, "%S : Event name not defined" ); |
|
3235 _LIT( KErrMsgUnknowKeyword, "Unknow keyword %S" ); |
|
3236 |
|
3237 TInt ret = KErrNone; |
|
3238 TInt key = TTestKeywords::Parse( aKeyword, TTestKeywords::Keyword ); |
|
3239 TBool continueTask = ETrue; |
|
3240 |
|
3241 TPtrC eventName; |
|
3242 // read eventname |
|
3243 ret = aItem->GetNextString( eventName ); |
|
3244 if ( ret != KErrNone ) |
|
3245 { |
|
3246 iRunErrorMessage.Format( KErrMsgEventNameNotDefined, &aKeyword ); |
|
3247 User::Leave( ret ); |
|
3248 } |
|
3249 |
|
3250 TEventIf event; |
|
3251 event.SetName( eventName ); |
|
3252 |
|
3253 __TRACE( KMessage, (_L("%S %S"), &aKeyword, &eventName)); |
|
3254 iTestScripter->TestModuleIf().Printf( KPrintPriLow, _L("Event"), |
|
3255 _L("%S %S"), &aKeyword, &eventName); |
|
3256 |
|
3257 switch( key ) |
|
3258 { |
|
3259 case TTestKeywords::ERequest: |
|
3260 { |
|
3261 HBufC* eName = eventName.AllocLC(); |
|
3262 User::LeaveIfError( iEventArray.Append( eName ) ); |
|
3263 CleanupStack::Pop( eName ); |
|
3264 event.SetType( TEventIf::EReqEvent ); |
|
3265 ret = iTestScripter->TestModuleIf().Event( event ); |
|
3266 } |
|
3267 break; |
|
3268 case TTestKeywords::EWait: |
|
3269 { |
|
3270 event.SetType( TEventIf::EWaitEvent ); |
|
3271 iTestScripter->TestModuleIf().Event( event, iStatus ); |
|
3272 SetActive(); |
|
3273 continueTask = EFalse; |
|
3274 } |
|
3275 break; |
|
3276 case TTestKeywords::ERelease: |
|
3277 { |
|
3278 event.SetType( TEventIf::ERelEvent ); |
|
3279 ret = iTestScripter->TestModuleIf().Event( event ); |
|
3280 if( ret == KErrNone ) |
|
3281 { |
|
3282 TPtrC eName; |
|
3283 TInt count = iEventArray.Count(); |
|
3284 for( TInt i = 0; i < count; i++ ) |
|
3285 { |
|
3286 eName.Set( iEventArray[i]->Des() ); |
|
3287 if( eName == eventName ) |
|
3288 { |
|
3289 HBufC* tmp = iEventArray[i]; |
|
3290 iEventArray.Remove(i); |
|
3291 delete tmp; |
|
3292 break; |
|
3293 } |
|
3294 } |
|
3295 } |
|
3296 } |
|
3297 break; |
|
3298 case TTestKeywords::ESet: |
|
3299 { |
|
3300 event.SetType( TEventIf::ESetEvent ); |
|
3301 |
|
3302 TPtrC tmp; |
|
3303 // Get optional set argument |
|
3304 if( aItem->GetNextString( tmp ) == KErrNone ) |
|
3305 { |
|
3306 // Parse optional set argument |
|
3307 if( tmp == _L("state") ) |
|
3308 { |
|
3309 __TRACE( KMessage, (_L("State event"))); |
|
3310 event.SetEventType( TEventIf::EState ); |
|
3311 } |
|
3312 else |
|
3313 { |
|
3314 __TRACE( KError, |
|
3315 (_L("Unknown argument for set %S"), |
|
3316 &tmp)); |
|
3317 } |
|
3318 } |
|
3319 |
|
3320 ret = iTestScripter->TestModuleIf().Event( event ); |
|
3321 } |
|
3322 break; |
|
3323 case TTestKeywords::EUnset: |
|
3324 { |
|
3325 event.SetType( TEventIf::EUnsetEvent ); |
|
3326 event.SetEventType( TEventIf::EState ); |
|
3327 ret = iTestScripter->TestModuleIf().Event( event ); |
|
3328 } |
|
3329 break; |
|
3330 default: |
|
3331 __TRACE( KError, (_L("Unknown keyword %S"), &aKeyword)); |
|
3332 iRunErrorMessage.Format( KErrMsgUnknowKeyword, &aKeyword ); |
|
3333 User::Leave( KErrGeneral ); |
|
3334 break; |
|
3335 } |
|
3336 if( ret != KErrNone ) |
|
3337 { |
|
3338 TName resultDescr; |
|
3339 resultDescr.Format(_L("Event %S returned error: %d"), &aKeyword, ret); |
|
3340 iTestScripter->UpdateTestCaseResult(ret, resultDescr); |
|
3341 // Stops execution from CTestRunner::RunError |
|
3342 User::Leave( KErrGeneral ); |
|
3343 } |
|
3344 |
|
3345 return continueTask; |
|
3346 |
|
3347 } |
|
3348 |
|
3349 /* |
|
3350 ------------------------------------------------------------------------------- |
|
3351 |
|
3352 Class: CTestRunner |
|
3353 |
|
3354 Method: ExecuteCommandL |
|
3355 |
|
3356 Description: Executes script line |
|
3357 |
|
3358 Parameters: TDesC& aObject: in: object name |
|
3359 CStifItemParser* aItem: in: script line |
|
3360 |
|
3361 Return Values: ETrue: continue script file execution |
|
3362 EFalse: stop script file execution |
|
3363 |
|
3364 Errors/Exceptions: Leaves on error situations. |
|
3365 |
|
3366 Status: Proposal |
|
3367 |
|
3368 ------------------------------------------------------------------------------- |
|
3369 */ |
|
3370 TBool CTestRunner::ExecuteCommandL( TDesC& aObject, CStifItemParser* aItem) |
|
3371 { |
|
3372 _LIT( KErrMsgUnknownObjOrKeyword, "Unknow keyword/object %S" ); |
|
3373 |
|
3374 TTestObjectBase* obj = iTestScripter->GetObject ( aObject ); |
|
3375 if( obj == NULL ) |
|
3376 { |
|
3377 iRunErrorMessage.Format( KErrMsgUnknownObjOrKeyword, &aObject ); |
|
3378 User::Leave( KErrGeneral ); |
|
3379 } |
|
3380 |
|
3381 if( iTestCaseResults.Count() == 0 ) |
|
3382 { |
|
3383 // KErrNone is the default result expected if nothing else is given |
|
3384 User::LeaveIfError( iTestCaseResults.Append( KErrNone ) ); |
|
3385 } |
|
3386 |
|
3387 // OOM heap testing with FAILNEXT |
|
3388 if( iHeapFailNext > 0 ) |
|
3389 { |
|
3390 __TRACE( KPrint, ( |
|
3391 _L( "OOM FAILNEXT is used with count value: %d " ), |
|
3392 iHeapFailNext) ); |
|
3393 User::__DbgSetAllocFail( RHeap::EUser, RHeap::EFailNext, iHeapFailNext ); |
|
3394 } |
|
3395 // OOM heap testing with SETFAIL |
|
3396 if( iHeapSetFailValue > 0 ) |
|
3397 { |
|
3398 __TRACE( KPrint, ( |
|
3399 _L("OOM SETFAIL is used with type:[%d] and value(rate):[%d]"), |
|
3400 iHeapSetFailType, iHeapSetFailValue ) ); |
|
3401 User::__DbgSetAllocFail( RHeap::EUser, iHeapSetFailType, iHeapSetFailValue ); |
|
3402 } |
|
3403 |
|
3404 TInt commandResult = KErrNone; |
|
3405 TRAP( commandResult, commandResult = obj->RunMethodL( *aItem ) ); |
|
3406 |
|
3407 |
|
3408 // Reset OOM macro immediately(Otherwise other allocations |
|
3409 // will be blocked) |
|
3410 User::__DbgSetAllocFail( RHeap::EUser, RHeap::ENone, 1 ); |
|
3411 |
|
3412 // OOM test class's build block handling |
|
3413 if( iTestScripter->iOOMIgnoreFailure ) |
|
3414 { |
|
3415 __TRACE( KPrint, ( |
|
3416 _L( "----------< OOM related test information >----------" ) ) ); |
|
3417 if( iHeapFailNext > 0 ) |
|
3418 { |
|
3419 __TRACE( KPrint, ( |
|
3420 _L( "'oomignorefailure' is:[ON] and 'failnextvalue' count is:[%d]" ), |
|
3421 iHeapFailNext ) ); |
|
3422 } |
|
3423 if( iHeapSetFailValue > 0 ) |
|
3424 { |
|
3425 __TRACE( KPrint, ( |
|
3426 _L( "'oomignorefailure' is:[ON], 'setfailtype' type is:[%d] and value is:[%d]" ), |
|
3427 iHeapSetFailType, iHeapSetFailValue ) ); |
|
3428 } |
|
3429 __TRACE( KPrint, ( |
|
3430 _L( "Test class build block execution with result:[%d]" ), |
|
3431 commandResult ) ); |
|
3432 __TRACE( KPrint, ( |
|
3433 _L( "----------------------------------------------------" ) ) ); |
|
3434 |
|
3435 // Continue testing, despite the memory error situations |
|
3436 iTestCaseResults.Reset(); |
|
3437 return ETrue; // Continue script executions |
|
3438 } |
|
3439 |
|
3440 // Normal test class's build block handling |
|
3441 if( iTestCaseResults.Find( commandResult ) < 0 ) |
|
3442 { |
|
3443 __TRACE( KError, ( _L("Command for [%S] failed (%d)"), |
|
3444 &aObject, commandResult )); |
|
3445 |
|
3446 // Added more logging for this special case |
|
3447 if( commandResult == KErrNone ) |
|
3448 { |
|
3449 __TRACE( KError, (_L("Test fails with result KErrGeneral, because execution result was KErrNone and expected results given with 'allownextresult' were Symbian's error codes (<0)"))); |
|
3450 } |
|
3451 |
|
3452 iTestScripter->UpdateTestCaseResult(commandResult, _L("CTestRunner::ExecuteCommandL returned error")); |
|
3453 |
|
3454 // Stops execution from CTestRunner::RunError |
|
3455 User::Leave( KErrGeneral ); |
|
3456 } |
|
3457 |
|
3458 iTestCaseResults.Reset(); |
|
3459 // Reset test case allow result to CTestModuleIf side too. This is |
|
3460 // used in TAL-TA5L macro handling. |
|
3461 User::LeaveIfError( |
|
3462 iTestScripter->TestModuleIf().ResetAllowResult() ); |
|
3463 |
|
3464 return ETrue; |
|
3465 } |
|
3466 |
|
3467 /* |
|
3468 ------------------------------------------------------------------------------- |
|
3469 |
|
3470 Class: CTestRunner |
|
3471 |
|
3472 Method: SetRunnerActive |
|
3473 |
|
3474 Description: Set CTestRunner active and complete. |
|
3475 |
|
3476 Parameters: None. |
|
3477 |
|
3478 Return Values: None. |
|
3479 |
|
3480 Errors/Exceptions: None. |
|
3481 |
|
3482 Status: Draft |
|
3483 |
|
3484 ------------------------------------------------------------------------------- |
|
3485 */ |
|
3486 void CTestRunner::SetRunnerActive() |
|
3487 { |
|
3488 __TRACEFUNC(); |
|
3489 // Update state |
|
3490 iState = ERunnerRunning; |
|
3491 |
|
3492 iStatus = KRequestPending; |
|
3493 TRequestStatus* rs = &iStatus; |
|
3494 SetActive(); |
|
3495 User::RequestComplete( rs, KErrNone ); |
|
3496 |
|
3497 } |
|
3498 |
|
3499 /* |
|
3500 ------------------------------------------------------------------------------- |
|
3501 |
|
3502 Class: CTestRunner |
|
3503 |
|
3504 Method: OOMIgnoreFailure |
|
3505 |
|
3506 Description: Handles 'oomignorefailure' keyword parsing. |
|
3507 |
|
3508 Parameters: CStifItemParser* aItem: in: Item object for parsing. |
|
3509 |
|
3510 Return Values: None. |
|
3511 |
|
3512 Errors/Exceptions: None. |
|
3513 |
|
3514 Status: Proposal |
|
3515 |
|
3516 ------------------------------------------------------------------------------- |
|
3517 */ |
|
3518 void CTestRunner::OOMIgnoreFailureL( CStifItemParser* aItem ) |
|
3519 { |
|
3520 _LIT( KerrMsgOOMIgnoreFailureUnknownArgument, "OOMIgnoreFailure : Invalid argument %S" ); |
|
3521 _LIT( KerrMsgOOMIgnoreFailureNoArgument, "OOMIgnoreFailure : Parameter not defined" ); |
|
3522 |
|
3523 __TRACEFUNC(); |
|
3524 |
|
3525 TPtrC tmp; |
|
3526 // Get result |
|
3527 if( aItem->GetNextString( tmp ) == KErrNone ) |
|
3528 { |
|
3529 if( tmp == _L("ON") || tmp == _L("on") ) |
|
3530 { |
|
3531 __TRACE( KMessage, (_L("OOM related 'oomignorefailure': ON"))); |
|
3532 iTestScripter->iOOMIgnoreFailure = ETrue; |
|
3533 } |
|
3534 else if( tmp == _L("OFF") || tmp == _L("off") ) |
|
3535 { |
|
3536 __TRACE( KMessage, (_L("OOM related 'oomignorefailure': OFF"))); |
|
3537 iTestScripter->iOOMIgnoreFailure = EFalse; |
|
3538 } |
|
3539 else |
|
3540 { |
|
3541 __TRACE( KError, |
|
3542 (_L("Unknown argument for 'oomignorefailure': [%S]"), |
|
3543 &tmp)); |
|
3544 iRunErrorMessage.Format( KerrMsgOOMIgnoreFailureUnknownArgument, &tmp ); |
|
3545 User::Leave( KErrArgument ); |
|
3546 } |
|
3547 } |
|
3548 else |
|
3549 { |
|
3550 __TRACE( KError, ( _L( "Unknown argument for 'oomignorefailure'" ) ) ); |
|
3551 iRunErrorMessage = KerrMsgOOMIgnoreFailureNoArgument; |
|
3552 User::Leave( KErrArgument ); |
|
3553 } |
|
3554 } |
|
3555 |
|
3556 /* |
|
3557 ------------------------------------------------------------------------------- |
|
3558 |
|
3559 Class: CTestRunner |
|
3560 |
|
3561 Method: OOMHeapFailNext |
|
3562 |
|
3563 Description: Handles 'oomheapfailnext' keyword parsing. |
|
3564 |
|
3565 Parameters: CStifItemParser* aItem: in: Item object for parsing. |
|
3566 |
|
3567 Return Values: None. |
|
3568 |
|
3569 Errors/Exceptions: None. |
|
3570 |
|
3571 Status: Proposal |
|
3572 |
|
3573 ------------------------------------------------------------------------------- |
|
3574 */ |
|
3575 void CTestRunner::OOMHeapFailNextL( CStifItemParser* aItem ) |
|
3576 { |
|
3577 _LIT( KErrMsgHeapFailNextNoArgument, "HeapFailNext : Parameters is not defined or has invalid value" ); |
|
3578 _LIT( KErrMsgHeapFailNextInvalidValue, "HeapFailNext : Argument value can't be <0" ); |
|
3579 __TRACEFUNC(); |
|
3580 |
|
3581 TInt heapfailNext( 0 ); |
|
3582 // If LOOP_COUNTER is used the GetNextInt returns a correct |
|
3583 // value(Because of the LOOP_COUNTER implementation). |
|
3584 if( aItem->GetNextInt( heapfailNext ) == KErrNone ) |
|
3585 { |
|
3586 if( heapfailNext < 0 ) |
|
3587 { |
|
3588 __TRACE( KError, ( _L( "Argument value must be >0" ) ) ); |
|
3589 iRunErrorMessage = KErrMsgHeapFailNextInvalidValue; |
|
3590 User::Leave( KErrArgument ); |
|
3591 } |
|
3592 // OOM heap's FAILNEXT range is from 1 to n |
|
3593 iHeapFailNext = heapfailNext + 1; |
|
3594 __TRACE( KMessage, ( _L( "'oomheapfailnext' count value(rate): %d" ), |
|
3595 iHeapFailNext ) ); |
|
3596 } |
|
3597 else |
|
3598 { |
|
3599 __TRACE( KError, ( _L( "Unknown argument for 'oomheapfailnext'" ) ) ); |
|
3600 iRunErrorMessage = KErrMsgHeapFailNextNoArgument; |
|
3601 User::Leave( KErrArgument ); |
|
3602 } |
|
3603 } |
|
3604 |
|
3605 /* |
|
3606 ------------------------------------------------------------------------------- |
|
3607 |
|
3608 Class: CTestRunner |
|
3609 |
|
3610 Method: OOMHeapSetFail |
|
3611 |
|
3612 Description: Handles 'oomheapsetfail' keyword parsing. |
|
3613 |
|
3614 Parameters: CStifItemParser* aItem: in: Item object for parsing. |
|
3615 |
|
3616 Return Values: None. |
|
3617 |
|
3618 Errors/Exceptions: None. |
|
3619 |
|
3620 Status: Proposal |
|
3621 |
|
3622 ------------------------------------------------------------------------------- |
|
3623 */ |
|
3624 void CTestRunner::OOMHeapSetFailL( CStifItemParser* aItem ) |
|
3625 { |
|
3626 _LIT( KErrMsgOOMHeapSetFailTypeNotDefined, "OOMHeapSetFail : Parameter type is not defined" ); |
|
3627 _LIT( KErrMsgOOMHeapSetFailRateNotDefined, "OOMHeapSetFail : Parameter rate is not defined" ); |
|
3628 _LIT( KErrMsgOOMHeapSetFailTypeInvalidValue, "OOMHeapSetFail : Parameter type has invalid value" ); |
|
3629 _LIT( KErrMsgOOMHeapSetFailRateInvalidValue, "OOMHeapSetFail : Parameter rate can't be <0" ); |
|
3630 __TRACEFUNC(); |
|
3631 |
|
3632 TPtrC type; |
|
3633 TInt value( 0 ); |
|
3634 |
|
3635 // NOTE: If error in type or value parsing => return without changing |
|
3636 // iHeapSetFailType or iHeapSetFailValue valiables. |
|
3637 |
|
3638 // Get type |
|
3639 if( aItem->GetNextString( type ) != KErrNone ) |
|
3640 { |
|
3641 __TRACE( KError, ( |
|
3642 _L( "Unknown argument for 'oomheapsetfail' type" ) ) ); |
|
3643 iRunErrorMessage = KErrMsgOOMHeapSetFailTypeNotDefined; |
|
3644 User::Leave( KErrArgument ); |
|
3645 } |
|
3646 // Get value(rate) |
|
3647 if( aItem->GetNextInt( value ) != KErrNone ) |
|
3648 { |
|
3649 __TRACE( KError, ( |
|
3650 _L( "Unknown argument for 'oomheapsetfail' value(rate)" ) ) ); |
|
3651 iRunErrorMessage = KErrMsgOOMHeapSetFailRateNotDefined; |
|
3652 User::Leave( KErrArgument ); |
|
3653 } |
|
3654 |
|
3655 // All parsing operations are passed, get type and value |
|
3656 |
|
3657 // Get type |
|
3658 if( type == _L("random") ) |
|
3659 { |
|
3660 __TRACE( KMessage, (_L("'oomheapsetfail' type: random"))); |
|
3661 iHeapSetFailType = RHeap::ERandom; |
|
3662 } |
|
3663 else if( type == _L("truerandom") ) |
|
3664 { |
|
3665 __TRACE( KMessage, (_L("'oomheapsetfail' type: truerandom"))); |
|
3666 iHeapSetFailType = RHeap::ETrueRandom; |
|
3667 } |
|
3668 else if( type == _L("deterministic") ) |
|
3669 { |
|
3670 __TRACE( KMessage, (_L("'oomheapsetfail' type: deterministic"))); |
|
3671 iHeapSetFailType = RHeap::EDeterministic; |
|
3672 } |
|
3673 else if( type == _L("none") ) |
|
3674 { |
|
3675 __TRACE( KMessage, (_L("'oomheapsetfail' type: none"))); |
|
3676 iHeapSetFailType = RHeap::ENone; |
|
3677 } |
|
3678 else if( type == _L("failnext") ) |
|
3679 { |
|
3680 __TRACE( KMessage, (_L("'oomheapsetfail' type: failnext"))); |
|
3681 iHeapSetFailType = RHeap::EFailNext; |
|
3682 } |
|
3683 else |
|
3684 { |
|
3685 __TRACE( KError, |
|
3686 ( _L( "Unknown argument for 'oomheapsetfail' type: [%S]" ), |
|
3687 &type ) ); |
|
3688 iRunErrorMessage = KErrMsgOOMHeapSetFailTypeInvalidValue; |
|
3689 User::Leave( KErrArgument ); |
|
3690 } |
|
3691 |
|
3692 if( value < 0 ) |
|
3693 { |
|
3694 __TRACE( KError, _L( "'oomheapsetfail' value(rate) can't be <0" ) ); |
|
3695 iRunErrorMessage = KErrMsgOOMHeapSetFailRateInvalidValue; |
|
3696 User::Leave( KErrArgument ); |
|
3697 } |
|
3698 // Get value |
|
3699 // OOM heap's SETFAIL range is from 1 to n |
|
3700 iHeapSetFailValue = value + 1; |
|
3701 __TRACE( KMessage, ( |
|
3702 _L( "'oomheapsetfail' value(rate): %d" ), iHeapSetFailValue ) ); |
|
3703 |
|
3704 } |
|
3705 |
|
3706 /* |
|
3707 ------------------------------------------------------------------------------- |
|
3708 |
|
3709 Class: CTestRunner |
|
3710 |
|
3711 Method: OOMHeapToNormal |
|
3712 |
|
3713 Description: Initialize all OOM related variables. |
|
3714 |
|
3715 Parameters: None. |
|
3716 |
|
3717 Return Values: None. |
|
3718 |
|
3719 Errors/Exceptions: None. |
|
3720 |
|
3721 Status: Proposal |
|
3722 |
|
3723 ------------------------------------------------------------------------------- |
|
3724 */ |
|
3725 void CTestRunner::OOMHeapToNormal() |
|
3726 { |
|
3727 __TRACEFUNC(); |
|
3728 |
|
3729 if( iTestScripter ) |
|
3730 { |
|
3731 // This should initialize also |
|
3732 iTestScripter->iOOMIgnoreFailure = EFalse; |
|
3733 } |
|
3734 |
|
3735 iHeapFailNext = 0; |
|
3736 iHeapSetFailType = RHeap::ENone; |
|
3737 iHeapSetFailValue = 0; |
|
3738 |
|
3739 } |
|
3740 |
|
3741 /* |
|
3742 ------------------------------------------------------------------------------- |
|
3743 |
|
3744 Class: CTestRunner |
|
3745 |
|
3746 Method: TestInterference |
|
3747 |
|
3748 Description: Starts test interference. |
|
3749 |
|
3750 Parameters: CStifItemParser* aItem: in: Item object for parsing. |
|
3751 |
|
3752 Return Values: None. |
|
3753 |
|
3754 Errors/Exceptions: None. |
|
3755 |
|
3756 Status: Approved |
|
3757 |
|
3758 ------------------------------------------------------------------------------- |
|
3759 */ |
|
3760 void CTestRunner::TestInterferenceL( CStifItemParser* aItem ) |
|
3761 { |
|
3762 _LIT( KErrMsgTestInterferenceNameNotDefined, "TestInterference : Parameter name is not defined" ); |
|
3763 _LIT( KErrMsgTestInterferenceCommandNotDefined, "TestInterference : Parameter command is not defined" ); |
|
3764 _LIT( KErrMsgTestInterferenceCommandInvalidValue, "TestInterference : Parameter command has invalid value" ); |
|
3765 __TRACEFUNC(); |
|
3766 TPtrC name; |
|
3767 TPtrC command; |
|
3768 |
|
3769 // Get name |
|
3770 if( aItem->GetNextString( name ) != KErrNone ) |
|
3771 { |
|
3772 __TRACE( KError, ( |
|
3773 _L( "Unknown argument for 'testinterference' name" ) ) ); |
|
3774 iRunErrorMessage = KErrMsgTestInterferenceNameNotDefined; |
|
3775 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
3776 } |
|
3777 // Get command |
|
3778 if( aItem->GetNextString( command ) != KErrNone ) |
|
3779 { |
|
3780 __TRACE( KError, ( |
|
3781 _L( "Unknown argument for 'testinterference' command" ) ) ); |
|
3782 iRunErrorMessage = KErrMsgTestInterferenceCommandNotDefined; |
|
3783 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
3784 } |
|
3785 |
|
3786 if( command == _L( "start" ) ) |
|
3787 { |
|
3788 __TRACE( KMessage, ( _L( "'testinterference' called, starts test interference") ) ); |
|
3789 StartInterferenceL( name, aItem ); |
|
3790 } |
|
3791 else if( command == _L( "stop" ) ) |
|
3792 { |
|
3793 __TRACE( KMessage, ( _L( "'testinterference' called, stops and releases test interference") ) ); |
|
3794 StopInterferenceL( name ); |
|
3795 } |
|
3796 else |
|
3797 { |
|
3798 __TRACE( KError, ( |
|
3799 _L( "Unknown command for 'testinterference'[%S]" ), &command ) ); |
|
3800 iRunErrorMessage = KErrMsgTestInterferenceCommandInvalidValue; |
|
3801 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
3802 } |
|
3803 |
|
3804 } |
|
3805 |
|
3806 /* |
|
3807 ------------------------------------------------------------------------------- |
|
3808 |
|
3809 Class: CTestRunner |
|
3810 |
|
3811 Method: StartInterference |
|
3812 |
|
3813 Description: |
|
3814 |
|
3815 Parameters: CStifItemParser* aItem: in: Item object for parsing. |
|
3816 |
|
3817 Return Values: None. |
|
3818 |
|
3819 Errors/Exceptions: None. |
|
3820 |
|
3821 Status: Approved |
|
3822 |
|
3823 ------------------------------------------------------------------------------- |
|
3824 */ |
|
3825 void CTestRunner::StartInterferenceL( TDesC& aName, CStifItemParser* aItem ) |
|
3826 { |
|
3827 _LIT( KErrMsgStartInterferenceCategoryNotDefined, "TestInterference : Parameter category is not defined" ); |
|
3828 _LIT( KErrMsgStartInterferenceCategoryInvalidValue, "TestInterference : Parameter category has invalid value" ); |
|
3829 _LIT( KErrMsgStartInterferenceTypeNotDefined, "TestInterference : Parameter type is not defined" ); |
|
3830 _LIT( KErrMsgStartInterferenceTypeInvalidValue, "TestInterference : Parameter type has invalid value" ); |
|
3831 _LIT( KErrMsgStartInterferenceIdleNotDefined, "TestInterference : Parameter idle is not defined or has invalid value" ); |
|
3832 _LIT( KErrMsgStartInterferenceIdleInvalidValue, "TestInterference : Parameter idle has invalid value" ); |
|
3833 _LIT( KErrMsgStartInterferenceActiveNotDefined, "TestInterference : Parameter active is not defined or has invalid value" ); |
|
3834 _LIT( KErrMsgStartInterferenceActiveInvalidValue, "TestInterference : Parameter active has invalid value" ); |
|
3835 |
|
3836 __TRACEFUNC(); |
|
3837 TPtrC category; |
|
3838 TPtrC type; |
|
3839 TInt idle( 0 ); |
|
3840 TInt active( 0 ); |
|
3841 TInt priority( 0 ); |
|
3842 |
|
3843 // Get category |
|
3844 if( aItem->GetNextString( category ) != KErrNone ) |
|
3845 { |
|
3846 __TRACE( KError, ( |
|
3847 _L( "Unknown argument for 'testinterference' category" ) ) ); |
|
3848 iRunErrorMessage = KErrMsgStartInterferenceCategoryNotDefined; |
|
3849 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
3850 } |
|
3851 // Get type |
|
3852 if( aItem->GetNextString( type ) != KErrNone ) |
|
3853 { |
|
3854 __TRACE( KError, ( |
|
3855 _L( "Unknown argument for 'testinterference' type" ) ) ); |
|
3856 iRunErrorMessage = KErrMsgStartInterferenceTypeNotDefined; |
|
3857 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
3858 } |
|
3859 |
|
3860 TPtrC timeStr; |
|
3861 TReal time; |
|
3862 // Get idle time |
|
3863 if( aItem->GetNextString( timeStr ) != KErrNone ) |
|
3864 { |
|
3865 __TRACE( KError, ( |
|
3866 _L( "Unknown argument for 'testinterference' idle" ) ) ); |
|
3867 iRunErrorMessage = KErrMsgStartInterferenceIdleNotDefined; |
|
3868 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
3869 } |
|
3870 if ( TLex( timeStr ).Val( time, '.' ) != KErrNone ) |
|
3871 { |
|
3872 __TRACE( KError, ( |
|
3873 _L( "Unknown argument for 'testinterference' idle" ) ) ); |
|
3874 iRunErrorMessage = KErrMsgStartInterferenceIdleNotDefined; |
|
3875 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
3876 } |
|
3877 // Convert idle time from milli to micro seconds |
|
3878 idle = static_cast<TInt>( time * 1000.0); |
|
3879 |
|
3880 if( idle < 0 ) |
|
3881 { |
|
3882 __TRACE( KError, ( |
|
3883 _L( "Argument 'testinterference' idle can't be <0" ) ) ); |
|
3884 iRunErrorMessage = KErrMsgStartInterferenceIdleInvalidValue; |
|
3885 User::Leave( KErrArgument ); |
|
3886 } |
|
3887 // Get active time |
|
3888 if( aItem->GetNextString( timeStr ) != KErrNone ) |
|
3889 { |
|
3890 __TRACE( KError, ( |
|
3891 _L( "Unknown argument for 'testinterference' active" ) ) ); |
|
3892 iRunErrorMessage = KErrMsgStartInterferenceActiveNotDefined; |
|
3893 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
3894 } |
|
3895 if ( TLex( timeStr ).Val( time, '.' ) != KErrNone ) |
|
3896 { |
|
3897 __TRACE( KError, ( |
|
3898 _L( "Unknown argument for 'testinterference' idle" ) ) ); |
|
3899 iRunErrorMessage = KErrMsgStartInterferenceIdleNotDefined; |
|
3900 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
3901 } |
|
3902 |
|
3903 // Convert active time from milli to micro seconds |
|
3904 active = static_cast<TInt>( time * 1000.0 ); |
|
3905 |
|
3906 if( active < 0 ) |
|
3907 { |
|
3908 __TRACE( KError, ( |
|
3909 _L( "Argument 'testinterference' active can't be <0" ) ) ); |
|
3910 iRunErrorMessage = KErrMsgStartInterferenceActiveInvalidValue; |
|
3911 User::Leave( KErrArgument ); |
|
3912 } |
|
3913 |
|
3914 // Get priority |
|
3915 if( aItem->GetNextInt( priority ) != KErrNone ) |
|
3916 { |
|
3917 // Log information only do not return. Priority value is optional. |
|
3918 __TRACE( KInit, ( |
|
3919 _L( "Unknown argument for 'testinterference' priority or value not given, default priority will be used" ) ) ); |
|
3920 } |
|
3921 |
|
3922 MSTIFTestInterference* interference = NULL; |
|
3923 |
|
3924 // Get category |
|
3925 if( category == _L("activeobject") ) |
|
3926 { |
|
3927 interference = MSTIFTestInterference::NewL( iTestScripter, |
|
3928 MSTIFTestInterference::EActiveObject ); |
|
3929 } |
|
3930 else if( category == _L("thread") ) |
|
3931 { |
|
3932 interference = MSTIFTestInterference::NewL( iTestScripter, |
|
3933 MSTIFTestInterference::EThread ); |
|
3934 } |
|
3935 else |
|
3936 { |
|
3937 __TRACE( KError, ( |
|
3938 _L( "Unknown argument for 'testinterference' category[%S]" ), &category ) ); |
|
3939 iRunErrorMessage = KErrMsgStartInterferenceCategoryInvalidValue; |
|
3940 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
3941 } |
|
3942 |
|
3943 // Create object that include test interference information and append this |
|
3944 // to array. |
|
3945 TTestInterference* object = new (ELeave) TTestInterference(); |
|
3946 object->iName = aName; |
|
3947 object->iInterference = interference; |
|
3948 |
|
3949 // Array for handling test interference between different objects |
|
3950 TInt ret = iTestInterferenceArray.Append( object ); |
|
3951 if( ret != KErrNone ) |
|
3952 { |
|
3953 delete object; |
|
3954 __TRACE( KError, ( |
|
3955 _L( "CTestRunner::StartInterference: iTestInterferenceArray.Append fails:[%d]" ), ret ) ); |
|
3956 User::Leave( ret ); |
|
3957 } |
|
3958 |
|
3959 // Set priority if user given |
|
3960 if( priority != 0 ) |
|
3961 { |
|
3962 interference->SetPriority( priority ); |
|
3963 } |
|
3964 |
|
3965 // Get type |
|
3966 if( type == _L("cpuload") ) |
|
3967 { |
|
3968 interference->StartL( MSTIFTestInterference::ECpuLoadMicroSeconds, idle , active ); |
|
3969 } |
|
3970 else if( type == _L("filesystemreadc") ) |
|
3971 { |
|
3972 interference->StartL( MSTIFTestInterference::EFileSystemReadCMicroSeconds, idle , active ); |
|
3973 } |
|
3974 else if( type == _L("filesystemreadd") ) |
|
3975 { |
|
3976 interference->StartL( MSTIFTestInterference::EFileSystemReadDMicroSeconds, idle , active ); |
|
3977 } |
|
3978 else if( type == _L("filesystemreade") ) |
|
3979 { |
|
3980 interference->StartL( MSTIFTestInterference::EFileSystemReadEMicroSeconds, idle , active ); |
|
3981 } |
|
3982 else if( type == _L("filesystemreadz") ) |
|
3983 { |
|
3984 interference->StartL( MSTIFTestInterference::EFileSystemReadZMicroSeconds, idle , active ); |
|
3985 } |
|
3986 else if( type == _L("filesystemwritec") ) |
|
3987 { |
|
3988 interference->StartL( MSTIFTestInterference::EFileSystemWriteCMicroSeconds, idle , active ); |
|
3989 } |
|
3990 else if( type == _L("filesystemwrited") ) |
|
3991 { |
|
3992 interference->StartL( MSTIFTestInterference::EFileSystemWriteDMicroSeconds, idle , active ); |
|
3993 } |
|
3994 else if( type == _L("filesystemwritee") ) |
|
3995 { |
|
3996 interference->StartL( MSTIFTestInterference::EFileSystemWriteEMicroSeconds, idle , active ); |
|
3997 } |
|
3998 else if( type == _L("filesystemfillandemptyc") ) |
|
3999 { |
|
4000 interference->StartL( MSTIFTestInterference::EFileSystemFillAndEmptyCMicroSeconds, idle , active ); |
|
4001 } |
|
4002 else if( type == _L("filesystemfillandemptyd") ) |
|
4003 { |
|
4004 interference->StartL( MSTIFTestInterference::EFileSystemFillAndEmptyDMicroSeconds, idle , active ); |
|
4005 } |
|
4006 else if( type == _L("filesystemfillandemptye") ) |
|
4007 { |
|
4008 interference->StartL( MSTIFTestInterference::EFileSystemFillAndEmptyEMicroSeconds, idle , active ); |
|
4009 } |
|
4010 else |
|
4011 { |
|
4012 __TRACE( KError, ( |
|
4013 _L( "Unknown argument for 'testinterference' type[%S]" ), &type ) ); |
|
4014 iRunErrorMessage = KErrMsgStartInterferenceTypeInvalidValue; |
|
4015 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
4016 } |
|
4017 |
|
4018 } |
|
4019 |
|
4020 /* |
|
4021 ------------------------------------------------------------------------------- |
|
4022 |
|
4023 Class: CTestRunner |
|
4024 |
|
4025 Method: StopInterference |
|
4026 |
|
4027 Description: Stops test interference. |
|
4028 |
|
4029 Parameters: TDesC& aName: in: Indicates right test interference object. |
|
4030 |
|
4031 Return Values: None. |
|
4032 |
|
4033 Errors/Exceptions: None. |
|
4034 |
|
4035 Status: Approved |
|
4036 |
|
4037 ------------------------------------------------------------------------------- |
|
4038 */ |
|
4039 void CTestRunner::StopInterferenceL( TDesC& aName ) |
|
4040 { |
|
4041 _LIT( KErrMsgStopInterference, "TestInterference : testinterference %S was not start" ); |
|
4042 __TRACEFUNC(); |
|
4043 |
|
4044 TInt count = iTestInterferenceArray.Count(); |
|
4045 for( TInt i = 0; i < count; i++ ) |
|
4046 { |
|
4047 if( iTestInterferenceArray[i]->iName == aName ) |
|
4048 { |
|
4049 // Found test module, return description |
|
4050 iTestInterferenceArray[i]->iInterference->Stop(); |
|
4051 // Delete data |
|
4052 delete iTestInterferenceArray[i]; |
|
4053 // Remove pointer to deleted data(Append()) |
|
4054 iTestInterferenceArray.Remove( i ); |
|
4055 // iTestMeasurementArray can contain only one type of measurement |
|
4056 // so we can break when type is removed. |
|
4057 return; |
|
4058 } |
|
4059 } |
|
4060 __TRACE( KError, ( |
|
4061 _L( "'testinterference' type[%S] was not start" ), &aName ) ); |
|
4062 iRunErrorMessage.Format( KErrMsgStopInterference, &aName ); |
|
4063 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
4064 } |
|
4065 |
|
4066 /* |
|
4067 ------------------------------------------------------------------------------- |
|
4068 |
|
4069 Class: CTestRunner |
|
4070 |
|
4071 Method: MeasurementL |
|
4072 |
|
4073 Description: Starts test measurement. |
|
4074 |
|
4075 Parameters: CStifItemParser* aItem: in: Item object for parsing. |
|
4076 |
|
4077 Return Values: None. |
|
4078 |
|
4079 Errors/Exceptions: Leaves if StartBappeaMeasurementL() fails. |
|
4080 Leaves if StopBappeaMeasurementL() fails. |
|
4081 |
|
4082 Status: Approved |
|
4083 |
|
4084 ------------------------------------------------------------------------------- |
|
4085 */ |
|
4086 void CTestRunner::MeasurementL( CStifItemParser* aItem ) |
|
4087 { |
|
4088 _LIT( KErrMsgMeasurementCommandNotDefined, "TestMeasurement : Parameter command is not defined" ); |
|
4089 _LIT( KErrMsgMeasurementTypeNotDefined, "TestMeasurement : Parameter type is not defined" ); |
|
4090 _LIT( KErrMsgMeasurementUnknownType, "TestMeasurement : Unknown measurement type %S" ); |
|
4091 _LIT( KErrMsgMeasurementUnknownCommand, "TestMeasurement : Unknown command %S" ); |
|
4092 __TRACEFUNC(); |
|
4093 TPtrC type; |
|
4094 TPtrC command; |
|
4095 |
|
4096 // Get command |
|
4097 if( aItem->GetNextString( command ) != KErrNone ) |
|
4098 { |
|
4099 __TRACE( KError, ( |
|
4100 _L( "Unknown argument for 'measurement' command" ) ) ); |
|
4101 iRunErrorMessage = KErrMsgMeasurementCommandNotDefined; |
|
4102 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
4103 } |
|
4104 // Get name |
|
4105 if( aItem->GetNextString( type ) != KErrNone ) |
|
4106 { |
|
4107 __TRACE( KError, ( |
|
4108 _L( "Unknown argument for 'measurement' type" ) ) ); |
|
4109 iRunErrorMessage = KErrMsgMeasurementTypeNotDefined; |
|
4110 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
4111 } |
|
4112 |
|
4113 // Verify measurement type |
|
4114 if( !( type == KParamMeasurement01 || |
|
4115 type == KParamMeasurement02 || |
|
4116 type == KParamMeasurement03 || |
|
4117 type == KParamMeasurement04 || |
|
4118 type == KParamMeasurement05 || |
|
4119 type == KParamMeasurementBappea ) ) |
|
4120 |
|
4121 { |
|
4122 __TRACE( KError, ( |
|
4123 _L( "Unknown measurement type:[%S]" ), &type ) ); |
|
4124 iRunErrorMessage.Format( KErrMsgMeasurementUnknownType, &type ); |
|
4125 User::Leave( KErrArgument ); // Error in types => Leave |
|
4126 } |
|
4127 |
|
4128 // Verify command |
|
4129 if( command == _L( "start" ) ) |
|
4130 { |
|
4131 // START measurement's process |
|
4132 __TRACE( KMessage, ( _L( "Start 'measurement' with '%S'"), &type ) ); |
|
4133 StartMeasurementL( type, aItem ); |
|
4134 } |
|
4135 else if( command == _L( "stop" ) ) |
|
4136 { |
|
4137 // STOP measurement's process |
|
4138 __TRACE( KMessage, ( _L( "'Stop 'measurement' with '%S'"), &type ) ); |
|
4139 StopMeasurementL( type ); |
|
4140 } |
|
4141 else |
|
4142 { |
|
4143 __TRACE( KError, ( |
|
4144 _L( "Unknown command for 'measurement' command:[%S] or type:[%S]" ), &command, &type ) ); |
|
4145 iRunErrorMessage.Format( KErrMsgMeasurementUnknownCommand, &command ); |
|
4146 User::Leave( KErrArgument ); // Error in commands => Leave |
|
4147 } |
|
4148 |
|
4149 } |
|
4150 |
|
4151 /* |
|
4152 ------------------------------------------------------------------------------- |
|
4153 |
|
4154 Class: CTestRunner |
|
4155 |
|
4156 Method: StartMeasurementL |
|
4157 |
|
4158 Description: Start measurement |
|
4159 |
|
4160 Parameters: const TDesC& aType: in: Plugin type. |
|
4161 CStifItemParser* aItem: in: Item object for parsing. |
|
4162 |
|
4163 Return Values: None. |
|
4164 |
|
4165 Errors/Exceptions: Leaves is measurement operation fails. |
|
4166 |
|
4167 Status: Approved |
|
4168 |
|
4169 ------------------------------------------------------------------------------- |
|
4170 */ |
|
4171 void CTestRunner::StartMeasurementL( const TDesC& aType, |
|
4172 CStifItemParser* aItem ) |
|
4173 { |
|
4174 _LIT( KErrMsgMeasurementUnknownPlugin, "Measurement : Unknown measurement plugin %S" ); |
|
4175 _LIT( KErrMsgMeasurementStartFail, "Measurement : Measurement start fails" ); |
|
4176 __TRACEFUNC(); |
|
4177 |
|
4178 CSTIFTestMeasurement* testMeasurement = NULL; |
|
4179 |
|
4180 // Get Measurement configuration info |
|
4181 TPtrC configurationInfo( KNullDesC() ); |
|
4182 if( aItem->Remainder( configurationInfo ) != KErrNone ) |
|
4183 { |
|
4184 __TRACE( KInit, ( |
|
4185 _L( "Using default path and file name for measurement configure" ) ) ); |
|
4186 } |
|
4187 |
|
4188 if( aType == KParamMeasurement01 ) |
|
4189 { |
|
4190 testMeasurement = CSTIFTestMeasurement::NewL( |
|
4191 iTestScripter, |
|
4192 CSTIFTestMeasurement::KStifMeasurementPlugin01, |
|
4193 configurationInfo ); |
|
4194 } |
|
4195 else if( aType == KParamMeasurement02 ) |
|
4196 { |
|
4197 testMeasurement = CSTIFTestMeasurement::NewL( |
|
4198 iTestScripter, |
|
4199 CSTIFTestMeasurement::KStifMeasurementPlugin02, |
|
4200 configurationInfo ); |
|
4201 } |
|
4202 else if( aType == KParamMeasurement03 ) |
|
4203 { |
|
4204 testMeasurement = CSTIFTestMeasurement::NewL( |
|
4205 iTestScripter, |
|
4206 CSTIFTestMeasurement::KStifMeasurementPlugin03, |
|
4207 configurationInfo ); |
|
4208 } |
|
4209 else if( aType == KParamMeasurement04 ) |
|
4210 { |
|
4211 testMeasurement = CSTIFTestMeasurement::NewL( |
|
4212 iTestScripter, |
|
4213 CSTIFTestMeasurement::KStifMeasurementPlugin04, |
|
4214 configurationInfo ); |
|
4215 } |
|
4216 else if( aType == KParamMeasurement05 ) |
|
4217 { |
|
4218 testMeasurement = CSTIFTestMeasurement::NewL( |
|
4219 iTestScripter, |
|
4220 CSTIFTestMeasurement::KStifMeasurementPlugin05, |
|
4221 configurationInfo ); |
|
4222 } |
|
4223 else if( aType == KParamMeasurementBappea ) |
|
4224 { |
|
4225 testMeasurement = CSTIFTestMeasurement::NewL( |
|
4226 iTestScripter, |
|
4227 CSTIFTestMeasurement::KStifMeasurementBappeaProfiler, |
|
4228 configurationInfo ); |
|
4229 } |
|
4230 else |
|
4231 { |
|
4232 __TRACE( KError, ( _L( "Unknown plugin[%S] for 'measurement'" ), &aType ) ); |
|
4233 iRunErrorMessage.Format( KErrMsgMeasurementUnknownPlugin, &aType ); |
|
4234 User::Leave( KErrArgument ); |
|
4235 } |
|
4236 |
|
4237 // Start test measurement |
|
4238 TInt start_ret( KErrNone ); |
|
4239 start_ret = testMeasurement->Start(); |
|
4240 if( start_ret != KErrNone ) |
|
4241 { |
|
4242 delete testMeasurement; |
|
4243 //CleanupStack::PopAndDestroy( setting_buf ); |
|
4244 __TRACE( KError, ( |
|
4245 _L( "CTestRunner::StartMeasurementL(): Measurement Start() fails:[%d]" ), start_ret ) ); |
|
4246 iRunErrorMessage = KErrMsgMeasurementStartFail; |
|
4247 User::Leave( start_ret ); |
|
4248 } |
|
4249 |
|
4250 TTestMeasurement* object = new (ELeave) TTestMeasurement(); |
|
4251 object->iName = aType; |
|
4252 object->iMeasurement = testMeasurement; |
|
4253 |
|
4254 // Array for handling test measurement between different objects |
|
4255 TInt ret = iTestMeasurementArray.Append( object ); |
|
4256 if( ret != KErrNone ) |
|
4257 { |
|
4258 delete object; |
|
4259 __TRACE( KError, ( |
|
4260 _L( "CTestRunner::StartMeasurementL(): iTestMeasurementArray.Append fails:[%d]" ), ret ) ); |
|
4261 User::Leave( ret ); |
|
4262 } |
|
4263 |
|
4264 } |
|
4265 |
|
4266 /* |
|
4267 ------------------------------------------------------------------------------- |
|
4268 |
|
4269 Class: CTestRunner |
|
4270 |
|
4271 Method: StopMeasurementL |
|
4272 |
|
4273 Description: Stops test measurement. |
|
4274 |
|
4275 Parameters: None. |
|
4276 |
|
4277 Return Values: None. |
|
4278 |
|
4279 Errors/Exceptions: None. |
|
4280 |
|
4281 Status: Approved |
|
4282 |
|
4283 ------------------------------------------------------------------------------- |
|
4284 */ |
|
4285 void CTestRunner::StopMeasurementL( const TDesC& aType ) |
|
4286 { |
|
4287 _LIT( KErrMsgMeasurementNotStarted, "Measurement : Measurement %S was not start" ); |
|
4288 __TRACEFUNC(); |
|
4289 |
|
4290 TInt count = iTestMeasurementArray.Count(); |
|
4291 for( TInt i = 0; i < count; i++ ) |
|
4292 { |
|
4293 if( iTestMeasurementArray[i]->iName == aType ) |
|
4294 { |
|
4295 // Found measurement module, stop |
|
4296 iTestMeasurementArray[i]->iMeasurement->Stop(); |
|
4297 // Delete data |
|
4298 delete iTestMeasurementArray[i]; |
|
4299 // Remove pointer to deleted data(Append()) |
|
4300 iTestMeasurementArray.Remove( i ); |
|
4301 // iTestMeasurementArray can contain only one type of measurement |
|
4302 // so we can break when type is removed. |
|
4303 return; |
|
4304 } |
|
4305 } |
|
4306 |
|
4307 __TRACE( KError, ( |
|
4308 _L( "CTestRunner::StopMeasurementL(): Measurement %S was not start" ), &aType ) ); |
|
4309 iRunErrorMessage.Format( KErrMsgMeasurementNotStarted, &aType ); |
|
4310 User::Leave( KErrArgument ); |
|
4311 } |
|
4312 |
|
4313 /* |
|
4314 ------------------------------------------------------------------------------- |
|
4315 |
|
4316 Class: CTestRunner |
|
4317 |
|
4318 Method: AddTestCaseResultL |
|
4319 |
|
4320 Description: Adds new test case result. Used with 'allownextresult' |
|
4321 and 'allowerrorcodes' keywords. |
|
4322 |
|
4323 Parameters: CStifItemParser* aItem: in: Item object for parsing. |
|
4324 |
|
4325 Return Values: None. |
|
4326 |
|
4327 Errors/Exceptions: Leaves if iTestCaseResults.Append fails. |
|
4328 Leaves if aItem->GetNextInt() fails. |
|
4329 |
|
4330 Status: Approved |
|
4331 |
|
4332 ------------------------------------------------------------------------------- |
|
4333 */ |
|
4334 void CTestRunner::AddTestCaseResultL( CStifItemParser* aItem ) |
|
4335 { |
|
4336 _LIT( KErrMsgAllowNextResultInvalidValue, "No expected result value given or value has invalid format" ); |
|
4337 TInt result; |
|
4338 |
|
4339 TPtrC codeBuf; |
|
4340 TBool found = EFalse; |
|
4341 while( aItem->GetNextString( codeBuf ) == KErrNone ) |
|
4342 { |
|
4343 TLex codeParser( codeBuf ); |
|
4344 if ( codeParser.Val( result ) != KErrNone ) |
|
4345 { |
|
4346 __TRACE( KError, (_L("ExecuteLineL: No expected result value given"))); |
|
4347 iRunErrorMessage = KErrMsgAllowNextResultInvalidValue; |
|
4348 User::Leave( KErrArgument ); |
|
4349 } |
|
4350 else |
|
4351 { |
|
4352 User::LeaveIfError( iTestCaseResults.Append( result ) ); |
|
4353 // Set test case allow result to CTestModuleIf side too. This is |
|
4354 // used in TAL-TA5L macro handling. |
|
4355 User::LeaveIfError( |
|
4356 iTestScripter->TestModuleIf().SetAllowResult( result ) ); |
|
4357 found = ETrue; |
|
4358 } |
|
4359 } |
|
4360 |
|
4361 if ( !found ) |
|
4362 { |
|
4363 __TRACE( KError, (_L("ExecuteLineL: No expected result value given"))); |
|
4364 iRunErrorMessage = KErrMsgAllowNextResultInvalidValue; |
|
4365 User::Leave( KErrArgument ); |
|
4366 } |
|
4367 } |
|
4368 |
|
4369 |
|
4370 /* |
|
4371 ------------------------------------------------------------------------------- |
|
4372 |
|
4373 DESCRIPTION |
|
4374 |
|
4375 This module contains the implementation of CTestContinue class |
|
4376 member functions. CTestContinue handles ContinueScript calls from |
|
4377 TestScripter. |
|
4378 |
|
4379 ------------------------------------------------------------------------------- |
|
4380 */ |
|
4381 // MACROS |
|
4382 #ifdef LOGGER |
|
4383 #undef LOGGER |
|
4384 #endif |
|
4385 #define LOGGER iTestScripter->iLog |
|
4386 |
|
4387 // ================= MEMBER FUNCTIONS ========================================= |
|
4388 |
|
4389 /* |
|
4390 ------------------------------------------------------------------------------- |
|
4391 |
|
4392 Class: CTestContinue |
|
4393 |
|
4394 Method: CTestContinue |
|
4395 |
|
4396 Description: Default constructor |
|
4397 |
|
4398 Parameters: CTestRunner* aTestRunner: in: Backpointer to CTestRunner |
|
4399 |
|
4400 Return Values: None |
|
4401 |
|
4402 Errors/Exceptions: None |
|
4403 |
|
4404 Status: Draft |
|
4405 |
|
4406 ------------------------------------------------------------------------------- |
|
4407 */ |
|
4408 CTestContinue::CTestContinue( CTestScripter* aTestScripter, |
|
4409 TTestObject* aObject ): |
|
4410 // Executed with lowest priority, must be lower than CTesRunner priority |
|
4411 CActive( CActive::EPriorityLow ), |
|
4412 iTestScripter( aTestScripter ), |
|
4413 iObject( aObject ) |
|
4414 { |
|
4415 CActiveScheduler::Add( this ); |
|
4416 __TRACEFUNC(); |
|
4417 |
|
4418 } |
|
4419 |
|
4420 /* |
|
4421 ------------------------------------------------------------------------------- |
|
4422 |
|
4423 Class: CTestContinue |
|
4424 |
|
4425 Method: ConstructL |
|
4426 |
|
4427 Description: Symbian OS second phase constructor |
|
4428 |
|
4429 Parameters: None |
|
4430 |
|
4431 Return Values: None |
|
4432 |
|
4433 Errors/Exceptions: None |
|
4434 |
|
4435 Status: Draft |
|
4436 |
|
4437 ------------------------------------------------------------------------------- |
|
4438 */ |
|
4439 void CTestContinue::ConstructL() |
|
4440 { |
|
4441 |
|
4442 iObject->iScript->EnableSignal( iStatus ); |
|
4443 SetActive(); |
|
4444 |
|
4445 } |
|
4446 |
|
4447 /* |
|
4448 ------------------------------------------------------------------------------- |
|
4449 |
|
4450 Class: CTestContinue |
|
4451 |
|
4452 Method: NewL |
|
4453 |
|
4454 Description: Two-phased constructor. |
|
4455 |
|
4456 Parameters: CTestRunner* aTestRunner: in: Backpointer to CTestRunner |
|
4457 |
|
4458 Return Values: CTestContinue*: new object |
|
4459 |
|
4460 Errors/Exceptions: Leaves if new or ConstructL leaves |
|
4461 |
|
4462 Status: Draft |
|
4463 |
|
4464 ------------------------------------------------------------------------------- |
|
4465 */ |
|
4466 |
|
4467 CTestContinue* CTestContinue::NewL( CTestScripter* aTestScripter, |
|
4468 TTestObject* aObject ) |
|
4469 { |
|
4470 CTestContinue* self = |
|
4471 new (ELeave) CTestContinue( aTestScripter, aObject ); |
|
4472 |
|
4473 CleanupStack::PushL( self ); |
|
4474 self->ConstructL(); |
|
4475 CleanupStack::Pop(); |
|
4476 |
|
4477 return self; |
|
4478 } |
|
4479 |
|
4480 /* |
|
4481 ------------------------------------------------------------------------------- |
|
4482 |
|
4483 Class: CTestContinue |
|
4484 |
|
4485 Method: ~CTestContinue |
|
4486 |
|
4487 Description: Destructor |
|
4488 |
|
4489 Parameters: None |
|
4490 |
|
4491 Return Values: None |
|
4492 |
|
4493 Errors/Exceptions: None |
|
4494 |
|
4495 Status: Draft |
|
4496 |
|
4497 ------------------------------------------------------------------------------- |
|
4498 */ |
|
4499 |
|
4500 CTestContinue::~CTestContinue() |
|
4501 { |
|
4502 __TRACEFUNC(); |
|
4503 Cancel(); |
|
4504 |
|
4505 } |
|
4506 |
|
4507 /* |
|
4508 ------------------------------------------------------------------------------- |
|
4509 |
|
4510 Class: CTestContinue |
|
4511 |
|
4512 Method: RunL |
|
4513 |
|
4514 Description: Derived from CActive, handles testcase execution. |
|
4515 |
|
4516 Parameters: None. |
|
4517 |
|
4518 Return Values: None. |
|
4519 |
|
4520 Errors/Exceptions: Leaves on error situations. |
|
4521 |
|
4522 Status: Draft |
|
4523 |
|
4524 ------------------------------------------------------------------------------- |
|
4525 */ |
|
4526 void CTestContinue::RunL() |
|
4527 { |
|
4528 |
|
4529 __TRACEFUNC(); |
|
4530 __TRACE( KMessage, (_L("CTestContinue::RunL: [%d] "), iStatus.Int() )); |
|
4531 |
|
4532 if( iObject->Signal() ) |
|
4533 { |
|
4534 // If OOM testing is ongoing ignore result check(given by user). |
|
4535 if( !iTestScripter->iOOMIgnoreFailure ) |
|
4536 { |
|
4537 // Erronous case RunError will called and test handling continue |
|
4538 // from there. |
|
4539 if( iTestScripter->TestRunner().TestCaseResults().Count() == 0 ) |
|
4540 { |
|
4541 // KErrNone is the default result expected |
|
4542 // if nothing else is given |
|
4543 User::LeaveIfError( iTestScripter->TestRunner(). |
|
4544 TestCaseResults().Append( KErrNone ) ); |
|
4545 } |
|
4546 |
|
4547 if( iTestScripter->TestRunner().TestCaseResults(). |
|
4548 Find( iStatus.Int() ) < 0 ) |
|
4549 { |
|
4550 __TRACE( KError, ( _L("Command for [%S] failed (%d)"), |
|
4551 &iObject->ObjectId(), iStatus.Int() )); |
|
4552 |
|
4553 |
|
4554 if( iStatus.Int() == KErrNone ) |
|
4555 { |
|
4556 User::Leave( KErrGeneral ); |
|
4557 } |
|
4558 else |
|
4559 { |
|
4560 User::Leave( iStatus.Int() ); |
|
4561 } |
|
4562 } |
|
4563 } |
|
4564 else |
|
4565 { |
|
4566 __TRACE( KMessage, ( |
|
4567 _L( "OOM test: 'oomignorefailure' is ON, signal result[%d] ignored" ), |
|
4568 iStatus.Int() )); |
|
4569 } |
|
4570 |
|
4571 iTestScripter->TestRunner().TestCaseResults().Reset(); |
|
4572 |
|
4573 __TRACE( KMessage, (_L("CTestContinue::RunL: Set runner active "))); |
|
4574 iTestScripter->iTestRunner->SetRunnerActive(); |
|
4575 } |
|
4576 else |
|
4577 { |
|
4578 // Signal called from test side but 'waittestclass' not yet processed |
|
4579 iObject->iAsyncResult = iStatus.Int(); |
|
4580 } |
|
4581 |
|
4582 iObject->iScript->EnableSignal( iStatus ); |
|
4583 SetActive(); |
|
4584 |
|
4585 } |
|
4586 |
|
4587 /* |
|
4588 ------------------------------------------------------------------------------- |
|
4589 |
|
4590 Class: CTestContinue |
|
4591 |
|
4592 Method: DoCancel |
|
4593 |
|
4594 Description: Derived from CActive handles the Cancel |
|
4595 |
|
4596 Parameters: None. |
|
4597 |
|
4598 Return Values: None. |
|
4599 |
|
4600 Errors/Exceptions: None. |
|
4601 |
|
4602 Status: Draft |
|
4603 |
|
4604 ------------------------------------------------------------------------------- |
|
4605 */ |
|
4606 void CTestContinue::DoCancel() |
|
4607 { |
|
4608 |
|
4609 __TRACEFUNC(); |
|
4610 __TRACE( KMessage, (_L("CTestContinue::DoCancel"))); |
|
4611 |
|
4612 iObject->iScript->CancelSignal(); |
|
4613 |
|
4614 } |
|
4615 |
|
4616 /* |
|
4617 ------------------------------------------------------------------------------- |
|
4618 |
|
4619 Class: CTestContinue |
|
4620 |
|
4621 Method: RunError |
|
4622 |
|
4623 Description: Derived from CActive handles the Cancel |
|
4624 |
|
4625 Parameters: None. |
|
4626 |
|
4627 Return Values: None. |
|
4628 |
|
4629 Errors/Exceptions: None. |
|
4630 |
|
4631 Status: Draft |
|
4632 |
|
4633 ------------------------------------------------------------------------------- |
|
4634 */ |
|
4635 TInt CTestContinue::RunError( TInt aError ) |
|
4636 { |
|
4637 |
|
4638 // Return error from here, if none given from execution |
|
4639 if( iTestScripter->iResult.iResult == KErrNone ) |
|
4640 { |
|
4641 iTestScripter->UpdateTestCaseResult(aError, _L("CTestContinue::RunError")); |
|
4642 } |
|
4643 CActiveScheduler::Current()->Stop(); |
|
4644 |
|
4645 return KErrNone; |
|
4646 |
|
4647 } |
|
4648 |
|
4649 /* |
|
4650 ------------------------------------------------------------------------------- |
|
4651 |
|
4652 DESCRIPTION |
|
4653 |
|
4654 This module contains the implementation of CDefinedValue class |
|
4655 member functions. |
|
4656 ------------------------------------------------------------------------------- |
|
4657 */ |
|
4658 |
|
4659 // ================= MEMBER FUNCTIONS ========================================= |
|
4660 /* |
|
4661 ------------------------------------------------------------------------------- |
|
4662 |
|
4663 Class: CDefinedValue |
|
4664 |
|
4665 Method: CDefinedValue |
|
4666 |
|
4667 Description: Default constructor |
|
4668 |
|
4669 C++ default constructor can NOT contain any code, that |
|
4670 might leave. |
|
4671 |
|
4672 Parameters: None |
|
4673 |
|
4674 Return Values: None |
|
4675 |
|
4676 Errors/Exceptions: None |
|
4677 |
|
4678 Status: Draft |
|
4679 |
|
4680 ------------------------------------------------------------------------------- |
|
4681 */ |
|
4682 CDefinedValue::CDefinedValue() |
|
4683 { |
|
4684 } |
|
4685 |
|
4686 /* |
|
4687 ------------------------------------------------------------------------------- |
|
4688 |
|
4689 Class: CDefinedValue |
|
4690 |
|
4691 Method: ConstructL |
|
4692 |
|
4693 Description: Symbian OS second phase constructor |
|
4694 |
|
4695 Symbian OS default constructor can leave. |
|
4696 |
|
4697 Parameters: TDesC& aName: in: Define name |
|
4698 TDesC& aValue: in: Define value |
|
4699 |
|
4700 Return Values: None |
|
4701 |
|
4702 Errors/Exceptions: None |
|
4703 |
|
4704 Status: Draft |
|
4705 |
|
4706 ------------------------------------------------------------------------------- |
|
4707 */ |
|
4708 void CDefinedValue::ConstructL( TDesC& aName, TDesC& aValue ) |
|
4709 { |
|
4710 |
|
4711 iNameBuf = aName.AllocLC(); |
|
4712 iName.Set( iNameBuf->Des() ); |
|
4713 iValueBuf = aValue.AllocLC(); |
|
4714 iValue.Set( iValueBuf->Des() ); |
|
4715 CleanupStack::Pop( iValueBuf ); |
|
4716 CleanupStack::Pop( iNameBuf ); |
|
4717 |
|
4718 } |
|
4719 |
|
4720 /* |
|
4721 ------------------------------------------------------------------------------- |
|
4722 |
|
4723 Class: CDefinedValue |
|
4724 |
|
4725 Method: NewL |
|
4726 |
|
4727 Description: Two-phased constructor. |
|
4728 |
|
4729 Parameters: TDesC& aName: in: Define name |
|
4730 TDesC& aValue: in: Define value |
|
4731 |
|
4732 Return Values: CDefinedValue*: new object |
|
4733 |
|
4734 Errors/Exceptions: Leaves if new or ConstructL leaves. |
|
4735 |
|
4736 Status: Draft |
|
4737 |
|
4738 ------------------------------------------------------------------------------- |
|
4739 */ |
|
4740 CDefinedValue* CDefinedValue::NewL( TDesC& aName, TDesC& aValue ) |
|
4741 { |
|
4742 |
|
4743 CDefinedValue* self = new (ELeave) CDefinedValue(); |
|
4744 |
|
4745 CleanupStack::PushL( self ); |
|
4746 self->ConstructL( aName, aValue ); |
|
4747 CleanupStack::Pop(); |
|
4748 |
|
4749 return self; |
|
4750 |
|
4751 } |
|
4752 |
|
4753 /* |
|
4754 ------------------------------------------------------------------------------- |
|
4755 |
|
4756 Class: CDefinedValue |
|
4757 |
|
4758 Method: ~CDefinedValue |
|
4759 |
|
4760 Description: Destructor |
|
4761 |
|
4762 Parameters: None |
|
4763 |
|
4764 Return Values: None |
|
4765 |
|
4766 Errors/Exceptions: None |
|
4767 |
|
4768 Status: Draft |
|
4769 |
|
4770 ------------------------------------------------------------------------------- |
|
4771 */ |
|
4772 CDefinedValue::~CDefinedValue() |
|
4773 { |
|
4774 |
|
4775 delete iValueBuf; |
|
4776 delete iNameBuf; |
|
4777 |
|
4778 } |
|
4779 |
|
4780 /* |
|
4781 ------------------------------------------------------------------------------- |
|
4782 |
|
4783 Class: CDefinedValue |
|
4784 |
|
4785 Method: SetValueL |
|
4786 |
|
4787 Description: Set new define value |
|
4788 |
|
4789 Parameters: TDesC& aValue: in: Define value |
|
4790 |
|
4791 Return Values: None |
|
4792 |
|
4793 Errors/Exceptions: Leaves on error. |
|
4794 |
|
4795 Status: Draft |
|
4796 |
|
4797 ------------------------------------------------------------------------------- |
|
4798 */ |
|
4799 void CDefinedValue::SetValueL( TDesC& aValue ) |
|
4800 { |
|
4801 delete iValueBuf; |
|
4802 iValueBuf = 0; |
|
4803 iValueBuf = aValue.AllocLC(); |
|
4804 iValue.Set( iValueBuf->Des() ); |
|
4805 CleanupStack::Pop( iValueBuf ); |
|
4806 |
|
4807 } |
|
4808 |
|
4809 |
|
4810 /* |
|
4811 ------------------------------------------------------------------------------- |
|
4812 |
|
4813 Class: CDefinedValue |
|
4814 |
|
4815 Method: Name |
|
4816 |
|
4817 Description: Returns define name. |
|
4818 |
|
4819 Parameters: None |
|
4820 |
|
4821 Return Values: TDesC: Define name |
|
4822 |
|
4823 Errors/Exceptions: None |
|
4824 |
|
4825 Status: Draft |
|
4826 |
|
4827 ------------------------------------------------------------------------------- |
|
4828 */ |
|
4829 TDesC& CDefinedValue::Name() |
|
4830 { |
|
4831 return iName; |
|
4832 } |
|
4833 |
|
4834 /* |
|
4835 ------------------------------------------------------------------------------- |
|
4836 |
|
4837 Class: CDefinedValue |
|
4838 |
|
4839 Method: Value |
|
4840 |
|
4841 Description: Returns define value. |
|
4842 |
|
4843 Parameters: None |
|
4844 |
|
4845 Return Values: TDesC: Define value |
|
4846 |
|
4847 Errors/Exceptions: None |
|
4848 |
|
4849 Status: Draft |
|
4850 |
|
4851 ------------------------------------------------------------------------------- |
|
4852 */ |
|
4853 TDesC& CDefinedValue::Value() |
|
4854 { |
|
4855 return iValue; |
|
4856 } |
|
4857 |
|
4858 |
|
4859 /* |
|
4860 ------------------------------------------------------------------------------- |
|
4861 |
|
4862 DESCRIPTION |
|
4863 |
|
4864 This module contains the implementation of TTestObjectBase class |
|
4865 member functions. |
|
4866 ------------------------------------------------------------------------------- |
|
4867 */ |
|
4868 |
|
4869 // ================= MEMBER FUNCTIONS ========================================= |
|
4870 /* |
|
4871 ------------------------------------------------------------------------------- |
|
4872 |
|
4873 Class: TTestObjectBase |
|
4874 |
|
4875 Method: TTestObjectBase |
|
4876 |
|
4877 Description: Constructor |
|
4878 |
|
4879 Parameters: None |
|
4880 |
|
4881 Return Values: None |
|
4882 |
|
4883 Errors/Exceptions: None |
|
4884 |
|
4885 Status: Draft |
|
4886 |
|
4887 ------------------------------------------------------------------------------- |
|
4888 */ |
|
4889 TTestObjectBase::TTestObjectBase( TObjectType aType ) : |
|
4890 iAsyncResult( KErrNone ), |
|
4891 iType( aType ) |
|
4892 { |
|
4893 |
|
4894 RDebug::Print( _L("TTestObjectBase::TTestObjectBase") ); |
|
4895 iName.Zero(); |
|
4896 |
|
4897 } |
|
4898 |
|
4899 /* |
|
4900 ------------------------------------------------------------------------------- |
|
4901 |
|
4902 Class: TTestObjectBase |
|
4903 |
|
4904 Method: ~TTestObjectBase |
|
4905 |
|
4906 Description: Destructor |
|
4907 |
|
4908 Parameters: None |
|
4909 |
|
4910 Return Values: None |
|
4911 |
|
4912 Errors/Exceptions: None |
|
4913 |
|
4914 Status: Draft |
|
4915 |
|
4916 ------------------------------------------------------------------------------- |
|
4917 */ |
|
4918 TTestObjectBase::~TTestObjectBase() |
|
4919 { |
|
4920 |
|
4921 RDebug::Print( _L("TTestObjectBase::~TTestObjectBase") ); |
|
4922 |
|
4923 } |
|
4924 |
|
4925 /* |
|
4926 ------------------------------------------------------------------------------- |
|
4927 |
|
4928 DESCRIPTION |
|
4929 |
|
4930 This module contains the implementation of TTestObject class |
|
4931 member functions. |
|
4932 ------------------------------------------------------------------------------- |
|
4933 */ |
|
4934 // ================= MEMBER FUNCTIONS ========================================= |
|
4935 |
|
4936 /* |
|
4937 ------------------------------------------------------------------------------- |
|
4938 |
|
4939 Class: TTestObject |
|
4940 |
|
4941 Method: TTestObject |
|
4942 |
|
4943 Description: Constructor |
|
4944 |
|
4945 Parameters: None |
|
4946 |
|
4947 Return Values: None |
|
4948 |
|
4949 Errors/Exceptions: None |
|
4950 |
|
4951 Status: Draft |
|
4952 |
|
4953 ------------------------------------------------------------------------------- |
|
4954 */ |
|
4955 TTestObject::TTestObject() : |
|
4956 TTestObjectBase( EObjectNormal ), |
|
4957 iScript(0), |
|
4958 iContinue(0), |
|
4959 iCount(0) |
|
4960 { |
|
4961 |
|
4962 RDebug::Print( _L("TTestObject::TTestObject") ); |
|
4963 |
|
4964 } |
|
4965 |
|
4966 /* |
|
4967 ------------------------------------------------------------------------------- |
|
4968 |
|
4969 Class: TTestObject |
|
4970 |
|
4971 Method: ~TTestObject |
|
4972 |
|
4973 Description: Destructor |
|
4974 |
|
4975 Parameters: None |
|
4976 |
|
4977 Return Values: None |
|
4978 |
|
4979 Errors/Exceptions: None |
|
4980 |
|
4981 Status: Draft |
|
4982 |
|
4983 ------------------------------------------------------------------------------- |
|
4984 */ |
|
4985 TTestObject::~TTestObject() |
|
4986 { |
|
4987 |
|
4988 RDebug::Print( _L("TTestObject::~TTestObject") ); |
|
4989 delete iContinue; |
|
4990 delete iScript; |
|
4991 |
|
4992 } |
|
4993 |
|
4994 /* |
|
4995 ------------------------------------------------------------------------------- |
|
4996 |
|
4997 Class: TTestObject |
|
4998 |
|
4999 Method: RunMethodL |
|
5000 |
|
5001 Description: Run specified method from testclass. |
|
5002 |
|
5003 Parameters: CStifItemParser* aItem: in: itemparser |
|
5004 |
|
5005 Return Values: Symbian OS error code |
|
5006 |
|
5007 Errors/Exceptions: None |
|
5008 |
|
5009 Status: Draft |
|
5010 |
|
5011 ------------------------------------------------------------------------------- |
|
5012 */ |
|
5013 TInt TTestObject::RunMethodL( CStifItemParser& aItem ) |
|
5014 { |
|
5015 |
|
5016 return iScript->RunMethodL( aItem ); |
|
5017 |
|
5018 } |
|
5019 |
|
5020 /* |
|
5021 ------------------------------------------------------------------------------- |
|
5022 |
|
5023 DESCRIPTION |
|
5024 |
|
5025 This module contains the implementation of TTestObjectKernel class |
|
5026 member functions. |
|
5027 ------------------------------------------------------------------------------- |
|
5028 */ |
|
5029 // ================= MEMBER FUNCTIONS ========================================= |
|
5030 |
|
5031 |
|
5032 /* |
|
5033 ------------------------------------------------------------------------------- |
|
5034 |
|
5035 Class: TTestObjectKernel |
|
5036 |
|
5037 Method: TTestObjectKernel |
|
5038 |
|
5039 Description: Constructor |
|
5040 |
|
5041 Parameters: None |
|
5042 |
|
5043 Return Values: None |
|
5044 |
|
5045 Errors/Exceptions: None |
|
5046 |
|
5047 Status: Draft |
|
5048 |
|
5049 ------------------------------------------------------------------------------- |
|
5050 */ |
|
5051 TTestObjectKernel::TTestObjectKernel() : |
|
5052 TTestObjectBase( EObjectKernel ) |
|
5053 { |
|
5054 |
|
5055 RDebug::Print( _L("TTestObjectKernel::TTestObjectKernel") ); |
|
5056 |
|
5057 } |
|
5058 |
|
5059 /* |
|
5060 ------------------------------------------------------------------------------- |
|
5061 |
|
5062 Class: TTestObjectKernel |
|
5063 |
|
5064 Method: ~TTestObjectKernel |
|
5065 |
|
5066 Description: Destructor |
|
5067 |
|
5068 Parameters: None |
|
5069 |
|
5070 Return Values: None |
|
5071 |
|
5072 Errors/Exceptions: None |
|
5073 |
|
5074 Status: Draft |
|
5075 |
|
5076 ------------------------------------------------------------------------------- |
|
5077 */ |
|
5078 TTestObjectKernel::~TTestObjectKernel() |
|
5079 { |
|
5080 |
|
5081 RDebug::Print( _L("TTestObjectKernel::~TTestObjectKernel") ); |
|
5082 |
|
5083 iTestClass.Close(); |
|
5084 User::FreeLogicalDevice( iLddName ); |
|
5085 |
|
5086 } |
|
5087 |
|
5088 /* |
|
5089 ------------------------------------------------------------------------------- |
|
5090 |
|
5091 Class: TTestObjectKernel |
|
5092 |
|
5093 Method: RunMethodL |
|
5094 |
|
5095 Description: Run specified method from kernel testclass. |
|
5096 |
|
5097 Parameters: CStifItemParser& aItem: in: itemparser |
|
5098 |
|
5099 Return Values: Symbian OS error code |
|
5100 |
|
5101 Errors/Exceptions: None |
|
5102 |
|
5103 Status: Draft |
|
5104 |
|
5105 ------------------------------------------------------------------------------- |
|
5106 */ |
|
5107 TInt TTestObjectKernel::RunMethodL( CStifItemParser& aItem ) |
|
5108 { |
|
5109 |
|
5110 TPtrC method; |
|
5111 TPtrC params; |
|
5112 |
|
5113 User::LeaveIfError( aItem.GetNextString( method ) ); |
|
5114 aItem.Remainder( params ); |
|
5115 |
|
5116 TInt result; |
|
5117 TMethodResultDes resultDes; |
|
5118 |
|
5119 // Need to change descriptors from 16bit to 8bit for EKA2 kernel |
|
5120 // because STIF Parser doesn't support 8bit parsing |
|
5121 HBufC8 * myBuf1 = HBufC8::NewL( method.Length() ); |
|
5122 TPtr8 met8 = myBuf1->Des(); |
|
5123 met8.Copy( method ); |
|
5124 |
|
5125 HBufC8 * myBuf2 = HBufC8::NewL( params.Length() ); |
|
5126 TPtr8 par8 = myBuf2->Des(); |
|
5127 par8.Copy( params ); |
|
5128 |
|
5129 TInt ret = iTestClass.RunMethod( met8, par8, result, resultDes ); |
|
5130 |
|
5131 delete myBuf1; |
|
5132 delete myBuf2; |
|
5133 |
|
5134 if( ret != KErrNone ) |
|
5135 { |
|
5136 return ret; |
|
5137 } |
|
5138 |
|
5139 return result; |
|
5140 |
|
5141 }; |
|
5142 |
|
5143 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
5144 |
|
5145 /* |
|
5146 ------------------------------------------------------------------------------- |
|
5147 |
|
5148 Function: LibEntryL |
|
5149 |
|
5150 Description: Polymorphic Dll Entry Point |
|
5151 |
|
5152 Parameters: None. |
|
5153 |
|
5154 Return Values: CTestScripter*: pointer to new CTestScripter |
|
5155 |
|
5156 Errors/Exceptions: Leaves if NewL leaves. |
|
5157 |
|
5158 Status: Draft |
|
5159 |
|
5160 ------------------------------------------------------------------------------- |
|
5161 */ |
|
5162 |
|
5163 EXPORT_C CTestScripter* LibEntryL() |
|
5164 { |
|
5165 return CTestScripter::NewL(); |
|
5166 |
|
5167 } |
|
5168 |
|
5169 // End of File |
|