stif/TestCombiner/src/TestCombiner.cpp
changeset 26 4fde310f06fe
parent 13 33016869e0dd
child 30 86a2e675b80a
equal deleted inserted replaced
21:f5d4820de50d 26:4fde310f06fe
  1650         CTCTestCase::NewL( this, 
  1650         CTCTestCase::NewL( this, 
  1651                            aStartInfo.iModule, 
  1651                            aStartInfo.iModule, 
  1652                            aStartInfo.iTestId, 
  1652                            aStartInfo.iTestId, 
  1653                            aStartInfo.iExpectedResult, 
  1653                            aStartInfo.iExpectedResult, 
  1654                            aStartInfo.iCategory,
  1654                            aStartInfo.iCategory,
       
  1655                            aStartInfo.iTestCaseArguments,
  1655                            module ); //--PYTHON--
  1656                            module ); //--PYTHON--
  1656 
  1657 
  1657     CleanupStack::PushL( tc );
  1658     CleanupStack::PushL( tc );
  1658     
  1659     
  1659     //If name of testcase was given, find testcase number
  1660     //If name of testcase was given, find testcase number
  1692     TestModuleIf().Printf( KPrintPriLow, _L("Start"),
  1693     TestModuleIf().Printf( KPrintPriLow, _L("Start"),
  1693         _L("testid(%S), module(%S), ini(%S), config(%S), case(%d), expect(%d)"), 
  1694         _L("testid(%S), module(%S), ini(%S), config(%S), case(%d), expect(%d)"), 
  1694          &aStartInfo.iTestId, &aStartInfo.iModule, &aStartInfo.iIniFile, 
  1695          &aStartInfo.iTestId, &aStartInfo.iModule, &aStartInfo.iIniFile, 
  1695          &aStartInfo.iConfig, aStartInfo.iCaseNum, aStartInfo.iExpectedResult );
  1696          &aStartInfo.iConfig, aStartInfo.iCaseNum, aStartInfo.iExpectedResult );
  1696 
  1697 
  1697     tc->TestExecution().RunTestCase( tc->iResultPckg, tc->iStatus );
  1698     if ( tc->TestCaseArguments().Length() > 0 )
       
  1699         {
       
  1700         tc->TestExecution().RunTestCase( tc->iResultPckg, tc->TestCaseArguments(), tc->iStatus );
       
  1701         }
       
  1702     else
       
  1703         {
       
  1704         tc->TestExecution().RunTestCase( tc->iResultPckg, tc->iStatus );
       
  1705         }
  1698 
  1706 
  1699     iRunningTests++;
  1707     iRunningTests++;
  1700 
  1708 
  1701     User::LeaveIfError( iTestCases.Append( tc ) );
  1709     User::LeaveIfError( iTestCases.Append( tc ) );
  1702     if( iLoopIsUsed )
  1710     if( iLoopIsUsed )
  2443     
  2451     
  2444 -------------------------------------------------------------------------------
  2452 -------------------------------------------------------------------------------
  2445 */
  2453 */
  2446 void CTestRunner::ConstructL()
  2454 void CTestRunner::ConstructL()
  2447     {
  2455     {
  2448     
  2456     TInt ret;
  2449     iPauseTimer.CreateLocal();
  2457     
       
  2458     ret = iPauseTimer.CreateLocal();
       
  2459     if(ret != KErrNone)
       
  2460         {
       
  2461         __TRACE( KError, (_L("Unable to create RTimer: iPauseTimer [%d] "), ret));
       
  2462         User::Leave(ret);
       
  2463         }
       
  2464         
       
  2465     ret = iPauseCombTimer.CreateLocal();
       
  2466     if(ret != KErrNone)
       
  2467         {
       
  2468         __TRACE( KError, (_L("Unable to create RTimer: iPauseCombTimer [%d] "), ret));
       
  2469         User::Leave(ret);
       
  2470         }
  2450     
  2471     
  2451     iRemoteTimer = CRemoteTimer::NewL( iTestCombiner );
  2472     iRemoteTimer = CRemoteTimer::NewL( iTestCombiner );
  2452     
  2473     
  2453     }
  2474     }
  2454 
  2475 
  2513     
  2534     
  2514     delete iLine;
  2535     delete iLine;
  2515     iLine = 0;
  2536     iLine = 0;
  2516     
  2537     
  2517     iPauseTimer.Close();
  2538     iPauseTimer.Close();
       
  2539     
       
  2540     iPauseCombTimer.Close();
  2518          
  2541          
  2519     }
  2542     }
  2520 
  2543 
  2521 /*
  2544 /*
  2522 -------------------------------------------------------------------------------
  2545 -------------------------------------------------------------------------------
  2548         ( iTestCombiner->iSectionParser == NULL ) )
  2571         ( iTestCombiner->iSectionParser == NULL ) )
  2549         {
  2572         {
  2550         User::Leave( KErrGeneral );
  2573         User::Leave( KErrGeneral );
  2551         }
  2574         }
  2552         
  2575         
  2553     TBool continueTask = EFalse; 
  2576     TBool continueTask = EFalse;
       
  2577     
       
  2578     // Check if there is still some time for combiner pause and we need to 
       
  2579     // continue pausing
       
  2580     if(iPauseCombRemainingTime > 0)
       
  2581         {           
       
  2582         // Maximum time for one RTimer::After request                   
       
  2583         TInt maximumTime = KMaxTInt / 1000;                       
  2554         
  2584         
       
  2585         __TRACE( KMessage, (_L("CTestRunner::RunL: Going to reissue PauseCombiner request ") ) );           
       
  2586         __TRACE( KMessage, (_L("CTestRunner::RunL: iRemainingTimeValue = %d"), iPauseCombRemainingTime ) );        
       
  2587         
       
  2588         if( iPauseCombRemainingTime < maximumTime )
       
  2589             {                           
       
  2590             iPauseCombTimer.After(iStatus, (iPauseCombRemainingTime * 1000));
       
  2591             iPauseCombRemainingTime = 0;
       
  2592             }
       
  2593         else
       
  2594             {            
       
  2595             iPauseCombRemainingTime -= maximumTime;
       
  2596             iPauseCombTimer.After(iStatus, (maximumTime * 1000));        
       
  2597             }     
       
  2598             
       
  2599         SetActive();
       
  2600         return;
       
  2601         }     
       
  2602  
       
  2603     // Handling runner states
  2555     switch( iState )
  2604     switch( iState )
  2556         {
  2605         {
  2557         case ERunnerWaitTimeout:
  2606         case ERunnerWaitTimeout:
  2558             {
  2607             {
  2559             __TRACE( KMessage, (_L("Resume %S"), &iPausedTestCase));
  2608             __TRACE( KMessage, (_L("Resume %S"), &iPausedTestCase));
  2692 void CTestRunner::DoCancel()
  2741 void CTestRunner::DoCancel()
  2693     {
  2742     {
  2694     __TRACEFUNC();
  2743     __TRACEFUNC();
  2695     __TRACE( KMessage, (_L("CTestRunner::DoCancel")));
  2744     __TRACE( KMessage, (_L("CTestRunner::DoCancel")));
  2696     iTestCombiner->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), _L("DoCancel"));
  2745     iTestCombiner->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), _L("DoCancel"));
       
  2746     
       
  2747     iPauseCombTimer.Cancel();
  2697     
  2748     
  2698     switch( iState )
  2749     switch( iState )
  2699         {
  2750         {
  2700         case ERunnerWaitTimeout:
  2751         case ERunnerWaitTimeout:
  2701             iPauseTimer.Cancel();
  2752             iPauseTimer.Cancel();
  3241            	    {
  3292            	    {
  3242                 __TRACE( KMessage, (_L("case title=%S"), &val));
  3293                 __TRACE( KMessage, (_L("case title=%S"), &val));
  3243                 aStartInfo.SetTitleL(val);
  3294                 aStartInfo.SetTitleL(val);
  3244                 break;
  3295                 break;
  3245            	    }
  3296            	    }
       
  3297             case TTCKeywords::EArgs:
       
  3298                 {
       
  3299                 __TRACE( KMessage, (_L("case arguments=%S"), &val));
       
  3300                 aStartInfo.SetTestCaseArgumentsL( val );
       
  3301                 }
       
  3302                 break;				
  3246             default:
  3303             default:
  3247 				{
  3304 				{
  3248                 __TRACE( KError, (_L("Unknown or illegal keyword")));
  3305                 __TRACE( KError, (_L("Unknown or illegal keyword")));
  3249                 //Unknown or illegal keyword
  3306                 //Unknown or illegal keyword
  3250                 iRunErrorMessage.Format( KErrMsgRunUnknowOrIllegalKeyword, &arg );
  3307                 iRunErrorMessage.Format( KErrMsgRunUnknowOrIllegalKeyword, &arg );
  3395 TBool CTestRunner::ExecuteCombinerPauseL( CStifItemParser* aItem )
  3452 TBool CTestRunner::ExecuteCombinerPauseL( CStifItemParser* aItem )
  3396 {
  3453 {
  3397 	_LIT( KErrMsgPauseTimeoutNotDefined, "PauseCombiner : No timeout value given or value has invalid format" );
  3454 	_LIT( KErrMsgPauseTimeoutNotDefined, "PauseCombiner : No timeout value given or value has invalid format" );
  3398 	_LIT( KErrMsgPauseTimeoutNotPositive, "PauseCombiner : Timeout value can't be <0" );
  3455 	_LIT( KErrMsgPauseTimeoutNotPositive, "PauseCombiner : Timeout value can't be <0" );
  3399 
  3456 
  3400     TBool continueTask = ETrue;
  3457     TBool continueTask = EFalse;
  3401     TInt pauseTime;
  3458     TInt pauseTime;
  3402     TInt ret = KErrNone;
  3459     TInt ret = KErrNone;
  3403     
  3460     
  3404     // Parse testid
  3461     // Parse testid
  3405     ret = aItem->GetNextInt( pauseTime );
  3462     ret = aItem->GetNextInt( pauseTime );
  3414         __TRACE( KError, (_L("CTestRunner::ExecuteCombinerPauseL: Given pause value < 0")));
  3471         __TRACE( KError, (_L("CTestRunner::ExecuteCombinerPauseL: Given pause value < 0")));
  3415         iRunErrorMessage = KErrMsgPauseTimeoutNotPositive;
  3472         iRunErrorMessage = KErrMsgPauseTimeoutNotPositive;
  3416         User::Leave( KErrArgument );
  3473         User::Leave( KErrArgument );
  3417         }    
  3474         }    
  3418     
  3475     
  3419     //Time given by End User should be given in miliseconds
  3476     
  3420     pauseTime*=1000;
  3477     // Maximum time for one RTimer::After request
  3421 
  3478     TInt maximumTime = KMaxTInt / 1000;
  3422     __TRACE( KMessage, (_L("time=%d"), pauseTime ) );
  3479 
  3423 
  3480     // Check if pause value is suitable for RTimer::After
  3424     User::After( pauseTime );
  3481     if(pauseTime < maximumTime)
       
  3482         {
       
  3483         iPauseCombTimer.After(iStatus, pauseTime * 1000);
       
  3484         iPauseCombRemainingTime = 0;
       
  3485         }
       
  3486     else
       
  3487         {
       
  3488         // Given pause value after multiplication with 1000 is
       
  3489         // larger than KMaxTInt, so we need to split it and 
       
  3490         // re-request After with remaining value from RunL
       
  3491 
       
  3492         iPauseCombRemainingTime = pauseTime - maximumTime;
       
  3493         iPauseCombTimer.After(iStatus, maximumTime * 1000);
       
  3494         }
       
  3495 
       
  3496     SetActive();
       
  3497 
       
  3498     __TRACE(KMessage, (_L("Executing pause, time=[%d]"), pauseTime));
       
  3499     
       
  3500     iState = ERunnerRunning;
  3425     
  3501     
  3426     return continueTask;
  3502     return continueTask;
  3427 }
  3503 }
  3428      
  3504      
  3429 /*
  3505 /*