stif/TestCombiner/src/TestCombiner.cpp
branchRCL_3
changeset 14 381827f66490
parent 8 ecff51f1e7fb
child 32 8f8df8006c40
equal deleted inserted replaced
12:7e287c5c61f0 14:381827f66490
  2443     
  2443     
  2444 -------------------------------------------------------------------------------
  2444 -------------------------------------------------------------------------------
  2445 */
  2445 */
  2446 void CTestRunner::ConstructL()
  2446 void CTestRunner::ConstructL()
  2447     {
  2447     {
  2448     
  2448     TInt ret;
  2449     iPauseTimer.CreateLocal();
  2449     
       
  2450     ret = iPauseTimer.CreateLocal();
       
  2451     if(ret != KErrNone)
       
  2452         {
       
  2453         __TRACE( KError, (_L("Unable to create RTimer: iPauseTimer [%d] "), ret));
       
  2454         User::Leave(ret);
       
  2455         }
       
  2456         
       
  2457     ret = iPauseCombTimer.CreateLocal();
       
  2458     if(ret != KErrNone)
       
  2459         {
       
  2460         __TRACE( KError, (_L("Unable to create RTimer: iPauseCombTimer [%d] "), ret));
       
  2461         User::Leave(ret);
       
  2462         }
  2450     
  2463     
  2451     iRemoteTimer = CRemoteTimer::NewL( iTestCombiner );
  2464     iRemoteTimer = CRemoteTimer::NewL( iTestCombiner );
  2452     
  2465     
  2453     }
  2466     }
  2454 
  2467 
  2513     
  2526     
  2514     delete iLine;
  2527     delete iLine;
  2515     iLine = 0;
  2528     iLine = 0;
  2516     
  2529     
  2517     iPauseTimer.Close();
  2530     iPauseTimer.Close();
       
  2531     
       
  2532     iPauseCombTimer.Close();
  2518          
  2533          
  2519     }
  2534     }
  2520 
  2535 
  2521 /*
  2536 /*
  2522 -------------------------------------------------------------------------------
  2537 -------------------------------------------------------------------------------
  2548         ( iTestCombiner->iSectionParser == NULL ) )
  2563         ( iTestCombiner->iSectionParser == NULL ) )
  2549         {
  2564         {
  2550         User::Leave( KErrGeneral );
  2565         User::Leave( KErrGeneral );
  2551         }
  2566         }
  2552         
  2567         
  2553     TBool continueTask = EFalse; 
  2568     TBool continueTask = EFalse;
       
  2569     
       
  2570     // Check if there is still some time for combiner pause and we need to 
       
  2571     // continue pausing
       
  2572     if(iPauseCombRemainingTime > 0)
       
  2573         {           
       
  2574         // Maximum time for one RTimer::After request                   
       
  2575         TInt maximumTime = KMaxTInt / 1000;                       
  2554         
  2576         
       
  2577         __TRACE( KMessage, (_L("CTestRunner::RunL: Going to reissue PauseCombiner request ") ) );           
       
  2578         __TRACE( KMessage, (_L("CTestRunner::RunL: iRemainingTimeValue = %d"), iPauseCombRemainingTime ) );        
       
  2579         
       
  2580         if( iPauseCombRemainingTime < maximumTime )
       
  2581             {                           
       
  2582             iPauseCombTimer.After(iStatus, (iPauseCombRemainingTime * 1000));
       
  2583             iPauseCombRemainingTime = 0;
       
  2584             }
       
  2585         else
       
  2586             {            
       
  2587             iPauseCombRemainingTime -= maximumTime;
       
  2588             iPauseCombTimer.After(iStatus, (maximumTime * 1000));        
       
  2589             }     
       
  2590             
       
  2591         SetActive();
       
  2592         return;
       
  2593         }     
       
  2594  
       
  2595     // Handling runner states
  2555     switch( iState )
  2596     switch( iState )
  2556         {
  2597         {
  2557         case ERunnerWaitTimeout:
  2598         case ERunnerWaitTimeout:
  2558             {
  2599             {
  2559             __TRACE( KMessage, (_L("Resume %S"), &iPausedTestCase));
  2600             __TRACE( KMessage, (_L("Resume %S"), &iPausedTestCase));
  2692 void CTestRunner::DoCancel()
  2733 void CTestRunner::DoCancel()
  2693     {
  2734     {
  2694     __TRACEFUNC();
  2735     __TRACEFUNC();
  2695     __TRACE( KMessage, (_L("CTestRunner::DoCancel")));
  2736     __TRACE( KMessage, (_L("CTestRunner::DoCancel")));
  2696     iTestCombiner->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), _L("DoCancel"));
  2737     iTestCombiner->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), _L("DoCancel"));
       
  2738     
       
  2739     iPauseCombTimer.Cancel();
  2697     
  2740     
  2698     switch( iState )
  2741     switch( iState )
  2699         {
  2742         {
  2700         case ERunnerWaitTimeout:
  2743         case ERunnerWaitTimeout:
  2701             iPauseTimer.Cancel();
  2744             iPauseTimer.Cancel();
  3395 TBool CTestRunner::ExecuteCombinerPauseL( CStifItemParser* aItem )
  3438 TBool CTestRunner::ExecuteCombinerPauseL( CStifItemParser* aItem )
  3396 {
  3439 {
  3397 	_LIT( KErrMsgPauseTimeoutNotDefined, "PauseCombiner : No timeout value given or value has invalid format" );
  3440 	_LIT( KErrMsgPauseTimeoutNotDefined, "PauseCombiner : No timeout value given or value has invalid format" );
  3398 	_LIT( KErrMsgPauseTimeoutNotPositive, "PauseCombiner : Timeout value can't be <0" );
  3441 	_LIT( KErrMsgPauseTimeoutNotPositive, "PauseCombiner : Timeout value can't be <0" );
  3399 
  3442 
  3400     TBool continueTask = ETrue;
  3443     TBool continueTask = EFalse;
  3401     TInt pauseTime;
  3444     TInt pauseTime;
  3402     TInt ret = KErrNone;
  3445     TInt ret = KErrNone;
  3403     
  3446     
  3404     // Parse testid
  3447     // Parse testid
  3405     ret = aItem->GetNextInt( pauseTime );
  3448     ret = aItem->GetNextInt( pauseTime );
  3414         __TRACE( KError, (_L("CTestRunner::ExecuteCombinerPauseL: Given pause value < 0")));
  3457         __TRACE( KError, (_L("CTestRunner::ExecuteCombinerPauseL: Given pause value < 0")));
  3415         iRunErrorMessage = KErrMsgPauseTimeoutNotPositive;
  3458         iRunErrorMessage = KErrMsgPauseTimeoutNotPositive;
  3416         User::Leave( KErrArgument );
  3459         User::Leave( KErrArgument );
  3417         }    
  3460         }    
  3418     
  3461     
  3419     //Time given by End User should be given in miliseconds
  3462     
  3420     pauseTime*=1000;
  3463     // Maximum time for one RTimer::After request
  3421 
  3464     TInt maximumTime = KMaxTInt / 1000;
  3422     __TRACE( KMessage, (_L("time=%d"), pauseTime ) );
  3465 
  3423 
  3466     // Check if pause value is suitable for RTimer::After
  3424     User::After( pauseTime );
  3467     if(pauseTime < maximumTime)
       
  3468         {
       
  3469         iPauseCombTimer.After(iStatus, pauseTime * 1000);
       
  3470         iPauseCombRemainingTime = 0;
       
  3471         }
       
  3472     else
       
  3473         {
       
  3474         // Given pause value after multiplication with 1000 is
       
  3475         // larger than KMaxTInt, so we need to split it and 
       
  3476         // re-request After with remaining value from RunL
       
  3477 
       
  3478         iPauseCombRemainingTime = pauseTime - maximumTime;
       
  3479         iPauseCombTimer.After(iStatus, maximumTime * 1000);
       
  3480         }
       
  3481 
       
  3482     SetActive();
       
  3483 
       
  3484     __TRACE(KMessage, (_L("Executing pause, time=[%d]"), pauseTime));
       
  3485     
       
  3486     iState = ERunnerRunning;
  3425     
  3487     
  3426     return continueTask;
  3488     return continueTask;
  3427 }
  3489 }
  3428      
  3490      
  3429 /*
  3491 /*