stif/TestCombiner/src/TestCombiner.cpp
changeset 25 9aaae25af322
parent 13 33016869e0dd
child 30 86a2e675b80a
--- a/stif/TestCombiner/src/TestCombiner.cpp	Tue May 25 18:01:01 2010 +0300
+++ b/stif/TestCombiner/src/TestCombiner.cpp	Mon Jun 14 11:37:33 2010 +0300
@@ -1652,6 +1652,7 @@
                            aStartInfo.iTestId, 
                            aStartInfo.iExpectedResult, 
                            aStartInfo.iCategory,
+                           aStartInfo.iTestCaseArguments,
                            module ); //--PYTHON--
 
     CleanupStack::PushL( tc );
@@ -1694,7 +1695,14 @@
          &aStartInfo.iTestId, &aStartInfo.iModule, &aStartInfo.iIniFile, 
          &aStartInfo.iConfig, aStartInfo.iCaseNum, aStartInfo.iExpectedResult );
 
-    tc->TestExecution().RunTestCase( tc->iResultPckg, tc->iStatus );
+    if ( tc->TestCaseArguments().Length() > 0 )
+        {
+        tc->TestExecution().RunTestCase( tc->iResultPckg, tc->TestCaseArguments(), tc->iStatus );
+        }
+    else
+        {
+        tc->TestExecution().RunTestCase( tc->iResultPckg, tc->iStatus );
+        }
 
     iRunningTests++;
 
@@ -2445,8 +2453,21 @@
 */
 void CTestRunner::ConstructL()
     {
-    
-    iPauseTimer.CreateLocal();
+    TInt ret;
+    
+    ret = iPauseTimer.CreateLocal();
+    if(ret != KErrNone)
+        {
+        __TRACE( KError, (_L("Unable to create RTimer: iPauseTimer [%d] "), ret));
+        User::Leave(ret);
+        }
+        
+    ret = iPauseCombTimer.CreateLocal();
+    if(ret != KErrNone)
+        {
+        __TRACE( KError, (_L("Unable to create RTimer: iPauseCombTimer [%d] "), ret));
+        User::Leave(ret);
+        }
     
     iRemoteTimer = CRemoteTimer::NewL( iTestCombiner );
     
@@ -2515,6 +2536,8 @@
     iLine = 0;
     
     iPauseTimer.Close();
+    
+    iPauseCombTimer.Close();
          
     }
 
@@ -2550,8 +2573,34 @@
         User::Leave( KErrGeneral );
         }
         
-    TBool continueTask = EFalse; 
+    TBool continueTask = EFalse;
+    
+    // Check if there is still some time for combiner pause and we need to 
+    // continue pausing
+    if(iPauseCombRemainingTime > 0)
+        {           
+        // Maximum time for one RTimer::After request                   
+        TInt maximumTime = KMaxTInt / 1000;                       
+        
+        __TRACE( KMessage, (_L("CTestRunner::RunL: Going to reissue PauseCombiner request ") ) );           
+        __TRACE( KMessage, (_L("CTestRunner::RunL: iRemainingTimeValue = %d"), iPauseCombRemainingTime ) );        
         
+        if( iPauseCombRemainingTime < maximumTime )
+            {                           
+            iPauseCombTimer.After(iStatus, (iPauseCombRemainingTime * 1000));
+            iPauseCombRemainingTime = 0;
+            }
+        else
+            {            
+            iPauseCombRemainingTime -= maximumTime;
+            iPauseCombTimer.After(iStatus, (maximumTime * 1000));        
+            }     
+            
+        SetActive();
+        return;
+        }     
+ 
+    // Handling runner states
     switch( iState )
         {
         case ERunnerWaitTimeout:
@@ -2695,6 +2744,8 @@
     __TRACE( KMessage, (_L("CTestRunner::DoCancel")));
     iTestCombiner->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), _L("DoCancel"));
     
+    iPauseCombTimer.Cancel();
+    
     switch( iState )
         {
         case ERunnerWaitTimeout:
@@ -3243,6 +3294,12 @@
                 aStartInfo.SetTitleL(val);
                 break;
            	    }
+            case TTCKeywords::EArgs:
+                {
+                __TRACE( KMessage, (_L("case arguments=%S"), &val));
+                aStartInfo.SetTestCaseArgumentsL( val );
+                }
+                break;				
             default:
 				{
                 __TRACE( KError, (_L("Unknown or illegal keyword")));
@@ -3397,7 +3454,7 @@
 	_LIT( KErrMsgPauseTimeoutNotDefined, "PauseCombiner : No timeout value given or value has invalid format" );
 	_LIT( KErrMsgPauseTimeoutNotPositive, "PauseCombiner : Timeout value can't be <0" );
 
-    TBool continueTask = ETrue;
+    TBool continueTask = EFalse;
     TInt pauseTime;
     TInt ret = KErrNone;
     
@@ -3416,12 +3473,31 @@
         User::Leave( KErrArgument );
         }    
     
-    //Time given by End User should be given in miliseconds
-    pauseTime*=1000;
-
-    __TRACE( KMessage, (_L("time=%d"), pauseTime ) );
-
-    User::After( pauseTime );
+    
+    // Maximum time for one RTimer::After request
+    TInt maximumTime = KMaxTInt / 1000;
+
+    // Check if pause value is suitable for RTimer::After
+    if(pauseTime < maximumTime)
+        {
+        iPauseCombTimer.After(iStatus, pauseTime * 1000);
+        iPauseCombRemainingTime = 0;
+        }
+    else
+        {
+        // Given pause value after multiplication with 1000 is
+        // larger than KMaxTInt, so we need to split it and 
+        // re-request After with remaining value from RunL
+
+        iPauseCombRemainingTime = pauseTime - maximumTime;
+        iPauseCombTimer.After(iStatus, maximumTime * 1000);
+        }
+
+    SetActive();
+
+    __TRACE(KMessage, (_L("Executing pause, time=[%d]"), pauseTime));
+    
+    iState = ERunnerRunning;
     
     return continueTask;
 }